receivePenData.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * utils/receivePenData.js
  3. * create: kimswang
  4. * date: 2018-10-31
  5. */
  6. var event = require('./event.js')
  7. var arrayDot = new Array();
  8. /**
  9. * 接收笔传过来的数据
  10. */
  11. function receivedData (dot) {
  12. var jsonDot = {
  13. counter: dot.counter, // 点计数
  14. sectionID: dot.sectionID, // 区域ID
  15. ownerID: dot.ownerID, // 客户ID
  16. bookID: dot.bookID, // 书号
  17. pageID: dot.pageID, // 页号
  18. timeLong: dot.timeLong, // 当前点的RTC 时间,返回时间戳 ms(起止时间是2018-01-01 00:00:00,000)
  19. x: dot.x, // 点横坐标,整数部分
  20. y: dot.y, // 点纵坐标,整数部分
  21. fx: dot.fx, // 点横坐标,小数部分
  22. fy: dot.fy, // 点纵坐标,小数部分
  23. ab_x: dot.ab_x, // 点横坐标,整数+小数部分
  24. ab_y: dot.ab_y, // 点纵坐标,整数+小数部分
  25. dotType: dot.dotType,
  26. force: dot.force, // 点的压力值
  27. angle: dot.angle, // 点的角度值
  28. color: dot.color, // 笔的颜色值
  29. };
  30. // console.log('jsonDot content is: ' + JSON.stringify(jsonDot));
  31. //console.log('dot.force'+ dot.force + 'dot.trpe' + dot.dotType + 'dot.x'+ dot.x + 'dot.y'+ dot.y);
  32. if (dot != null){
  33. event.emit('AddressDataChanged', dot)
  34. }
  35. // arrayDot.push(jsonDot);
  36. }
  37. /**
  38. * 送出数据
  39. */
  40. function getBleData () {
  41. var dotData;
  42. if (arrayDot.length > 0) {
  43. for (let i = 0; i < arrayDot.length; i++) {
  44. dotData = arrayDot[i];
  45. if (arrayDot.length != 0) {
  46. arrayDot.splice(i,1);
  47. }
  48. return dotData;
  49. }
  50. } else {
  51. //console.log('Dot data is null : ' + JSON.stringify(arrayDot));
  52. }
  53. }
  54. module.exports = {
  55. receivedData: receivedData,
  56. getBleData: getBleData
  57. }