Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
fa5e8efd25
1 file changed
+13
-12
@@ -123,7 +123,8 @@ namespace DyeingComputer.ViewModel
|
|||||||
lk++;
|
lk++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerialPort port = new SerialPort();//创建串口
|
public static SerialPort port = new SerialPort();//创建串口
|
||||||
|
|
||||||
void UPort()
|
void UPort()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -140,19 +141,17 @@ namespace DyeingComputer.ViewModel
|
|||||||
LogGing.LogGingDATA("800_SerialPort_Not");
|
LogGing.LogGingDATA("800_SerialPort_Not");
|
||||||
LogGing.LogGingDATA(e.Message);
|
LogGing.LogGingDATA(e.Message);
|
||||||
}
|
}
|
||||||
|
ModbusFactory factory = new ModbusFactory();
|
||||||
|
|
||||||
|
|
||||||
|
IModbusMaster master = factory.CreateRtuMaster(port);
|
||||||
// var factory = new ModbusFactory();
|
|
||||||
// IModbusMaster master = factory.CreateRtuMaster(port);
|
// byte slaveId = 1;
|
||||||
// IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port);
|
// ushort startAddress = 1;
|
||||||
byte slaveId = 1;
|
// ushort[] registers = new ushort[] { 1, 2, 3 };
|
||||||
ushort startAddress = 100;
|
|
||||||
ushort[] registers = new ushort[] { 1, 2, 3 };
|
|
||||||
|
|
||||||
// write three registers
|
// write three registers
|
||||||
|
// master.WriteMultipleRegisters(slaveId, startAddress, registers);
|
||||||
var master = ModbusRtuMaster.CreateSerial("COM1", 9600, Parity.None, 8, StopBits.One);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,8 +171,10 @@ namespace DyeingComputer.ViewModel
|
|||||||
SQLiteHelpers.Close();
|
SQLiteHelpers.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IO_data()//刷新
|
void IO_data()//刷新
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
updata_dtm("1001", lk);
|
updata_dtm("1001", lk);
|
||||||
updata_dtd("2001", Convert.ToBoolean(1));
|
updata_dtd("2001", Convert.ToBoolean(1));
|
||||||
updata_dta("4001",10000+lk);
|
updata_dta("4001",10000+lk);
|
||||||
|
|||||||
Reference in new issue
Block a user