示例#1
0
def insertDefaultOffsets(qhawax_name):
    """
    To insert a Default Offset 

    """
    last_gas_sensor_id = 0
    last_gas_sensor = get_business_helper.queryGetLastGasSensor()

    if (last_gas_sensor != None):
        last_gas_sensor_id = last_gas_sensor[0]

    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        qhawax_id = int(same_helper.getQhawaxID(qhawax_name))
        initial_serial_number = qhawax_id * 100
        start = 1
        for index in range(len(var_gases)):
            sensor_data = {
                'id': last_gas_sensor_id + start,
                'qhawax_id': qhawax_id,
                'serial_number': initial_serial_number + start,
                'type': var_gases[index],
                'WE': 0.0,
                'AE': 0.0,
                'sensitivity': 0.0,
                'sensitivity_2': 0.0,
                'C0': 0.0,
                'C1': 0.0,
                'C2': 0.0,
                'NC0': 0.0,
                'NC1': 0.0
            }
            sensor_data_var = GasSensor(**sensor_data)
            session.add(sensor_data_var)
            session.commit()
            start += 1
示例#2
0
def verifyIfQhawaxExist():
    """Verify if qHAWAX exist"""
    name = request.args.get("name")
    try:
        return str(same_helper.qhawaxExistBasedOnName(name))
    except TypeError as e:
        json_message = jsonify({"error": " '%s' " % (e)})
        return make_response(json_message, 400)
示例#3
0
def getQhawaxStatus(qhawax_name):
    """
    Get qHAWAX status based on name

    """
    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        return session.query(Qhawax.state).filter_by(name=qhawax_name).one()[0]
    return None
示例#4
0
def saveStatusOffQhawaxTable(qhawax_name):
    """
    Set qHAWAX OFF in qHAWAX table

    """
    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        session.query(Qhawax).filter_by(name=qhawax_name).\
                              update(values={'state': "OFF",'main_inca':-1})
        session.commit()
def isAerealQhawax(qhawax_name):
    """Helper Drone Flight function to check if qhawax is aereal"""
    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        aereal_qhawax = session.query(Qhawax.id).filter_by(
            name=qhawax_name, qhawax_type='AEREAL').all()
        if (aereal_qhawax == []):
            return False
        return True
    return None
示例#6
0
def updateMainIncaQhawaxTable(new_main_inca, qhawax_name):
    """
    Helper qHAWAX function to save main inca value in qHAWAX table

    """
    if (type(new_main_inca) not in [int]):
        raise TypeError("Inca value " + str(new_main_inca) + " should be int")

    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        session.query(Qhawax).filter_by(name=qhawax_name).update(
            values={'main_inca': new_main_inca})
        session.commit()
示例#7
0
def changeMode(qhawax_name, mode):
    """
    Change To Other Mode

    """
    if (isinstance(mode, str) is not True):
        raise TypeError("Mode value " + str(mode) + " should be string")

    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        session.query(Qhawax).filter_by(name=qhawax_name).update(
            values={'mode': mode})
        session.commit()
示例#8
0
def updateMainIncaQhawaxInstallationTable(new_main_inca, qhawax_name):
    """
    Helper qHAWAX function to save main inca value in qHAWAX Installation table

    """
    if (type(new_main_inca) not in [int]):
        raise TypeError("Inca value " + str(new_main_inca) + " should be int")

    if (same_helper.qhawaxExistBasedOnName(qhawax_name)):
        installation_id = same_helper.getInstallationIdBaseName(qhawax_name)
        session.query(QhawaxInstallationHistory).filter_by(id=installation_id).\
                                                 update(values={'main_inca': new_main_inca})
        session.commit()
 def test_qhawax_exist_based_on_name_valid(self):
     self.assertAlmostEqual(same_helper.qhawaxExistBasedOnName("qH004"),
                            True)
     self.assertAlmostEqual(same_helper.qhawaxExistBasedOnName("qH100"),
                            False)