using MaterialTraceability.Common;
using MaterialTraceability.Entity.DTO;
using MaterialTraceability.Entity.Enum;
using MaterialTraceability.Plc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MaterialTraceability.Business
{
///
/// PLC业务类
///
public class PlcBusiness
{
private BackgroundWorker m_bgwDeviceDetect = new BackgroundWorker();
private ManualResetEvent ExitEvent = new ManualResetEvent(false);
private ManualResetEvent DetectEvent = new ManualResetEvent(false);
private static IPlc plcInstance = null;
private static AppConfigDto appConfig = AppConfigDto.Instance;
private static DateTime last_Left_Time;
private static DateTime last_Right_Time;
private static DateTime last_Down_Left_EndTime;
private static DateTime last_up_Left_EndTime;
private static DateTime last_Down_Right_EndTime;
private static DateTime last_up_Right_EndTime;
private static DateTime last_Down_Left_Time;
private static DateTime last_Down_Right_Time;
private static DateTime last_Up_Left_Time;
private static DateTime last_Up_Right_Time;
#region 定义间隔判断时间
private static DateTime lastReadTime_A_Begin;
private static DateTime lastReadTime_A_End;
private static DateTime lastReadTime_B_Begin;
private static DateTime lastReadTime_B_End;
private static DateTime lastReadTime_Force;
private static DateTime A1EndReadTime_Force;
private static DateTime A2EndReadTime_Force;
private static DateTime B1EndReadTime_Force;
private static DateTime B2EndReadTime_Force;
//放卷结束信号
private static DateTime LastEndTime;
//开机启动信号
private static DateTime StartUpTime;
//涨紧信号
private static DateTime A1ZJ;
private static DateTime A2ZJ;
private static DateTime B1ZJ;
private static DateTime B2ZJ;
private static DateTime lastReadTime_ForceSecond; //模切暂用
#endregion
///
/// 信号刷新事件
///
///
public delegate void SignalReadRefresh(int status, int position);
public event SignalReadRefresh SignalRefreshEvent;
///
/// 日志刷新
///
/// 日志内容
///
public delegate void LogRefresh(LogType logType, string massage);
public static event LogRefresh LogRefreshEvent;
private static System.Timers.Timer timer = new System.Timers.Timer(appConfig.plcSingalReadTime);
public void EndSignalInit(int status, int position)
{
SignalRefreshEvent?.Invoke(status, position);
}
///
/// 初始化PLC
///
///
///
public IPlc InitPlc(string PLCType)
{
try
{
string str = System.Environment.CurrentDirectory;
str = str + "\\MaterialTraceability.Plc.dll";
Assembly assembly = Assembly.LoadFile(str); // 加载程序集(EXE 或 DLL)
string AssemName = "MaterialTraceability.Plc.Impl." + PLCType;
var obj = assembly.CreateInstance(AssemName, true);
plcInstance = obj as IPlc;
if (plcInstance == null)
{
LogHelper.Info("PLC初始化失败!!!");
return null;
}
else
{
LogHelper.Info("PLC初始化成功");
#region 读取时间初始化
var initTime = DateTime.Now.AddMinutes(-1);
lastReadTime_A_Begin = initTime;
lastReadTime_A_End = initTime;
lastReadTime_B_Begin = initTime;
lastReadTime_B_End = initTime;
lastReadTime_Force = initTime;
lastReadTime_ForceSecond = initTime;
A1EndReadTime_Force = initTime;
A2EndReadTime_Force = initTime;
B1EndReadTime_Force = initTime;
B2EndReadTime_Force = initTime;
LastEndTime = initTime;
StartUpTime = initTime;
A1ZJ = initTime;
A2ZJ = initTime;
B1ZJ = initTime;
B2ZJ = initTime;
last_Left_Time = initTime;
last_Right_Time = initTime;
last_Down_Left_EndTime = initTime;
last_up_Left_EndTime = initTime;
last_Down_Right_EndTime = initTime;
last_up_Right_EndTime = initTime;
last_Down_Left_Time = initTime;
last_Down_Right_Time = initTime;
last_Up_Left_Time = initTime;
last_Up_Right_Time = initTime;
#endregion
return plcInstance;
}
}
catch (Exception ex)
{
LogHelper.Error("PLC初始化异常", ex);
return null;
}
}
public bool Connect()
{
if (!plcInstance.IsConnected)
{
bool connectResult = plcInstance.Connect(appConfig.plcIPAddress, appConfig.plcPort);
ReadContinue = true;
return connectResult;
}
return plcInstance.IsConnected;
}
///
/// 获取PLC连接状态
///
///
public bool IsConnected()
{
return plcInstance.IsConnected;
}
public bool ReConnect()
{
try
{
if (plcInstance.IsConnected)
{
if (plcInstance.DisConnect())
{
LogHelper.PlcLog("PLC断开成功");
ReadContinue = false;
}
}
//断开后关闭定时器
if (timer.Enabled)
{
timer.Stop();
timer.Close();
timer.Dispose();
timer = new System.Timers.Timer(appConfig.plcSingalReadTime);
}
LogHelper.PlcLog("定时器关闭,等待2S后进行重连");
Thread.Sleep(1000 * 2);
if (Connect())
{
LogHelper.PlcLog("PLC连接成功,开启定时器");
ReadContinue = true;
//LoopRead();
NewLoopRead();
}
}
catch(Exception ex)
{
LogHelper.Error("PLC重连异常",ex);
ReadContinue = false;
}
var result = plcInstance.IsConnected;
return result;
}
public void Dispose()
{
if (plcRead != null)
{
plcRead.Abort();
}
}
bool ReadContinue = false;
Thread plcRead;
public void CreatPLCClient()
{
if (appConfig.PLCType.Contains("XDJRPLcAddress") || appConfig.PLCType.Contains("JYMQPLcAddress")|| appConfig.PLCType.Contains("LYHTJPLcAddress") || appConfig.PLCType.Contains("LYHTJ2PLcAddress") || appConfig.PLCType.Contains("YKTBPLcAddress") || appConfig.PLCType.Contains("JTTBPLcAddress") || appConfig.PLCType.Contains("HNTBPLcAddress"))
{
m_bgwDeviceDetect.DoWork += new DoWorkEventHandler(bgwDeviceDetect_DoWork);
m_bgwDeviceDetect.RunWorkerAsync(this);
}
}
private void bgwDeviceDetect_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker backgroundworker = sender as BackgroundWorker;
while (true)
{
try
{
if (ExitEvent.WaitOne(0, false))
{
e.Cancel = true;
ExitEvent.Reset();
return;
}
if (appConfig.processId == "MQ_A" || appConfig.processId == "MQ_B")
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.心跳, 1);
}
else if (appConfig.processId == "TB")
{
plcInstance.writeInt32ByAddress(appConfig.TbAddress.心跳, 1);
}
else if (appConfig.processId == "TJ" || appConfig.processId == "TJ2")
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.心跳, 1);
}
DetectEvent.Reset();
DetectEvent.WaitOne(1 * 1000, false);
}
catch (Exception ex)
{
}
}
}
public void NewLoopRead()
{
try
{
plcRead = new Thread(readplc);
plcRead.Start();
}
catch (Exception ex)
{
}
}
private void readplc(object o)
{
while (ReadContinue)
{
Thread.Sleep(appConfig.plcSingalReadTime);
try
{
//获取工序编号 TB-涂布、LY冷压预分切、MQ-模切、JR-卷绕
string processCode = appConfig.processId;
#region 涂布
if (processCode.Equals("TB"))
{
lock (string.Empty)
{
//写入心跳
//plcInstance.writeInt32ByAddress(appConfig.TbAddress.心跳, 1);
//LogHelper.PlcLog("RFID系统写入心跳D9628");
//Thread.Sleep(200);
// A轴收卷涨紧 A轴position设为1
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A收卷轴涨紧) == 1)
{
LogHelper.PlcLog("A轴收卷涨紧");
//plcInstance.writeInt32ByAddress(appConfig.TbAddress.涨紧信号清除, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.A收卷轴涨紧, 0);
if (isReadFlag(ref lastReadTime_A_Begin, 30))
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
// B轴收卷涨紧 B轴position设为2
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B收卷轴涨紧) == 1)
{
LogHelper.PlcLog("B轴收卷涨紧");
//plcInstance.writeInt32ByAddress(appConfig.TbAddress.涨紧信号清除, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.B收卷轴涨紧, 0);
if (isReadFlag(ref lastReadTime_B_Begin, 30))
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
#region 收卷开始信号 Add By wenjy 2022-11-29
// A轴收卷开始信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.收卷轴开始) == 1)
{
LogHelper.PlcLog("A轴收卷开始信号 D9720==1 -> 0");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.收卷轴开始, 0);
if (isReadFlag(ref lastReadTime_A_End, 30))
{
SignalRefreshEvent?.Invoke(7, 1);
}
}
// B轴收卷开始信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.收卷轴开始) == 2)
{
LogHelper.PlcLog("B轴收卷开始信号 D9720==2 -> 0");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.收卷轴开始, 0);
if (isReadFlag(ref lastReadTime_B_End, 30))
{
SignalRefreshEvent?.Invoke(7, 2);
}
}
#endregion
// A轴收卷完工信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A收卷轴完工) == 1)
{
LogHelper.PlcLog("A轴收卷完工信号");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.控制下料, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.A收卷轴完工, 0);
if (isReadFlag(ref lastReadTime_A_End,30))
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
// B轴收卷完工信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B收卷轴完工) == 1)
{
LogHelper.PlcLog("B轴收卷完工信号");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.控制下料, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.B收卷轴完工, 0);
if (isReadFlag(ref lastReadTime_B_End,30))
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
//A轴强制下料
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.强制下料) == 1)
{
LogHelper.PlcLog("A轴强制下料");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.强制下料, 0);
if (isReadFlag(ref lastReadTime_Force, 30))
{
SignalRefreshEvent?.Invoke(5, 1);
}
}
//B轴强制下料
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.强制下料) == 2)
{
LogHelper.PlcLog("B轴强制下料");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.强制下料, 0);
if (isReadFlag(ref lastReadTime_Force, 30))
{
SignalRefreshEvent?.Invoke(5, 2);
}
}
}
}
#endregion
#region 贴胶
if (processCode.Equals("TJ")|| processCode.Equals("TJ2"))
{
Thread.Sleep(100);
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.开机启动) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.开机启动, 0);
SignalRefreshEvent?.Invoke(8, 0);
}
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.左放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.左放卷涨紧, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(1, 6);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(1, 5);
}
}
//右放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.右放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.右放卷涨紧, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(1, 5);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(1, 6);
}
}
//左放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.左放卷开始)== 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.左放卷开始, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(6, 5);
}
}
//右放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.右放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.右放卷开始, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(6, 6);
}
}
//上收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.上左收卷开始, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(7, 1);
}
}
//上收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.上右收卷开始, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(7, 3);
}
}
//左放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.左放卷结束) == 1)
{
writePlc(appConfig.tjAddress.左放卷结束, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(2, 6);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(2, 5);
}
}
//右放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.右放卷结束) == 1)
{
writePlc(appConfig.tjAddress.右放卷结束, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(2, 5);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(2, 6);
}
}
//上收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.上左收卷涨紧, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(3, 3);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
//上收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.tjAddress.上右收卷涨紧, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(3, 1);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
//上左收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上左收卷结束) == 1)
{
writePlc(appConfig.tjAddress.上左收卷结束, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(4, 3);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
//上右收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.tjAddress.上右收卷结束) == 1)
{
writePlc(appConfig.tjAddress.上右收卷结束, 0);
if (appConfig.machineId == 21)
{
SignalRefreshEvent?.Invoke(4, 1);
}
if (appConfig.machineId == 22)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
}
#endregion
#region 冷压
if (processCode.Equals("LY"))
{
//A放卷 涨紧信号
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.A放卷涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.A放卷涨紧, 0);
SignalRefreshEvent?.Invoke(1, 0);
}
//B放卷 涨紧信号
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.B放卷涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.B放卷涨紧, 0);
SignalRefreshEvent?.Invoke(1, 9);
}
//A放卷结束信号
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.A放卷结束) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.A放卷结束, 2);
if (isReadFlag(ref LastEndTime, 30))
{
SignalRefreshEvent?.Invoke(2, 0);
}
}
//B放卷结束信号
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.B放卷结束) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.B放卷结束, 2);
if (isReadFlag(ref LastEndTime, 30))
{
SignalRefreshEvent?.Invoke(2, 9);
}
}
//收卷涨紧信号-1A气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1A涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1A涨紧, 0);
SignalRefreshEvent?.Invoke(3, 1);
}
//收卷涨紧信号-1B气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1B涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1B涨紧, 0);
SignalRefreshEvent?.Invoke(3, 2);
}
//收卷涨紧信号-2A气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2A涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2A涨紧, 0);
SignalRefreshEvent?.Invoke(3, 3);
}
//收卷涨紧信号-2B气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2B涨紧) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2B涨紧, 0);
SignalRefreshEvent?.Invoke(3, 4);
}
//收卷结束信号-1A气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1A结束) == 1)
{
writeInt16Plc(appConfig.LyAddress.收卷1A结束, 0);
if (isReadFlag(ref A1EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
}
//收卷结束信号-1B气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1B结束) == 1)
{
writeInt16Plc(appConfig.LyAddress.收卷1B结束, 0);
if (isReadFlag(ref B1EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
}
//收卷结束信号-2A气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2A结束) == 1)
{
writeInt16Plc(appConfig.LyAddress.收卷2A结束, 0);
if (isReadFlag(ref A2EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
}
//收卷结束信号-2B气胀轴
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2B结束) == 1)
{
writeInt16Plc(appConfig.LyAddress.收卷2B结束, 0);
if (isReadFlag(ref B2EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
//异常下料-1A
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1A异常下料) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 1);
}
//异常下料-1B
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1B异常下料) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 2);
}
//异常下料-2A
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2A异常下料) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 3);
}
//异常下料-2B
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2B异常下料) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 4);
}
if (plcInstance.readInteractiveSignal(appConfig.LyAddress.开机启动) == 1)
{
plcInstance.writeInt16ByAddress(appConfig.LyAddress.开机启动, 2);
SignalRefreshEvent?.Invoke(8, 0);
}
}
//冷压工序、赢合厂家
if (processCode.Equals("LY_A"))
{
//LogRefreshEvent?.Invoke(LogType.PlcLog, "开始信号轮询...");
//放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.A放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷涨紧, 0);
SignalRefreshEvent?.Invoke(1, 0);
}
//放卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.A放卷结束) == 1)
{
if (appConfig.PLCType == "HNLYPLcAddress")
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷结束, 2);
}
else
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷结束, 0);
}
if (isReadFlag(ref LastEndTime, 30))
{
SignalRefreshEvent?.Invoke(2, 0);
}
}
//收卷涨紧信号-1A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A涨紧, 0);
if (isReadFlag(ref A1ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
//收卷涨紧信号-1B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B涨紧, 0);
if (isReadFlag(ref B1ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
//收卷涨紧信号-2A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A涨紧, 0);
if (isReadFlag(ref A2ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
//收卷涨紧信号-2B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B涨紧, 0);
if (isReadFlag(ref B2ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
//收卷结束信号-1A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A结束, 0);
if (isReadFlag(ref A1EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
}
//收卷结束信号-1B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B结束, 0);
if (isReadFlag(ref B1EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
}
//收卷结束信号-2A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A结束, 0);
if (isReadFlag(ref A2EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
}
//收卷结束信号-2B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B结束, 0);
if (isReadFlag(ref B2EndReadTime_Force, 30))
{
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
//异常下料-1A
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 1);
}
//异常下料-1B
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 2);
}
//异常下料-2A
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 3);
}
//异常下料-2B
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 4);
}
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.开机启动) == 1)
{
if (appConfig.PLCType==("HNLYPLcAddress"))
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.开机启动, 2);
}
else
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.开机启动, 0);
}
if (isReadFlag(ref StartUpTime, 30))
{
SignalRefreshEvent?.Invoke(8, 0);
}
}
//LogRefreshEvent?.Invoke(LogType.PlcLog, "结束信号轮询...");
}
#endregion
#region 模切
if (processCode.Equals("MQ_A"))
{
//if (!appConfig.PLCType.Contains("HMXMQPLcAddress") || !appConfig.PLCType.Contains("JYMQPLcAddress"))
//{
// plcInstance.writeInt32ByAddress(appConfig.mqAddress.心跳, 1);
//}
//开机启动信号 Add By WenJy 2022-10-12
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.开机启动) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.开机启动, 0);
SignalRefreshEvent?.Invoke(8, 0);
}
//左放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷涨紧, 0);
if (isReadFlag(ref last_Left_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 5);
}
}
}
//右放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷涨紧, 0);
if (isReadFlag(ref last_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 6);
}
}
}
//海目星开始信号为bool量
if (appConfig.PLCType.Contains("HMXMQPLcAddress"))
{
//左放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.左放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.左放卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.右放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.右放卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 6);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上左收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下左收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
else
{
//左放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 6);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
//左放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷结束) == 1)
{
writePlc(appConfig.mqAddress.左放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 5);
}
}
//右放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷结束) == 1)
{
writePlc(appConfig.mqAddress.右放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 6);
}
}
//上收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷涨紧, 0);
if (isReadFlag(ref last_Up_Left_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
}
//上收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷涨紧, 0);
if (isReadFlag(ref last_Up_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
}
//下收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷涨紧, 0);
if (isReadFlag(ref last_Down_Left_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
}
//下收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷涨紧, 0);
if (isReadFlag(ref last_Down_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
}
//上左收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上左收卷结束, 0);
if (isReadFlag(ref last_Down_Left_EndTime, 30))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
}
//上右收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上右收卷结束, 0);
if (isReadFlag(ref last_Down_Right_EndTime, 30))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
}
//下左收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下左收卷结束, 0);
if (isReadFlag(ref last_up_Left_EndTime, 30))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
}
//下右收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下右收卷结束, 0);
if (isReadFlag(ref last_up_Right_EndTime, 30))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
}
//先导模切
else if (processCode.Equals("MQ_B"))
{
//plcInstance.writeInt32ByAddress(appConfig.mqAddress.心跳, 1);
//开机启动信号 Add By WenJy 2022-10-12
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.开机启动) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.开机启动, 0);
SignalRefreshEvent?.Invoke(8, 0);
}
//左放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷涨紧, 0);
if (isReadFlag(ref last_Left_Time, 5))
{
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(1, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 5);
}
}
}
//右放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷涨紧, 0);
if (isReadFlag(ref last_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 6);
}
}
}
if (appConfig.PLCType.Contains("HMXMQPLcAddress"))
{
//左放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.左放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.左放卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.右放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.右放卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上左收卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下左收卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
else
{
//左放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
//左放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷结束) == 1)
{
writePlc(appConfig.mqAddress.左放卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(2, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 5);
}
}
//右放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷结束) == 1)
{
writePlc(appConfig.mqAddress.右放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 6);
}
}
//上收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷涨紧, 0);
if (isReadFlag(ref last_Up_Left_Time, 5))
{
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(3, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
}
//上收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷涨紧, 0);
if (isReadFlag(ref last_Up_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
}
//下收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷涨紧, 0);
if (isReadFlag(ref last_Down_Left_Time, 5))
{
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(3, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
}
//下收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷涨紧, 0);
if (isReadFlag(ref last_Down_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
}
//上左收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上左收卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(4, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
//上右收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
//下左收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下左收卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(4, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
//下右收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
#endregion
#region 卷绕
if (processCode.Equals("JR"))
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.心跳, 1);
#region 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极左卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极左卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 1);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极右卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极右卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 2);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极左卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极左卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 3);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极右卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极右卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 4);
}
#endregion 涨紧信号
#region 开始过账信号
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极左卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极左卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 1);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极右卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极右卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 2);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极左卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极左卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 3);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极右卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极右卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 4);
}
#endregion 开始过账信号
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error("PLC读取异常", ex);
}
}
}
///
/// 读取PLC信号 object source, System.Timers.ElapsedEventArgs e
///
///
///
private void readPlc(object source, System.Timers.ElapsedEventArgs e)
{
try
{
//获取工序编号 TB-涂布、LY冷压预分切、MQ-模切、JR-卷绕
string processCode = appConfig.processId;
#region 涂布
if (processCode.Equals("TB"))
{
lock (string.Empty)
{
//写入心跳
plcInstance.writeInt32ByAddress(appConfig.TbAddress.心跳, 1);
LogHelper.PlcLog("RFID系统写入心跳D9628");
Thread.Sleep(200);
// A轴收卷涨紧 A轴position设为1
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A收卷轴涨紧) == 1)
{
LogHelper.PlcLog("A轴收卷涨紧");
//plcInstance.writeInt32ByAddress(appConfig.TbAddress.涨紧信号清除, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.A收卷轴涨紧, 0);
if (isReadFlag(ref lastReadTime_A_Begin, 30))
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
// B轴收卷涨紧 B轴position设为2
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B收卷轴涨紧) == 1)
{
LogHelper.PlcLog("B轴收卷涨紧");
//plcInstance.writeInt32ByAddress(appConfig.TbAddress.涨紧信号清除, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.B收卷轴涨紧, 0);
if (isReadFlag(ref lastReadTime_B_Begin, 30))
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
#region 收卷开始信号 Add By wenjy 2022-11-29
// A轴收卷开始信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.收卷轴开始) == 1)
{
LogHelper.PlcLog("A轴收卷开始信号 D9720==1 -> 0");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.收卷轴开始, 0);
if (isReadFlag(ref lastReadTime_A_End, 30))
{
SignalRefreshEvent?.Invoke(7, 1);
}
}
// B轴收卷开始信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.收卷轴开始) == 2)
{
LogHelper.PlcLog("B轴收卷开始信号 D9720==2 -> 0");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.收卷轴开始, 0);
if (isReadFlag(ref lastReadTime_B_End, 30))
{
SignalRefreshEvent?.Invoke(7, 2);
}
}
#endregion
// A轴收卷完工信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A收卷轴完工) == 1)
{
LogHelper.PlcLog("A轴收卷完工信号");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.控制下料, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.A收卷轴完工, 0);
if (isReadFlag(ref lastReadTime_A_End, 30))
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
// B轴收卷完工信号
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B收卷轴完工) == 1)
{
LogHelper.PlcLog("B轴收卷完工信号");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.控制下料, 1);
plcInstance.writeInt32ByAddress(appConfig.TbAddress.B收卷轴完工, 0);
if (isReadFlag(ref lastReadTime_B_End, 30))
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
//A轴强制下料
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.强制下料) == 1)
{
LogHelper.PlcLog("A轴强制下料");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.强制下料, 0);
if (isReadFlag(ref lastReadTime_Force, 30))
{
SignalRefreshEvent?.Invoke(5, 1);
}
}
//B轴强制下料
if (plcInstance.readInt32ByAddress(appConfig.TbAddress.强制下料) == 2)
{
LogHelper.PlcLog("B轴强制下料");
plcInstance.writeInt32ByAddress(appConfig.TbAddress.强制下料, 0);
if (isReadFlag(ref lastReadTime_Force, 30))
{
SignalRefreshEvent?.Invoke(5, 2);
}
}
}
}
#endregion
#region 冷压
//冷压工序、赢合厂家
if (processCode.Equals("LY_A"))
{
//放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.A放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷涨紧, 0);
SignalRefreshEvent?.Invoke(1, 0);
}
//放卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.A放卷结束) == 1)
{
if (appConfig.PLCType.Contains("HNLYPLcAddress"))
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷结束, 2);
}
else
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.A放卷结束, 0);
}
if (isReadFlag(ref LastEndTime, 30))
{
SignalRefreshEvent?.Invoke(2, 0);
}
}
//收卷涨紧信号-1A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A涨紧, 0);
if (isReadFlag(ref A1ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
//收卷涨紧信号-1B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B涨紧, 0);
if (isReadFlag(ref B1ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
//收卷涨紧信号-2A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A涨紧, 0);
if (isReadFlag(ref A2ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
//收卷涨紧信号-2B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B涨紧, 0);
if (isReadFlag(ref B2ZJ, 30))
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
//收卷结束信号-1A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A结束, 0);
if (isReadFlag(ref A1EndReadTime_Force, 30))
{
LogHelper.Error("收卷1A结束信号");
LogHelper.Error("收卷1A结束信号复位");
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
}
//收卷结束信号-1B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B结束, 0);
if (isReadFlag(ref B1EndReadTime_Force, 30))
{
LogHelper.Error("收卷1B结束");
LogHelper.Error("收卷1B结束信号复位");
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
}
//收卷结束信号-2A气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A结束, 0);
if (isReadFlag(ref A2EndReadTime_Force, 30))
{
LogHelper.Error("收卷2A结束");
LogHelper.Error("收卷2A结束信号复位");
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
}
//收卷结束信号-2B气胀轴
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B结束) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B结束, 0);
if (isReadFlag(ref B2EndReadTime_Force, 30))
{
LogHelper.Error("收卷2B结束");
LogHelper.Error("收卷2B结束信号复位");
lock (string.Empty)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
//异常下料-1A
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1A异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 1);
}
//异常下料-1B
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷1B异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷1B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 2);
}
//异常下料-2A
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2A异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2A异常下料, 0);
SignalRefreshEvent?.Invoke(5, 3);
}
//异常下料-2B
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.收卷2B异常下料) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.收卷2B异常下料, 0);
SignalRefreshEvent?.Invoke(5, 4);
}
if (plcInstance.readInt32ByAddress(appConfig.LyAddress.开机启动) == 1)
{
if (appConfig.PLCType.Contains("HNLYPLcAddress"))
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.开机启动, 2);
}
else
{
plcInstance.writeInt32ByAddress(appConfig.LyAddress.开机启动, 0);
}
if (isReadFlag(ref StartUpTime, 30))
{
SignalRefreshEvent?.Invoke(8, 0);
}
}
}
#endregion
#region 模切
if (processCode.Equals("MQ_A"))
{
if (!appConfig.PLCType.Contains("HMXMQPLcAddress"))
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.心跳, 1);
}
//开机启动信号 Add By WenJy 2022-10-12
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.开机启动) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.开机启动, 0);
SignalRefreshEvent?.Invoke(8, 0);
}
//左放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 5);
}
}
//右放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 6);
}
}
//海目星开始信号为bool量
if (appConfig.PLCType.Contains("HMXMQPLcAddress"))
{
//左放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.左放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.左放卷开始,false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.右放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.右放卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 6);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上左收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下左收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
else
{
//左放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 6);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
//左放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷结束) == 1)
{
writePlc(appConfig.mqAddress.左放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 5);
}
}
//右放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷结束) == 1)
{
writePlc(appConfig.mqAddress.右放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 6);
}
}
//上收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
//上收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
//下收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
//下收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
//上左收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上左收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
//上右收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
//下左收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下左收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
//下右收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
//先导模切
else if (processCode.Equals("MQ_B"))
{
//plcInstance.writeInt32ByAddress(appConfig.mqAddress.心跳, 1);
//开机启动信号 Add By WenJy 2022-10-12
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.开机启动) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.开机启动, 0);
SignalRefreshEvent?.Invoke(8, 0);
}
//左放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷涨紧, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(1, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 5);
}
}
//右放卷 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷涨紧, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(1, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(1, 6);
}
}
if (appConfig.PLCType.Contains("HMXMQPLcAddress"))
{
//左放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.左放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.左放卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.右放卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.右放卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上左收卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.上右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.上右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下左收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下左收卷开始, false);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readBoolByAddress(appConfig.mqAddress.下右收卷开始))
{
plcInstance.writeBoolByAddress(appConfig.mqAddress.下右收卷开始, false);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
else
{
//左放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.左放卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(6, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_Begin))
//{
// LogHelper.PlcLog("读到左放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
//}
}
//右放卷 开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.右放卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(6, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(6, 5);
}
//if (isReadFlag(ref lastReadTime_A_End))
//{
// LogHelper.PlcLog("读到右放卷开始信号");
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(6, 5);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(6, 6);
// }
//}
}
//上收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 1);
}
//if (isReadFlag(ref lastReadTime_B_Begin))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
//}
}
//上收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 3);
}
//if (isReadFlag(ref lastReadTime_B_End))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 1);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 3);
// }
//}
}
//下收卷左侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷开始, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(7, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 2);
}
//if (isReadFlag(ref lastReadTime_Force))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
//}
}
//下收卷右侧开始信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷开始) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷开始, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(7, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(7, 4);
}
//if (isReadFlag(ref lastReadTime_ForceSecond))
//{
// if (appConfig.machineId == 3)
// {
// SignalRefreshEvent?.Invoke(7, 2);
// }
// if (appConfig.machineId == 4)
// {
// SignalRefreshEvent?.Invoke(7, 4);
// }
//}
}
}
//左放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.左放卷结束) == 1)
{
writePlc(appConfig.mqAddress.左放卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(2, 6);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 5);
}
}
//右放卷 结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.右放卷结束) == 1)
{
writePlc(appConfig.mqAddress.右放卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(2, 5);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(2, 6);
}
}
//上收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上左收卷涨紧, 0);
if (isReadFlag(ref last_Up_Left_Time, 5))
{
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(3, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 1);
}
}
}
//上收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.上右收卷涨紧, 0);
if (isReadFlag(ref last_Up_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 3);
}
}
}
//下收卷左侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下左收卷涨紧, 0);
if (isReadFlag(ref last_Down_Left_Time, 5))
{
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(3, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 2);
}
}
}
//下收卷右侧涨紧 信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.mqAddress.下右收卷涨紧, 0);
if (isReadFlag(ref last_Down_Right_Time, 5))
{
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(3, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(3, 4);
}
}
}
//上左收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上左收卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(4, 3);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 1);
}
}
//上右收卷结束信号
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.上右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.上右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 1);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 3);
}
}
//下左收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下左收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下左收卷结束, 0);
if (appConfig.machineId == 3 || appConfig.machineId == 5)
{
SignalRefreshEvent?.Invoke(4, 4);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 2);
}
}
//下右收卷结束
if (plcInstance.readInt32ByAddress(appConfig.mqAddress.下右收卷结束) == 1)
{
writePlc(appConfig.mqAddress.下右收卷结束, 0);
if (appConfig.machineId == 3)
{
SignalRefreshEvent?.Invoke(4, 2);
}
if (appConfig.machineId == 4)
{
SignalRefreshEvent?.Invoke(4, 4);
}
}
}
#endregion
#region 卷绕
if (processCode.Equals("JR"))
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.心跳, 1);
#region 涨紧信号
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极左卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极左卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 1);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极右卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极右卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 2);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极左卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极左卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 3);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极右卷轴涨紧) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极右卷轴涨紧, 0);
SignalRefreshEvent?.Invoke(1, 4);
}
#endregion 涨紧信号
#region 开始过账信号
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极左卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极左卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 1);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阳极右卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阳极右卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 2);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极左卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极左卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 3);
}
if (plcInstance.readInt32ByAddress(appConfig.JrAddress.阴极右卷轴开始过账) == 1)
{
plcInstance.writeInt32ByAddress(appConfig.JrAddress.阴极右卷轴开始过账, 0);
SignalRefreshEvent?.Invoke(6, 4);
}
#endregion 开始过账信号
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error("读取PLC信号异常",ex);
}
}
public void writeInt16Plc(string address, int value)
{
plcInstance.writeInt16ByAddress(address, value);
}
///
/// 根据时间差判断信号是否处理
///
///
///
public static bool isReadFlag(ref DateTime lastReadTime,int diff)
{
DateTime nowReadTime = DateTime.Now;
TimeSpan info = nowReadTime - lastReadTime;
int elapsedTime = Convert.ToInt32(info.TotalSeconds);
LogHelper.PlcLog("开始时间:" + lastReadTime.ToString("G") + ";结束时间:" + nowReadTime.ToString("G") + ";时间差:" + elapsedTime);
if (elapsedTime < diff)
{
LogHelper.PlcLog("距离上次读取时间小于"+ diff + "S,不触发逻辑处理");
return false;
}
else
{
//上次读取时间
lastReadTime = nowReadTime;
return true;
}
}
///
/// PLC地址写入
///
///
///
public void writePlc(string address,int value)
{
plcInstance.writeInt32ByAddress(address, value);
}
///
/// 写入String类型数据
///
///
///
public static void writeStrPlc(string address, string value)
{
plcInstance.writeStringByAddress(address, value);
}
///
/// 写入double类型
///
///
///
public void writeDoublePlc(string address, int value)
{
plcInstance.writeDoubleByAddress(address, value);
}
///
/// 读取String类型数据
///
///
///
public static string readStrPlc(string address,ushort length)
{
return plcInstance.readStringByAddress(address, length);
}
///
/// PLC地址读取
///
///
///
public static int readPlc(string address)
{
var info = plcInstance.readInt32ByAddress(address);
return info;
}
///
/// PLC地址读取-bool
///
///
///
public static bool readBoolPlc(string address)
{
var info = plcInstance.readBoolByAddress(address);
return info;
}
}
}