@iotize/tap
Version:
IoTize Device client for Javascript
1,602 lines (1,591 loc) • 66.6 kB
JavaScript
import { VariableFormat, AbstractService, extendServiceContainer } from '@iotize/tap';
import { TapRequestFrame } from '@iotize/tap/client/api';
import { createEnumConverter, createEnumArrayConverter, converters } from '@iotize/tap/service/core';
import { TapStreamReader, TapStreamWriter, enumKeyOrValueToNumber } from '@iotize/tap/client/impl';
import { KaitaiStreamWriter } from '@iotize/common/byte-stream';
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
var TargetCoreType;
(function (TargetCoreType) {
TargetCoreType[TargetCoreType["M0_CORTEX"] = 0] = "M0_CORTEX";
TargetCoreType[TargetCoreType["M1_CORTEX"] = 1] = "M1_CORTEX";
})(TargetCoreType || (TargetCoreType = {}));
var TargetS3PProtocolConfiguration;
(function (TargetS3PProtocolConfiguration) {
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let Mode;
(function (Mode) {
Mode[Mode["EMULATION"] = 0] = "EMULATION";
Mode[Mode["INDEXED"] = 1] = "INDEXED";
})(Mode = TargetS3PProtocolConfiguration.Mode || (TargetS3PProtocolConfiguration.Mode = {}));
})(TargetS3PProtocolConfiguration || (TargetS3PProtocolConfiguration = {}));
var TargetCanProtocolConfiguration;
(function (TargetCanProtocolConfiguration) {
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let Mode;
(function (Mode) {
Mode[Mode["NORMAL"] = 0] = "NORMAL";
Mode[Mode["NO_ACK"] = 1] = "NO_ACK";
Mode[Mode["LISTEN"] = 2] = "LISTEN";
})(Mode = TargetCanProtocolConfiguration.Mode || (TargetCanProtocolConfiguration.Mode = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let Filter;
(function (Filter) {
Filter[Filter["DUAL"] = 0] = "DUAL";
Filter[Filter["SINGLE"] = 1] = "SINGLE";
})(Filter = TargetCanProtocolConfiguration.Filter || (TargetCanProtocolConfiguration.Filter = {}));
})(TargetCanProtocolConfiguration || (TargetCanProtocolConfiguration = {}));
var ModbusOptions;
(function (ModbusOptions) {
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let ObjectType;
(function (ObjectType) {
ObjectType[ObjectType["DEFAULT"] = 0] = "DEFAULT";
ObjectType[ObjectType["COIL"] = 1] = "COIL";
ObjectType[ObjectType["DISCRET_INPUT"] = 2] = "DISCRET_INPUT";
ObjectType[ObjectType["HOLDING_REGISTER"] = 3] = "HOLDING_REGISTER";
ObjectType[ObjectType["INPUT_REGISTER"] = 4] = "INPUT_REGISTER";
})(ObjectType = ModbusOptions.ObjectType || (ModbusOptions.ObjectType = {}));
})(ModbusOptions || (ModbusOptions = {}));
var SerialSettings;
(function (SerialSettings) {
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let BitParity;
(function (BitParity) {
BitParity[BitParity["NONE"] = 0] = "NONE";
BitParity[BitParity["ODD"] = 1] = "ODD";
BitParity[BitParity["EVEN"] = 2] = "EVEN";
})(BitParity = SerialSettings.BitParity || (SerialSettings.BitParity = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let HardwareFlowControl;
(function (HardwareFlowControl) {
HardwareFlowControl[HardwareFlowControl["NONE"] = 0] = "NONE";
HardwareFlowControl[HardwareFlowControl["RTS"] = 1] = "RTS";
HardwareFlowControl[HardwareFlowControl["CTS"] = 2] = "CTS";
HardwareFlowControl[HardwareFlowControl["RTS_CTS"] = 3] = "RTS_CTS";
})(HardwareFlowControl = SerialSettings.HardwareFlowControl || (SerialSettings.HardwareFlowControl = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let StopBits;
(function (StopBits) {
StopBits[StopBits["ONE"] = 0] = "ONE";
StopBits[StopBits["ONE_AND_HALF"] = 1] = "ONE_AND_HALF";
StopBits[StopBits["TWO"] = 2] = "TWO";
})(StopBits = SerialSettings.StopBits || (SerialSettings.StopBits = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let PhysicalPort;
(function (PhysicalPort) {
PhysicalPort[PhysicalPort["NONE"] = 0] = "NONE";
PhysicalPort[PhysicalPort["RS232"] = 1] = "RS232";
PhysicalPort[PhysicalPort["USB"] = 3] = "USB";
PhysicalPort[PhysicalPort["RS485_WITH_SIGNAL_DIRECTION"] = 4] = "RS485_WITH_SIGNAL_DIRECTION";
PhysicalPort[PhysicalPort["AUTO"] = 6] = "AUTO";
PhysicalPort[PhysicalPort["RS485"] = 10] = "RS485";
})(PhysicalPort = SerialSettings.PhysicalPort || (SerialSettings.PhysicalPort = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let HandshakeDelimiter;
(function (HandshakeDelimiter) {
HandshakeDelimiter[HandshakeDelimiter["NONE"] = 0] = "NONE";
HandshakeDelimiter[HandshakeDelimiter["CR"] = 1] = "CR";
HandshakeDelimiter[HandshakeDelimiter["LF"] = 2] = "LF";
HandshakeDelimiter[HandshakeDelimiter["CR_LF"] = 3] = "CR_LF";
})(HandshakeDelimiter = SerialSettings.HandshakeDelimiter || (SerialSettings.HandshakeDelimiter = {}));
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
let DataBits;
(function (DataBits) {
DataBits[DataBits["_7"] = 0] = "_7";
DataBits[DataBits["_8"] = 1] = "_8";
DataBits[DataBits["_9"] = 2] = "_9";
})(DataBits = SerialSettings.DataBits || (SerialSettings.DataBits = {}));
})(SerialSettings || (SerialSettings = {}));
/**
* Generated file. Do not edit
*/
TapStreamReader.prototype.readTargetComStats = function () {
const model = {};
model.nbFailCom = this.readUnsigned(4);
model.nbSuccessfulCom = this.readUnsigned(4);
return model;
};
TapStreamReader.prototype.readTargetSerialModbusProtocolConfiguration =
function () {
const model = {};
model.modbus = this.readTargetSerialModbusProtocolConfigurationModbus();
model.serial = this.readTargetSerialModbusProtocolConfigurationSerial();
return model;
};
TapStreamReader.prototype.readTargetSerialModbusProtocolConfigurationModbus =
function () {
const model = {};
model.slave = this.readUnsigned(1);
this.forwardBits(3);
model.offsetFirstRegister = this.readBoolean(1);
return model;
};
TapStreamReader.prototype.readTargetSerialModbusProtocolConfigurationSerial =
function () {
const model = {};
model.baudRate = this.readBits(20);
this.forwardBits(1);
this.forwardBits(1);
this.forwardBits(1);
this.forwardBits(1);
model.physicalPort = this.readBits(4);
model.stopBits = this.readBits(2);
model.bitParity = this.readBits(4);
model.dataBits = this.readBits(2);
model.handshakeDelimiter = this.readBits(4);
model.hardwareFlowControl = this.readBits(4);
model.timeout = this.readUnsigned(1);
return model;
};
TapStreamReader.prototype.readTargetS3PProtocolConfiguration =
function () {
const model = {};
model.delay = this.readUnsigned(1);
model.mode = this.readUnsigned(1);
return model;
};
TapStreamReader.prototype.readTargetModbusTcpProtocolConfiguration =
function () {
const model = {};
model.firstRegisterAddress = this.readUnsigned(1);
model.ip = this.readStringTerminator(':');
model.port = this.readStringTerminator(':');
model.timeout = this.readString();
return model;
};
TapStreamReader.prototype.readTargetCanProtocolConfiguration =
function () {
const model = {};
model.frequency = this.readUnsigned(2);
model.mode = this.readUnsigned(1);
model.filter = this.readUnsigned(1);
model.code = this.readUnsigned(4);
model.mask = this.readUnsigned(4);
return model;
};
TapStreamReader.prototype.readModbusWriteOptions =
function () {
const model = {};
model.options = this.readModbusOptions();
model.data = this.readBytes();
return model;
};
TapStreamReader.prototype.readModbusOptions = function () {
const model = {};
this.forwardBits(5);
model.objectType = this.readBits(3);
model.slave = this.readUnsigned(1);
model.address = this.readUnsigned(2);
model.length = this.readUnsigned(4);
model.format = this.readUnsigned(1);
return model;
};
TapStreamReader.prototype.readMemoryInfo = function () {
const model = {};
model.address = this.readUnsigned(4);
model.length = this.readUnsigned(4);
model.format = this.readUnsigned(1);
return model;
};
TapStreamReader.prototype.readMemoryWriteInfo = function () {
const model = {};
model.info = this.readMemoryInfo();
model.data = this.readBytes();
return model;
};
TapStreamReader.prototype.readSerialSettings = function () {
const model = {};
return model;
};
// TapStreamWriter.prototype.write(model: TargetComStats) : TapStreamWriter{
// return this.writeTargetComStats(model)
// }
TapStreamWriter.prototype.writeTargetComStats = function (model) {
this.writeUnsigned(model.nbFailCom, 4);
this.writeUnsigned(model.nbSuccessfulCom, 4);
return this;
};
// TapStreamWriter.prototype.write(model: TargetSerialModbusProtocolConfiguration) : TapStreamWriter{
// return this.writeTargetSerialModbusProtocolConfiguration(model)
// }
TapStreamWriter.prototype.writeTargetSerialModbusProtocolConfiguration =
function (model) {
this.writeTargetSerialModbusProtocolConfigurationModbus(model.modbus);
this.writeTargetSerialModbusProtocolConfigurationSerial(model.serial);
return this;
};
TapStreamWriter.prototype.writeTargetSerialModbusProtocolConfigurationModbus =
function (model) {
this.writeUnsigned(model.slave, 1);
this.forwardBits(3);
this.writeBoolean(model.offsetFirstRegister, 1);
return this;
};
TapStreamWriter.prototype.writeTargetSerialModbusProtocolConfigurationSerial =
function (model) {
this.writeBits(model.baudRate, 20);
this.forwardBits(1);
this.forwardBits(1);
this.forwardBits(1);
this.forwardBits(1);
this.writeBitsInt(enumKeyOrValueToNumber(model.physicalPort, SerialSettings.PhysicalPort), 4);
this.writeBitsInt(enumKeyOrValueToNumber(model.stopBits, SerialSettings.StopBits), 2);
this.writeBitsInt(enumKeyOrValueToNumber(model.bitParity, SerialSettings.BitParity), 4);
this.writeBitsInt(enumKeyOrValueToNumber(model.dataBits, SerialSettings.DataBits), 2);
this.writeBitsInt(enumKeyOrValueToNumber(model.handshakeDelimiter, SerialSettings.HandshakeDelimiter), 4);
this.writeBitsInt(enumKeyOrValueToNumber(model.hardwareFlowControl, SerialSettings.HardwareFlowControl), 4);
this.writeUnsigned(model.timeout, 1);
return this;
};
// TapStreamWriter.prototype.write(model: TargetS3PProtocolConfiguration) : TapStreamWriter{
// return this.writeTargetS3PProtocolConfiguration(model)
// }
TapStreamWriter.prototype.writeTargetS3PProtocolConfiguration = function (model) {
this.writeUnsigned(model.delay, 1);
this.writeBitsInt(enumKeyOrValueToNumber(model.mode, TargetS3PProtocolConfiguration.Mode), 8);
return this;
};
// TapStreamWriter.prototype.write(model: TargetModbusTcpProtocolConfiguration) : TapStreamWriter{
// return this.writeTargetModbusTcpProtocolConfiguration(model)
// }
TapStreamWriter.prototype.writeTargetModbusTcpProtocolConfiguration = function (model) {
this.writeUnsigned(model.firstRegisterAddress, 1);
this.writeString(model.ip + ':');
this.writeString(model.port + ':');
this.writeString(model.timeout);
return this;
};
// TapStreamWriter.prototype.write(model: TargetCanProtocolConfiguration) : TapStreamWriter{
// return this.writeTargetCanProtocolConfiguration(model)
// }
TapStreamWriter.prototype.writeTargetCanProtocolConfiguration = function (model) {
this.writeUnsigned(model.frequency, 2);
this.writeBitsInt(enumKeyOrValueToNumber(model.mode, TargetCanProtocolConfiguration.Mode), 8);
this.writeBitsInt(enumKeyOrValueToNumber(model.filter, TargetCanProtocolConfiguration.Filter), 8);
this.writeUnsigned(model.code, 4);
this.writeUnsigned(model.mask, 4);
return this;
};
// TapStreamWriter.prototype.write(model: ModbusWriteOptions) : TapStreamWriter{
// return this.writeModbusWriteOptions(model)
// }
TapStreamWriter.prototype.writeModbusWriteOptions = function (model) {
this.writeModbusOptions(model.options);
this.writeBytes(model.data);
return this;
};
// TapStreamWriter.prototype.write(model: ModbusOptions) : TapStreamWriter{
// return this.writeModbusOptions(model)
// }
TapStreamWriter.prototype.writeModbusOptions = function (model) {
this.forwardBits(5);
this.writeBitsInt(enumKeyOrValueToNumber(model.objectType, ModbusOptions.ObjectType), 3);
this.writeUnsigned(model.slave, 1);
this.writeUnsigned(model.address, 2);
this.writeUnsigned(model.length, 4);
this.writeBitsInt(enumKeyOrValueToNumber(model.format, VariableFormat), 8);
return this;
};
// TapStreamWriter.prototype.write(model: MemoryInfo) : TapStreamWriter{
// return this.writeMemoryInfo(model)
// }
TapStreamWriter.prototype.writeMemoryInfo = function (model) {
this.writeUnsigned(model.address, 4);
this.writeUnsigned(model.length, 4);
this.writeBitsInt(enumKeyOrValueToNumber(model.format, VariableFormat), 8);
return this;
};
// TapStreamWriter.prototype.write(model: MemoryWriteInfo) : TapStreamWriter{
// return this.writeMemoryWriteInfo(model)
// }
TapStreamWriter.prototype.writeMemoryWriteInfo = function (model) {
this.writeMemoryInfo(model.info);
this.writeBytes(model.data);
return this;
};
// TapStreamWriter.prototype.write(model: SerialSettings) : TapStreamWriter{
// return this.writeSerialSettings(model)
// }
TapStreamWriter.prototype.writeSerialSettings = function (model) {
return this;
};
/**
* Generated file. Do not edit
*/
class TargetComStatsConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeTargetComStats(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readTargetComStats();
}
}
class TargetSerialModbusProtocolConfigurationConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeTargetSerialModbusProtocolConfiguration(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readTargetSerialModbusProtocolConfiguration();
}
}
class TargetS3PProtocolConfigurationConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeTargetS3PProtocolConfiguration(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readTargetS3PProtocolConfiguration();
}
}
class TargetModbusTcpProtocolConfigurationConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeTargetModbusTcpProtocolConfiguration(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readTargetModbusTcpProtocolConfiguration();
}
}
class TargetCanProtocolConfigurationConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeTargetCanProtocolConfiguration(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readTargetCanProtocolConfiguration();
}
}
class ModbusWriteOptionsConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeModbusWriteOptions(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readModbusWriteOptions();
}
}
class ModbusOptionsConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeModbusOptions(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readModbusOptions();
}
}
class MemoryInfoConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeMemoryInfo(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readMemoryInfo();
}
}
class MemoryWriteInfoConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeMemoryWriteInfo(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readMemoryWriteInfo();
}
}
class SerialSettingsConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeSerialSettings(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readSerialSettings();
}
}
/**
* Generated file. Do not edit
*/
const targetCoreType = createEnumConverter(TargetCoreType, 1);
const targetCoreTypeArray = createEnumArrayConverter(TargetCoreType, 1);
const targetComStats = new TargetComStatsConverter();
const targetSerialModbusProtocolConfiguration = new TargetSerialModbusProtocolConfigurationConverter();
const targetS3PProtocolConfiguration = new TargetS3PProtocolConfigurationConverter();
const targetModbusTcpProtocolConfiguration = new TargetModbusTcpProtocolConfigurationConverter();
const targetCanProtocolConfiguration = new TargetCanProtocolConfigurationConverter();
const modbusWriteOptions = new ModbusWriteOptionsConverter();
const modbusOptions = new ModbusOptionsConverter();
const memoryInfo = new MemoryInfoConverter();
const memoryWriteInfo = new MemoryWriteInfoConverter();
const serialSettings = new SerialSettingsConverter();
var serviceConverters = /*#__PURE__*/Object.freeze({
__proto__: null,
targetCoreType: targetCoreType,
targetCoreTypeArray: targetCoreTypeArray,
targetComStats: targetComStats,
targetSerialModbusProtocolConfiguration: targetSerialModbusProtocolConfiguration,
targetS3PProtocolConfiguration: targetS3PProtocolConfiguration,
targetModbusTcpProtocolConfiguration: targetModbusTcpProtocolConfiguration,
targetCanProtocolConfiguration: targetCanProtocolConfiguration,
modbusWriteOptions: modbusWriteOptions,
modbusOptions: modbusOptions,
memoryInfo: memoryInfo,
memoryWriteInfo: memoryWriteInfo,
serialSettings: serialSettings
});
const PROTOCOL_CONF_CTR_LENGHT = 8;
const END_OF_USB_ALIASES = Uint8Array.from([0, 0, 0, 0, 0]);
class ReversedTargetSerialModbusConfigurationConverter {
constructor() {
this.converter = new TargetSerialModbusProtocolConfigurationConverter();
}
decode(data) {
return this.converter.decode(this._reorderBytes(data.slice(0, data.length - END_OF_USB_ALIASES.length)));
}
encode(settings) {
return KaitaiStreamWriter.mergeArrays(this._reorderBytes(this.converter.encode(settings)), END_OF_USB_ALIASES);
}
_reorderBytes(data) {
return KaitaiStreamWriter.mergeArrays(data.slice(0, PROTOCOL_CONF_CTR_LENGHT).reverse(), data.slice(PROTOCOL_CONF_CTR_LENGHT));
}
}
const reversedTargetSerialModbusConfiguration = new ReversedTargetSerialModbusConfigurationConverter();
var customConverters = /*#__PURE__*/Object.freeze({
__proto__: null,
reversedTargetSerialModbusConfiguration: reversedTargetSerialModbusConfiguration
});
/**
* Generated file. Do not edit
*/
const allConverters = Object.assign(Object.assign(Object.assign({}, converters), serviceConverters), customConverters);
const SERVICE_CALLS = {
getProtocol: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/protocol',
path: '/1027//1',
responseBodyDecoder: allConverters.targetProtocol,
},
setProtocol: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/protocol',
path: '/1027//1',
bodyEncoder: allConverters.targetProtocol,
},
putProtocol: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/protocol',
path: '/1027//1',
bodyEncoder: allConverters.targetProtocol,
},
getCoreType: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/core-type',
path: '/1027//2',
responseBodyDecoder: allConverters.targetCoreType,
},
putCoreType: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/core-type',
path: '/1027//2',
bodyEncoder: allConverters.targetCoreType,
},
isConnected: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/connect',
path: '/1027//3',
responseBodyDecoder: allConverters.boolean,
},
connect: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/connect',
path: '/1027//3',
},
disconnect: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/disconnect',
path: '/1027//4',
},
reset: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/reset',
path: '/1027//5',
},
getFirmwareVersion: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/firmware-version',
path: '/1027//6',
responseBodyDecoder: allConverters.stringVersion,
},
putFirmwareVersion: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/firmware-version',
path: '/1027//6',
bodyEncoder: allConverters.stringVersion,
},
getVcc: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/vcc',
path: '/1027//7',
responseBodyDecoder: allConverters.uint16,
},
getMinVoltage: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/min-voltage',
path: '/1027//8',
responseBodyDecoder: allConverters.uint16,
},
putMinVoltage: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/min-voltage',
path: '/1027//8',
bodyEncoder: allConverters.uint16,
},
getMaxVoltage: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/max-voltage',
path: '/1027//9',
responseBodyDecoder: allConverters.uint16,
},
putMaxVoltage: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/max-voltage',
path: '/1027//9',
bodyEncoder: allConverters.uint16,
},
getPageSize: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/page-size',
path: '/1027//10',
responseBodyDecoder: allConverters.uint32,
},
putPageSize: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/page-size',
path: '/1027//10',
bodyEncoder: allConverters.uint32,
},
getComStats: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/com-stats',
path: '/1027//11',
responseBodyDecoder: allConverters.targetComStats,
},
clearComStats: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/com-stats',
path: '/1027//11',
},
getAvailableProtocols: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/available-protocols',
path: '/1027//20',
responseBodyDecoder: allConverters.targetProtocolArray,
},
getSerialModbusConfiguration: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/serial-modbus-configuration',
path: '/1027//21',
responseBodyDecoder: allConverters.reversedTargetSerialModbusConfiguration,
},
setSerialModbusConfiguration: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/serial-modbus-configuration',
path: '/1027//21',
bodyEncoder: allConverters.reversedTargetSerialModbusConfiguration,
},
putSerialModbusConfiguration: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/serial-modbus-configuration',
path: '/1027//21',
bodyEncoder: allConverters.reversedTargetSerialModbusConfiguration,
},
getModbusDefaultSlaveAddress: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/modbus-default-slave-address',
path: '/1027//22',
responseBodyDecoder: allConverters.uint32,
},
putModbusDefaultSlaveAddress: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/modbus-default-slave-address',
path: '/1027//22',
bodyEncoder: allConverters.uint32,
},
getS3PConfiguration: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/s3p-configuration',
path: '/1027//21',
responseBodyDecoder: allConverters.targetS3PProtocolConfiguration,
},
setS3PConfiguration: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/s3p-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetS3PProtocolConfiguration,
},
putS3PConfiguration: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/s3p-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetS3PProtocolConfiguration,
},
getModbusTcpConfiguration: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/modbus-tcp-configuration',
path: '/1027//21',
responseBodyDecoder: allConverters.targetModbusTcpProtocolConfiguration,
},
setModbusTcpConfiguration: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/modbus-tcp-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetModbusTcpProtocolConfiguration,
},
putModbusTcpConfiguration: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/modbus-tcp-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetModbusTcpProtocolConfiguration,
},
getCanConfiguration: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/can-configuration',
path: '/1027//21',
responseBodyDecoder: allConverters.targetCanProtocolConfiguration,
},
setCanConfiguration: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/can-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetCanProtocolConfiguration,
},
putCanConfiguration: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/target/can-configuration',
path: '/1027//21',
bodyEncoder: allConverters.targetCanProtocolConfiguration,
},
postResetKeep: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/reset-keep',
path: '/1027//30',
},
readDebug: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/debug-access',
path: '/1027//31',
bodyEncoder: allConverters.uint32,
},
writeDebug: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/debug-access',
path: '/1027//31',
},
getRegisterAccess: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/register-access',
path: '/1027//32',
},
postRegisterAccess: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/register-access',
path: '/1027//32',
},
sendReceive: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/transparent/send-receive',
path: '/1027//34',
},
send: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/transparent/send',
path: '/1027//34',
},
readBytes: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/transparent/read-bytes',
path: '/1027//35',
},
modbusWrite: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/modbus/write',
path: '/1027//37',
bodyEncoder: allConverters.modbusWriteOptions,
},
modbusRead: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/modbus/read',
path: '/1027//38',
bodyEncoder: allConverters.modbusOptions,
},
getSubProtocol: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/sub-protocol',
path: '/1027//40',
responseBodyDecoder: allConverters.targetProtocol,
},
getReceivedCount: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/received-count',
path: '/1027//43',
responseBodyDecoder: allConverters.uint16,
},
readAddress: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/target/read-address',
path: '/1027//33',
bodyEncoder: allConverters.memoryInfo,
},
writeAddress: {
method: TapRequestFrame.MethodType.POST,
pathAlias: '/target/read-address',
path: '/1027//33',
bodyEncoder: allConverters.memoryWriteInfo,
},
};
class TargetService extends AbstractService {
constructor() {
super(...arguments);
this.resources = SERVICE_CALLS;
}
/**
* Get target protocol
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @return
*/
getProtocol() {
return this.serviceCallRunner.execute(this.getProtocolCall());
}
/**
*
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @return call options
*/
getProtocolCall() {
const callOptions = Object.assign({}, this.resources.getProtocol);
return callOptions;
}
/**
* Temporarily change target protocol
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @param targetProtocol input
* @return
*/
setProtocol(
/*
* TargetProtocol object to set
*/
targetProtocol) {
return this.serviceCallRunner.execute(this.setProtocolCall(targetProtocol));
}
/**
*
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @param targetProtocol input
* @return call options
*/
setProtocolCall(
/*
* TargetProtocol object to set
*/
targetProtocol) {
const callOptions = Object.assign({}, this.resources.setProtocol);
callOptions.body = targetProtocol;
return callOptions;
}
/**
* Write target protocol in configuration
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @param targetProtocol input
* @return
*/
putProtocol(
/*
* TargetProtocol object to set
*/
targetProtocol) {
return this.serviceCallRunner.execute(this.putProtocolCall(targetProtocol));
}
/**
*
*
* LWM2M path: /1027//1
*
* @tapVersion(">=1.0")
* @param targetProtocol input
* @return call options
*/
putProtocolCall(
/*
* TargetProtocol object to set
*/
targetProtocol) {
const callOptions = Object.assign({}, this.resources.putProtocol);
callOptions.body = targetProtocol;
return callOptions;
}
/**
* Get core type
*
* LWM2M path: /1027//2
*
* @tapVersion(">=1.0")
* @return
*/
getCoreType() {
return this.serviceCallRunner.execute(this.getCoreTypeCall());
}
/**
*
*
* LWM2M path: /1027//2
*
* @tapVersion(">=1.0")
* @return call options
*/
getCoreTypeCall() {
const callOptions = Object.assign({}, this.resources.getCoreType);
return callOptions;
}
/**
* Write core type
*
* LWM2M path: /1027//2
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putCoreType(
/*
* Write core type
*/
value) {
return this.serviceCallRunner.execute(this.putCoreTypeCall(value));
}
/**
*
*
* LWM2M path: /1027//2
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putCoreTypeCall(
/*
* Write core type
*/
value) {
const callOptions = Object.assign({}, this.resources.putCoreType);
callOptions.body = value;
return callOptions;
}
/**
* Read target protocol connection status
*
* LWM2M path: /1027//3
*
* @tapVersion(">=1.63")
* @return
*/
isConnected() {
return this.serviceCallRunner.execute(this.isConnectedCall());
}
/**
*
*
* LWM2M path: /1027//3
*
* @tapVersion(">=1.63")
* @return call options
*/
isConnectedCall() {
const callOptions = Object.assign({}, this.resources.isConnected);
return callOptions;
}
/**
* Connect to target
*
* LWM2M path: /1027//3
*
* @tapVersion(">=1.0")
* @return
*/
connect() {
return this.serviceCallRunner.execute(this.connectCall());
}
/**
*
*
* LWM2M path: /1027//3
*
* @tapVersion(">=1.0")
* @return call options
*/
connectCall() {
const callOptions = Object.assign({}, this.resources.connect);
return callOptions;
}
/**
* Disconnect from target
*
* LWM2M path: /1027//4
*
* @tapVersion(">=1.0")
* @return
*/
disconnect() {
return this.serviceCallRunner.execute(this.disconnectCall());
}
/**
*
*
* LWM2M path: /1027//4
*
* @tapVersion(">=1.0")
* @return call options
*/
disconnectCall() {
const callOptions = Object.assign({}, this.resources.disconnect);
return callOptions;
}
/**
* Reset target
*
* LWM2M path: /1027//5
*
* @tapVersion(">=1.0")
* @return
*/
reset() {
return this.serviceCallRunner.execute(this.resetCall());
}
/**
*
*
* LWM2M path: /1027//5
*
* @tapVersion(">=1.0")
* @return call options
*/
resetCall() {
const callOptions = Object.assign({}, this.resources.reset);
return callOptions;
}
/**
* Get target firmware version
*
* LWM2M path: /1027//6
*
* @tapVersion(">=1.0")
* @return
*/
getFirmwareVersion() {
return this.serviceCallRunner.execute(this.getFirmwareVersionCall());
}
/**
*
*
* LWM2M path: /1027//6
*
* @tapVersion(">=1.0")
* @return call options
*/
getFirmwareVersionCall() {
const callOptions = Object.assign({}, this.resources.getFirmwareVersion);
return callOptions;
}
/**
* Write target firmware version
*
* LWM2M path: /1027//6
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putFirmwareVersion(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.putFirmwareVersionCall(value));
}
/**
*
*
* LWM2M path: /1027//6
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putFirmwareVersionCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.putFirmwareVersion);
callOptions.body = value;
return callOptions;
}
/**
* Get vcc
*
* LWM2M path: /1027//7
*
* @tapVersion(">=1.0")
* @return
*/
getVcc() {
return this.serviceCallRunner.execute(this.getVccCall());
}
/**
*
*
* LWM2M path: /1027//7
*
* @tapVersion(">=1.0")
* @return call options
*/
getVccCall() {
const callOptions = Object.assign({}, this.resources.getVcc);
return callOptions;
}
/**
* Get min target voltage
*
* LWM2M path: /1027//8
*
* @tapVersion(">=1.0")
* @return
*/
getMinVoltage() {
return this.serviceCallRunner.execute(this.getMinVoltageCall());
}
/**
*
*
* LWM2M path: /1027//8
*
* @tapVersion(">=1.0")
* @return call options
*/
getMinVoltageCall() {
const callOptions = Object.assign({}, this.resources.getMinVoltage);
return callOptions;
}
/**
* Write min target voltage value
*
* LWM2M path: /1027//8
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putMinVoltage(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.putMinVoltageCall(value));
}
/**
*
*
* LWM2M path: /1027//8
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putMinVoltageCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.putMinVoltage);
callOptions.body = value;
return callOptions;
}
/**
* Get max target voltage
*
* LWM2M path: /1027//9
*
* @tapVersion(">=1.0")
* @return
*/
getMaxVoltage() {
return this.serviceCallRunner.execute(this.getMaxVoltageCall());
}
/**
*
*
* LWM2M path: /1027//9
*
* @tapVersion(">=1.0")
* @return call options
*/
getMaxVoltageCall() {
const callOptions = Object.assign({}, this.resources.getMaxVoltage);
return callOptions;
}
/**
* Write max target voltage value
*
* LWM2M path: /1027//9
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putMaxVoltage(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.putMaxVoltageCall(value));
}
/**
*
*
* LWM2M path: /1027//9
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putMaxVoltageCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.putMaxVoltage);
callOptions.body = value;
return callOptions;
}
/**
* Get target page size
*
* LWM2M path: /1027//10
*
* @tapVersion(">=1.0")
* @return
*/
getPageSize() {
return this.serviceCallRunner.execute(this.getPageSizeCall());
}
/**
*
*
* LWM2M path: /1027//10
*
* @tapVersion(">=1.0")
* @return call options
*/
getPageSizeCall() {
const callOptions = Object.assign({}, this.resources.getPageSize);
return callOptions;
}
/**
* Write target page size
*
* LWM2M path: /1027//10
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putPageSize(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.putPageSizeCall(value));
}
/**
*
*
* LWM2M path: /1027//10
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putPageSizeCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.putPageSize);
callOptions.body = value;
return callOptions;
}
/**
* Get communication stats
*
* LWM2M path: /1027//11
*
* @tapVersion(">=1.0")
* @return
*/
getComStats() {
return this.serviceCallRunner.execute(this.getComStatsCall());
}
/**
*
*
* LWM2M path: /1027//11
*
* @tapVersion(">=1.0")
* @return call options
*/
getComStatsCall() {
const callOptions = Object.assign({}, this.resources.getComStats);
return callOptions;
}
/**
* Clear communication stats
*
* LWM2M path: /1027//11
*
* @tapVersion(">=1.0")
* @return
*/
clearComStats() {
return this.serviceCallRunner.execute(this.clearComStatsCall());
}
/**
*
*
* LWM2M path: /1027//11
*
* @tapVersion(">=1.0")
* @return call options
*/
clearComStatsCall() {
const callOptions = Object.assign({}, this.resources.clearComStats);
return callOptions;
}
/**
* List available target protocols
*
* LWM2M path: /1027//20
*
* @tapVersion(">=1.0")
* @return
*/
getAvailableProtocols() {
return this.serviceCallRunner.execute(this.getAvailableProtocolsCall());
}
/**
*
*
* LWM2M path: /1027//20
*
* @tapVersion(">=1.0")
* @return call options
*/
getAvailableProtocolsCall() {
const callOptions = Object.assign({}, this.resources.getAvailableProtocols);
return callOptions;
}
/**
* Get Serial/Modbus protocol configuration options
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @return
*/
getSerialModbusConfiguration() {
return this.serviceCallRunner.execute(this.getSerialModbusConfigurationCall());
}
/**
*
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @return call options
*/
getSerialModbusConfigurationCall() {
const callOptions = Object.assign({}, this.resources.getSerialModbusConfiguration);
return callOptions;
}
/**
* Temporary update configuration
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
setSerialModbusConfiguration(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.setSerialModbusConfigurationCall(value));
}
/**
*
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
setSerialModbusConfigurationCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.setSerialModbusConfiguration);
callOptions.body = value;
return callOptions;
}
/**
* Write protocol options in Tap configuration
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putSerialModbusConfiguration(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.putSerialModbusConfigurationCall(value));
}
/**
*
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
putSerialModbusConfigurationCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.putSerialModbusConfiguration);
callOptions.body = value;
return callOptions;
}
/**
* Get modbus default slave address
*
* LWM2M path: /1027//22
*
* @tapVersion(">=1.0")
* @return
*/
getModbusDefaultSlaveAddress() {
return this.serviceCallRunner.execute(this.getModbusDefaultSlaveAddressCall());
}
/**
*
*
* LWM2M path: /1027//22
*
* @tapVersion(">=1.0")
* @return call options
*/
getModbusDefaultSlaveAddressCall() {
const callOptions = Object.assign({}, this.resources.getModbusDefaultSlaveAddress);
return callOptions;
}
/**
* Write modbus default slave address
*
* LWM2M path: /1027//22
*
* @tapVersion(">=1.0")
* @param address input
* @return
*/
putModbusDefaultSlaveAddress(
/*
* New default modbus slave address
*/
address) {
return this.serviceCallRunner.execute(this.putModbusDefaultSlaveAddressCall(address));
}
/**
*
*
* LWM2M path: /1027//22
*
* @tapVersion(">=1.0")
* @param address input
* @return call options
*/
putModbusDefaultSlaveAddressCall(
/*
* New default modbus slave address
*/
address) {
const callOptions = Object.assign({}, this.resources.putModbusDefaultSlaveAddress);
callOptions.body = address;
return callOptions;
}
/**
* Get S3P protocol configuration
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @return
*/
getS3PConfiguration() {
return this.serviceCallRunner.execute(this.getS3PConfigurationCall());
}
/**
*
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @return call options
*/
getS3PConfigurationCall() {
const callOptions = Object.assign({}, this.resources.getS3PConfiguration);
return callOptions;
}
/**
* Temporary update S3P configuration
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
setS3PConfiguration(
/*
*
*/
value) {
return this.serviceCallRunner.execute(this.setS3PConfigurationCall(value));
}
/**
*
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return call options
*/
setS3PConfigurationCall(
/*
*
*/
value) {
const callOptions = Object.assign({}, this.resources.setS3PConfiguration);
callOptions.body = value;
return callOptions;
}
/**
* Update protocol configuration
*
* LWM2M path: /1027//21
*
* @tapVersion(">=1.0")
* @param value input
* @return
*/
putS3PConfiguration(
/*
*