(self, node_id, start, end, nb_values)
| 99 | 'THEN MIN(SourceTimestamp) ELSE NULL END FROM "{tn}")', (count,)) |
| 100 | |
| 101 | def read_node_history(self, node_id, start, end, nb_values): |
| 102 | with self._lock: |
| 103 | _c_read = self._conn.cursor() |
| 104 | |
| 105 | table = self._get_table_name(node_id) |
| 106 | start_time, end_time, order, limit = self._get_bounds(start, end, nb_values) |
| 107 | |
| 108 | cont = None |
| 109 | results = [] |
| 110 | |
| 111 | # select values from the database; recreate UA Variant from binary |
| 112 | try: |
| 113 | for row in _c_read.execute('SELECT * FROM "{tn}" WHERE "SourceTimestamp" BETWEEN ? AND ? ' |
| 114 | 'ORDER BY "_Id" {dir} LIMIT ?'.format(tn=table, dir=order), |
| 115 | (start_time, end_time, limit,)): |
| 116 | |
| 117 | # rebuild the data value object |
| 118 | dv = ua.DataValue(variant_from_binary(Buffer(row[6]))) |
| 119 | dv.ServerTimestamp = row[1] |
| 120 | dv.SourceTimestamp = row[2] |
| 121 | dv.StatusCode = ua.StatusCode(row[3]) |
| 122 | |
| 123 | results.append(dv) |
| 124 | |
| 125 | except sqlite3.Error as e: |
| 126 | self.logger.error('Historizing SQL Read Error for %s: %s', node_id, e) |
| 127 | |
| 128 | if nb_values: |
| 129 | if len(results) > nb_values: |
| 130 | cont = results[nb_values].SourceTimestamp |
| 131 | |
| 132 | results = results[:nb_values] |
| 133 | |
| 134 | return results, cont |
| 135 | |
| 136 | def new_historized_event(self, source_id, evtypes, period, count=0): |
| 137 | with self._lock: |
nothing calls this directly
no test coverage detected