From 26a42772628be38d69b7a508f6cd693fa11ffd10 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 6 Jan 2022 10:46:25 -0500 Subject: communication with i800 temperature controller is cached --- qolab/hardware/i_server/i800.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qolab/hardware/i_server/i800.py b/qolab/hardware/i_server/i800.py index 0e83444..318be11 100644 --- a/qolab/hardware/i_server/i800.py +++ b/qolab/hardware/i_server/i800.py @@ -7,9 +7,14 @@ Querying of this controller is slo-o-o-w at least 0.2 second and can be longer. """ from qolab.hardware.basic import BasicInstrument +from cachetools import cached, TTLCache import socket class I800(BasicInstrument): + """ Newport i800 series controller, should work with similar Omega controllers """ + TTL_MEASURED = 30 # Time To Live for device measured things, i.e. Temperature + TTL_SEATABLES = 600 # Time To Live for user seatables, i.e. SetPoints, Gains, etc + def __init__(self, *args, host='192.168.1.200', port=1000, **kwds): """ host - default hostname or IP of the controller unit (192.168.1.200) is factory default @@ -38,6 +43,7 @@ class I800(BasicInstrument): return reply[5:-1] # last symbol is '\r' @BasicInstrument.tsdb_append + @cached(cache=TTLCache(maxsize=1, ttl=TTL_MEASURED)) def getTemperature(self): command='X01'; # give decimal representation (X) of the temperature (01 address) return float(self.query(command)) @@ -65,12 +71,14 @@ class I800(BasicInstrument): return(sign*val/scale) @BasicInstrument.tsdb_append + @cached(cache=TTLCache(maxsize=1, ttl=TTL_SEATABLES)) def getSetPoint1(self): command='R01' reply=self.query(command) return (self.setPoinStr2value(reply)) @BasicInstrument.tsdb_append + @cached(cache=TTLCache(maxsize=1, ttl=TTL_SEATABLES)) def getSetPoint2(self): command='R02' reply=self.query(command) -- cgit v1.2.3