Skip to content

Commit

Permalink
优化驱动
Browse files Browse the repository at this point in the history
  • Loading branch information
iioter committed Jan 16, 2022
1 parent abcdcd9 commit 0247527
Show file tree
Hide file tree
Showing 27 changed files with 214 additions and 43 deletions.
Binary file modified .vs/IoTGateway/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/IoTGateway/v16/.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_PublishTargetUrl>E:\workbench\iotgateway\IoTGateway\bin\Release\net5.0\publish\</_PublishTargetUrl>
<History>True|2021-12-24T11:18:19.0736393Z;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00;</History>
<History>True|2022-01-16T05:59:48.3664224Z;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00;</History>
</PropertyGroup>
</Project>
84 changes: 70 additions & 14 deletions Plugins/Drivers/DriverAllenBradley/AllenBradley.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,46 +96,102 @@ public DriverReturnValueModel Read(DriverAddressIoArgModel ioarg)
switch (ioarg.ValueType)
{
case PluginInterface.DataTypeEnum.Bit:
ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0;
var resultBit = plc.ReadBoolean(ioarg.Address);
if (resultBit.IsSucceed)
ret.Value = resultBit.Value == true ? 1 : 0;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Bool:
ret.Value = plc.ReadBoolean(ioarg.Address).Value;
var resultBool = plc.ReadBoolean(ioarg.Address);
if (resultBool.IsSucceed)
ret.Value = resultBool.Value == true ? 1 : 0;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.UByte:
ret.Value = plc.ReadByte(ioarg.Address).Value;
var resultUByte = plc.ReadByte(ioarg.Address);
if (resultUByte.IsSucceed)
ret.Value = resultUByte.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Byte:
ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value;
var resultByte = plc.ReadByte(ioarg.Address);
if (resultByte.IsSucceed)
ret.Value = (sbyte)resultByte.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint16:
ret.Value =plc.ReadUInt16(ioarg.Address).Value;
var resultUint = plc.ReadUInt16(ioarg.Address);
if (resultUint.IsSucceed)
ret.Value = resultUint.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int16:
ret.Value = plc.ReadInt16(ioarg.Address).Value;
var resultInt = plc.ReadInt16(ioarg.Address);
if (resultInt.IsSucceed)
ret.Value = resultInt.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint32:
ret.Value =plc.ReadUInt32(ioarg.Address).Value;
var resultUint32 = plc.ReadUInt32(ioarg.Address);
if (resultUint32.IsSucceed)
ret.Value = resultUint32.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int32:
ret.Value = plc.ReadInt32(ioarg.Address).Value;
var resultInt32 = plc.ReadInt32(ioarg.Address);
if (resultInt32.IsSucceed)
ret.Value = resultInt32.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Float:
ret.Value = plc.ReadFloat(ioarg.Address).Value;
var resultFloat = plc.ReadFloat(ioarg.Address);
if (resultFloat.IsSucceed)
ret.Value = resultFloat.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Double:
ret.Value = plc.ReadDouble(ioarg.Address).Value;
var resultDouble = plc.ReadDouble(ioarg.Address);
if (resultDouble.IsSucceed)
ret.Value = resultDouble.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint64:
ret.Value = plc.ReadUInt64(ioarg.Address).Value;
var resultUint64 = plc.ReadUInt64(ioarg.Address);
if (resultUint64.IsSucceed)
ret.Value = resultUint64.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int64:
ret.Value = plc.ReadInt64(ioarg.Address).Value;
var resultInt64 = plc.ReadInt64(ioarg.Address);
if (resultInt64.IsSucceed)
ret.Value = resultInt64.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.AsciiString:
ret.Value = plc.ReadString(ioarg.Address);
var resultIntAsciiStr = plc.ReadString(ioarg.Address);
if (resultIntAsciiStr.IsSucceed)
ret.Value = resultIntAsciiStr.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Utf8String:
ret.Value = plc.ReadString(ioarg.Address);
var resultIntUtf8Str = plc.ReadString(ioarg.Address);
if (resultIntUtf8Str.IsSucceed)
ret.Value = resultIntUtf8Str.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
default:
break;
Expand Down
84 changes: 70 additions & 14 deletions Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,46 +100,102 @@ public DriverReturnValueModel Read(DriverAddressIoArgModel ioarg)
switch (ioarg.ValueType)
{
case PluginInterface.DataTypeEnum.Bit:
ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0;
var resultBit = plc.ReadBoolean(ioarg.Address);
if (resultBit.IsSucceed)
ret.Value = resultBit.Value == true ? 1 : 0;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Bool:
ret.Value = plc.ReadBoolean(ioarg.Address).Value;
var resultBool = plc.ReadBoolean(ioarg.Address);
if (resultBool.IsSucceed)
ret.Value = resultBool.Value == true ? 1 : 0;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.UByte:
ret.Value = plc.ReadByte(ioarg.Address).Value;
var resultUByte = plc.ReadByte(ioarg.Address);
if (resultUByte.IsSucceed)
ret.Value = resultUByte.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Byte:
ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value;
var resultByte = plc.ReadByte(ioarg.Address);
if (resultByte.IsSucceed)
ret.Value = (sbyte)resultByte.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint16:
ret.Value =plc.ReadUInt16(ioarg.Address).Value;
var resultUint = plc.ReadUInt16(ioarg.Address);
if (resultUint.IsSucceed)
ret.Value = resultUint.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int16:
ret.Value = plc.ReadInt16(ioarg.Address).Value;
var resultInt = plc.ReadInt16(ioarg.Address);
if (resultInt.IsSucceed)
ret.Value = resultInt.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint32:
ret.Value =plc.ReadUInt32(ioarg.Address).Value;
var resultUint32 = plc.ReadUInt32(ioarg.Address);
if (resultUint32.IsSucceed)
ret.Value = resultUint32.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int32:
ret.Value = plc.ReadInt32(ioarg.Address).Value;
var resultInt32 = plc.ReadInt32(ioarg.Address);
if (resultInt32.IsSucceed)
ret.Value = resultInt32.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Float:
ret.Value = plc.ReadFloat(ioarg.Address).Value;
var resultFloat = plc.ReadFloat(ioarg.Address);
if (resultFloat.IsSucceed)
ret.Value = resultFloat.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Double:
ret.Value = plc.ReadDouble(ioarg.Address).Value;
var resultDouble = plc.ReadDouble(ioarg.Address);
if (resultDouble.IsSucceed)
ret.Value = resultDouble.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Uint64:
ret.Value = plc.ReadUInt64(ioarg.Address).Value;
var resultUint64 = plc.ReadUInt64(ioarg.Address);
if (resultUint64.IsSucceed)
ret.Value = resultUint64.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Int64:
ret.Value = plc.ReadInt64(ioarg.Address).Value;
var resultInt64 = plc.ReadInt64(ioarg.Address);
if (resultInt64.IsSucceed)
ret.Value = resultInt64.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.AsciiString:
ret.Value = plc.ReadString(ioarg.Address);
var resultIntAsciiStr = plc.ReadString(ioarg.Address);
if (resultIntAsciiStr.IsSucceed)
ret.Value = resultIntAsciiStr.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
case PluginInterface.DataTypeEnum.Utf8String:
ret.Value = plc.ReadString(ioarg.Address);
var resultIntUtf8Str = plc.ReadString(ioarg.Address);
if (resultIntUtf8Str.IsSucceed)
ret.Value = resultIntUtf8Str.Value;
else
ret.StatusType = VaribaleStatusTypeEnum.Bad;
break;
default:
break;
Expand Down
Loading

0 comments on commit 0247527

Please sign in to comment.