@hg8496/energyday-creator
Version:
A tool that create proto buffers from GridVis REST API
67 lines • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapProtoBufferToInput = exports.mapInputToProtoBuffer = void 0;
var definitions_1 = require("@hg8496/definitions");
var Input = definitions_1.janitza.values.Input;
var Line = definitions_1.janitza.values.Line;
function mapInputToProtoBuffer(input) {
var result = null;
switch (input) {
case "L1":
result = new Input({ line: definitions_1.janitza.values.Line.L1 });
break;
case "L2":
result = new Input({ line: definitions_1.janitza.values.Line.L2 });
break;
case "L3":
result = new Input({ line: definitions_1.janitza.values.Line.L3 });
break;
case "L4":
result = new Input({ line: definitions_1.janitza.values.Line.L4 });
break;
case "N":
result = new Input({ line: definitions_1.janitza.values.Line.N });
break;
case "SUM13":
result = new Input({ line: definitions_1.janitza.values.Line.SUM13 });
break;
default:
var match = input.match(/\d+/);
if (match) {
result = new Input({ channel: Number(match[0]) });
}
}
return result;
}
exports.mapInputToProtoBuffer = mapInputToProtoBuffer;
function mapProtoBufferToInput(input) {
var result = null;
if (input.line) {
switch (input.line) {
case Line.L1:
result = "L1";
break;
case Line.L2:
result = "L2";
break;
case Line.L3:
result = "L3";
break;
case Line.L4:
result = "L4";
break;
case Line.N:
result = "N";
break;
case Line.SUM13:
result = "SUM13";
break;
}
}
else if (input.channel) {
result = "Input-" + input.channel;
}
return result;
}
exports.mapProtoBufferToInput = mapProtoBufferToInput;
//# sourceMappingURL=InputMapper.js.map