Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1331b6a0c | ||
|
|
10d66b642b | ||
|
|
cd2310e4a8 | ||
|
|
1b399cf6b0 |
@@ -22,7 +22,9 @@
|
||||
|
||||
[ThingsGateway演示地址](http://120.24.62.140:5000/)
|
||||
|
||||
账户 : **superAdmin** 密码 : **111111**
|
||||
账户 : **superAdmin**
|
||||
|
||||
密码 : **111111**
|
||||
|
||||
## 赞助
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.0.7.0</Version>
|
||||
<Version>2.0.8.0</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.40" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.40" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.8.8.40" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.96" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.99" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.2" />
|
||||
|
||||
@@ -330,11 +330,6 @@ public class CollectDeviceCore
|
||||
return ThreadRunReturn.Continue;
|
||||
}
|
||||
|
||||
if (DeviceVariableSourceReads.Count == 0 && Device.DeviceVariableRunTimes.Where(a => string.IsNullOrEmpty(a.OtherMethod)).Any())
|
||||
{
|
||||
//无采集变量
|
||||
return ThreadRunReturn.Continue;
|
||||
}
|
||||
if (token.IsCancellationRequested)
|
||||
return ThreadRunReturn.Break;
|
||||
|
||||
@@ -534,7 +529,7 @@ public class CollectDeviceCore
|
||||
|
||||
if (!string.IsNullOrEmpty(methodResult.MethodStr))
|
||||
{
|
||||
string[] strs = methodResult.MethodStr?.Trim()?.Split(';');
|
||||
string[] strs = methodResult.MethodStr?.Trim()?.TrimEnd(';').Split(';');
|
||||
try
|
||||
{
|
||||
int index = 0;
|
||||
@@ -546,6 +541,8 @@ public class CollectDeviceCore
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strs.Length <= index)
|
||||
continue;
|
||||
//得到对于的方法参数值
|
||||
methodResult.MethodObj[i] = methodResult.Converter.ConvertFrom(strs[index], ps[i].ParameterType);
|
||||
index++;
|
||||
@@ -601,8 +598,8 @@ public class CollectDeviceCore
|
||||
|
||||
if (!string.IsNullOrEmpty(deviceVariableMethodSource.MethodStr) || !string.IsNullOrEmpty(value))
|
||||
{
|
||||
string[] strs1 = deviceVariableMethodSource.MethodStr?.Trim()?.Split(';');
|
||||
string[] strs2 = value?.Trim()?.Split(';');
|
||||
string[] strs1 = deviceVariableMethodSource.MethodStr?.Trim()?.TrimEnd(';').Split(';');
|
||||
string[] strs2 = value?.Trim()?.TrimEnd(';').Split(';');
|
||||
//通过分号分割,并且合并参数
|
||||
var strs = strs1?.SpliceArray(strs2);
|
||||
int index = 0;
|
||||
@@ -668,18 +665,25 @@ public class CollectDeviceCore
|
||||
if (method.HasReturn && result != null && result.IsSuccess)
|
||||
{
|
||||
var content = deviceVariableMethodSource.Converter.ConvertTo(result.Content?.ToString()?.Replace($"\0", ""));
|
||||
var operResult = deviceVariableMethodSource.DeviceVariable.SetValue(content);
|
||||
if (!operResult.IsSuccess)
|
||||
if (isRead)
|
||||
{
|
||||
_logger?.LogWarning(operResult.Message, ToString());
|
||||
var operResult = deviceVariableMethodSource.DeviceVariable.SetValue(content);
|
||||
if (!operResult.IsSuccess)
|
||||
{
|
||||
_logger?.LogWarning(operResult.Message, ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var operResult = deviceVariableMethodSource.DeviceVariable.SetValue(null);
|
||||
if (!operResult.IsSuccess)
|
||||
if (isRead)
|
||||
{
|
||||
_logger?.LogWarning(operResult.Message, ToString());
|
||||
var operResult = deviceVariableMethodSource.DeviceVariable.SetValue(null);
|
||||
if (!operResult.IsSuccess)
|
||||
{
|
||||
_logger?.LogWarning(operResult.Message, ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0-beta.135" />
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0-beta.138" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)'!='net45'">
|
||||
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.0.7.0</Version>
|
||||
<Version>2.0.8.0</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -53,18 +53,19 @@ namespace ThingsGateway.Siemens
|
||||
}
|
||||
else if (it.DataTypeEnum.GetSystemType() == typeof(string))
|
||||
{
|
||||
lastLen = it.ThingsGatewayBitConverter.StringLength;
|
||||
if (siemensS7Net.CurrentPlc == SiemensEnum.S200Smart)
|
||||
{
|
||||
//字符串在S200Smart中,第一个字节不属于实际内容
|
||||
it.Index += 1;
|
||||
it.ThingsGatewayBitConverter.StringLength -= 1;
|
||||
//it.ThingsGatewayBitConverter.StringLength -= 1;
|
||||
lastLen = it.ThingsGatewayBitConverter.StringLength + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//字符串在S7中,前两个字节不属于实际内容
|
||||
it.Index += 2;
|
||||
it.ThingsGatewayBitConverter.StringLength -= 2;
|
||||
//it.ThingsGatewayBitConverter.StringLength -= 2;
|
||||
lastLen = it.ThingsGatewayBitConverter.StringLength + 2;
|
||||
}
|
||||
}
|
||||
else if (it.DataTypeEnum.GetSystemType() == typeof(object))
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Threading.Tasks;
|
||||
|
||||
using ThingsGateway.Application;
|
||||
using ThingsGateway.Foundation;
|
||||
using ThingsGateway.Foundation.Extension;
|
||||
|
||||
namespace ThingsGateway.Siemens;
|
||||
/// <summary>
|
||||
@@ -79,53 +80,49 @@ public abstract class Siemens : CollectBase
|
||||
/// <see cref="SiemensS7PLC.ReadDateAsync(string,CancellationToken)"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DeviceMethod("ReadDate", "")]
|
||||
public Task<OperResult<System.DateTime>> ReadDateAsync(string address, CancellationToken token)
|
||||
[DeviceMethod("ReadWriteDateAsync", "")]
|
||||
public async Task<OperResult<System.DateTime>> ReadWriteDateAsync(string address, System.DateTime? value = null, CancellationToken token = default)
|
||||
{
|
||||
return _plc?.ReadDateAsync(address, token);
|
||||
if (value == null)
|
||||
return await _plc?.ReadDateAsync(address, token);
|
||||
else
|
||||
return (await _plc?.WriteDateAsync(address, value.Value, token)).Copy<System.DateTime>();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiemensS7PLC.ReadDateTimeAsync(string,CancellationToken)"/>
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[DeviceMethod("ReadDateTime", "")]
|
||||
public Task<OperResult<System.DateTime>> ReadDateTimeAsync(string address, CancellationToken token)
|
||||
[DeviceMethod("ReadWriteDateTimeAsync", "")]
|
||||
public async Task<OperResult<System.DateTime>> ReadWriteDateTimeAsync(string address, System.DateTime? value = null, CancellationToken token = default)
|
||||
{
|
||||
return _plc?.ReadDateTimeAsync(address, token);
|
||||
if (value == null)
|
||||
return await _plc?.ReadDateTimeAsync(address, token);
|
||||
else
|
||||
return (await _plc?.WriteDateTimeAsync(address, value.Value, token)).Copy<System.DateTime>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiemensS7PLC.ReadStringAsync(string,Encoding,CancellationToken)"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DeviceMethod("ReadString", "")]
|
||||
public Task<OperResult<string>> ReadStringAsync(string address, Encoding encoding, CancellationToken token)
|
||||
[DeviceMethod("ReadWriteStringAsync", "")]
|
||||
public async Task<OperResult<string>> ReadWriteStringAsync(string address, Encoding encoding, string value = null, CancellationToken token = default)
|
||||
{
|
||||
return _plc?.ReadStringAsync(address, encoding, token);
|
||||
encoding ??= Encoding.UTF8;
|
||||
if (value == null)
|
||||
return await _plc?.ReadStringAsync(address, encoding, token);
|
||||
else
|
||||
return (await _plc?.WriteAsync(address, value, token)).Copy<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiemensS7PLC.WriteDateAsync(string,System.DateTime,CancellationToken)"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DeviceMethod("WriteDate", "")]
|
||||
public Task<OperResult> WriteDateAsync(string address, System.DateTime dateTime, CancellationToken token)
|
||||
{
|
||||
return _plc?.WriteDateAsync(address, dateTime, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiemensS7PLC.WriteDateTimeAsync(string,System.DateTime,CancellationToken)"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DeviceMethod("WriteDateTime", "")]
|
||||
public Task<OperResult> WriteDateTimeAsync(string address, System.DateTime dateTime, CancellationToken token)
|
||||
{
|
||||
return _plc?.WriteDateTimeAsync(address, dateTime, token);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<OperResult> WriteValueAsync(DeviceVariableRunTime deviceVariable, JToken value, CancellationToken token)
|
||||
|
||||
@@ -117,38 +117,27 @@
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.LoadSourceRead(System.Collections.Generic.List{ThingsGateway.Application.DeviceVariableRunTime})">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadDateAsync(System.String,System.Threading.CancellationToken)">
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadWriteDateAsync(System.String,System.Nullable{System.DateTime},System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
<see cref="M:ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC.ReadDateAsync(System.String,System.Threading.CancellationToken)"/>
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadDateTimeAsync(System.String,System.Threading.CancellationToken)">
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadWriteDateTimeAsync(System.String,System.Nullable{System.DateTime},System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
<see cref="M:ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC.ReadDateTimeAsync(System.String,System.Threading.CancellationToken)"/>
|
||||
</summary>
|
||||
<param name="address"></param>
|
||||
<param name="value"></param>
|
||||
<param name="token"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadStringAsync(System.String,System.Text.Encoding,System.Threading.CancellationToken)">
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.ReadWriteStringAsync(System.String,System.Text.Encoding,System.String,System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
<see cref="M:ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC.ReadStringAsync(System.String,System.Text.Encoding,System.Threading.CancellationToken)"/>
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.WriteDateAsync(System.String,System.DateTime,System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
<see cref="M:ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC.WriteDateAsync(System.String,System.DateTime,System.Threading.CancellationToken)"/>
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.WriteDateTimeAsync(System.String,System.DateTime,System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
<see cref="M:ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC.WriteDateTimeAsync(System.String,System.DateTime,System.Threading.CancellationToken)"/>
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Siemens.Siemens.WriteValueAsync(ThingsGateway.Application.DeviceVariableRunTime,Newtonsoft.Json.Linq.JToken,System.Threading.CancellationToken)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
|
||||
Reference in New Issue
Block a user