module import { BinaryStream , OutputBinaryStream } from "node-opcua-binary-stream" ; import { registerBasicType } from "node-opcua-factory" ; import { _make_flag } from "./_make_flag" ; export enum AccessLevelFlag { CurrentRead = 0x01 , CurrentWrite = 0x02 , HistoryRead = 0x04 , HistoryWrite = 0x08 , SemanticChange = 0x10 , StatusWrite = 0x20 , TimestampWrite = 0x40 , NONE = 0x800 , None = 0x800 } export type AccessLevelFlagString = "CurrentRead" | "CurrentWrite" | "HistoryRead" | "HistoryWrite" | "StatusWrite" | "TimestampWrite" ; export function convertAccessLevelFlagToByte ( accessLevel ) { return accessLevel & 0x7f ; } export function makeAccessLevelFlag ( str ) { return _make_flag ( str , AccessLevelFlag . None , AccessLevelFlag ) as AccessLevelFlag ; } export const coerceAccessLevelFlag = makeAccessLevelFlag ; export function randomAccessLevel ( ) { return AccessLevelFlag . CurrentRead ; } export function _accessLevelFlagToString ( accessLevelFlag ) { const retVal = [ ] ; if ( accessLevelFlag & AccessLevelFlag . CurrentRead ) { retVal . push ( "CurrentRead" ) ; } if ( accessLevelFlag & AccessLevelFlag . CurrentWrite ) { retVal . push ( "CurrentWrite" ) ; } if ( accessLevelFlag & AccessLevelFlag . StatusWrite ) { retVal . push ( "StatusWrite" ) ; } if ( accessLevelFlag & AccessLevelFlag . TimestampWrite ) { retVal . push ( "TimestampWrite" ) ; } if ( accessLevelFlag & AccessLevelFlag . HistoryRead ) { retVal . push ( "HistoryRead" ) ; } if ( accessLevelFlag & AccessLevelFlag . HistoryWrite ) { retVal . push ( "HistoryWrite" ) ; } if ( accessLevelFlag & AccessLevelFlag . SemanticChange ) { retVal . push ( "SemanticChange" ) ; } return retVal ; } export function accessLevelFlagToString ( accessLevelFlag ) { const retVal = _accessLevelFlagToString ( accessLevelFlag ) ; if ( retVal . length === 0 ) { retVal . push ( "None" ) ; } return retVal . join ( " | " ) ; } export function decodeAccessLevelFlag ( stream ) { const code = stream . readUInt8 ( ) ; return code ; } export function encodeAccessLevelFlag ( value , stream ) { stream . writeUInt8 ( value & 0xff ) ; } registerBasicType ( { name : "AccessLevelFlag" , subType : "Byte" , defaultValue : AccessLevelFlag . CurrentRead | AccessLevelFlag . CurrentWrite , coerce : makeAccessLevelFlag , decode : decodeAccessLevelFlag , encode : encodeAccessLevelFlag , random : randomAccessLevel } ) ;