Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
81dc24761d
1 file changed
+19
-10
@@ -101,7 +101,7 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
DispatcherTimer timer5s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(5)//秒
|
||||
Interval = TimeSpan.FromSeconds(3)//秒
|
||||
};
|
||||
timer5s.Tick += Tick_Event_5S;
|
||||
timer5s.Start();
|
||||
@@ -120,7 +120,7 @@ namespace DyeingComputer.ViewModel
|
||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件
|
||||
{
|
||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
Work_Temp = Selet_dtm("1002") + " ℃";
|
||||
Work_Temp = Selet_dtm("1010") + " ℃";
|
||||
Work_Numder = WorkNumder.ToString();
|
||||
// Status_Str = "qweqeqwqqfwfqef";
|
||||
|
||||
@@ -162,15 +162,13 @@ namespace DyeingComputer.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
bool LINK_OK = false;
|
||||
public static async void Modbus_link()
|
||||
private bool LINK_OK = false;
|
||||
private int LINK_RUN = 0;
|
||||
private int LINK_ERR = 0;
|
||||
private async void Modbus_link()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
byte slaveId = 1;
|
||||
ushort startAddress = 100;
|
||||
ushort[] registers = new ushort[] { 1, 2, 3 };
|
||||
|
||||
master.Transport.ReadTimeout = 500;
|
||||
master.Transport.WriteTimeout = 500;
|
||||
|
||||
@@ -178,13 +176,24 @@ namespace DyeingComputer.ViewModel
|
||||
// write three registers
|
||||
try
|
||||
{
|
||||
LINK_RUN++;
|
||||
|
||||
|
||||
byte slaveId = 1;
|
||||
ushort startAddress = 100;
|
||||
ushort[] registers = new ushort[] { 1, 2, 3 };
|
||||
master.WriteMultipleRegisters(slaveId, startAddress, registers);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LINK_ERR++;
|
||||
LogGing.LogGingDATA(ex.Message);
|
||||
Name_err = "PLC"+Properties.Resources.Connectionlost;
|
||||
}
|
||||
|
||||
updata_dtm("1001", LINK_RUN);
|
||||
updata_dtm("1002", LINK_ERR);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,13 +231,13 @@ namespace DyeingComputer.ViewModel
|
||||
int index = Convert.ToInt16(arrRows[0]["Value"].ToString());
|
||||
return index;
|
||||
}
|
||||
private bool selet_dtd(string key)//D寄存器
|
||||
private bool Selet_dtd(string key)//D寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID=" + key);
|
||||
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
||||
return true;
|
||||
}
|
||||
private int selet_dta(string key)//A寄存器
|
||||
private int Selet_dta(string key)//A寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID=" + key);
|
||||
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
||||
|
||||
Reference in new issue
Block a user