@iotize/tap
Version:
IoTize Device client for Javascript
16 lines (14 loc) • 17.8 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@iotize/tap"),require("@iotize/tap/client/api"),require("@iotize/tap/service/impl/target"),require("@iotize/tap/client/impl"),require("@iotize/tap/service/core"),require("@iotize/common/byte-stream")):"function"==typeof define&&define.amd?define("@iotize/tap/service/impl/tapnpass",["exports","@iotize/tap","@iotize/tap/client/api","@iotize/tap/service/impl/target","@iotize/tap/client/impl","@iotize/tap/service/core","@iotize/common/byte-stream"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).iotize=t.iotize||{},t.iotize.tap=t.iotize.tap||{},t.iotize.tap.service=t.iotize.tap.service||{},t.iotize.tap.service.impl=t.iotize.tap.service.impl||{},t.iotize.tap.service.impl.tapnpass={}),t.iotize.tap,t.iotize.tap.client.api,t.iotize.tap.service.impl.target,t.iotize.tap.client.impl,t.iotize.tap.service.core,t.byteStream)}(this,(function(t,e,r,o,i,n,a){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},s(t,e)};Object.create;function p(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],o=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,i,n=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var o,i=0,n=e.length;i<n;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}var c,l,h,f;Object.create;t.AdpControlIn=void 0,l=t.AdpControlIn||(t.AdpControlIn={}),(c=l.Command||(l.Command={}))[c.NONE=0]="NONE",c[c.ZIP=32769]="ZIP",c[c.UNZIP=32770]="UNZIP",c[c.SET_TRANSMISSION_BUFFER_SIZE=32771]="SET_TRANSMISSION_BUFFER_SIZE",c[c.TOTAL_BUFFER_SIZE=32772]="TOTAL_BUFFER_SIZE",c[c.GET_TRANSMISSION_BUFFER_SIZE=32773]="GET_TRANSMISSION_BUFFER_SIZE",c[c.SET_RESPONSE_DELIMITER_LOW=32774]="SET_RESPONSE_DELIMITER_LOW",c[c.SET_RESPONSE_DELIMITER_HIGH=32775]="SET_RESPONSE_DELIMITER_HIGH",c[c.SET_COMMAND_DELIMITER_LOW=32776]="SET_COMMAND_DELIMITER_LOW",c[c.EXEC_COMMANDS=32777]="EXEC_COMMANDS",t.AdpControlOut=void 0,f=t.AdpControlOut||(t.AdpControlOut={}),(h=f.ResultCode||(f.ResultCode={}))[h.NONE=0]="NONE",h[h.OK=32768]="OK",h[h.ZIP_TIMEOUT=32769]="ZIP_TIMEOUT",h[h.UNZIP_TIMEOUT=32770]="UNZIP_TIMEOUT",h[h.ZIP_ERROR=32771]="ZIP_ERROR",h[h.UNZIP_ERROR=32772]="UNZIP_ERROR",h[h.UNKNOWN_COMMAND=32773]="UNKNOWN_COMMAND",h[h.INVALID_PARAM=32774]="INVALID_PARAM",i.TapStreamReader.prototype.readTapnpassProtocolConfiguration=function(){var t={};return t.modbus=this.readTapnpassProtocolConfigurationModbus(),t.serial=this.readTapnpassProtocolConfigurationSerial(),t.usb=this.readTapnpassProtocolConfigurationUsb(),t},i.TapStreamReader.prototype.readTapnpassProtocolConfigurationModbus=function(){var t={};return t.slave=this.readUnsigned(1),this.forwardBits(3),t.offsetFirstRegister=this.readBoolean(1),t},i.TapStreamReader.prototype.readTapnpassProtocolConfigurationSerial=function(){var t={};return t.baudRate=this.readBits(20),t.identification=this.readBoolean(1),this.forwardBits(1),t.ledStatus=this.readBoolean(1),this.forwardBits(1),t.physicalPort=this.readBits(4),t.stopBits=this.readBits(2),t.bitParity=this.readBits(4),t.dataBits=this.readBits(2),t.handshakeDelimiter=this.readBits(4),t.hardwareFlowControl=this.readBits(4),t.timeout=this.readUnsigned(1),t},i.TapStreamReader.prototype.readTapnpassProtocolConfigurationUsb=function(){for(var t={aliases:[]};!this.isEof();)t.aliases.push(this.readTapnpassProtocolConfigurationUsbAlias());return t},i.TapStreamReader.prototype.readTapnpassProtocolConfigurationUsbAlias=function(){var t={};return t.pid=this.readUnsigned(2),t.vid=this.readUnsigned(2),t.equ=this.readUnsigned(1),t},i.TapStreamReader.prototype.readAdpStats=function(){var t={};return t.header=this.readAdpStatsHeader(),t.state=this.readAdpStatsState(),t.uart=this.readAdpStatsUart(),t.usb=this.readAdpStatsUsb(),t.current=this.readBytes(4),t.com=this.readAdpStatsCom(),t.battery=this.readBytes(4),t.intern=this.readAdpStatsIntern(),t},i.TapStreamReader.prototype.readAdpStatsHeader=function(){var t={};return this.forwardBits(16),t.version=this.readAdpStatsVersion(),t.errorCode=this.readUnsigned(1),this.forwardBits(16),t},i.TapStreamReader.prototype.readAdpStatsVersion=function(){var t={};return t.major=this.readUnsigned(1),t.minor=this.readUnsigned(1),t.patch=this.readUnsigned(1),t},i.TapStreamReader.prototype.readAdpStatsIntern=function(){var t={};return t.time=this.readBytes(4),t.nbBoots=this.readBytes(4),t.nbShutdown=this.readBytes(2),t.nbAdpFault=this.readBytes(2),t.nbAdpMemFault=this.readBytes(2),t.nbAdpBusFault=this.readBytes(2),t.nbAdpUsageFault=this.readBytes(2),this.forwardBits(16),t.temperature=this.readBytes(4),t},i.TapStreamReader.prototype.readAdpStatsState=function(){var t={};return this.forwardBits(7),t.usbDisconnected=this.readBoolean(1),this.forwardBits(24),t},i.TapStreamReader.prototype.readAdpStatsUart=function(){var t={};return t.nbPartityError=this.readUnsigned(1),t.nbNoiseError=this.readUnsigned(1),t.nbFrameError=this.readUnsigned(1),t.nbDmaError=this.readUnsigned(1),t.nbTxError=this.readUnsigned(1),t.nbRxError=this.readUnsigned(1),t.nbOverRun=this.readUnsigned(1),this.forwardBits(8),t},i.TapStreamReader.prototype.readAdpStatsUsb=function(){var t={};return t.nbFail=this.readUnsigned(1),t.nbTimeout=this.readUnsigned(1),t.nbError=this.readUnsigned(1),t.nbUnknownClass=this.readUnsigned(1),t.nbDisconnect=this.readUnsigned(1),t.nbOff=this.readUnsigned(1),this.forwardBits(16),t},i.TapStreamReader.prototype.readAdpStatsCom=function(){var t={};return t.txBufferOverRun=this.readUnsigned(1),t.rxBufferOverRun=this.readUnsigned(1),t.nbErrorSettings=this.readUnsigned(1),this.forwardBits(8),t.nbComAdp=this.readBytes(4),t},i.TapStreamReader.prototype.readAdpControlIn=function(){var t={};return t.command=this.readUnsigned(2),t.param=this.readUnsigned(2),t},i.TapStreamReader.prototype.readAdpControlOut=function(){var t={};return t.resultCode=this.readUnsigned(2),t.param=this.readUnsigned(2),t},i.TapStreamWriter.prototype.writeTapnpassProtocolConfiguration=function(t){return this.writeTapnpassProtocolConfigurationModbus(t.modbus),this.writeTapnpassProtocolConfigurationSerial(t.serial),this.writeTapnpassProtocolConfigurationUsb(t.usb),this},i.TapStreamWriter.prototype.writeTapnpassProtocolConfigurationModbus=function(t){return this.writeUnsigned(t.slave,1),this.forwardBits(3),this.writeBoolean(t.offsetFirstRegister,1),this},i.TapStreamWriter.prototype.writeTapnpassProtocolConfigurationSerial=function(t){return this.writeBits(t.baudRate,20),this.writeBoolean(t.identification,1),this.forwardBits(1),this.writeBoolean(t.ledStatus,1),this.forwardBits(1),this.writeBitsInt(i.enumKeyOrValueToNumber(t.physicalPort,o.SerialSettings.PhysicalPort),4),this.writeBitsInt(i.enumKeyOrValueToNumber(t.stopBits,o.SerialSettings.StopBits),2),this.writeBitsInt(i.enumKeyOrValueToNumber(t.bitParity,o.SerialSettings.BitParity),4),this.writeBitsInt(i.enumKeyOrValueToNumber(t.dataBits,o.SerialSettings.DataBits),2),this.writeBitsInt(i.enumKeyOrValueToNumber(t.handshakeDelimiter,o.SerialSettings.HandshakeDelimiter),4),this.writeBitsInt(i.enumKeyOrValueToNumber(t.hardwareFlowControl,o.SerialSettings.HardwareFlowControl),4),this.writeUnsigned(t.timeout,1),this},i.TapStreamWriter.prototype.writeTapnpassProtocolConfigurationUsb=function(t){var e,r;try{for(var o=p(t.aliases),i=o.next();!i.done;i=o.next()){var n=i.value;this.writeTapnpassProtocolConfigurationUsbAlias(n)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return this},i.TapStreamWriter.prototype.writeTapnpassProtocolConfigurationUsbAlias=function(t){return this.writeUnsigned(t.pid,2),this.writeUnsigned(t.vid,2),this.writeUnsigned(t.equ,1),this},i.TapStreamWriter.prototype.writeAdpStats=function(t){return this.writeAdpStatsHeader(t.header),this.writeAdpStatsState(t.state),this.writeAdpStatsUart(t.uart),this.writeAdpStatsUsb(t.usb),this.writeBytes(t.current,4),this.writeAdpStatsCom(t.com),this.writeBytes(t.battery,4),this.writeAdpStatsIntern(t.intern),this},i.TapStreamWriter.prototype.writeAdpStatsHeader=function(t){return this.forwardBits(16),this.writeAdpStatsVersion(t.version),this.writeUnsigned(t.errorCode,1),this.forwardBits(16),this},i.TapStreamWriter.prototype.writeAdpStatsVersion=function(t){return this.writeUnsigned(t.major,1),this.writeUnsigned(t.minor,1),this.writeUnsigned(t.patch,1),this},i.TapStreamWriter.prototype.writeAdpStatsIntern=function(t){return this.writeBytes(t.time,4),this.writeBytes(t.nbBoots,4),this.writeBytes(t.nbShutdown,2),this.writeBytes(t.nbAdpFault,2),this.writeBytes(t.nbAdpMemFault,2),this.writeBytes(t.nbAdpBusFault,2),this.writeBytes(t.nbAdpUsageFault,2),this.forwardBits(16),this.writeBytes(t.temperature,4),this},i.TapStreamWriter.prototype.writeAdpStatsState=function(t){return this.forwardBits(7),this.writeBoolean(t.usbDisconnected,1),this.forwardBits(24),this},i.TapStreamWriter.prototype.writeAdpStatsUart=function(t){return this.writeUnsigned(t.nbPartityError,1),this.writeUnsigned(t.nbNoiseError,1),this.writeUnsigned(t.nbFrameError,1),this.writeUnsigned(t.nbDmaError,1),this.writeUnsigned(t.nbTxError,1),this.writeUnsigned(t.nbRxError,1),this.writeUnsigned(t.nbOverRun,1),this.forwardBits(8),this},i.TapStreamWriter.prototype.writeAdpStatsUsb=function(t){return this.writeUnsigned(t.nbFail,1),this.writeUnsigned(t.nbTimeout,1),this.writeUnsigned(t.nbError,1),this.writeUnsigned(t.nbUnknownClass,1),this.writeUnsigned(t.nbDisconnect,1),this.writeUnsigned(t.nbOff,1),this.forwardBits(16),this},i.TapStreamWriter.prototype.writeAdpStatsCom=function(t){return this.writeUnsigned(t.txBufferOverRun,1),this.writeUnsigned(t.rxBufferOverRun,1),this.writeUnsigned(t.nbErrorSettings,1),this.forwardBits(8),this.writeBytes(t.nbComAdp,4),this},i.TapStreamWriter.prototype.writeAdpControlIn=function(e){return this.writeBitsInt(i.enumKeyOrValueToNumber(e.command,t.AdpControlIn.Command),16),this.writeUnsigned(e.param,2),this},i.TapStreamWriter.prototype.writeAdpControlOut=function(e){return this.writeBitsInt(i.enumKeyOrValueToNumber(e.resultCode,t.AdpControlOut.ResultCode),16),this.writeUnsigned(e.param,2),this};var y=function(){function t(){}return t.prototype.encode=function(t,e){return void 0===e&&(e=new i.TapStreamWriter),e.writeTapnpassProtocolConfiguration(t),e.toBytes},t.prototype.decode=function(t){return(t instanceof i.TapStreamReader?t:i.TapStreamReader.create(t)).readTapnpassProtocolConfiguration()},t}(),S=function(){function t(){}return t.prototype.encode=function(t,e){return void 0===e&&(e=new i.TapStreamWriter),e.writeAdpStats(t),e.toBytes},t.prototype.decode=function(t){return(t instanceof i.TapStreamReader?t:i.TapStreamReader.create(t)).readAdpStats()},t}(),g=function(){function t(){}return t.prototype.encode=function(t,e){return void 0===e&&(e=new i.TapStreamWriter),e.writeAdpControlIn(t),e.toBytes},t.prototype.decode=function(t){return(t instanceof i.TapStreamReader?t:i.TapStreamReader.create(t)).readAdpControlIn()},t}(),C=function(){function t(){}return t.prototype.encode=function(t,e){return void 0===e&&(e=new i.TapStreamWriter),e.writeAdpControlOut(t),e.toBytes},t.prototype.decode=function(t){return(t instanceof i.TapStreamReader?t:i.TapStreamReader.create(t)).readAdpControlOut()},t}(),m=new y,T=new S,w=new g,b=new C,A=Object.freeze({__proto__:null,tapnpassProtocolConfiguration:m,adpStats:T,adpControlIn:w,adpControlOut:b}),O=Uint8Array.from([0,0,0,0,0]),B=function(){function t(){this.converter=new y}return t.prototype.decode=function(t){return this.converter.decode(this._reorderBytes(t.slice(0,t.length-O.length)))},t.prototype.encode=function(t){return a.KaitaiStreamWriter.mergeArrays(this._reorderBytes(this.converter.encode(t)),O)},t.prototype._reorderBytes=function(t){return a.KaitaiStreamWriter.mergeArrays(t.slice(0,8).reverse(),t.slice(8))},t}(),v=new B,U=Object.freeze({__proto__:null,reversedTapnpassProtocolConfiguration:v}),R=Object.assign(Object.assign(Object.assign({},n.converters),A),U),E={getProtocolConfiguration:{method:r.TapRequestFrame.MethodType.GET,pathAlias:"/tapnpass/protocol-configuration",path:"/1027//21",responseBodyDecoder:R.reversedTapnpassProtocolConfiguration},setProtocolConfiguration:{method:r.TapRequestFrame.MethodType.POST,pathAlias:"/tapnpass/protocol-configuration",path:"/1027//21",bodyEncoder:R.reversedTapnpassProtocolConfiguration},putProtocolConfiguration:{method:r.TapRequestFrame.MethodType.PUT,pathAlias:"/tapnpass/protocol-configuration",path:"/1027//21",bodyEncoder:R.reversedTapnpassProtocolConfiguration},getStatus:{method:r.TapRequestFrame.MethodType.GET,pathAlias:"/tapnpass/status",path:"/1027//36",responseBodyDecoder:R.adpStats},postAction:{method:r.TapRequestFrame.MethodType.POST,pathAlias:"/tapnpass/action",path:"/1027//39"},getControlIn:{method:r.TapRequestFrame.MethodType.GET,pathAlias:"/tapnpass/control-in",path:"/1027//41",responseBodyDecoder:R.adpControlIn},setControlIn:{method:r.TapRequestFrame.MethodType.POST,pathAlias:"/tapnpass/control-in",path:"/1027//41",bodyEncoder:R.adpControlIn},getControlOut:{method:r.TapRequestFrame.MethodType.GET,pathAlias:"/tapnpass/control-out",path:"/1027//42",responseBodyDecoder:R.adpControlOut},setAdpControlOut:{method:r.TapRequestFrame.MethodType.POST,pathAlias:"/tapnpass/control-out",path:"/1027//42",responseBodyDecoder:R.adpControlOut,bodyEncoder:R.adpControlOut}},I=function(t){function e(){var e=t.apply(this,u([],d(arguments)))||this;return e.resources=E,e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.getProtocolConfiguration=function(){return this.serviceCallRunner.execute(this.getProtocolConfigurationCall())},e.prototype.getProtocolConfigurationCall=function(){return Object.assign({},this.resources.getProtocolConfiguration)},e.prototype.setProtocolConfiguration=function(t){return this.serviceCallRunner.execute(this.setProtocolConfigurationCall(t))},e.prototype.setProtocolConfigurationCall=function(t){var e=Object.assign({},this.resources.setProtocolConfiguration);return e.body=t,e},e.prototype.putProtocolConfiguration=function(t){return this.serviceCallRunner.execute(this.putProtocolConfigurationCall(t))},e.prototype.putProtocolConfigurationCall=function(t){var e=Object.assign({},this.resources.putProtocolConfiguration);return e.body=t,e},e.prototype.getStatus=function(){return this.serviceCallRunner.execute(this.getStatusCall())},e.prototype.getStatusCall=function(){return Object.assign({},this.resources.getStatus)},e.prototype.postAction=function(t){return this.serviceCallRunner.execute(this.postActionCall(t))},e.prototype.postActionCall=function(t){var e=Object.assign({},this.resources.postAction);return e.body=t,e},e.prototype.getControlIn=function(){return this.serviceCallRunner.execute(this.getControlInCall())},e.prototype.getControlInCall=function(){return Object.assign({},this.resources.getControlIn)},e.prototype.setControlIn=function(t){return this.serviceCallRunner.execute(this.setControlInCall(t))},e.prototype.setControlInCall=function(t){var e=Object.assign({},this.resources.setControlIn);return e.body=t,e},e.prototype.getControlOut=function(){return this.serviceCallRunner.execute(this.getControlOutCall())},e.prototype.getControlOutCall=function(){return Object.assign({},this.resources.getControlOut)},e.prototype.setAdpControlOut=function(t){return this.serviceCallRunner.execute(this.setAdpControlOutCall(t))},e.prototype.setAdpControlOutCall=function(t){var e=Object.assign({},this.resources.setAdpControlOut);return e.body=t,e},e}(e.AbstractService),P=e.extendServiceContainer("tapnpass",I);t.AdpControlInConverter=g,t.AdpControlOutConverter=C,t.AdpStatsConverter=S,t.ReversedTapnpassProtocolConfigurationConverter=B,t.TAPNPASS_SERVICE_CALLS=E,t.TapnpassProtocolConfigurationConverter=y,t.TapnpassResourceMetaData={"/tapnpass/protocol-configuration":{put:{minApiVersion:1,configModeRequired:!0,schema:{$ref:"./definitions.yaml#/TapnpassProtocolConfiguration"}}}},t.TapnpassService=I,t._TAP_SERVICE_EXTENSION_TAPNPASS_=P,t.reversedTapnpassProtocolConfiguration=v,t.tapnpassConverters=A,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=iotize-tap-service-impl-tapnpass.umd.min.js.map