diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-14 00:14:58 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-14 00:18:07 -0400 |
commit | f39d1fb8282ffe24ed915052cd628214dc83443a (patch) | |
tree | d523d106794754c2b439be0601ef8f17a6409527 /qolab/tsdb | |
parent | 935c05ae3b0421537e1d4aa06b24ac5fad869661 (diff) | |
download | qolab-f39d1fb8282ffe24ed915052cd628214dc83443a.tar.gz qolab-f39d1fb8282ffe24ed915052cd628214dc83443a.zip |
improved docs string
Diffstat (limited to 'qolab/tsdb')
-rw-r--r-- | qolab/tsdb/__init__.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/qolab/tsdb/__init__.py b/qolab/tsdb/__init__.py index f4d703c..b4ea644 100644 --- a/qolab/tsdb/__init__.py +++ b/qolab/tsdb/__init__.py @@ -16,7 +16,49 @@ logger.setLevel(logging.INFO) class Ingester(utsdb.Ingester): """Same as universal_tsdb.Ingester but sets measurement_prefix. - so measurement becomes measurement_prefix.measurement""" + + Handy with ``@tsdb_append_metric_for_class_setter_or_getter`` decorator + to be used in hardware controlled classes + + Parameters + ---------- + measurement_prefix: str (default is empty) + standard ``utsdb`` measurement becomes measurement_prefix.measurement + + Example + ------- + + >>> from qolab.hardware.basic import BasicInstrument + >>> from qolab.tsdb import Ingester + >>> tsdb_client = Client("influx", "http://localhost:8428", database="qolab") + >>> tsdb_ingester = Ingester( + >>> tsdb_client, batch=10, measurement_prefix="experiment.title" + >>> ) + >>> + >>> class InstWithLog(BasicInstrument): + >>> def __init__(self, *args, **kwds): + >>> super().__init__(*args, **kwds) + >>> self.config["Device type"] = "TestTSDBLogger" + >>> self.config["Device model"] = "v01" + >>> self.config["FnamePrefix"] = "test_log" + >>> self.config["SavePath"] = "./data" + >>> self.deviceProperties.update({"D"}) + >>> self.d = 13.45 + >>> + >>> @BasicInstrument.tsdb_append + >>> def setD(self, val): + >>> self.d = val + >>> + >>> @BasicInstrument.tsdb_append + >>> def getD(self): + >>> return self.d + >>> + >>> dev = InstWithLog(tsdb_ingester=tsdb_ingester, device_nickname="tester") + >>> dev.getD() + >>> dev.setD(3) + >>> + >>> tsdb_ingester.commit() + """ def __init__(self, client, batch=0, measurement_prefix=""): super().__init__(client, batch=batch) |