Skip to content

Commit

Permalink
Update Features.ts
Browse files Browse the repository at this point in the history
- to simulate stream status issues
  • Loading branch information
cristian-recoseanu committed Jul 2, 2024
1 parent 6a2788c commit 0c4b41a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions code/src/NCModel/Features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ enum NcStreamStatus
Unhealthy = 3
}

function DelayTask(timeMs: number | undefined)
{
return new Promise(resolve => setTimeout(resolve, timeMs));
}

export class NcReceiverMonitor extends NcStatusMonitor
{
public static staticClassID: number[] = [ 1, 2, 2, 1 ];
Expand Down Expand Up @@ -524,6 +529,46 @@ export class NcReceiverMonitor extends NcStatusMonitor

this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 8), NcPropertyChangeType.ValueChanged, this.streamStatus, null);
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 9), NcPropertyChangeType.ValueChanged, this.streamStatusMessage, null);

DelayTask(5000).then(() => this.StreamBroken());
}

public StreamBroken()
{
if(this.overallStatus != NcOverallStatus.Inactive)
{
this.overallStatus = NcOverallStatus.Unhealthy;
this.overallStatusMessage = "Receiver stream status is unhealthy";

this.streamStatus = NcStreamStatus.Unhealthy;
this.streamStatusMessage = "Stream cannot be decoded";

this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 1), NcPropertyChangeType.ValueChanged, this.overallStatus, null);
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 2), NcPropertyChangeType.ValueChanged, this.overallStatusMessage, null);

this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 8), NcPropertyChangeType.ValueChanged, this.streamStatus, null);
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 9), NcPropertyChangeType.ValueChanged, this.streamStatusMessage, null);

DelayTask(2000).then(() => this.StreamFixed());
}
}

public StreamFixed()
{
if(this.overallStatus != NcOverallStatus.Inactive)
{
this.overallStatus = NcOverallStatus.Healthy;
this.overallStatusMessage = "Receiver is connected and healthy";

this.streamStatus = NcStreamStatus.Healthy;
this.streamStatusMessage = "Receiver is connected and stream is healthy";

this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 1), NcPropertyChangeType.ValueChanged, this.overallStatus, null);
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 2), NcPropertyChangeType.ValueChanged, this.overallStatusMessage, null);

this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 8), NcPropertyChangeType.ValueChanged, this.streamStatus, null);
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(4, 9), NcPropertyChangeType.ValueChanged, this.streamStatusMessage, null);
}
}

public Disconnected()
Expand Down

0 comments on commit 0c4b41a

Please sign in to comment.