@@ -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+
395487export 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
0 commit comments