release:6.1.0.24

fix: modbus、s7 读取字节某一位开始的数组时,请求长度太大
feat: linux桌面软件添加net8实现
This commit is contained in:
Diego
2024-09-07 20:03:41 +08:00
parent 58917c1ff8
commit d79c874aa5
14 changed files with 62 additions and 31 deletions

View File

@@ -2,16 +2,16 @@
<!--PRO插件需补充 LicenseKey 文件也可以不依赖单独放到Plugins文件夹内-->
<ItemGroup Condition="'$(SolutionName)'!='ThingsGateway - Admin'">
<PackageReference Include="ThingsGateway.Plugin.DCON" Version="6.1.0.23"/>
<!--<PackageReference Include="ThingsGateway.Plugin.DKQ_A16D" Version="6.1.0.23" />-->
<PackageReference Include="ThingsGateway.Plugin.EDPF_NT" Version="6.1.0.23" />
<!--<PackageReference Include="ThingsGateway.Plugin.IDR210" Version="6.1.0.23" />-->
<PackageReference Include="ThingsGateway.Plugin.KELID2008" Version="6.1.0.23" />
<PackageReference Include="ThingsGateway.Plugin.LKSIS" Version="6.1.0.23" />
<PackageReference Include="ThingsGateway.Plugin.Melsec" Version="6.1.0.23" />
<PackageReference Include="ThingsGateway.Plugin.Omron" Version="6.1.0.23" />
<!--<PackageReference Include="ThingsGateway.Plugin.URF_R330" Version="6.1.0.23" />-->
<PackageReference Include="ThingsGateway.Plugin.USBScaner" Version="6.1.0.23" />
<PackageReference Include="ThingsGateway.Plugin.DCON" Version="6.1.0.24"/>
<!--<PackageReference Include="ThingsGateway.Plugin.DKQ_A16D" Version="6.1.0.24" />-->
<PackageReference Include="ThingsGateway.Plugin.EDPF_NT" Version="6.1.0.24" />
<!--<PackageReference Include="ThingsGateway.Plugin.IDR210" Version="6.1.0.24" />-->
<PackageReference Include="ThingsGateway.Plugin.KELID2008" Version="6.1.0.24" />
<PackageReference Include="ThingsGateway.Plugin.LKSIS" Version="6.1.0.24" />
<PackageReference Include="ThingsGateway.Plugin.Melsec" Version="6.1.0.24" />
<PackageReference Include="ThingsGateway.Plugin.Omron" Version="6.1.0.24" />
<!--<PackageReference Include="ThingsGateway.Plugin.URF_R330" Version="6.1.0.24" />-->
<PackageReference Include="ThingsGateway.Plugin.USBScaner" Version="6.1.0.24" />
</ItemGroup>

View File

@@ -90,13 +90,18 @@ public interface IProtocol : IDisposable
/// </summary>
/// <returns></returns>
string GetAddressDescription();
/// <summary>
/// 获取变量地址对应的bit偏移默认0
/// </summary>
/// <param name="address">变量地址</param>
/// <returns></returns>
int GetBitOffsetDefault(string address);
/// <summary>
/// 获取变量地址对应的bit偏移
/// </summary>
/// <param name="address">变量地址</param>
/// <returns></returns>
int GetBitOffset(string address);
int? GetBitOffset(string address);
/// <summary>
/// 获取数据类型对应的寄存器长度

View File

@@ -169,15 +169,23 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
{
return DefaultResource.Localizer["DefaultAddressDes"];
}
/// <summary>
/// 获取bit偏移量
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public virtual int GetBitOffset(string address)
public int GetBitOffsetDefault(string address)
{
int bitIndex = 0;
return GetBitOffset(address) ?? 0;
}
/// <summary>
/// 获取bit偏移量
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public virtual int? GetBitOffset(string address)
{
int? bitIndex = null;
if (address?.IndexOf('.') > 0)
bitIndex = address.SplitStringByDelimiter().Last().ToInt();
return bitIndex;
@@ -193,7 +201,7 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
public virtual int GetLength(string address, int length, int typeLength, bool isBool = false)
{
var result = Math.Ceiling((double)length * typeLength / RegisterByteLength);
if (isBool)
if (isBool && GetBitOffset(address) != null)
{
var data = Math.Ceiling((double)length / RegisterByteLength / 8);
return (int)data;
@@ -537,7 +545,7 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
var result = await ReadAsync(address, GetLength(address, length, RegisterByteLength, true), cancellationToken).ConfigureAwait(false);
return result.OperResultFrom(() => bitConverter.ToBoolean(result.Content, GetBitOffset(address), length, BitReverse(address)));
return result.OperResultFrom(() => bitConverter.ToBoolean(result.Content, GetBitOffsetDefault(address), length, BitReverse(address)));
}
/// <inheritdoc/>

View File

@@ -0,0 +1,9 @@
<Project>
<Target Name="PostPublish" AfterTargets="Publish">
<Exec Command=" &#xD;&#xA; set dir=&quot;bin\$(Configuration)\$(TargetFramework)\Plugins&quot;&#xD;&#xA; &#xD;&#xA; if not exist %dir% md %dir% &#xD;&#xA;&#xD;&#xA; set dir1=&quot;$(PublishDir)Plugins&quot;&#xD;&#xA; &#xD;&#xA; if not exist %dir1% md %dir1% &#xD;&#xA;&#xD;&#xA; xcopy %dir% %dir1% /E /H /C /K /Y &#xD;&#xA;&#xD;&#xA;" />
<!--<ItemGroup>
<PDBFilesToDelete Include="$(PublishDir)\*.pdb" />
</ItemGroup>
<Delete Files="@(PDBFilesToDelete)" />-->
</Target>
</Project>

View File

@@ -57,9 +57,7 @@ internal class Program
app.Services.UseServicesWithoutWeb();
app.MainWindow.ContextMenuEnabled = false;
#if !DEBUG
app.MainWindow.DevToolsEnabled = false;
#endif
app.MainWindow.DevToolsEnabled = true;
app.MainWindow.GrantBrowserPermissions = true;
app.MainWindow.SetUseOsDefaultLocation(false);
app.MainWindow.SetUseOsDefaultSize(false);

View File

@@ -8,7 +8,7 @@
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<TargetFrameworks>net6.0;</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<!--<PublishAot>true</PublishAot>-->
<!--动态适用GC-->
@@ -62,7 +62,7 @@
<None Include="..\ThingsGateway.Server\Directory.Build.targets" Link="Directory.Build.targets" />
<Content Include="..\ThingsGateway.Server\wwwroot\favicon.ico" Link="wwwroot\favicon.ico" />
<Content Include="..\ThingsGateway.Server\wwwroot\favicon.png" Link="wwwroot\favicon.png" />
<Content Include="..\ThingsGateway.Server\appsettings.Development.json" Link="appsettings.Development.json">

View File

@@ -0,0 +1,9 @@
<Project>
<Target Name="PostPublish" AfterTargets="Publish">
<Exec Command=" &#xD;&#xA; set dir=&quot;bin\$(Configuration)\$(TargetFramework)\Plugins&quot;&#xD;&#xA; &#xD;&#xA; if not exist %dir% md %dir% &#xD;&#xA;&#xD;&#xA; set dir1=&quot;$(PublishDir)Plugins&quot;&#xD;&#xA; &#xD;&#xA; if not exist %dir1% md %dir1% &#xD;&#xA;&#xD;&#xA; xcopy %dir% %dir1% /E /H /C /K /Y &#xD;&#xA;&#xD;&#xA;" />
<!--<ItemGroup>
<PDBFilesToDelete Include="$(PublishDir)\*.pdb" />
</ItemGroup>
<Delete Files="@(PDBFilesToDelete)" />-->
</Target>
</Project>

View File

@@ -64,8 +64,7 @@
<Compile Include="..\ThingsGateway.Server\SingleFilePublish.cs" Link="SingleFilePublish.cs" />
<None Include="..\ThingsGateway.Server\Directory.Build.targets" Link="Directory.Build.targets" />
<Content Include="..\ThingsGateway.Server\wwwroot\favicon.ico" Link="wwwroot\favicon.ico" />
<Content Include="..\ThingsGateway.Server\wwwroot\favicon.png" Link="wwwroot\favicon.png" />
<Content Include="..\ThingsGateway.Server\appsettings.Development.json" Link="appsettings.Development.json">

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>6.1.0.23</Version>
<Version>6.1.0.24</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -34,7 +34,7 @@ internal static class PackHelper
item.ThingsGatewayBitConverter = transformParameter;
item.Index = 0;
if (item.DataType == DataTypeEnum.Boolean)
item.Index = device.GetBitOffset(item.RegisterAddress);
item.Index = device.GetBitOffsetDefault(item.RegisterAddress);
}
var group = deviceVariables.GroupBy(a => a.RegisterAddress);
foreach (var item in group)

View File

@@ -50,7 +50,7 @@ public class PackHelper
item.Index = 0;
// 获取变量的位偏移量
//if (item.DataType == DataTypeEnum.Boolean)
item.Index = device.GetBitOffset(address);
item.Index = device.GetBitOffsetDefault(address);
if (item.DataType == DataTypeEnum.Byte)
item.Index += (item.Index % 2 == 0) ? 1 : -1;
}

View File

@@ -36,7 +36,7 @@ internal static class PackHelper
item.ThingsGatewayBitConverter = transformParameter;
item.Index = 0;
if (item.DataType == DataTypeEnum.Boolean)
item.Index = device.GetBitOffset(address);
item.Index = device.GetBitOffsetDefault(address);
}
// 按读取间隔分组

View File

@@ -79,7 +79,7 @@ public partial class SiemensS7Master : ProtocolBase
}
/// <inheritdoc/>
public override int GetBitOffset(string address)
public override int? GetBitOffset(string address)
{
if (address.IndexOf('.') > 0)
{
@@ -97,7 +97,10 @@ public partial class SiemensS7Master : ProtocolBase
return 0;
}
}
return 0;
else
{
return null;
}
}
/// <inheritdoc/>

View File

@@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<!--动态适用GC-->
<GarbageCollectionAdaptationMode>true</GarbageCollectionAdaptationMode>