UNPKG

test-bed-time-service

Version:

A time service for the test-bed, producing messages with real time, fictive time and scenario duration.

38 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const node_test_bed_adapter_1 = require("node-test-bed-adapter"); const time_service_states_1 = require("./time-service-states"); const time_service_idle_state_1 = require("./time-service-idle-state"); class Stopped extends time_service_states_1.TimeServiceBaseState { get name() { return node_test_bed_adapter_1.TimeState.Stopped; } transition(controlMsg) { switch (controlMsg.command) { case node_test_bed_adapter_1.TimeCommand.Reset: { this.log.info('Received command ' + controlMsg.command + '. Transitioning to Idle.'); return new time_service_idle_state_1.Idle(this.timeService); } default: { this.log.warn('Received command ' + controlMsg.command + ' while in Stopped state. Doing nothing!'); return this; } } } createTimeMessage() { const newUpdateTime = Date.now(); const timeElapsed = newUpdateTime - this.timeService.realStartTime; // unlike when started, don't progress the trialtime before sending an update const trialTime = this.timeService.trialTime; const timeMsg = { updatedAt: newUpdateTime, trialTime: trialTime, timeElapsed: timeElapsed, trialTimeSpeed: 0, state: node_test_bed_adapter_1.TimeState.Stopped }; return timeMsg; } } exports.Stopped = Stopped; //# sourceMappingURL=time-service-stopped-state.js.map