Advertisement
Guest User

Untitled

a guest
Feb 15th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. I add this to tk10x server vode and realize run this function by special command to server.
  2.  
  3. // ------------------------------------------------------------------------
  4.  
  5. private byte[] CheckDevicesFunction(String s)
  6. {
  7. Print.logWarn("CheckDevicesFunction Realization\n");
  8.  
  9. long TimeStampDiffConst = 1000;
  10.  
  11. String fld[] = StringTools.parseString(s, ',');
  12.  
  13. String mobileID = null;
  14. mobileID = StringTools.trim(fld[1]);
  15. if (StringTools.isBlank(mobileID)) {
  16. Print.logError("'imei:' value is missing");
  17. return null;
  18. }
  19. long serverTimeStamp = StringTools.parseLong(fld[2], 0L);
  20. Print.logInfo("******Server Event Timestamp : " + serverTimeStamp);
  21.  
  22. Device device = DCServerFactory.loadDeviceByPrefixedModemID(UNIQUEID_PREFIX, mobileID);
  23. if (device == null) {
  24. return null; // errors already displayed
  25. }
  26. long ReadLastEventTimestamp = device.getLastEventTimestamp();
  27. Print.logInfo("******Read Last Event Timestamp : " + ReadLastEventTimestamp);
  28.  
  29. if (( serverTimeStamp - ReadLastEventTimestamp ) > TimeStampDiffConst)
  30. {
  31. if (device.getDeviceLostSignal() == true)
  32. {
  33. // we already send notification, signal level not restored
  34. device.setNotificationFlag(true);
  35. Print.logInfo("******Notification already send, not sending twice\n ");
  36. }
  37. else
  38. {
  39. device.setDeviceLostSignal(true);
  40. device.setNotificationFlag(false);
  41. Print.logInfo("******Notification not yet send, setting flag to notification\n ");
  42. }
  43. } else
  44. {
  45. device.setDeviceLostSignal(false);
  46. device.setNotificationFlag(true);
  47. Print.logInfo("******Device not losting signal\n ");
  48. }
  49. /* save device changes */
  50. try {
  51. //DBConnection.pushShowExecutedSQL();
  52. device.updateChangedEventFields();
  53. } catch (DBException dbe) {
  54. Print.logException("Unable to update Device: " + mobileID, dbe);
  55. } finally {
  56. //DBConnection.popShowExecutedSQL();
  57. }
  58. return null;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement