From f39d1fb8282ffe24ed915052cd628214dc83443a Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Sun, 14 Jul 2024 00:14:58 -0400 Subject: improved docs string --- qolab/tsdb/__init__.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'qolab/tsdb') 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) -- cgit v1.2.3