Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
4f94917dca
1 file changed
+19
-7
@@ -165,6 +165,8 @@ namespace DyeingComputer.ViewModel
|
||||
private bool LINK_OK = false;
|
||||
private int LINK_RUN = 0;
|
||||
private int LINK_ERR = 0;
|
||||
bool[] DQ = new bool[12];
|
||||
ushort DQ_L = 12;
|
||||
private async void Modbus_link()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
@@ -174,23 +176,27 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
//master.Transport.Retries = 100;
|
||||
// write three registers
|
||||
try
|
||||
|
||||
LINK_RUN++;
|
||||
// try
|
||||
{
|
||||
LINK_RUN++;
|
||||
|
||||
|
||||
|
||||
byte slaveId = 1;
|
||||
ushort startAddress = 100;
|
||||
ushort startAddress = 46001;
|
||||
ushort[] registers = new ushort[] { 1, 2, 3 };
|
||||
master.WriteMultipleRegisters(slaveId, startAddress, registers);
|
||||
// master.WriteMultipleRegisters(slaveId, startAddress, registers);
|
||||
|
||||
// bool[] x = master.ReadInputs(slaveId, 1001, 100);
|
||||
DQ = master.ReadCoils(slaveId,0, DQ_L);
|
||||
}
|
||||
catch (Exception ex)
|
||||
// catch (Exception ex)
|
||||
{
|
||||
LINK_ERR++;
|
||||
LogGing.LogGingDATA(ex.Message);
|
||||
// LogGing.LogGingDATA(ex.Message);
|
||||
Name_err = "PLC"+Properties.Resources.Connectionlost;
|
||||
}
|
||||
|
||||
updata_dtm("1001", LINK_RUN);
|
||||
updata_dtm("1002", LINK_ERR);
|
||||
|
||||
@@ -218,7 +224,13 @@ namespace DyeingComputer.ViewModel
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
for (ushort i = 0; i < DQ_L; i++)
|
||||
{
|
||||
|
||||
//updata_dtd(i.ToString(), DQ[i]);
|
||||
|
||||
}
|
||||
updata_dtd("1", false);
|
||||
SYSData_A = ToObservableCollection<DATA_A>(dt_a);
|
||||
SYSData_D = ToObservableCollection<DATA_D>(dt_d);
|
||||
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
|
||||
|
||||
Reference in new issue
Block a user