Advertisement
Bocci94

Untitled

Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. startEvent = function () {
  2.  
  3.       var ws = new WebSocket("ws://127.0.0.1:5678/");
  4.  
  5.       ws.onmessage = function (event) {
  6.  
  7.         obj = JSON.parse(event.data);
  8.  
  9.         if ($('#Start').text() !== 'Start') {
  10.           fio2 = parseFloat(obj.type.Ossimetro.property.O2);
  11.         }
  12.  
  13.  
  14.  
  15.         if ($('#Start').text() === 'Start') {
  16.           obj = [];
  17.           fio2 = 0;
  18.         }
  19.  
  20.         console.log("FIO2 ORIGINALE: ", fio2);
  21.  
  22.         if (fio2>= 90){        
  23.         startTime = null;    
  24.       }
  25.  
  26.       if (fio2<90 && !startTime) {
  27.         startTime = Date.now()
  28.         console.log("starttime: ",startTime)
  29.  
  30.  
  31.         }
  32.  
  33.         if ((Date.now() - startTime) > 30000) {
  34.         console.log("errore");
  35.         startTime = null;
  36.         }
  37.  
  38.       };
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement