def qhawaxEndCalibration(): """qHAWAX update end calibration mode, set main inca original, depends of mode (customer or stand by)""" req_json = request.get_json() try: qH_name, in_charge = exception_helper.getEndCalibrationFields(req_json) ( mode, description, main_inca, ) = get_business_helper.getLastValuesOfQhawax(qH_name) post_business_helper.updateMainIncaQhawaxTable(main_inca, qH_name) post_business_helper.updateMainIncaQhawaxInstallationTable( main_inca, qH_name ) # post_business_helper.updateTimeOnPreviousTurnOn(qH_name,1) # update last_registration relatively to the physically_turn_on post_business_helper.changeMode(qH_name, mode) post_business_helper.writeBinnacle(qH_name, description, in_charge) return make_response( {"Success": "qHAWAX has been changed to original mode - open"}, 200 ) except (TypeError, ValueError) as e: json_message = jsonify({"error": "'%s'" % (e)}) return make_response(json_message, 400) except (Exception) as e: json_message = jsonify({"database error": "'%s'" % (e)}) return make_response(json_message, 400)
def qhawaxEndCalibration(): """ qHAWAX update end calibration mode, set main inca original, depends of mode (customer or stand by) """ req_json = request.get_json() try: qhawax_name = str(req_json['qhawax_name']).strip() person_in_charge = str(req_json['person_in_charge']) flag_costumer = get_business_helper.isItFieldQhawax(qhawax_name) if (flag_costumer == True): post_business_helper.turnOnAfterCalibration(qhawax_name) mode = "Cliente" description = "Se cambió a modo cliente" main_inca = 0 else: mode = "Stand By" description = "Se cambió a modo stand by" main_inca = -1 post_business_helper.changeMode(qhawax_name, mode) post_business_helper.updateMainIncaQhawaxTable(main_inca, qhawax_name) post_business_helper.updateMainIncaQhawaxInstallationTable( main_inca, qhawax_name) post_business_helper.writeBinnacle(qhawax_name, description, person_in_charge) return make_response( {'Success': 'qHAWAX have changed to original mode'}, 200) except TypeError as e: json_message = jsonify({'error': '\'%s\'' % (e)}) return make_response(json_message, 400)
def qhawaxChangeToCalibration(): """ qHAWAX update to Calibration mode, set main inca -2 value """ req_json = request.get_json() try: qhawax_name = str(req_json['qhawax_name']).strip() person_in_charge = req_json['person_in_charge'] description = req_json['description'] qhawax_time_off = now.replace(tzinfo=None) post_business_helper.saveStatusOffQhawaxTable(qhawax_name) post_business_helper.updateMainIncaQhawaxTable(-2, qhawax_name) if (same_helper.getQhawaxMode(qhawax_name) == 'Cliente'): post_business_helper.saveStatusOffQhawaxInstallationTable( name, qhawax_time_off) post_business_helper.updateMainIncaQhawaxInstallationTable( -2, qhawax_name) post_business_helper.changeMode(qhawax_name, "Calibracion") post_business_helper.writeBinnacle(qhawax_name, description, person_in_charge) return make_response( {'Success': 'qHAWAX have changed to calibration mode'}, 200) except TypeError as e: json_message = jsonify({'error': '\'%s\'' % (e)}) return make_response(json_message, 400)
def qhawaxEndCalibration(): """ qHAWAX update end calibration mode, set main inca original, depends of mode (customer or stand by)""" req_json = request.get_json() try: qH_name, in_charge = exception_helper.getEndCalibrationFields(req_json) mode, description, main_inca = get_business_helper.getLastValuesOfQhawax( qH_name) post_business_helper.updateMainIncaQhawaxTable(main_inca, qH_name) post_business_helper.updateMainIncaQhawaxInstallationTable( main_inca, qH_name) post_business_helper.changeMode(qH_name, mode) post_business_helper.writeBinnacle(qH_name, description, in_charge) return make_response( {'Success': 'qHAWAX has been changed to original mode - open'}, 200) except (TypeError, ValueError) as e: json_message = jsonify({'error': '\'%s\'' % (e)}) return make_response(json_message, 400) except (Exception) as e: json_message = jsonify({'database error': '\'%s\'' % (e)}) return make_response(json_message, 400)
def qhawaxChangeToCalibration(): """ qHAWAX update to Calibration mode, set main inca -2 value """ req_json = request.get_json() qhawax_time_off = datetime.datetime.now(dateutil.tz.tzutc()) description = "qHAWAX has been changed to calibration mode" try: qH_name, in_charge = exception_helper.getChangeCalibrationFields( req_json) post_business_helper.updateMainIncaQhawaxTable(-2, qH_name) post_business_helper.saveStatusOffQhawaxInstallationTable( qH_name, qhawax_time_off) post_business_helper.updateMainIncaQhawaxInstallationTable(-2, qH_name) post_business_helper.changeMode(qH_name, "Calibration") post_business_helper.writeBinnacle(qH_name, description, in_charge) return make_response( {'Success': 'qHAWAX has been changed to calibration mode - open'}, 200) except (TypeError, ValueError) as e: json_message = jsonify({'error': '\'%s\'' % (e)}) return make_response(json_message, 400) except (Exception) as e: json_message = jsonify({'database error': '\'%s\'' % (e)}) return make_response(json_message, 400)
def qhawaxChangeToCalibration(): """qHAWAX update to Calibration mode, set main inca -2 value""" req_json = request.get_json() qhawax_time_off = datetime.datetime.now(dateutil.tz.tzutc()) description = "qHAWAX has been changed to calibration mode" try: qH_name, in_charge = exception_helper.getChangeCalibrationFields( req_json ) comercial_name = same_helper.getComercialName(qH_name) qhawax_type = same_helper.queryQhawaxType(qH_name) post_business_helper.updateMainIncaQhawaxTable(-2, qH_name) if ( qhawax_type != "MOBILE_EXT" ): # Mobile qhawaxs should not be affected by this condition. Nor any other qhawaxs though.. post_business_helper.saveStatusOffQhawaxInstallationTable( qH_name, qhawax_time_off ) post_business_helper.updateMainIncaQhawaxInstallationTable(-2, qH_name) post_business_helper.changeMode(qH_name, "Calibration") post_business_helper.writeBinnacle(qH_name, description, in_charge) # if (qhawax_type == 'MOBILE_EXT'): # post_data_helper.recordEndTrip(qH_name, str(comercial_name)) # jsonLatLon = get_data_helper.getMobileLatestLatLonValidProcessedMeasurement(qH_name) # if(jsonLatLon!=None): # post_data_helper.updateLastestLatLonMobile(qH_name,jsonLatLon) return make_response( {"Success": "qHAWAX has been changed to calibration mode - open"}, 200, ) except (TypeError, ValueError) as e: json_message = jsonify({"error": "'%s'" % (e)}) return make_response(json_message, 400) except (Exception) as e: json_message = jsonify({"database error": "'%s'" % (e)}) return make_response(json_message, 400)
def saveEndWorkField(): """ Save last date of qHAWAX in field """ data_json = request.get_json() try: qhawax_id = data_json['qhawax_id'] end_date = data_json['end_date'] description = data_json['description'] person_in_charge = data_json['person_in_charge'] date_format = '%d-%m-%Y %H:%M:%S.%f' post_business_helper.saveEndWorkFieldDate(qhawax_id, end_date, date_format) post_business_helper.setAvailableQhawax(qhawax_id) qhawax_name = same_helper.getQhawaxName(qhawax_id) post_business_helper.changeMode(qhawax_name, "Stand By") post_business_helper.writeBinnacle(qhawax_name, description, person_in_charge) except TypeError as e: json_message = jsonify({'error': '\'%s\'' % (e)}) return make_response(json_message, 400) else: return make_response('Success: Save qHAWAX last day in field', 200)
def test_change_mode_valid(self): post_business_helper.changeMode("qH015", "Stand By")