Add GetBit (SubAddress and typeof(bool)) Support
This commit is contained in:
@@ -12,6 +12,11 @@ namespace Modbus.Net.Modbus
|
||||
{
|
||||
return area + " " + address;
|
||||
}
|
||||
|
||||
public override string FormatAddress(string area, int address, int subAddress)
|
||||
{
|
||||
return area + " " + address + "." + subAddress;
|
||||
}
|
||||
}
|
||||
|
||||
public class AddressFormaterModbus : AddressFormater
|
||||
@@ -20,5 +25,10 @@ namespace Modbus.Net.Modbus
|
||||
{
|
||||
return area + " " + address;
|
||||
}
|
||||
|
||||
public override string FormatAddress(string area, int address, int subAddress)
|
||||
{
|
||||
return area + " " + address + "." + subAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,16 +60,29 @@ namespace Modbus.Net.Modbus
|
||||
string[] splitString = address.Split(' ');
|
||||
string head = splitString[0];
|
||||
string tail = splitString[1];
|
||||
string sub;
|
||||
if (tail.Contains('.'))
|
||||
{
|
||||
string[] splitString2 = tail.Split('.');
|
||||
sub = splitString2[1];
|
||||
tail = splitString2[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
sub = "0";
|
||||
}
|
||||
return isRead
|
||||
? new AddressDef()
|
||||
{
|
||||
Area = ReadFunctionCodeDictionary[head].Code,
|
||||
Address = TransDictionary[head] + int.Parse(tail) - 1,
|
||||
SubAddress = int.Parse(sub),
|
||||
}
|
||||
: new AddressDef()
|
||||
{
|
||||
Area = WriteFunctionCodeDictionary[head].Code,
|
||||
Address = TransDictionary[head] + int.Parse(tail) - 1,
|
||||
SubAddress = int.Parse(sub),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -109,16 +122,29 @@ namespace Modbus.Net.Modbus
|
||||
string[] splitString = address.Split(' ');
|
||||
string head = splitString[0];
|
||||
string tail = splitString[1];
|
||||
string sub;
|
||||
if (tail.Contains('.'))
|
||||
{
|
||||
string[] splitString2 = tail.Split('.');
|
||||
sub = splitString2[1];
|
||||
tail = splitString2[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
sub = "0";
|
||||
}
|
||||
return isRead
|
||||
? new AddressDef()
|
||||
{
|
||||
Area = ReadFunctionCodeDictionary[head].Code,
|
||||
Address = int.Parse(tail) - 1,
|
||||
SubAddress = int.Parse(sub),
|
||||
}
|
||||
: new AddressDef()
|
||||
{
|
||||
Area = WriteFunctionCodeDictionary[head].Code,
|
||||
Address = int.Parse(tail) - 1,
|
||||
SubAddress = int.Parse(sub),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user