串口连接数据修改
This commit is contained in:
commit
baa1266f55
1 file changed
+7
-7
@@ -239,7 +239,7 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
DispatcherTimer timer5s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(5)//秒
|
||||
Interval = TimeSpan.FromSeconds(5)//
|
||||
};
|
||||
timer5s.Tick += Tick_Event_5S;
|
||||
timer5s.Start();
|
||||
@@ -247,9 +247,9 @@ namespace DyeingComputer.ViewModel
|
||||
//设置定时器
|
||||
DispatcherTimer disTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(500) //毫秒
|
||||
Interval = TimeSpan.FromMilliseconds(200) //毫秒
|
||||
};
|
||||
disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法
|
||||
disTimer.Tick += DisTimer_200MS;
|
||||
disTimer.Start();//计时开始
|
||||
}//时间周期初始化
|
||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||
@@ -284,10 +284,10 @@ namespace DyeingComputer.ViewModel
|
||||
if (!LINK_OK) Modbus_link();
|
||||
Chart();//写入记录
|
||||
|
||||
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 10) || (Selet_dtm("1010") > 160)))
|
||||
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160)))
|
||||
{ Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
||||
}
|
||||
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
||||
void DisTimer_200MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
||||
{
|
||||
if (LINK_OK) Modbus_link();
|
||||
if (LINK_OK) IO_data();
|
||||
@@ -1465,9 +1465,9 @@ namespace DyeingComputer.ViewModel
|
||||
LINK_RUN++;
|
||||
try
|
||||
{
|
||||
master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈
|
||||
master.WriteMultipleCoils(slaveId, 02000, DQ); //写入线圈
|
||||
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
||||
DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈
|
||||
DO = master.ReadCoils(slaveId, 02255, DO_L); //读取线圈
|
||||
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
||||
LINK_OK = true;
|
||||
Name_err = "";
|
||||
|
||||
Reference in new issue
Block a user