Skip to content

Commit 8a40c99

Browse files
Update descriptors related to some of the feature sets (#28)
1 parent 31674cf commit 8a40c99

File tree

4 files changed

+224
-64
lines changed

4 files changed

+224
-64
lines changed

code/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/src/NCModel/Core.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -554,38 +554,6 @@ export class NcMethodResultId extends NcMethodResult
554554
}
555555
}
556556

557-
export class NcMethodResultReceiverStatus extends NcMethodResult
558-
{
559-
public value: NcReceiverStatus;
560-
561-
public constructor(
562-
status: NcMethodStatus,
563-
value: NcReceiverStatus)
564-
{
565-
super(status);
566-
567-
this.value = value;
568-
}
569-
570-
public static override GetTypeDescriptor(includeInherited: boolean): NcDatatypeDescriptor
571-
{
572-
let currentClassDescriptor = new NcDatatypeDescriptorStruct("NcMethodResultReceiverStatus", [
573-
new NcFieldDescriptor("value", "NcReceiverStatus", false, false, null, "Receiver status method result value")
574-
], "NcMethodResult", null, "Method result containing receiver status information as the value")
575-
576-
if(includeInherited)
577-
{
578-
let baseDescriptor = super.GetTypeDescriptor(includeInherited);
579-
580-
let baseDescriptorStruct = baseDescriptor as NcDatatypeDescriptorStruct;
581-
if(baseDescriptorStruct)
582-
currentClassDescriptor.fields = currentClassDescriptor.fields.concat(baseDescriptorStruct.fields);
583-
}
584-
585-
return currentClassDescriptor;
586-
}
587-
}
588-
589557
export class NcMethodResultBlockMemberDescriptors extends NcMethodResult
590558
{
591559
public value: NcBlockMemberDescriptor[];

code/src/NCModel/Features.ts

Lines changed: 205 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,98 @@ export class NcGain extends NcActuator
392392
}
393393
}
394394

395+
export class NcLevelSensor extends NcSensor
396+
{
397+
public static staticClassID: number[] = [ 1, 2, 1, 2, 1 ];
398+
399+
@myIdDecorator('1p1')
400+
public override classID: number[] = NcLevelSensor.staticClassID;
401+
402+
@myIdDecorator('5p1')
403+
public reading: number;
404+
405+
public constructor(
406+
oid: number,
407+
constantOid: boolean,
408+
owner: number | null,
409+
role: string,
410+
userLabel: string,
411+
touchpoints: NcTouchpoint[],
412+
runtimePropertyConstraints: NcPropertyConstraints[] | null,
413+
enabled: boolean,
414+
ports: NcPort[] | null,
415+
latency: number | null,
416+
reading: number,
417+
description: string,
418+
notificationContext: INotificationContext)
419+
{
420+
super(oid, constantOid, owner, role, userLabel, touchpoints, runtimePropertyConstraints, enabled, ports, latency, description, notificationContext);
421+
422+
this.reading = reading;
423+
}
424+
425+
//'1m1'
426+
public override Get(oid: number, propertyId: NcElementId, handle: number) : CommandResponseNoValue
427+
{
428+
if(oid == this.oid)
429+
{
430+
let key: string = `${propertyId.level}p${propertyId.index}`;
431+
432+
switch(key)
433+
{
434+
case '5p1':
435+
return new CommandResponseWithValue(handle, NcMethodStatus.OK, this.reading);
436+
default:
437+
return super.Get(oid, propertyId, handle);
438+
}
439+
}
440+
441+
return new CommandResponseError(handle, NcMethodStatus.InvalidRequest, 'OID could not be found');
442+
}
443+
444+
//'1m2'
445+
public override Set(oid: number, id: NcElementId, value: any, handle: number) : CommandResponseNoValue
446+
{
447+
if(oid == this.oid)
448+
{
449+
let key: string = `${id.level}p${id.index}`;
450+
451+
switch(key)
452+
{
453+
case '5p1':
454+
return new CommandResponseError(handle, NcMethodStatus.Readonly, 'Property is readonly');
455+
default:
456+
return super.Set(oid, id, value, handle);
457+
}
458+
}
459+
460+
return new CommandResponseError(handle, NcMethodStatus.InvalidRequest, 'OID could not be found');
461+
}
462+
463+
public static override GetClassDescriptor(includeInherited: boolean): NcClassDescriptor
464+
{
465+
let currentClassDescriptor = new NcClassDescriptor(`${NcLevelSensor.name} class descriptor`,
466+
NcLevelSensor.staticClassID, NcLevelSensor.name, null,
467+
[
468+
new NcPropertyDescriptor(new NcElementId(5, 1), "reading", "NcDB", true, false, false, false, null, "Level sensor reading in DB")
469+
],
470+
[],
471+
[]
472+
);
473+
474+
if(includeInherited)
475+
{
476+
let baseDescriptor = super.GetClassDescriptor(includeInherited);
477+
478+
currentClassDescriptor.properties = currentClassDescriptor.properties.concat(baseDescriptor.properties);
479+
currentClassDescriptor.methods = currentClassDescriptor.methods.concat(baseDescriptor.methods);
480+
currentClassDescriptor.events = currentClassDescriptor.events.concat(baseDescriptor.events);
481+
}
482+
483+
return currentClassDescriptor;
484+
}
485+
}
486+
395487
export class NcIdentBeacon extends NcWorker
396488
{
397489
public static staticClassID: number[] = [ 1, 2, 2 ];
@@ -640,18 +732,122 @@ export class NcReceiverMonitor extends NcWorker
640732
return new CommandResponseError(handle, NcMethodStatus.InvalidRequest, 'OID could not be found');
641733
}
642734

643-
public override InvokeMethod(socket: WebSocketConnection, oid: number, methodId: NcElementId, args: { [key: string]: any; } | null, handle: number): CommandResponseNoValue
735+
public static override GetClassDescriptor(includeInherited: boolean): NcClassDescriptor
736+
{
737+
let currentClassDescriptor = new NcClassDescriptor(`${NcReceiverMonitor.name} class descriptor`,
738+
NcReceiverMonitor.staticClassID, NcReceiverMonitor.name, null,
739+
[
740+
new NcPropertyDescriptor(new NcElementId(3, 1), "connectionStatus", "NcConnectionStatus", true, false, false, false, null, "Connection status property"),
741+
new NcPropertyDescriptor(new NcElementId(3, 2), "connectionStatusMessage", "NcString", true, false, true, false, null, "Connection status message property"),
742+
new NcPropertyDescriptor(new NcElementId(3, 3), "payloadStatus", "NcPayloadStatus", true, false, false, false, null, "Payload status property"),
743+
new NcPropertyDescriptor(new NcElementId(3, 4), "payloadStatusMessage", "NcString", true, false, true, false, null, "Payload status message property")
744+
],
745+
[],
746+
[]
747+
);
748+
749+
if(includeInherited)
750+
{
751+
let baseDescriptor = super.GetClassDescriptor(includeInherited);
752+
753+
currentClassDescriptor.properties = currentClassDescriptor.properties.concat(baseDescriptor.properties);
754+
currentClassDescriptor.methods = currentClassDescriptor.methods.concat(baseDescriptor.methods);
755+
currentClassDescriptor.events = currentClassDescriptor.events.concat(baseDescriptor.events);
756+
}
757+
758+
return currentClassDescriptor;
759+
}
760+
}
761+
762+
export class NcReceiverMonitorProtected extends NcReceiverMonitor
763+
{
764+
public static staticClassID: number[] = [ 1, 2, 3, 1 ];
765+
766+
@myIdDecorator('1p1')
767+
public override classID: number[] = NcReceiverMonitorProtected.staticClassID;
768+
769+
@myIdDecorator('4p1')
770+
public signalProtectionStatus: boolean;
771+
772+
public constructor(
773+
oid: number,
774+
constantOid: boolean,
775+
owner: number | null,
776+
role: string,
777+
userLabel: string,
778+
touchpoints: NcTouchpoint[],
779+
runtimePropertyConstraints: NcPropertyConstraints[] | null,
780+
enabled: boolean,
781+
description: string,
782+
notificationContext: INotificationContext)
783+
{
784+
super(oid, constantOid, owner, role, userLabel, touchpoints, runtimePropertyConstraints, enabled, description, notificationContext);
785+
786+
this.connectionStatus = NcConnectionStatus.Undefined;
787+
this.connectionStatusMessage = null;
788+
789+
this.payloadStatus = NcPayloadStatus.Undefined;
790+
this.payloadStatusMessage = null;
791+
792+
this.signalProtectionStatus = false;
793+
}
794+
795+
public Connected()
796+
{
797+
this.connectionStatus = NcConnectionStatus.Connected;
798+
this.payloadStatus = NcPayloadStatus.PayloadOK;
799+
800+
this.connectionStatusMessage = null;
801+
this.payloadStatusMessage = null;
802+
803+
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 1), NcPropertyChangeType.ValueChanged, this.connectionStatus, null);
804+
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 3), NcPropertyChangeType.ValueChanged, this.payloadStatus, null);
805+
}
806+
807+
public Disconnected()
808+
{
809+
this.connectionStatus = NcConnectionStatus.Undefined;
810+
this.payloadStatus = NcPayloadStatus.Undefined;
811+
812+
this.connectionStatusMessage = null;
813+
this.payloadStatusMessage = null;
814+
815+
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 1), NcPropertyChangeType.ValueChanged, this.connectionStatus, null);
816+
this.notificationContext.NotifyPropertyChanged(this.oid, new NcElementId(3, 3), NcPropertyChangeType.ValueChanged, this.payloadStatus, null);
817+
}
818+
819+
//'1m1'
820+
public override Get(oid: number, id: NcElementId, handle: number) : CommandResponseNoValue
644821
{
645822
if(oid == this.oid)
646823
{
647-
let key: string = `${methodId.level}m${methodId.index}`;
824+
let key: string = `${id.level}p${id.index}`;
648825

649826
switch(key)
650827
{
651-
case '3m1':
652-
return new CommandResponseWithValue(handle, NcMethodStatus.OK, new NcReceiverStatus(this.connectionStatus, this.payloadStatus));
828+
case '4p1':
829+
return new CommandResponseWithValue(handle, NcMethodStatus.OK, this.signalProtectionStatus);
653830
default:
654-
return super.InvokeMethod(socket, oid, methodId, args, handle);
831+
return super.Get(oid, id, handle);
832+
}
833+
}
834+
835+
return new CommandResponseError(handle, NcMethodStatus.InvalidRequest, 'OID could not be found');
836+
}
837+
838+
//'1m2'
839+
public override Set(oid: number, id: NcElementId, value: any, handle: number) : CommandResponseNoValue
840+
{
841+
if(oid == this.oid)
842+
{
843+
let key: string = `${id.level}p${id.index}`;
844+
845+
switch(key)
846+
{
847+
case '4p1':
848+
return new CommandResponseError(handle, NcMethodStatus.Readonly, 'Property is readonly');
849+
default:
850+
return super.Set(oid, id, value, handle);
655851
}
656852
}
657853

@@ -660,17 +856,12 @@ export class NcReceiverMonitor extends NcWorker
660856

661857
public static override GetClassDescriptor(includeInherited: boolean): NcClassDescriptor
662858
{
663-
let currentClassDescriptor = new NcClassDescriptor(`${NcReceiverMonitor.name} class descriptor`,
664-
NcReceiverMonitor.staticClassID, NcReceiverMonitor.name, null,
665-
[
666-
new NcPropertyDescriptor(new NcElementId(3, 1), "connectionStatus", "NcConnectionStatus", true, false, false, false, null, "Connection status property"),
667-
new NcPropertyDescriptor(new NcElementId(3, 2), "connectionStatusMessage", "NcString", true, false, true, false, null, "Connection status message property"),
668-
new NcPropertyDescriptor(new NcElementId(3, 3), "payloadStatus", "NcPayloadStatus", true, false, false, false, null, "Payload status property"),
669-
new NcPropertyDescriptor(new NcElementId(3, 4), "payloadStatusMessage", "NcString", true, false, true, false, null, "Payload status message property")
670-
],
859+
let currentClassDescriptor = new NcClassDescriptor(`${NcReceiverMonitorProtected.name} class descriptor`,
860+
NcReceiverMonitorProtected.staticClassID, NcReceiverMonitorProtected.name, null,
671861
[
672-
new NcMethodDescriptor(new NcElementId(3, 1), "GetStatus", "NcMethodResultReceiverStatus", [], "Method to retrieve both connection status and payload status in one call")
862+
new NcPropertyDescriptor(new NcElementId(4, 1), "signalProtectionStatus", "NcBoolean", true, false, false, false, null, "Indicates if signal protection is active"),
673863
],
864+
[],
674865
[]
675866
);
676867

code/src/NCModel/Managers.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
NcMethodResultError,
3131
NcMethodResultId,
3232
NcMethodResultPropertyValue,
33-
NcMethodResultReceiverStatus,
3433
NcMethodStatus,
3534
NcObject,
3635
NcParameterConstraints,
@@ -54,7 +53,7 @@ import {
5453
NcTouchpointResource,
5554
NcTouchpointResourceNmos,
5655
NcTouchpointResourceNmosChannelMapping} from './Core';
57-
import { DemoDataType, NcActuator, NcDemo, NcGain, NcIdentBeacon, NcReceiverMonitor, NcReceiverStatus, NcSensor, NcSignalWorker, NcWorker } from './Features';
56+
import { DemoDataType, NcActuator, NcDemo, NcGain, NcIdentBeacon, NcLevelSensor, NcReceiverMonitor, NcReceiverMonitorProtected, NcReceiverStatus, NcSensor, NcSignalWorker, NcWorker } from './Features';
5857

5958
export abstract class NcManager extends NcObject
6059
{
@@ -569,14 +568,16 @@ export class NcClassManager extends NcManager
569568
'1.2': NcWorker.GetClassDescriptor(false),
570569
'1.2.1': NcSignalWorker.GetClassDescriptor(false),
571570
'1.2.1.1': NcActuator.GetClassDescriptor(false),
571+
'1.2.1.1.1': NcGain.GetClassDescriptor(false),
572572
'1.2.1.2': NcSensor.GetClassDescriptor(false),
573-
'1.3': NcManager.GetClassDescriptor(false),
574-
'1.3.1': NcDeviceManager.GetClassDescriptor(false),
575-
'1.3.2': NcClassManager.GetClassDescriptor(false),
573+
'1.2.1.2.1': NcLevelSensor.GetClassDescriptor(false),
576574
'1.2.0.1': NcDemo.GetClassDescriptor(false),
577575
'1.2.2': NcIdentBeacon.GetClassDescriptor(false),
578576
'1.2.3': NcReceiverMonitor.GetClassDescriptor(false),
579-
'1.2.1.1.1': NcGain.GetClassDescriptor(false)
577+
'1.2.3.1': NcReceiverMonitorProtected.GetClassDescriptor(false),
578+
'1.3': NcManager.GetClassDescriptor(false),
579+
'1.3.1': NcDeviceManager.GetClassDescriptor(false),
580+
'1.3.2': NcClassManager.GetClassDescriptor(false)
580581
};
581582

582583
return register;
@@ -593,14 +594,16 @@ export class NcClassManager extends NcManager
593594
case '1.2': return NcWorker.GetClassDescriptor(true);
594595
case '1.2.1': return NcSignalWorker.GetClassDescriptor(true);
595596
case '1.2.1.1': return NcActuator.GetClassDescriptor(true);
597+
case '1.2.1.1.1': return NcGain.GetClassDescriptor(true);
596598
case '1.2.1.2': return NcSensor.GetClassDescriptor(true);
597-
case '1.3': return NcManager.GetClassDescriptor(true);
598-
case '1.3.1': return NcDeviceManager.GetClassDescriptor(true);
599-
case '1.3.2': return NcClassManager.GetClassDescriptor(true);
599+
case '1.2.1.2.1': return NcLevelSensor.GetClassDescriptor(true);
600600
case '1.2.0.1': return NcDemo.GetClassDescriptor(true);
601601
case '1.2.2': return NcIdentBeacon.GetClassDescriptor(true);
602602
case '1.2.3': return NcReceiverMonitor.GetClassDescriptor(true);
603-
case '1.2.1.1.1': return NcGain.GetClassDescriptor(true);
603+
case '1.2.3.1': return NcReceiverMonitorProtected.GetClassDescriptor(true);
604+
case '1.3': return NcManager.GetClassDescriptor(true);
605+
case '1.3.1': return NcDeviceManager.GetClassDescriptor(true);
606+
case '1.3.2': return NcClassManager.GetClassDescriptor(true);
604607
default: return null;
605608
}
606609
}
@@ -711,7 +714,6 @@ export class NcClassManager extends NcManager
711714
'NcMethodResultClassDescriptor': NcMethodResultClassDescriptor.GetTypeDescriptor(false),
712715
'NcMethodResultDatatypeDescriptor': NcMethodResultDatatypeDescriptor.GetTypeDescriptor(false),
713716
'NcReceiverStatus': NcReceiverStatus.GetTypeDescriptor(false),
714-
'NcMethodResultReceiverStatus': NcMethodResultReceiverStatus.GetTypeDescriptor(false),
715717
'NcIoDirection': new NcDatatypeDescriptorEnum("NcIoDirection", [
716718
new NcEnumItemDescriptor("Undefined", 0, "Not defined"),
717719
new NcEnumItemDescriptor("Input", 1, "Input direction"),
@@ -794,7 +796,6 @@ export class NcClassManager extends NcManager
794796
case 'NcMethodResultClassDescriptor': return NcMethodResultClassDescriptor.GetTypeDescriptor(true);
795797
case 'NcMethodResultDatatypeDescriptor': return NcMethodResultDatatypeDescriptor.GetTypeDescriptor(true);
796798
case 'NcMethodResultId': return NcMethodResultId.GetTypeDescriptor(true);
797-
case 'NcMethodResultReceiverStatus': return NcMethodResultReceiverStatus.GetTypeDescriptor(true);
798799
default: return this.dataTypesRegister[name];
799800
}
800801
}

0 commit comments

Comments
 (0)