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

3704 lines
163 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
{
/// <summary>
/// PLC业务类
/// </summary>
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
/// <summary>
/// 信号刷新事件
/// </summary>
/// <param name="status"></param>
public delegate void SignalReadRefresh(int status, int position);
public event SignalReadRefresh SignalRefreshEvent;
/// <summary>
/// 日志刷新
/// </summary>
/// <param name="type">日志内容</param>
/// <param name="massage"></param>
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);
}
/// <summary>
/// 初始化PLC
/// </summary>
/// <param name="PLCType"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 获取PLC连接状态
/// </summary>
/// <returns></returns>
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);
}
}
}
/// <summary>
/// 读取PLC信号 object source, System.Timers.ElapsedEventArgs e
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 根据时间差判断信号是否处理
/// </summary>
/// <param name="lastReadTime"></param>
/// <returns></returns>
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;
}
}
/// <summary>
/// PLC地址写入
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void writePlc(string address,int value)
{
plcInstance.writeInt32ByAddress(address, value);
}
/// <summary>
/// 写入String类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public static void writeStrPlc(string address, string value)
{
plcInstance.writeStringByAddress(address, value);
}
/// <summary>
/// 写入double类型
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void writeDoublePlc(string address, int value)
{
plcInstance.writeDoubleByAddress(address, value);
}
/// <summary>
/// 读取String类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="length"></param>
public static string readStrPlc(string address,ushort length)
{
return plcInstance.readStringByAddress(address, length);
}
/// <summary>
/// PLC地址读取
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public static int readPlc(string address)
{
var info = plcInstance.readInt32ByAddress(address);
return info;
}
/// <summary>
/// PLC地址读取-bool
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public static bool readBoolPlc(string address)
{
var info = plcInstance.readBoolByAddress(address);
return info;
}
}
}