2014-08-27 update 3

This commit is contained in:
parallelbgls@outlook.com
2014-08-28 08:53:30 +08:00
parent da82933c52
commit eb631389a9
4 changed files with 19 additions and 21 deletions

View File

@@ -90,6 +90,7 @@ namespace NA200H.UI.ConsoleApp
//先初始化一个协议转换器这里构造Modbus/Rtu协议。
BaseProtocal wrapper = new ModbusRtuProtocal();
/*
//调用方法一:手动构造
//第一步先生成一个输入信息的object数组
object[] inputObjects = new object[]{(byte)0x02,(byte)0x01,(short)0x00,(short)0x03};
@@ -102,8 +103,15 @@ namespace NA200H.UI.ConsoleApp
}
Console.WriteLine();
Console.Read();
Console.Read();
Console.Read();*/
ReadHoldRegisterModbusProtocal.ReadHoldRegisterInputStruct readHoldRegisterInputStruct = new ReadHoldRegisterModbusProtocal.ReadHoldRegisterInputStruct(2, "0", 4);
ReadHoldRegisterModbusProtocal.ReadHoldRegisterOutputStruct readHoldRegisterOutputStruct = (ReadHoldRegisterModbusProtocal.ReadHoldRegisterOutputStruct)wrapper.SendReceive(wrapper["ReadHoldRegisterModbusProtocal"], readHoldRegisterInputStruct);
for (int i = 0; i < readHoldRegisterOutputStruct.HoldRegisterStatus.Length; i++)
{
Console.WriteLine(readHoldRegisterOutputStruct.HoldRegisterStatus[i]);
}
Console.Read();
/*
//调用方法二:自动构造
//第一步:先生成一个输入结构体,然后向这个结构体中填写数据