forked from M-Labs/artiq
Controller cleanups
This commit is contained in:
parent
b45ad9d1a3
commit
2651050c83
|
@ -26,6 +26,10 @@ class Ldasim:
|
|||
def get_att_step_size(self):
|
||||
return self._att_step_size
|
||||
|
||||
def close(self):
|
||||
"""Close the device."""
|
||||
pass
|
||||
|
||||
def get_attenuation(self):
|
||||
"""Reads last attenuation value set to the simulated device.
|
||||
|
||||
|
|
|
@ -211,6 +211,10 @@ class Tcube:
|
|||
self.port.flush()
|
||||
logger.debug("baud rate set to 115200")
|
||||
|
||||
def close(self):
|
||||
"""Close the device."""
|
||||
self.port.close()
|
||||
|
||||
def send(self, msg):
|
||||
msg.send(self.port)
|
||||
|
||||
|
|
|
@ -27,8 +27,11 @@ def main():
|
|||
lda = Ldasim()
|
||||
else:
|
||||
lda = Lda(args.serial, args.product)
|
||||
simple_server_loop({"lda": lda},
|
||||
args.bind, args.port)
|
||||
try:
|
||||
simple_server_loop({"lda": lda},
|
||||
args.bind, args.port)
|
||||
finally:
|
||||
lda.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -37,7 +37,10 @@ def main():
|
|||
elif args.product == "TPZ001":
|
||||
dev = Tpz(args.device)
|
||||
|
||||
simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
|
||||
try:
|
||||
simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
|
||||
finally:
|
||||
dev.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue