SHARE
TWEET

Untitled

a guest Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable no-console */
  2. // "use strict";
  3. var fs = require('fs')
  4. var Excel = require('exceljs');
  5.  
  6. var workbook = new Excel.Workbook();
  7.  
  8. workbook.views = [
  9.   {
  10.     x: 0, y: 0, width: 10000, height: 20000,
  11.     firstSheet: 0, activeTab: 0, visibility: 'visible'
  12.   }
  13. ]
  14.  
  15. var sheet1 = workbook.addWorksheet('BR Node 1');
  16. var sheet2 = workbook.addWorksheet('Node 2');
  17. var sheet3 = workbook.addWorksheet('Node 3');
  18. var sheet4 = workbook.addWorksheet('Node 4');
  19. var sheet5 = workbook.addWorksheet('Node 5');
  20. var sheet6 = workbook.addWorksheet('Node 6');
  21. var sheet7 = workbook.addWorksheet('Node 7');
  22. var sheet8 = workbook.addWorksheet('Node 8');
  23. var sheet9 = workbook.addWorksheet('Node 9');
  24. var sheet10 = workbook.addWorksheet('Node 10');
  25.  
  26.  
  27. // var logger = fs.createWriteStream('log.txt', {
  28. //   flags: 'w' // 'a' means appending (old data will be preserved)
  29. // })
  30.  
  31. sheet1.columns = [
  32.   //{ header: 'Time', key: 'Time', width: 15 },
  33.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  34.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  35.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  36.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  37. ];
  38.  
  39. sheet2.columns = [
  40.   //{ header: 'Time', key: 'Time', width: 15 },
  41.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  42.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  43.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  44.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  45. ];
  46.  
  47. sheet3.columns = [
  48.   //{ header: 'Time', key: 'Time', width: 15 },
  49.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  50.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  51.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  52.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  53. ];
  54.  
  55. sheet4.columns = [
  56.   //{ header: 'Time', key: 'Time', width: 15 },
  57.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  58.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  59.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  60.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  61. ];
  62.  
  63. sheet5.columns = [
  64.   //{ header: 'Time', key: 'Time', width: 15 },
  65.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  66.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  67.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  68.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  69. ];
  70.  
  71. sheet6.columns = [
  72.   //{ header: 'Time', key: 'Time', width: 15 },
  73.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  74.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  75.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  76.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  77. ];
  78.  
  79. sheet7.columns = [
  80.   //{ header: 'Time', key: 'Time', width: 15 },
  81.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  82.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  83.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  84.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  85. ];
  86.  
  87. sheet8.columns = [
  88.   //{ header: 'Time', key: 'Time', width: 15 },
  89.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  90.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  91.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  92.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  93. ];
  94.  
  95. sheet9.columns = [
  96.   //{ header: 'Time', key: 'Time', width: 15 },
  97.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  98.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  99.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  100.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  101. ];
  102.  
  103. sheet10.columns = [
  104.   //{ header: 'Time', key: 'Time', width: 15 },
  105.   { header: 'ALL_CPU', key: 'ALL_CPU', width: 15 },
  106.   { header: 'ALL_LPM', key: 'ALL_LPM', width: 15 },
  107.   { header: 'ALL_TX', key: 'ALL_TX', width: 15 },
  108.   { header: 'ALL_RX', key: 'ALL_RX', width: 15 },
  109. ];
  110.  
  111.  
  112. var lineReader = require('readline').createInterface({
  113.     input: require('fs').createReadStream('./Logs/serial.log')
  114. });
  115.  
  116. // sheet1.addRow({ALL_CPU: 5, ALL_LPM: 6, ALL_TX: 4, ALL_RX: 3});
  117. // sheet2.addRow({ALL_CPU: 5, ALL_LPM: 6, ALL_TX: 4, ALL_RX: 3});
  118. // sheet3.addRow({ALL_CPU: 5, ALL_LPM: 6, ALL_TX: 4, ALL_RX: 3});
  119.  
  120.  
  121. lineReader.on('line', function (line) {
  122.  
  123.     var msgArray = line.split('t');
  124.     var msgArray2 = msgArray[2].split(' ');
  125.     if(msgArray2[2] == "P"){
  126.         var msgArray3 = msgArray[1].split(':');
  127.         if(msgArray3[1]=="1"){
  128.           sheet1.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]}).commit();
  129.  
  130.         }
  131.         else if(msgArray3[1]=="2"){
  132.           sheet2.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  133.  
  134.         }
  135.         else if(msgArray3[1]=="3"){
  136.           sheet3.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  137.  
  138.         }
  139.         else if(msgArray3[1]=="4"){
  140.           sheet4.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  141.  
  142.         }
  143.         else if(msgArray3[1]=="5"){
  144.           sheet5.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  145.  
  146.         }
  147.         else if(msgArray3[1]=="6"){
  148.           sheet6.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  149.  
  150.         }
  151.         else if(msgArray3[1]=="7"){
  152.           sheet7.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  153.  
  154.         }
  155.         else if(msgArray3[1]=="8"){
  156.           sheet8.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  157.  
  158.         }
  159.         else if(msgArray3[1]=="9"){
  160.           sheet9.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  161.  
  162.         }
  163.         else if(msgArray3[1]=="10"){
  164.           sheet10.addRow({ALL_CPU: msgArray2[5], ALL_LPM: msgArray2[6], ALL_TX: msgArray2[7], ALL_RX: msgArray2[8]});
  165.  
  166.         }
  167.  
  168.     }
  169. }
  170.  
  171.  
  172. );
  173.  
  174. workbook.xlsx.writeFile('123.xlsx').then(function() {
  175.     console.log("File has been written !!n");    
  176. });
  177.      
  178. 1771447979  ID:17    226665 P 193.12 58 1132721 56867074 123088 723836 0 0 14516 969042 1281 11840 0 0 (radio 1.-29% / 1.33% tx 0.21% / 0.13% listen 1.-50% / 1.20%)
  179. 1771480190  ID:22    226663 P 193.12 58 1075246 56924030 120236 802650 0 0 13298 969741 560 12976 0 0 (radio 1.-89% / 1.37% tx 0.20% / 0.05% listen 1.-36% / 1.31%)
  180. 1771484879  ID:7     226665 P 193.12 58 1125921 56873866 121595 786028 0 0 19233 964306 4072 13831 0 0 (radio 1.-92% / 1.82% tx 0.20% / 0.41% listen 1.-39% / 1.40%)
  181. 1771507455  ID:6     226663 P 193.12 58 1070690 56928597 115309 646256 0 0 15784 967255 2000 10407 0 0 (radio 1.-43% / 1.26% tx 0.19% / 0.20% listen 1.-63% / 1.05%)
  182. 1771515258  ID:15    226663 P 193.12 58 1088440 56910840 122783 505817 0 0 16169 966870 2481 8026 0 0 (radio 1.-66% / 1.06% tx 0.21% / 0.25% listen 0.13% / 0.81%)
  183. 1771597470  ID:11    226663 P 193.12 58 1053182 56946099 103885 793313 0 0 11573 971467 0 12768 0 0 (radio 1.-94% / 1.29% tx 0.17% / 0.00% listen 1.-38% / 1.29%)
  184. 1771642307  ID:29    226665 P 193.12 58 1083898 56915878 116093 782510 0 0 20643 962896 4894 14455 0 0 (radio 1.-94% / 1.96% tx 0.20% / 0.49% listen 1.-40% / 1.46%)
  185. 1771648153  ID:25    226665 P 193.12 58 2101486 55898313 155086 832175 0 0 33149 949889 1737 12886 0 0 (radio 1.-78% / 1.48% tx 0.26% / 0.17% listen 1.-31% / 1.31%)
  186. 1771721376  ID:18    226663 P 193.12 58 1084317 56914959 118001 786849 0 0 15075 967964 1680 12877 0 0 (radio 1.-93% / 1.48% tx 0.20% / 0.17% listen 1.-39% / 1.30%)
  187. 1771762392  ID:8     226663 P 193.12 58 1070464 56928824 118222 508692 0 0 18969 964071 3796 8589 0 0 (radio 1.-66% / 1.25% tx 0.20% / 0.38% listen 0.13% / 0.87%)
  188. 1771842367  ID:10    226663 P 193.12 58 1066581 56932700 117837 791378 0 0 11531 971509 0 12344 0 0 (radio 1.-92% / 1.25% tx 0.20% / 0.00% listen 1.-38% / 1.25%)
  189. 1771859573  ID:30    226663 P 193.12 58 1049816 56949460 102028 808123 0 0 14864 968175 1762 13270 0 0 (radio 1.-92% / 1.52% tx 0.17% / 0.17% listen 1.-35% / 1.34%)
  190. 1771865307  ID:16    226663 P 193.12 58 1150569 56848707 135263 825070 0 0 16549 966489 2961 13628 0 0 (radio 1.-83% / 1.68% tx 0.23% / 0.30% listen 1.-32% / 1.38%)
  191. 1771879217  ID:26    226663 P 193.12 58 1134157 56865120 124927 723048 0 0 11629 971411 0 10440 0 0 (radio 1.-28% / 1.06% tx 0.21% / 0.00% listen 1.-50% / 1.06%)
  192. 1771880521  ID:9     226663 P 193.12 58 1141876 56857413 139757 708414 0 0 14379 968662 1180 10621 0 0 (radio 1.-28% / 1.20% tx 0.24% / 0.12% listen 1.-52% / 1.08%)
  193. 1771890691  ID:5     226663 P 193.12 58 1083559 56915728 130056 496103 0 0 15088 967951 1920 7606 0 0 (radio 1.-67% / 0.96% tx 0.22% / 0.19% listen 0.11% / 0.77%)
  194. 1771898179  ID:21    226663 P 193.12 58 1131959 56867317 117883 692492 0 0 16060 966978 1200 11141 0 0 (radio 1.-35% / 1.25% tx 0.20% / 0.12% listen 1.-55% / 1.13%)
  195. 1772451975  ID:27   Sending DATA to 1 'Hello 29' with NodeID= 27
  196. 1772453582  ID:27   Size of data 31
  197. 1772456430  ID:27   Data is Hello 29 from the client abhive
  198. 1772650206  ID:1    Received DATA recv 'Hello 29 from the client abhive' from 27 at NodeID= 1
  199. 1778943530  ID:25   Sending DATA to 1 'Hello 29' with NodeID= 25
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top