Skip to content

Commit

Permalink
trim public
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 28, 2024
1 parent 9fca42a commit 2db2202
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion NewLife.IoT/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IDevice
{
#region 属性
/// <summary>设备编码。在平台中唯一标识设备</summary>
public String Code { get; set; }
String Code { get; set; }

/// <summary>属性集合</summary>
IDictionary<String, Object?> Properties { get; }
Expand Down
4 changes: 2 additions & 2 deletions NewLife.IoT/NewLife.IoT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'!='net40'">
<PackageReference Include="NewLife.Core" Version="10.10.2024.0501" />
<PackageReference Include="NewLife.Core" Version="10.10.2024.0625-beta1559" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<PackageReference Include="NewLife.Core" Version="10.10.2024.0501-net40" />
<PackageReference Include="NewLife.Core" Version="10.10.2024.0623-net40" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 7 additions & 17 deletions NewLife.IoT/ThingModels/IPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,13 @@ public static Object Convert(this IPoint point, Byte[] data)
}
if (type == null) return null;

switch (type.GetTypeCode())
return type.GetTypeCode() switch
{
case TypeCode.Boolean:
case TypeCode.Byte:
case TypeCode.SByte:
return data.ToBoolean() ? [(UInt16)0x01] : [(UInt16)0x00];
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
return data.ToInt() > 0 ? [(UInt16)0x01] : [(UInt16)0x00];
case TypeCode.Int64:
case TypeCode.UInt64:
return data.ToLong() > 0 ? [(UInt16)0x01] : [(UInt16)0x00];
default:
return data.ToBoolean() ? [(UInt16)0x01] : [(UInt16)0x00];
}
TypeCode.Boolean or TypeCode.Byte or TypeCode.SByte => data.ToBoolean() ? [0x01] : [0x00],
TypeCode.Int16 or TypeCode.UInt16 or TypeCode.Int32 or TypeCode.UInt32 => data.ToInt() > 0 ? [0x01] : [0x00],
TypeCode.Int64 or TypeCode.UInt64 => data.ToLong() > 0 ? [0x01] : [0x00],
_ => data.ToBoolean() ? [0x01] : [0x00],
};
}

/// <summary>根据点位信息和物模型信息,把原始数据转寄存器/字</summary>
Expand All @@ -139,7 +129,7 @@ public static Object Convert(this IPoint point, Byte[] data)
case TypeCode.Boolean:
case TypeCode.Byte:
case TypeCode.SByte:
return data.ToBoolean() ? [(UInt16)0x01] : [(UInt16)0x00];
return data.ToBoolean() ? [0x01] : [0x00];
case TypeCode.Int16:
case TypeCode.UInt16:
return [(UInt16)data.ToInt()];
Expand Down

0 comments on commit 2db2202

Please sign in to comment.