1 line
2.3 KiB
JavaScript
1 line
2.3 KiB
JavaScript
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},e=function(){function t(t,e){for(var o in e){var i=e[o];i.configurable=!0,i.value&&(i.writable=!0)}Object.defineProperties(t,e)}return function(e,o,i){return o&&t(e.prototype,o),i&&t(e,i),e}}(),o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},i=t(require("async")),s=function(){function t(){o(this,t),this.bs={},this.bs.axisState={ts:[],pos:0,inc_pos:0,vel:0,cur:0,pwm:0,status:0,vel_limit:0,acc_limit:0,cur_limit:0,mode:0,ref:0,ticks:0},this.bs.miscState={ts:[],main_board_temp:0,neck_motor_temp:0,torso_motor_temp:0,pelvis_motor_temp:0},this.bs.touchState={ts:[],touched:!1,pad_state:[0,0,0,0,0,0],changed:[0,0,0,0,0,0]},this.bs.powerState={ts:[],source:"",vsys:0,battery:{id:0,cycles:0,capacity:0,max_capacity:0,charge_rate:0,temp:0}}}return e(t,{init:{value:function(t,e){this.bodyServiceURL=t,i.parallel([this.createAxisSocket.bind(this),this.createMiscSocket.bind(this),this.createTouchSocket.bind(this),this.createPowerSocket.bind(this)],e)}},createAxisSocket:{value:function(t){var e=this;this.axisSocket=new WebSocket(this.bodyServiceURL+"/axis_state"),this.axisSocket.onerror=function(){console.error("Error opening axis state socket at "+e.bodyServiceURL+"/axis_state")},this.axisSocket.onmessage=function(t){e.bs.axisData=JSON.parse(t.data)},t()}},createMiscSocket:{value:function(t){var e=this;this.MiscSocket=new WebSocket(this.bodyServiceURL+"/misc"),this.MiscSocket.onerror=function(){console.error("Error opening misc state socket at "+e.bodyServiceURL+"/misc")},this.MiscSocket.onmessage=function(t){e.bs.miscData=JSON.parse(t.data)},t()}},createTouchSocket:{value:function(t){var e=this;this.TouchSocket=new WebSocket(this.bodyServiceURL+"/touch"),this.TouchSocket.onerror=function(){console.error("Error opening touch state socket at "+e.bodyServiceURL+"/touch")},this.TouchSocket.onmessage=function(t){e.bs.touchData=JSON.parse(t.data)},t()}},createPowerSocket:{value:function(t){var e=this;this.PowerSocket=new WebSocket(this.bodyServiceURL+"/power"),this.PowerSocket.onerror=function(){console.error("Error opening power state socket at "+e.bodyServiceURL+"/power")},this.PowerSocket.onmessage=function(t){e.bs.powerData=JSON.parse(t.data)},t()}}}),t}();module.exports=new s; |