2014-10-09 update 1
This commit is contained in:
@@ -291,6 +291,11 @@ namespace ModBus.Net
|
|||||||
return translateTarget.ToArray();
|
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,
|
public object[] ByteArrayToObjectArray(byte[] contents,
|
||||||
IEnumerable<KeyValuePair<Type, int>> translateTypeAndCount)
|
IEnumerable<KeyValuePair<Type, int>> translateTypeAndCount)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace NA200H.UI.ConsoleApp
|
|||||||
bool[] array =
|
bool[] array =
|
||||||
ValueHelper.Instance.ObjectArrayToDestinationArray<bool>(
|
ValueHelper.Instance.ObjectArrayToDestinationArray<bool>(
|
||||||
ValueHelper.Instance.ByteArrayToObjectArray(readCoilStatusOutputStruct.DataValue,
|
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++)
|
for (int i = 0; i < array.Length; i++)
|
||||||
{
|
{
|
||||||
Console.WriteLine(array[i]);
|
Console.WriteLine(array[i]);
|
||||||
@@ -79,7 +79,7 @@ namespace NA200H.UI.ConsoleApp
|
|||||||
ushort[] array2 =
|
ushort[] array2 =
|
||||||
ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(
|
ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(
|
||||||
ValueHelper.Instance.ByteArrayToObjectArray(readHoldRegisterOutputStruct.DataValue,
|
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++)
|
for (int i = 0; i < array2.Length; i++)
|
||||||
{
|
{
|
||||||
Console.WriteLine(array2[i]);
|
Console.WriteLine(array2[i]);
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ namespace NA200H.UI.WPF
|
|||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
byte[] getNum = utility.GetDatas(0x02, (byte)ModbusProtocalReadDataFunctionCode.ReadHoldRegister, "10000", 4);
|
byte[] getNum = utility.GetDatas(0x02, (byte)ModbusProtocalReadDataFunctionCode.ReadHoldRegister, "10000", 4);
|
||||||
object[] getNumObjects =
|
object[] getNumObjects =
|
||||||
ValueHelper.Instance.ByteArrayToObjectArray(getNum,
|
ValueHelper.Instance.ByteArrayToObjectArray(getNum, new KeyValuePair<Type, int>(typeof(ushort), 4));
|
||||||
new List<KeyValuePair<Type, int>>() { { new KeyValuePair<Type, int>(typeof(ushort), 4) } });
|
|
||||||
ushort[] getNumUshorts = ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(getNumObjects);
|
ushort[] getNumUshorts = ValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(getNumObjects);
|
||||||
SetValue(getNumUshorts);
|
SetValue(getNumUshorts);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user