|
|
- using Leit.FrameWork.Log;
- using Leit.Model;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Leit.StationFunction
- {
- public static class Function_OP80
- {
- /// <summary>
- /// 工位标签信息
- /// </summary>
- public static List<StationTagInfo> StationTagInfos { get; set; }
-
-
- /// <summary>
- /// 工位报警标签信息
- /// </summary>
- public static List<StationTagInfo> StationAlarmTagInfos { get; set; }
-
- /// <summary>
- /// 工位质量数据标签信息
- /// </summary>
- public static List<StationTagInfo> StationQualityTagInfos { get; set; }
-
- /// <summary>
- /// 工位交互数据标签信息
- /// </summary>
- public static List<StationTagInfo> StationCommunicatedTagInfos { get; set; }
-
-
- /// <summary>
- /// 工位信息
- /// </summary>
- public static StationInfo StationInf { get; set; }
-
- /// <summary>
- /// 托盘号
- /// </summary>
- public static byte PalletNum { get; set; }
-
- public static bool ReadDataOk { get; set; }
-
- /// <summary>
- /// 业务逻辑
- /// </summary>
- public static void CycleRunTimer()
- {
-
- try
- {
- //读取托盘号
- byte palletNum = ServiceData.OpcTags.Where(p => p.TagId == StationCommunicatedTagInfos.Where(q => q.TagMarkCode == 1010).First().TagId).First().GetValue<byte>();
- if (palletNum != 0)
- {
- //托盘号保持
- PalletNum = palletNum;
- }
- if (ServiceData.OpcTags.Where(p => p.TagId == StationCommunicatedTagInfos.Where(q => q.TagMarkCode == 1050).First().TagId).First().GetValue<byte>() == 1)
- {
- //收到允许保存 保存质量数据
- if (!ReadDataOk)
- {
- //读取质量数据.
-
- //读取质量数据.
- string sql = "update Deploy_Data set ";
-
- foreach (var item in StationQualityTagInfos)
- {
-
- if (item.TagDataType == "byte")
- {
- sql = sql + item.ColName + "='" + ServiceData.OpcTags.Where(p => p.TagId == item.TagId).First().GetValue<byte>()+"'";
- }
- else if (item.TagDataType == "float")
- {
- sql = sql + item.ColName + "='" + ServiceData.OpcTags.Where(p => p.TagId == item.TagId).First().GetValue<float>().ToString()+"'";
- }
-
- sql = sql + ",";
- }
-
- sql = sql.Remove(sql.Length - 1, 1);
- sql = sql + $",op80_time='{DateTime.Now}' where tuopan_id={PalletNum} and process_state=1";
- SqlSugarAdo.ExecuteCommand(sql);
- ReadDataOk = true;
-
- }
-
-
-
- //回写保存完成
- ServiceData.PlcServer.Write(StationCommunicatedTagInfos.Where(p => p.TagMarkCode == 1060).First().TagAddr, 1);
-
-
- }
- else
- {
- ReadDataOk = false;
- }
-
- }
- catch (Exception ex)
- {
- LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
- }
-
-
-
-
-
-
-
-
-
-
- }
- }
- }
|