|
@@ -541,11 +541,11 @@ namespace YSAI.Mitsubishi
|
|
|
{
|
|
{
|
|
|
case DevType.A1E:
|
|
case DevType.A1E:
|
|
|
details = ParseA1E(address);
|
|
details = ParseA1E(address);
|
|
|
- command = ReadCommand_A1E(details.BeginAddress, details.TypeCode, length, isBit);
|
|
|
|
|
|
|
+ command = ReadCommand_A1E(details.BeginAddress, details.TypeCode, (ushort)length, isBit);
|
|
|
break;
|
|
break;
|
|
|
case DevType.QNA3E:
|
|
case DevType.QNA3E:
|
|
|
details = ParseQNA3E(address);
|
|
details = ParseQNA3E(address);
|
|
|
- command = ReadCommand_QNA3E(details.BeginAddress, details.TypeCode, length, isBit);
|
|
|
|
|
|
|
+ command = ReadCommand_QNA3E(details.BeginAddress, details.TypeCode, (ushort)length, isBit);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
//发送等待结果
|
|
//发送等待结果
|
|
@@ -579,7 +579,30 @@ namespace YSAI.Mitsubishi
|
|
|
//读取失败返回
|
|
//读取失败返回
|
|
|
return new byte[] { };
|
|
return new byte[] { };
|
|
|
}
|
|
}
|
|
|
- return bytes;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int len = length;
|
|
|
|
|
+ byte[] RValue = null;
|
|
|
|
|
+ switch (basics.DType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case DevType.A1E:
|
|
|
|
|
+ RValue= new byte[bytes.Length - 2];
|
|
|
|
|
+ Array.Copy(bytes, 2, RValue, 0, RValue.Length);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case DevType.QNA3E:
|
|
|
|
|
+ if (isBit)
|
|
|
|
|
+ {
|
|
|
|
|
+ len = (ushort)Math.Ceiling(len * 0.5);
|
|
|
|
|
+ }
|
|
|
|
|
+ RValue = new byte[len];
|
|
|
|
|
+ Array.Copy(bytes, bytes.Length - len, RValue, 0, len);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (RValue == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ //读取失败返回
|
|
|
|
|
+ return new byte[] { };
|
|
|
|
|
+ }
|
|
|
|
|
+ return RValue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -746,6 +769,14 @@ namespace YSAI.Mitsubishi
|
|
|
{
|
|
{
|
|
|
addressData.addressName = item.AddressName;
|
|
addressData.addressName = item.AddressName;
|
|
|
}
|
|
}
|
|
|
|
|
+ ////如果是string 类型 (地址,长度)
|
|
|
|
|
+ //if (item.AddressDataType == Core.@enum.DataType.String)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // byte[] strByte = R(addressData.addressName, (ushort)addressData.count);
|
|
|
|
|
+ // Value = BitConverter.ToString(strByte).ToString();
|
|
|
|
|
+ //}
|
|
|
|
|
+ //else
|
|
|
|
|
+ //{
|
|
|
if (addressData.count.Equals(0))
|
|
if (addressData.count.Equals(0))
|
|
|
{
|
|
{
|
|
|
switch (item.AddressDataType)
|
|
switch (item.AddressDataType)
|
|
@@ -838,6 +869,7 @@ namespace YSAI.Mitsubishi
|
|
|
Value = $"不支持{item.AddressDataType}类型批量读取";
|
|
Value = $"不支持{item.AddressDataType}类型批量读取";
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ //}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//数据处理
|
|
//数据处理
|