Exemple #1
0
 def get_data_info(self, tables, type_id, dev_id, owner, start_time,
                   end_time):
     data_list = []
     for table in tables:
         data_list.extend(
             Data.find_by(
                 'where device_id = ? and type_id = ? and owner= ? and created_at between ? and ?',
                 dev_id,
                 type_id,
                 owner,
                 start_time,
                 end_time,
                 sub_name=str(table.index)))
     res = {}
     dev = Device.get(dev_id)
     data_info = DataParser.get_instance().get_data_type(
         dev.dev_type, type_id, owner)
     res['name'] = data_info['name']
     res['type_id'] = data_info['type_id']
     res['unit'] = data_info['unit']
     res['values'] = []
     for data_item in data_list:
         res['values'].append(
             [data_item.created_at * 1000, data_item.value])
     return res
Exemple #2
0
    def get_data_info(self, tables, type_id, dev_id, start_time, end_time):
        data_list = []
        for table in tables:
            data_list.extend(Data.find_by('where device_id = ? and type_id = ? and created_at between ? and ?', dev_id, type_id, start_time, end_time, sub_name = str(table.index)))

        dev  = Device.get(dev_id)
        data_info = DataParser.get_instance().get_data_type(dev.dev_type, type_id)

        if data_info['duration'] == 0:
            return self.deal_for_single(data_list, data_info)

        if data_info['duration'] > 0:
            return self.deal_for_accumulate(data_list, data_info)
Exemple #3
0
 def get_data_info(self, tables, type_id, dev_id, owner, start_time, end_time):
     data_list = []
     for table in tables:
         data_list.extend(Data.find_by('where device_id = ? and type_id = ? and owner= ? and created_at between ? and ?', dev_id, type_id, owner, start_time, end_time, sub_name = str(table.index)))
     res = {}
     dev  = Device.get(dev_id)
     data_info = DataParser.get_instance().get_data_type(dev.dev_type, type_id, owner)
     res['name'] = data_info['name']
     res['type_id'] = data_info['type_id']
     res['unit'] = data_info['unit']
     res['values'] = []
     for data_item in data_list:
         res['values'].append([data_item.created_at*1000, data_item.value])
     return res
Exemple #4
0
    def get_data_info(self, tables, type_id, dev_id, start_time, end_time):
        data_list = []
        for table in tables:
            data_list.extend(
                Data.find_by(
                    'where device_id = ? and type_id = ? and created_at between ? and ?',
                    dev_id,
                    type_id,
                    start_time,
                    end_time,
                    sub_name=str(table.index)))

        dev = Device.get(dev_id)
        data_info = DataParser.get_instance().get_data_type(
            dev.dev_type, type_id)

        if data_info['duration'] == 0:
            return self.deal_for_single(data_list, data_info)

        if data_info['duration'] > 0:
            return self.deal_for_accumulate(data_list, data_info)