This commit is contained in:
Diego
2025-06-18 22:04:48 +08:00
parent d922296b70
commit 5f38076b1b
10 changed files with 21 additions and 29 deletions

View File

@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<PluginVersion>10.8.6</PluginVersion>
<ProPluginVersion>10.8.6</ProPluginVersion>
<PluginVersion>10.8.7</PluginVersion>
<ProPluginVersion>10.8.7</ProPluginVersion>
<AuthenticationVersion>2.8.0</AuthenticationVersion>
<SourceGeneratorVersion>10.8.2</SourceGeneratorVersion>
<NET8Version>8.0.17</NET8Version>

View File

@@ -549,7 +549,7 @@ public abstract class DeviceBase : DisposableObject, IDevice
Channel.ChannelReceivedWaitDict.TryAdd(sign, ChannelReceived);
var sendOperResult = await SendAsync(command, clientChannel, endPoint, cancellationToken).ConfigureAwait(false);
if (!sendOperResult.IsSuccess)
throw sendOperResult.Exception ?? new(sendOperResult.ErrorMessage);
throw sendOperResult.Exception ?? new(sendOperResult.ErrorMessage ?? "unknown error");
await waitData.WaitAsync(timeout).ConfigureAwait(false);

View File

@@ -0,0 +1,7 @@
namespace ThingsGateway.Gateway.Application
{
public interface IScheduledIntIntervalTask
{
int IntervalMS { get; }
}
}

View File

@@ -5,10 +5,10 @@ using TouchSocket.Core;
namespace ThingsGateway.Gateway.Application;
public class ScheduledAsyncTask : DisposeBase, IScheduledTask
public class ScheduledAsyncTask : DisposeBase, IScheduledTask, IScheduledIntIntervalTask
{
private int _interval10MS = 10;
private int _intervalMS;
public int IntervalMS { get; }
private readonly Func<object?, CancellationToken, Task> _taskFunc;
private readonly CancellationToken _token;
private TimerX? _timer;
@@ -19,7 +19,7 @@ public class ScheduledAsyncTask : DisposeBase, IScheduledTask
public ScheduledAsyncTask(int interval, Func<object?, CancellationToken, Task> taskFunc, object? state, ILog log, CancellationToken token)
{
_intervalMS = interval;
IntervalMS = interval;
LogMessage = log;
_state = state;
_taskFunc = taskFunc;
@@ -30,7 +30,7 @@ public class ScheduledAsyncTask : DisposeBase, IScheduledTask
{
_timer?.Dispose();
if (!_token.IsCancellationRequested)
_timer = new TimerX(DoAsync, _state, _intervalMS, _intervalMS, nameof(IScheduledTask)) { Async = true };
_timer = new TimerX(DoAsync, _state, IntervalMS, IntervalMS, nameof(IScheduledTask)) { Async = true };
}
private async Task DoAsync(object? state)
@@ -78,6 +78,7 @@ public class ScheduledAsyncTask : DisposeBase, IScheduledTask
_timer?.SetNext(_interval10MS);
}
public void Stop()
{
_timer?.Dispose();

View File

@@ -5,10 +5,10 @@ using TouchSocket.Core;
namespace ThingsGateway.Gateway.Application;
public class ScheduledSyncTask : DisposeBase, IScheduledTask
public class ScheduledSyncTask : DisposeBase, IScheduledTask, IScheduledIntIntervalTask
{
private int _interval10MS = 10;
private int _intervalMS;
public int IntervalMS { get; }
private readonly Action<object?, CancellationToken> _taskAction;
private readonly CancellationToken _token;
private TimerX? _timer;
@@ -19,7 +19,7 @@ public class ScheduledSyncTask : DisposeBase, IScheduledTask
public ScheduledSyncTask(int interval, Action<object?, CancellationToken> taskFunc, object? state, ILog log, CancellationToken token)
{
_intervalMS = interval;
IntervalMS = interval;
LogMessage = log;
_state = state;
_taskAction = taskFunc;
@@ -30,7 +30,7 @@ public class ScheduledSyncTask : DisposeBase, IScheduledTask
{
_timer?.Dispose();
if (!_token.IsCancellationRequested)
_timer = new TimerX(TimerCallback, _state, _intervalMS, _intervalMS, nameof(IScheduledTask)) { Async = true };
_timer = new TimerX(TimerCallback, _state, IntervalMS, IntervalMS, nameof(IScheduledTask)) { Async = true };
}
private void TimerCallback(object? state)
@@ -82,13 +82,6 @@ public class ScheduledSyncTask : DisposeBase, IScheduledTask
_timer?.SetNext(_interval10MS);
}
public void Change(int dueTime, int period)
{
_intervalMS = period;
if (!_token.IsCancellationRequested)
_timer?.Change(dueTime, period);
}
public void Stop()
{
_timer?.Dispose();

View File

@@ -12,6 +12,7 @@ public class TaskSchedulerLoop
{
return Tasks.Count;
}
public void Start()
{
foreach (var task in Tasks)

View File

@@ -40,12 +40,6 @@ public abstract class CollectPropertyBase : DriverPropertyBase
/// </summary>
public abstract class CollectPropertyRetryBase : CollectPropertyBase
{
/// <summary>
/// 离线后恢复运行的间隔时间
/// </summary>
[DynamicProperty]
public override int ReIntervalTime { get; set; } = 0;
/// <summary>
/// 失败重试次数默认3
/// </summary>

View File

@@ -298,11 +298,9 @@
},
"ThingsGateway.Gateway.Application.CollectPropertyBase": {
"ConcurrentCount": "ConcurrentCount",
"ReIntervalTime": "ReIntervalTime",
"RetryCount": "RetryCount"
},
"ThingsGateway.Gateway.Application.CollectPropertyRetryBase": {
"ReIntervalTime": "ReIntervalTime",
"RetryCount": "RetryCount"
},
"ThingsGateway.Gateway.Application.ControlController": {

View File

@@ -297,11 +297,9 @@
},
"ThingsGateway.Gateway.Application.CollectPropertyBase": {
"ConcurrentCount": "最大并发数量",
"ReIntervalTime": "离线恢复时间",
"RetryCount": "失败重试次数"
},
"ThingsGateway.Gateway.Application.CollectPropertyRetryBase": {
"ReIntervalTime": "离线恢复时间",
"RetryCount": "失败重试次数"
},
"ThingsGateway.Gateway.Application.ControlController": {

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.8.6</Version>
<Version>10.8.7</Version>
</PropertyGroup>
<ItemGroup>