Files
agent/config-serializer/config-items/DelayMacroAction.ts
Sam Rang 6e218387fc changing how assertions access instance variables to make them non-static-like (#37)
Changing how assertions access instance variables
2016-05-09 19:17:54 +02:00

38 lines
971 B
TypeScript

import {UhkBuffer} from '../UhkBuffer';
import {MacroAction, macroActionType, MacroActionId} from './MacroAction';
import {assertUInt16} from '../assert';
export class DelayMacroAction extends MacroAction {
@assertUInt16
delay: number;
_fromJsObject(jsObject: any): DelayMacroAction {
this.assertMacroActionType(jsObject);
this.delay = jsObject.delay;
return this;
}
_fromBinary(buffer: UhkBuffer): DelayMacroAction {
this.readAndAssertMacroActionId(buffer);
this.delay = buffer.readUInt16();
return this;
}
_toJsObject(): any {
return {
macroActionType: macroActionType.DelayMacroAction,
delay: this.delay
};
}
_toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(MacroActionId.DelayMacroAction);
buffer.writeUInt16(this.delay);
}
toString(): string {
return `<DelayMacroAction delay="${this.delay}">`;
}
}