Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I add this to tk10x server vode and realize run this function by special command to server.
- // ------------------------------------------------------------------------
- private byte[] CheckDevicesFunction(String s)
- {
- Print.logWarn("CheckDevicesFunction Realization\n");
- long TimeStampDiffConst = 1000;
- String fld[] = StringTools.parseString(s, ',');
- String mobileID = null;
- mobileID = StringTools.trim(fld[1]);
- if (StringTools.isBlank(mobileID)) {
- Print.logError("'imei:' value is missing");
- return null;
- }
- long serverTimeStamp = StringTools.parseLong(fld[2], 0L);
- Print.logInfo("******Server Event Timestamp : " + serverTimeStamp);
- Device device = DCServerFactory.loadDeviceByPrefixedModemID(UNIQUEID_PREFIX, mobileID);
- if (device == null) {
- return null; // errors already displayed
- }
- long ReadLastEventTimestamp = device.getLastEventTimestamp();
- Print.logInfo("******Read Last Event Timestamp : " + ReadLastEventTimestamp);
- if (( serverTimeStamp - ReadLastEventTimestamp ) > TimeStampDiffConst)
- {
- if (device.getDeviceLostSignal() == true)
- {
- // we already send notification, signal level not restored
- device.setNotificationFlag(true);
- Print.logInfo("******Notification already send, not sending twice\n ");
- }
- else
- {
- device.setDeviceLostSignal(true);
- device.setNotificationFlag(false);
- Print.logInfo("******Notification not yet send, setting flag to notification\n ");
- }
- } else
- {
- device.setDeviceLostSignal(false);
- device.setNotificationFlag(true);
- Print.logInfo("******Device not losting signal\n ");
- }
- /* save device changes */
- try {
- //DBConnection.pushShowExecutedSQL();
- device.updateChangedEventFields();
- } catch (DBException dbe) {
- Print.logException("Unable to update Device: " + mobileID, dbe);
- } finally {
- //DBConnection.popShowExecutedSQL();
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement