mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 18:51:28 +08:00
release:6.1.0.24
fix: modbus、s7 读取字节某一位开始的数组时,请求长度太大 feat: linux桌面软件添加net8实现
This commit is contained in:
@@ -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>
|
||||
|
||||
|
@@ -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>
|
||||
/// 获取数据类型对应的寄存器长度
|
||||
|
@@ -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/>
|
||||
|
9
src/ThingsGateway.Photino/Directory.Build.targets
Normal file
9
src/ThingsGateway.Photino/Directory.Build.targets
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project>
|
||||
<Target Name="PostPublish" AfterTargets="Publish">
|
||||
<Exec Command=" 
 set dir="bin\$(Configuration)\$(TargetFramework)\Plugins"
 
 if not exist %dir% md %dir% 

 set dir1="$(PublishDir)Plugins"
 
 if not exist %dir1% md %dir1% 

 xcopy %dir% %dir1% /E /H /C /K /Y 

" />
|
||||
<!--<ItemGroup>
|
||||
<PDBFilesToDelete Include="$(PublishDir)\*.pdb" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(PDBFilesToDelete)" />-->
|
||||
</Target>
|
||||
</Project>
|
@@ -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);
|
||||
|
@@ -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">
|
||||
|
9
src/ThingsGateway.Winform/Directory.Build.targets
Normal file
9
src/ThingsGateway.Winform/Directory.Build.targets
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project>
|
||||
<Target Name="PostPublish" AfterTargets="Publish">
|
||||
<Exec Command=" 
 set dir="bin\$(Configuration)\$(TargetFramework)\Plugins"
 
 if not exist %dir% md %dir% 

 set dir1="$(PublishDir)Plugins"
 
 if not exist %dir1% md %dir1% 

 xcopy %dir% %dir1% /E /H /C /K /Y 

" />
|
||||
<!--<ItemGroup>
|
||||
<PDBFilesToDelete Include="$(PublishDir)\*.pdb" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(PDBFilesToDelete)" />-->
|
||||
</Target>
|
||||
</Project>
|
@@ -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">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>6.1.0.23</Version>
|
||||
<Version>6.1.0.24</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
// 按读取间隔分组
|
||||
|
@@ -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/>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user