@corvina/device-example
Version:
Corvina Device Example base on @corvina/device-client
95 lines • 2.89 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeviceConfigDTO = exports.AlarmDescDTO = exports.MultiLangStringDTO = exports.TagDescDTO = exports.SimulationDescDTO = exports.NoiseSimulationPropertiesDTO = exports.NullableSimulationPropertiesDTO = exports.NullableSimulationStateMachineDTO = void 0;
class NullableSimulationStateMachineDTO {
nullifying;
start;
duration;
}
exports.NullableSimulationStateMachineDTO = NullableSimulationStateMachineDTO;
class NullableSimulationPropertiesDTO {
probability;
dt_min;
dt_max;
state;
}
exports.NullableSimulationPropertiesDTO = NullableSimulationPropertiesDTO;
class NoiseSimulationPropertiesDTO {
type;
amplitude;
}
exports.NoiseSimulationPropertiesDTO = NoiseSimulationPropertiesDTO;
class SimulationDescDTO {
type;
noise;
nullable;
}
exports.SimulationDescDTO = SimulationDescDTO;
class TagDescDTO {
name;
type;
simulation;
}
exports.TagDescDTO = TagDescDTO;
class MultiLangStringDTO {
}
exports.MultiLangStringDTO = MultiLangStringDTO;
class AlarmDescDTO {
name;
desc;
source;
severity;
ack_required;
reset_required;
enabled;
simulation;
}
exports.AlarmDescDTO = AlarmDescDTO;
class DeviceConfigDTO {
activationKey;
pairingEndpoint;
availableTagsFile;
availableTags;
simulateTags;
availableAlarms;
simulateAlarms;
packetFormat;
arrayToMap(input) {
const map = new Map();
for (const item of input) {
map.set(item.name, item);
}
return map;
}
mapToArray(input) {
const array = [];
input.forEach((value, key) => {
array.push({ name: key, value });
});
return array;
}
toDeviceConfig() {
return {
activationKey: this.activationKey,
pairingEndpoint: this.pairingEndpoint,
availableTagsFile: this.availableTagsFile,
availableTags: this.arrayToMap(this.availableTags),
simulateTags: this.simulateTags,
availableAlarms: this.arrayToMap(this.availableAlarms),
simulateAlarms: this.simulateAlarms,
packetFormat: this.packetFormat,
};
}
constructor(deviceConfig) {
this.activationKey = deviceConfig.activationKey;
this.pairingEndpoint = deviceConfig.pairingEndpoint;
this.availableTagsFile = deviceConfig.availableTagsFile;
this.availableTags = this.mapToArray(deviceConfig.availableTags);
this.simulateTags = deviceConfig.simulateTags;
this.availableAlarms = this.mapToArray(deviceConfig.availableAlarms);
this.simulateAlarms = deviceConfig.simulateAlarms;
this.packetFormat = deviceConfig.packetFormat;
}
}
exports.DeviceConfigDTO = DeviceConfigDTO;
//# sourceMappingURL=deviceconfig.dto.js.map