Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
0c24c679ce
1 file changed
+53
-27
@@ -9,7 +9,9 @@ using Microsoft.Win32;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NModbus;
|
using NModbus;
|
||||||
using NModbus.Serial;
|
using NModbus.Serial;
|
||||||
|
using OpenHardwareMonitor.Hardware;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -35,7 +37,6 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using OpenHardwareMonitor.Hardware;
|
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
{
|
{
|
||||||
@@ -3392,35 +3393,50 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
if (protocols_ == "MODBUS_RTU")
|
try
|
||||||
{
|
{
|
||||||
DO = master.ReadCoils(slaveId, 0, DO_L); //读取线圈
|
if (protocols_ == "MODBUS_RTU")
|
||||||
RW = master.ReadHoldingRegisters(slaveId, 0, RW_L); //读取寄存器
|
{
|
||||||
master.WriteMultipleCoils(slaveId, 0, DQ); //写入线圈
|
while (_logQueue.Count>0)
|
||||||
master.WriteMultipleRegisters(slaveId, 0, DW); //写入寄存器
|
{
|
||||||
}//MODBUSRTU
|
QueueS d=_logQueue.Dequeue();
|
||||||
else
|
master.WriteSingleCoil(slaveId,Convert.ToUInt16(d.ID),d.D_DAT);
|
||||||
|
}
|
||||||
|
DO = master.ReadCoils(slaveId, 0, DO_L); //读取线圈
|
||||||
|
RW = master.ReadHoldingRegisters(slaveId, 0, RW_L); //读取寄存器
|
||||||
|
DQ = master.ReadCoils(slaveId, 0, DQ_L);
|
||||||
|
//master.WriteMultipleCoils(slaveId, 0, DQ); //写入线圈
|
||||||
|
master.WriteMultipleRegisters(slaveId, 0, DW); //写入寄存器
|
||||||
|
}//MODBUSRTU
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (_logQueue.Count > 0)
|
||||||
|
{
|
||||||
|
QueueS d = _logQueue.Dequeue();
|
||||||
|
master.WriteSingleCoil(slaveId, Convert.ToUInt16(d.ID+02000), d.D_DAT);
|
||||||
|
}
|
||||||
|
DO = master.ReadCoils(slaveId, 02255, DO_L); //读取线圈
|
||||||
|
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
||||||
|
DQ = master.ReadCoils(slaveId, 02000, DQ_L);
|
||||||
|
// master.WriteMultipleCoils(slaveId, 02000, DQ); //写入线圈
|
||||||
|
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
||||||
|
}//SCMODBUSRTU
|
||||||
|
LINK_OK = true;
|
||||||
|
ERRinf.ERRinf_d(errTabler, "ERR001");
|
||||||
|
LINK_RUN++;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
DO = master.ReadCoils(slaveId, 02255, DO_L); //读取线圈
|
LINK_OK = false;
|
||||||
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
LINK_ERR++;
|
||||||
master.WriteMultipleCoils(slaveId, 02000, DQ); //写入线圈
|
ERRinf.ERRinf_w(errTabler, "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")", "ERR001");
|
||||||
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
}
|
||||||
}//SCMODBUSRTU
|
finally
|
||||||
LINK_OK = true;
|
{
|
||||||
ERRinf.ERRinf_d(errTabler, "ERR001");
|
// Port_link();
|
||||||
LINK_RUN++;
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LINK_OK = false;
|
|
||||||
LINK_ERR++;
|
|
||||||
ERRinf.ERRinf_w(errTabler, "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")", "ERR001");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Port_link();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -3702,6 +3718,10 @@ namespace DyeingComputer.ViewModel
|
|||||||
, e.Row.Field<string>("ID")
|
, e.Row.Field<string>("ID")
|
||||||
, e.Row.Field<string>("PLC"));
|
, e.Row.Field<string>("PLC"));
|
||||||
}
|
}
|
||||||
|
if (MD < 4000 && MD > 3000)
|
||||||
|
{
|
||||||
|
_logQueue.Enqueue(new QueueS {ID = MD - 3001 ,D_DAT= e.Row.Field<bool>("DIO") });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
@@ -3981,6 +4001,11 @@ namespace DyeingComputer.ViewModel
|
|||||||
public string PLC { get; set; }
|
public string PLC { get; set; }
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
}
|
}
|
||||||
|
public class QueueS
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public bool D_DAT { get; set; }
|
||||||
|
}
|
||||||
public class TechnologicalProcess
|
public class TechnologicalProcess
|
||||||
{
|
{
|
||||||
public int RUN { get; set; }
|
public int RUN { get; set; }
|
||||||
@@ -4009,6 +4034,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
public string DYELOT { get; set; }
|
public string DYELOT { get; set; }
|
||||||
public string Remark { get; set; }
|
public string Remark { get; set; }
|
||||||
}
|
}
|
||||||
|
public static Queue<QueueS> _logQueue = new Queue<QueueS>();
|
||||||
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
||||||
{
|
{
|
||||||
Type t = typeof(T);
|
Type t = typeof(T);
|
||||||
|
|||||||
Reference in new issue
Block a user