"use strict" ; import { GW_FRAME_COMMAND_REQ } from "./common" ; import { CommandOriginator , PriorityLevel , ParameterActive , PriorityLevelLock , LockTime as lt , PriorityLevelInformation } from "./GW_COMMAND" ; import { Velocity } from "./GW_SYSTEMTABLE_DATA" ; export class GW_ACTIVATE_PRODUCTGROUP_REQ extends GW_FRAME_COMMAND_REQ { constructor ( readonly GroupID , readonly Position , readonly PriorityLevel = 3 , readonly CommandOriginator = 1 , readonly ParameterActive = 0 , readonly Velocity = 0 , readonly PriorityLevelLock = 0 , readonly PriorityLevels = [ ] , readonly LockTime = Infinity ) { super ( 13 ) ; const buff = this . Data . slice ( this . offset ) ; buff . writeUInt16BE ( this . SessionID , 0 ) ; buff . writeUInt8 ( this . CommandOriginator , 2 ) ; buff . writeUInt8 ( this . PriorityLevel , 3 ) ; buff . writeUInt8 ( this . GroupID , 4 ) ; buff . writeUInt8 ( this . ParameterActive , 5 ) ; buff . writeUInt16BE ( this . Position , 6 ) ; buff . writeUInt8 ( this . Velocity , 8 ) ; buff . writeUInt8 ( this . PriorityLevelLock , 9 ) ; if ( this . PriorityLevels . length > 8 ) throw new Error ( "Too many priority levels." ) ; let PLI = 0 ; for ( let pliIndex = 0 ; pliIndex < this . PriorityLevels . length ; pliIndex ++ ) { const pli = this . PriorityLevels [ pliIndex ] ; if ( pli < 0 || pli > 3 ) throw new Error ( "Priority level lock out of range." ) ; PLI <<= 2 ; PLI |= pli ; } PLI <<= 2 * ( 8 - this . PriorityLevels . length ) ; buff . writeUInt16BE ( PLI , 10 ) ; buff . writeUInt8 ( lt . lockTimeTolockTimeValue ( this . LockTime ) , 12 ) ; } }