@@ 142-208 (lines=67) @@ | ||
139 | parameters_data['timestamps'] = list() |
|
140 | parameters_data['values'] = list() |
|
141 | ||
142 | if not is_quick_mode: |
|
143 | for point in point_list: |
|
144 | point_values = [] |
|
145 | point_timestamps = [] |
|
146 | if point['object_type'] == 'ENERGY_VALUE': |
|
147 | energy_value_data['name'] = point['name'] + ' (' + point['units'] + ')' |
|
148 | query = (" SELECT utc_date_time, actual_value " |
|
149 | " FROM tbl_energy_value " |
|
150 | " WHERE point_id = %s " |
|
151 | " AND utc_date_time BETWEEN %s AND %s " |
|
152 | " ORDER BY utc_date_time ") |
|
153 | cursor_historical.execute(query, (point['id'], |
|
154 | reporting_start_datetime_utc, |
|
155 | reporting_end_datetime_utc)) |
|
156 | rows = cursor_historical.fetchall() |
|
157 | if rows is not None and len(rows) > 0: |
|
158 | for row in rows: |
|
159 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
160 | timedelta(minutes=timezone_offset) |
|
161 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
162 | energy_value_data['timestamps'].append(current_datetime) |
|
163 | energy_value_data['values'].append(row[1]) |
|
164 | elif point['object_type'] == 'ANALOG_VALUE': |
|
165 | ||
166 | query = (" SELECT utc_date_time, actual_value " |
|
167 | " FROM tbl_analog_value " |
|
168 | " WHERE point_id = %s " |
|
169 | " AND utc_date_time BETWEEN %s AND %s " |
|
170 | " ORDER BY utc_date_time ") |
|
171 | cursor_historical.execute(query, (point['id'], |
|
172 | reporting_start_datetime_utc, |
|
173 | reporting_end_datetime_utc)) |
|
174 | rows = cursor_historical.fetchall() |
|
175 | ||
176 | if rows is not None and len(rows) > 0: |
|
177 | for row in rows: |
|
178 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
179 | timedelta(minutes=timezone_offset) |
|
180 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
181 | point_timestamps.append(current_datetime) |
|
182 | point_values.append(row[1]) |
|
183 | ||
184 | parameters_data['names'].append(point['name'] + ' (' + point['units'] + ')') |
|
185 | parameters_data['timestamps'].append(point_timestamps) |
|
186 | parameters_data['values'].append(point_values) |
|
187 | elif point['object_type'] == 'DIGITAL_VALUE': |
|
188 | query = (" SELECT utc_date_time, actual_value " |
|
189 | " FROM tbl_digital_value " |
|
190 | " WHERE point_id = %s " |
|
191 | " AND utc_date_time BETWEEN %s AND %s " |
|
192 | " ORDER BY utc_date_time ") |
|
193 | cursor_historical.execute(query, (point['id'], |
|
194 | reporting_start_datetime_utc, |
|
195 | reporting_end_datetime_utc)) |
|
196 | rows = cursor_historical.fetchall() |
|
197 | ||
198 | if rows is not None and len(rows) > 0: |
|
199 | for row in rows: |
|
200 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
201 | timedelta(minutes=timezone_offset) |
|
202 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
203 | point_timestamps.append(current_datetime) |
|
204 | point_values.append(row[1]) |
|
205 | ||
206 | parameters_data['names'].append(point['name'] + ' (' + point['units'] + ')') |
|
207 | parameters_data['timestamps'].append(point_timestamps) |
|
208 | parameters_data['values'].append(point_values) |
|
209 | ||
210 | ################################################################################################################ |
|
211 | # Step 6: construct the report |
@@ 132-198 (lines=67) @@ | ||
129 | parameters_data['timestamps'] = list() |
|
130 | parameters_data['values'] = list() |
|
131 | ||
132 | if not is_quick_mode: |
|
133 | for point in point_list: |
|
134 | point_values = [] |
|
135 | point_timestamps = [] |
|
136 | if point['object_type'] == 'ENERGY_VALUE': |
|
137 | energy_value_data['name'] = point['name'] + ' (' + point['units'] + ')' |
|
138 | query = (" SELECT utc_date_time, actual_value " |
|
139 | " FROM tbl_energy_value " |
|
140 | " WHERE point_id = %s " |
|
141 | " AND utc_date_time BETWEEN %s AND %s " |
|
142 | " ORDER BY utc_date_time ") |
|
143 | cursor_historical.execute(query, (point['id'], |
|
144 | reporting_start_datetime_utc, |
|
145 | reporting_end_datetime_utc)) |
|
146 | rows = cursor_historical.fetchall() |
|
147 | if rows is not None and len(rows) > 0: |
|
148 | for row in rows: |
|
149 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
150 | timedelta(minutes=timezone_offset) |
|
151 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
152 | energy_value_data['timestamps'].append(current_datetime) |
|
153 | energy_value_data['values'].append(row[1]) |
|
154 | elif point['object_type'] == 'ANALOG_VALUE': |
|
155 | ||
156 | query = (" SELECT utc_date_time, actual_value " |
|
157 | " FROM tbl_analog_value " |
|
158 | " WHERE point_id = %s " |
|
159 | " AND utc_date_time BETWEEN %s AND %s " |
|
160 | " ORDER BY utc_date_time ") |
|
161 | cursor_historical.execute(query, (point['id'], |
|
162 | reporting_start_datetime_utc, |
|
163 | reporting_end_datetime_utc)) |
|
164 | rows = cursor_historical.fetchall() |
|
165 | ||
166 | if rows is not None and len(rows) > 0: |
|
167 | for row in rows: |
|
168 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
169 | timedelta(minutes=timezone_offset) |
|
170 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
171 | point_timestamps.append(current_datetime) |
|
172 | point_values.append(row[1]) |
|
173 | ||
174 | parameters_data['names'].append(point['name'] + ' (' + point['units'] + ')') |
|
175 | parameters_data['timestamps'].append(point_timestamps) |
|
176 | parameters_data['values'].append(point_values) |
|
177 | elif point['object_type'] == 'DIGITAL_VALUE': |
|
178 | query = (" SELECT utc_date_time, actual_value " |
|
179 | " FROM tbl_digital_value " |
|
180 | " WHERE point_id = %s " |
|
181 | " AND utc_date_time BETWEEN %s AND %s " |
|
182 | " ORDER BY utc_date_time ") |
|
183 | cursor_historical.execute(query, (point['id'], |
|
184 | reporting_start_datetime_utc, |
|
185 | reporting_end_datetime_utc)) |
|
186 | rows = cursor_historical.fetchall() |
|
187 | ||
188 | if rows is not None and len(rows) > 0: |
|
189 | for row in rows: |
|
190 | current_datetime_local = row[0].replace(tzinfo=timezone.utc) + \ |
|
191 | timedelta(minutes=timezone_offset) |
|
192 | current_datetime = current_datetime_local.isoformat()[0:19] |
|
193 | point_timestamps.append(current_datetime) |
|
194 | point_values.append(row[1]) |
|
195 | ||
196 | parameters_data['names'].append(point['name'] + ' (' + point['units'] + ')') |
|
197 | parameters_data['timestamps'].append(point_timestamps) |
|
198 | parameters_data['values'].append(point_values) |
|
199 | ||
200 | ################################################################################################################ |
|
201 | # Step 5: construct the report |