You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

102 lines
3.5 KiB

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_OP40
{
/// <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)
{
//读取质量数据.
float prossure = ServiceData.OpcTags.Where(p => p.TagId == StationQualityTagInfos.Where(q => q.TagMarkCode == 3010 && q.ColName == "op40_pressure").First().TagId).First().GetValue<float>();
float shift = ServiceData.OpcTags.Where(p => p.TagId == StationQualityTagInfos.Where(q => q.TagMarkCode == 3010 && q.ColName == "op40_shift").First().TagId).First().GetValue<float>();
byte op40State = ServiceData.OpcTags.Where(p => p.TagId == StationQualityTagInfos.Where(q => q.TagMarkCode == 3010 && q.ColName == "op40_state").First().TagId).First().GetValue<byte>();
//只修改一次数据
Deploy_Data.Update(p => new Deploy_Data() { op40_time = DateTime.Now, op40_pressure = Convert.ToDouble(prossure.ToString()), op40_shift = Convert.ToDouble(shift.ToString()), op40_state = op40State }, p => p.tuopan_id == PalletNum && p.process_state == 1);
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);
}
}
}
}