added reading z from channel name

This commit is contained in:
2020-12-04 17:50:19 +01:00
parent 4b236edd4e
commit 362defe110
+15 -1
View File
@@ -9,7 +9,7 @@ class Device(BaseDevice):
self.Id = Id
self.name = name
self.description = description
self.z_undulator = z_undulator
self.z_undulator = decide_z(Id, z_undulator)
def __repr__(self):
@@ -24,3 +24,17 @@ class Device(BaseDevice):
def decide_z(chan, z):
return z if z is not None else read_z_from_channel(chan)
def read_z_from_channel(chan):
chan = chan.split(":")[0]
z = chan[-3:]
try:
return int(z)
except ValueError:
return None