2016-01-07 update 1 version 1.1 support little endian protocal and change the description of TaskManager ReturnValue and AddressTranslator.
This commit is contained in:
@@ -26,9 +26,10 @@ namespace Modbus.Net.Siemens
|
||||
};
|
||||
}
|
||||
|
||||
public override KeyValuePair<int, int> AddressTranslate(string address, bool isRead)
|
||||
public override AddressDef AddressTranslate(string address, bool isRead)
|
||||
{
|
||||
/*address = address.ToUpper();
|
||||
/*
|
||||
address = address.ToUpper();
|
||||
if (address.Substring(0, 2) == "DB")
|
||||
{
|
||||
var addressSplit = address.Split('.');
|
||||
@@ -36,8 +37,11 @@ namespace Modbus.Net.Siemens
|
||||
addressSplit[0] = addressSplit[0].Substring(2);
|
||||
if (addressSplit[1].Substring(0, 2) == "DB")
|
||||
addressSplit[1] = addressSplit[1].Substring(2);
|
||||
return new KeyValuePair<int, int>(int.Parse(addressSplit[1]),
|
||||
int.Parse(addressSplit[0])*256 + AreaCodeDictionary["DB"]);
|
||||
return new AddressDef()
|
||||
{
|
||||
Area = int.Parse(addressSplit[0])*256 + AreaCodeDictionary["DB"],
|
||||
Address = int.Parse(addressSplit[1])
|
||||
};
|
||||
}
|
||||
int i = 0;
|
||||
int t;
|
||||
@@ -49,8 +53,11 @@ namespace Modbus.Net.Siemens
|
||||
string head = address.Substring(0, i);
|
||||
string tail = address.Substring(i);
|
||||
return
|
||||
new KeyValuePair<int, int>(int.Parse(tail),
|
||||
AreaCodeDictionary[head]);
|
||||
new AddressDef()
|
||||
{
|
||||
Area = AreaCodeDictionary[head],
|
||||
Address = int.Parse(tail)
|
||||
};
|
||||
*/
|
||||
string[] splitString = address.Split(' ');
|
||||
string head = splitString[0];
|
||||
@@ -58,12 +65,18 @@ namespace Modbus.Net.Siemens
|
||||
if (head.Length > 1 && head.Substring(0, 2) == "DB")
|
||||
{
|
||||
head = head.Substring(2);
|
||||
return new KeyValuePair<int, int>(int.Parse(tail),
|
||||
int.Parse(head)*256 + AreaCodeDictionary["DB"]);
|
||||
return new AddressDef()
|
||||
{
|
||||
Area = int.Parse(head)*256 + AreaCodeDictionary["DB"],
|
||||
Address = int.Parse(tail)
|
||||
};
|
||||
}
|
||||
return
|
||||
new KeyValuePair<int, int>(int.Parse(tail),
|
||||
AreaCodeDictionary[head]);
|
||||
new AddressDef()
|
||||
{
|
||||
Area = AreaCodeDictionary[head],
|
||||
Address = int.Parse(tail)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user