e-register state change

This commit is contained in:
Stoyan Zlatev 2025-04-29 13:17:33 +02:00
parent d5b6e033e4
commit afc19d9fd5
3 changed files with 29 additions and 16 deletions

View File

@ -64,39 +64,39 @@
public void SetCancelled()
{
this.awaiter.Set();
this.State = SIRTTaskState.Cancelled;
this.awaiter.Set();
}
public void SetCompleted()
{
this.awaiter.Set();
this.State = SIRTTaskState.Completed;
this.awaiter.Set();
}
public void SetPending()
{
this.awaiter.Set();
this.awaiter.Reset();
this.State = SIRTTaskState.Pending;
this.awaiter.Set();
}
public void SetRunning()
{
this.State = SIRTTaskState.Running;
this.awaiter.Reset();
}
public virtual byte[] Start()
{
this.awaiter.Reset();
this.State = SIRTTaskState.Running;
this.Timestamp = DateTimeOffset.UtcNow;
this.awaiter.Reset();
return this.request.GetBytes();
}

View File

@ -234,6 +234,7 @@
this.runningTasks.Enqueue(new EregisterCheckInitializationTask(this.parameters, frequency)
{
Timeout = 20_000,
SlotNr = features.SlotNr,
PoNr = features.PoNr,
SerialNr = features.SerialNr,

View File

@ -16,7 +16,7 @@
public EregisterTask(int frequency)
{
this.Timeout = 15_000;
this.Timeout = 5_000;
this.Frequency = frequency;
this.RSSI = new RSSI(0, frequency);
this.Label = nameof(SIRTTaskState.Pending);
@ -32,7 +32,22 @@
public string Name { get; internal set; }
public string Label { get; internal set; }
private string label;
public string Label
{
get => this.label;
set
{
this.label = value;
var changeEvent = this.Changed;
if (changeEvent != null)
{
changeEvent(this);
}
}
}
public string Info { get; private set; }
@ -110,7 +125,7 @@
{
this.Label = nameof(SIRTTaskState.Cancelled);
}
else if (this.State == SIRTTaskState.Running)
else if (this.State != SIRTTaskState.Completed)
{
if (response.Address == this.ResponseAddress)
{
@ -225,16 +240,13 @@
if (this.Label != "AKN")
{
this.awaiter.Set();
this.awaiter.Reset();
this.SetPending();
}
}
else
{
this.Label = "NA";
}
this.Changed?.Invoke(this);
}
}