def saveTurnOnLastTimeProcessedMobile(qhawax_name): """Updates last_time_physically_turn_on_zone based on last registration time zone""" latest_turn_off = get_business_helper.queryLastRegistrationTimezone( qhawax_name) if not (latest_turn_off == None or latest_turn_off == []): now2 = datetime.datetime.now(dateutil.tz.tzutc()) difference = now2 - latest_turn_off seconds_interval = 1800 if seconds_interval < int( difference.total_seconds() ): # if reconnection takes longer than 30 minutes, we update the last_turn_on # every reconnection longer than 30 mins, includes the ones that last longer than a day so they should not be an issue qhawax_json_on = { "main_inca": 0, "last_time_physically_turn_on_zone": now2.replace(tzinfo=None), } same_helper.qhawaxInstallationQueryUpdate(qhawax_json_on, qhawax_name) trip_start, trip_id = get_data_helper.getqHAWAXMobileLatestTripStart( qhawax_name) if trip_id != None and trip_start != None: # trip_start = datetime.datetime.strptime('2021-07-12 12:00:00', '%Y-%m-%d %H:%M:%S') # test date_start = (trip_start - datetime.timedelta(hours=5)).date() # local now_date = (datetime.datetime.now(dateutil.tz.tzutc()) - datetime.timedelta(hours=5)).date() if date_start == now_date: same_helper.setTripEndNull(trip_id)
def saveStatusOffQhawaxInstallationTable(qhawax_name, time): """Set qHAWAX OFF in qHAWAX Installation table""" qhawax_json_status_off = { "main_inca": -1, "last_registration_time_zone": time, } same_helper.qhawaxInstallationQueryUpdate(qhawax_json_status_off, qhawax_name)
def saveTurnOnLastTime(qhawax_name): """Set qHAWAX ON in qHAWAX Installation table""" now2 = datetime.datetime.now(dateutil.tz.tzutc()) qhawax_json_on = { "main_inca": 0, "last_time_physically_turn_on_zone": now2.replace(tzinfo=None), } same_helper.qhawaxInstallationQueryUpdate(qhawax_json_on, qhawax_name)
def turnOnAfterCalibration(qhawax_name): """Set qHAWAX ON in qHAWAX Installation table""" now2 = datetime.datetime.now(dateutil.tz.tzutc()) qhawax_json_on_after_calibration = { "last_time_physically_turn_on_zone": now2.replace(tzinfo=None) } same_helper.qhawaxInstallationQueryUpdate(qhawax_json_on_after_calibration, qhawax_name)
def updateMainIncaQhawaxInstallationTable(new_main_inca, qhawax_name): """Helper qHAWAX function to save main inca value in qHAWAX Installation table""" new_main_inca = exceptions.checkVariable_helper(new_main_inca, int) qhawax_json_main_inca_installation = {"main_inca": new_main_inca} same_helper.qhawaxInstallationQueryUpdate( qhawax_json_main_inca_installation, qhawax_name)
def updateLastLocation(qhawax_name, location): """Helper Drone Log function to update location of andean drone in qHAWAX Installation table""" location = exceptions.checkVariable_helper(location, dict) same_helper.qhawaxInstallationQueryUpdate(location, qhawax_name)
def updateTimeOffWithLastTurnOff(time_turn_off_binnacle, qhawax_name): qhawax_json_last_turn_off = { "last_registration_time_zone": time_turn_off_binnacle } same_helper.qhawaxInstallationQueryUpdate(qhawax_json_last_turn_off, qhawax_name)
def saveEndWorkFieldDate(qhawax_name, end_date): """Save End Work in Field""" qhawax_json_end_field = {"end_date_zone": end_date} same_helper.qhawaxInstallationQueryUpdate(qhawax_json_end_field, qhawax_name)