2014-10-09 update 1

This commit is contained in:
parallelbgls@outlook.com
2014-10-09 09:08:42 +08:00
parent 2d2f117a44
commit c31a38d99a
3 changed files with 8 additions and 4 deletions

View File

@@ -291,6 +291,11 @@ namespace ModBus.Net
return translateTarget.ToArray();
}
public object[] ByteArrayToObjectArray(byte[] contents, KeyValuePair<Type, int> translateTypeAndCount)
{
return ByteArrayToObjectArray(contents, new List<KeyValuePair<Type, int>>() {translateTypeAndCount});
}
public object[] ByteArrayToObjectArray(byte[] contents,
IEnumerable<KeyValuePair<Type, int>> translateTypeAndCount)
{

View File

@@ -65,7 +65,7 @@ namespace NA200H.UI.ConsoleApp
bool[] array =
ValueHelper.Instance.ObjectArrayToDestinationArray<bool>(
ValueHelper.Instance.ByteArrayToObjectArray(readCoilStatusOutputStruct.DataValue,
new List<KeyValuePair<Type, int>>() {new KeyValuePair<Type, int>(typeof (bool), 0x0a)}));
new KeyValuePair<Type, int>(typeof (bool), 0x0a)));
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine(array[i]);
@@ -79,7 +79,7 @@ namespace NA200H.UI.ConsoleApp
ushort[] array2 =
ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(
ValueHelper.Instance.ByteArrayToObjectArray(readHoldRegisterOutputStruct.DataValue,
new List<KeyValuePair<Type, int>>() {new KeyValuePair<Type, int>(typeof (ushort), 8)}));
new KeyValuePair<Type, int>(typeof (ushort), 8)));
for (int i = 0; i < array2.Length; i++)
{
Console.WriteLine(array2[i]);

View File

@@ -47,8 +47,7 @@ namespace NA200H.UI.WPF
Thread.Sleep(100);
byte[] getNum = utility.GetDatas(0x02, (byte)ModbusProtocalReadDataFunctionCode.ReadHoldRegister, "10000", 4);
object[] getNumObjects =
ValueHelper.Instance.ByteArrayToObjectArray(getNum,
new List<KeyValuePair<Type, int>>() { { new KeyValuePair<Type, int>(typeof(ushort), 4) } });
ValueHelper.Instance.ByteArrayToObjectArray(getNum, new KeyValuePair<Type, int>(typeof(ushort), 4));
ushort[] getNumUshorts = ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(getNumObjects);
SetValue(getNumUshorts);
}