Loading
  1.  
  2. DECLARE latitide_ float(10);
  3. DECLARE longitude_ float(10);
  4. DECLARE creationTime_ int(11);
  5. DECLARE lat float(10);
  6. DECLARE lon float(10);
  7. DECLARE mystring varchar(50);
  8. DECLARE field_id_ int(11);
  9. DECLARE field_name_ varchar(50);
  10.  
  11.   latitude, longitude, creationTime
  12.   latitide_, longitude_,creationTime_
  13.   eventdata
  14.   deviceID = new.deviceid
  15. order by creationtime desc limit 1;
  16.  
  17.  
  18. set new.astra_report_code = TRIM(LEADING 'R=' FROM SPLIT_STR(new.rawData, ';', 1));
  19. set new.astra_status_code = TRIM(LEADING 'S=' FROM SPLIT_STR(new.rawData, ';', 2));
  20. set new.astra_ext_battery = TRIM(TRAILING 'V' FROM TRIM(LEADING 'P=' FROM SPLIT_STR(new.rawData, ';', 3)));
  21. set new.astra_int_battery = TRIM(TRAILING '%' FROM TRIM(LEADING 'B=' FROM SPLIT_STR(new.rawData, ';', 4)));
  22. set new.astra_digital_io =  TRIM(LEADING 'D=' FROM SPLIT_STR(new.rawData, ';', 5));
  23. set new.astra_analogue1 = TRIM(TRAILING 'V' FROM TRIM(LEADING 'A1=' FROM SPLIT_STR(new.rawData, ';', 6)));
  24. set new.astra_analogue2 = TRIM(TRAILING 'V' FROM TRIM(LEADING 'A2=' FROM SPLIT_STR(new.rawData, ';', 7)));
  25. set new.astra_max_speed = TRIM(TRAILING 'km/h' FROM TRIM(LEADING 'M=' FROM SPLIT_STR(new.rawData, ';', 8)));
  26. set new.astra_x = trim(LEADING 'X=' FROM SPLIT_STR(new.rawData, ';', 9));
  27. set new.astra_y = trim(LEADING 'Y=' FROM SPLIT_STR(new.rawData, ';', 10));
  28. set new.astra_z = trim(LEADING 'Z=' FROM SPLIT_STR(new.rawData, ';', 11));
  29. set new.astra_idle =TRIM(TRAILING 's' FROM TRIM(LEADING 'I=' FROM SPLIT_STR(NEW.rawData, ';', 12)));
  30. set new.astra_io3 = CONV(mid(new.astra_digital_io,1,2),16,2);
  31. set new.astra_io2 = CONV(mid(new.astra_digital_io,3,2),16,2);
  32. set new.astra_input_mask = CONV(mid(new.astra_digital_io,5,2),16,2);
  33.  
  34.  
  35.  
  36. set new.dist_since_last_report = fn_distance(latitide_,longitude_,new.latitude, new.longitude)*1000;
  37. set new.time_since_last_report = (new.creationtime-creationtime_);
  38. set new.est_forward_speed = ((fn_distance(latitide_,longitude_,new.latitude, new.longitude))/(((new.creationtime-creationtime_)/60)/60));
  39.  
  40.  
  41.  

Comments