示例#1
0
 def test_equipments_manufactory(self):
     dataloggers = EquipmentModel.get_all_dataloggers_from_nrl()
     sensors = EquipmentModel.get_all_sensors_from_nrl()
     self.assertIsNotNone(dataloggers)
     self.assertIsNotNone(sensors)
     print(dataloggers)
     print(sensors)
示例#2
0
    def update(cls, channel_dict: dict):
        """
        Update the current channel.

        Import: You must use save() to storage it in the database.

        :param channel_dict: A dictionary representation of the channel.

        :return: The updated channel or None if user if not valid.
        """
        channel: ChannelModel = cls.from_dict(channel_dict)
        valid_channel: ChannelModel = ChannelModel.find_by_id(channel.id)
        if not valid_channel:
            return None

        # validate creation to check if there is time overlap.
        channel.creation_validation()

        # Copy all attributes from channel to valid_channel.
        valid_channel << channel

        # update equipments.
        equipments = [
            EquipmentModel.from_dict(eq_dict)
            for eq_dict in channel_dict.get("equipments")
        ]
        valid_channel._delete_equipments()
        valid_channel.add_equipments(equipments)

        return valid_channel
示例#3
0
    def create_channel(cls, channel_dict: dict):
        channel: ChannelModel = cls.from_dict(channel_dict)
        channel.id = app_utils.generate_id(16)

        # validate creation
        channel.creation_validation()

        # Add equipments relational field.
        equipments = [
            EquipmentModel.from_dict(eq_dict)
            for eq_dict in channel_dict.get("equipments")
        ]
        channel.add_equipments(equipments=equipments)

        return channel.save()
示例#4
0
 def get_equipment(self):
     return EquipmentModel.find_by_id(self.equipment_id)
示例#5
0
def get_nrl_instrument(instrument_type: str, manufactory: str):
    instruments = EquipmentModel.get_instruments_nrl(instrument_type,
                                                     manufactory)
    return response.string_to_response(instruments)
示例#6
0
 def test_equipment_model(self):
     equipment: EquipmentModel = EquipmentModel.find_by(name="DATACUBE")
     self.assertIsNotNone(equipment)
     print(equipment.to_dict())
示例#7
0
def create_equipment(equipment_dict: dict):
    was_created = EquipmentModel.create_equipments(equipment_dict)
    return response.bool_to_response(was_created)
示例#8
0
def get_nrl_manufacturers(instrument_type: str):
    manufactures = EquipmentModel.get_all_manufactures_nrl(instrument_type)
    return response.string_to_response(manufactures)
示例#9
0
def get_sample_rates(manufactory: str, instrument: str, gain: str):
    sr = EquipmentModel.get_sample_rate_from_nrl(manufactory, instrument, gain)
    return response.string_to_response(sr)
示例#10
0
def get_gains(manufactory: str, instrument: str):
    gains = EquipmentModel.get_gain_from_nrl(manufactory, instrument)
    return response.string_to_response(gains)
示例#11
0
def get_sensor_extra_info(manufactory: str, instrument: str):
    sr = EquipmentModel.get_sensor_extra_information(manufactory, instrument)
    return response.string_to_response(sr)
示例#12
0
def get_data_sensors():
    sensors = EquipmentModel.find_by(type="Sensor",
                                     order_by=EquipmentModel.name,
                                     get_first=False)
    return response.model_to_response(sensors)
示例#13
0
def get_data_loggers():
    dataloggers = EquipmentModel.find_by(type="Datalogger",
                                         order_by=EquipmentModel.manufactory,
                                         get_first=False)
    return response.model_to_response(dataloggers)