module.exports = { // buffer 转16进制 buf2hex:function (buffer) { // create a byte array (Uint8Array) that we can use to read the array buffer const byteArray = new Uint8Array(buffer); // for each element, we want to get its two-digit hexadecimal representation const hexParts = []; for(let i = 0; i < byteArray.length; i++) { // convert value to hexadecimal const hex = byteArray[i].toString(16); // pad with zeros to length 2 const paddedHex = ('00' + hex).slice(-2); // push to array hexParts.push(paddedHex); } // join all the hex values of the elements into a single string return hexParts.join(''); }, // 足压数据补齐点位为60*60 并进行点扩散 setPressureData:function (data) { let dataAll = [] // 补到之前 60*60 个点位 for (let j =0;j<60;j++) { dataAll[j] = [] for (let k =0;k<60;k++) { if(typeof (data[j]) == 'undefined') { dataAll[j][k] = 0 } else { if(typeof (data[j][k]) == 'undefined') { dataAll[j][k] = 0 } else { dataAll[j][k] = data[j][k] } } } } return pressureDataProcess(dataAll,2.5,4) }, } function pressureDataProcess(a,scale,size) { var height = 60; var width = 60; var newHeight = 60*scale; var newWidth = 60*scale; var u =0.0; var v = 0.0; var x = 0.0; var y = 0.0; var m = 0; var n = 0; let temp = new Array() let rearr = [] for(let i = 0;i0) { tt.value = temp[i][j] rearr.push(tt) } } } return rearr }