This commit is contained in:
parallelbgls
2023-04-23 17:02:29 +08:00
parent d724dcc0f8
commit cbd84ff6e0
7 changed files with 20 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.IO.Ports;
namespace Modbus.Net.Siemens namespace Modbus.Net.Siemens
{ {
@@ -16,7 +17,11 @@ namespace Modbus.Net.Siemens
/// <param name="com">串口地址</param> /// <param name="com">串口地址</param>
/// <param name="slaveAddress">从站号</param> /// <param name="slaveAddress">从站号</param>
public SiemensPpiProtocolLinker(string com, int slaveAddress) public SiemensPpiProtocolLinker(string com, int slaveAddress)
: base(com, slaveAddress, parity:Parity.Even) : base(com, slaveAddress, parity:
ConfigurationReader.GetValue("COM:Siemens", "Parity") != null
? Enum.Parse<Parity>(ConfigurationReader.GetValue("COM:Siemens", "Parity"))
: null
)
{ {
((IConnectorWithController<byte[], byte[]>)BaseConnector).AddController(new FifoController( ((IConnectorWithController<byte[], byte[]>)BaseConnector).AddController(new FifoController(
int.Parse(ConfigurationReader.GetValue("COM:" + com + ":" + slaveAddress, "FetchSleepTime")), int.Parse(ConfigurationReader.GetValue("COM:" + com + ":" + slaveAddress, "FetchSleepTime")),

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {

View File

@@ -35,7 +35,8 @@
"COM": "COM1" "COM": "COM1"
}, },
"Siemens": { "Siemens": {
"COM": "COM2" "COM": "COM2",
"Parity": "Even"
} }
}, },
"Controller": { "Controller": {