...
|
...
|
@@ -26,7 +26,7 @@ export let log = loger; |
|
|
* @param {Number} number 十进制数
|
|
|
* @return {Number} 16进制数字
|
|
|
*/
|
|
|
export let tenToHex = function (number) {
|
|
|
export let tenToHex = function(number) {
|
|
|
return (parseInt(number, 10) >>> 0).toString(16);
|
|
|
};
|
|
|
|
...
|
...
|
@@ -37,7 +37,7 @@ export let tenToHex = function (number) { |
|
|
* @param {Boolean} minus true表示负数,false表示正数
|
|
|
* @return {Number} 十进制数字
|
|
|
*/
|
|
|
export let hexToTen = function (number, minus) {
|
|
|
export let hexToTen = function(number, minus) {
|
|
|
if (minus) {
|
|
|
return parseInt('FFFF' + number, 16) >> 0;
|
|
|
} else {
|
...
|
...
|
@@ -52,7 +52,7 @@ export let hexToTen = function (number, minus) { |
|
|
* @param {Buff} data 返回数据流
|
|
|
* @return {Array} 转成16进制的数组
|
|
|
*/
|
|
|
export let toHex = function (data) {
|
|
|
export let toHex = function(data) {
|
|
|
let arr = [];
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
arr[i] = tenToHex(data.readUIntLE(i));
|
...
|
...
|
@@ -69,7 +69,7 @@ export let toHex = function (data) { |
|
|
* @param {Object} output 标准输出的规格对象
|
|
|
* @return {object} 标准输出
|
|
|
*/
|
|
|
export let returnProc = function (data, ip, output) {
|
|
|
export let returnProc = function(data, ip, output) {
|
|
|
if (!_.isArray(data) || _.size(data) < 1) {
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -78,7 +78,7 @@ export let returnProc = function (data, ip, output) { |
|
|
if (!output[ret]) {
|
|
|
return false;
|
|
|
}
|
|
|
//log.info("读写器(" + ip + ")返回:" + output[ret].message + " 返回码:" + ret);
|
|
|
log.info("读写器(" + ip + ")返回:" + output[ret].message + " 返回码:" + ret);
|
|
|
output[ret].hex = data;
|
|
|
return output[ret];
|
|
|
};
|
...
|
...
|
@@ -90,7 +90,7 @@ export let returnProc = function (data, ip, output) { |
|
|
* @param {String} data 得到的指令数据结果集
|
|
|
* @return {Object} 返回拆分结果和拆分依据的指令头
|
|
|
*/
|
|
|
export let spliteRet = function (mq, data) {
|
|
|
export let spliteRet = function(mq, data) {
|
|
|
let indexes = [],
|
|
|
rets = [],
|
|
|
i,
|
...
|
...
|
@@ -147,9 +147,9 @@ export let spliteRet = function (mq, data) { |
|
|
* @param {Array} data 返回的结果集 eg. ['f0','2','0','0']
|
|
|
* @return {Object} 返回定位到的指令
|
|
|
*/
|
|
|
export let locateOrder = function (orders, data) {
|
|
|
export let locateOrder = function(orders, data) {
|
|
|
let orderRet = {};
|
|
|
_.forIn(orders, function (val, key) {
|
|
|
_.forIn(orders, function(val, key) {
|
|
|
var order = val.input.toLowerCase();
|
|
|
var prefix = data[0].toLowerCase();
|
|
|
|
...
|
...
|
|