diff --git a/TimeBaseAOMDriver/blacs_workers.py b/TimeBaseAOMDriver/blacs_workers.py index 5803f2941d29f26fa6375da5b0a6f9a9cdf4b89d..ebc970fd6760fe43416982c09663702a846e9123 100644 --- a/TimeBaseAOMDriver/blacs_workers.py +++ b/TimeBaseAOMDriver/blacs_workers.py @@ -45,12 +45,13 @@ class TimeBaseWorker(Worker): for attr,value in group[channel].attrs.items(): if self.smart_cache[channel].get(attr) != group[channel].attrs[attr] or fresh: any_changed = True - print(f"Programming {channel}, {attr}={value}") if ":" in attr: # For segment mode self.client.send(f"{channel}|{attr}{value}\r\n".encode()) + print(f"Programming {channel}, {attr}{value}") else: self.client.send(f"{channel}|{attr}:{value:.0f}\r\n".encode()) + print(f"Programming {channel}, {attr}:{value}") self.smart_cache[channel][attr] = group[channel].attrs[attr] time.sleep(0.01) # TODO: What's the best time here? Do we need to wait at all? According to the DIM-3000 manual the rate is 10 commands per second, it seems router can also handle faster times? if group[channel].attrs["Sswpm"] != 0 and any_changed: @@ -62,6 +63,12 @@ class TimeBaseWorker(Worker): self.smart_cache[channel]["Sswpm"] = {group[channel].attrs['Sswpm']} time.sleep(0.01) + if "Mseg" in group[channel].attrs: + # Seems like this should also be set after the "Wseg" commands + print(f"Programming {channel}, Mseg:{group[channel].attrs['Mseg']}") + self.client.send(f"{channel}|Mseg:{group[channel].attrs['Mseg']}\r\n".encode()) + time.sleep(0.03) + if not initial_values[channel]["gate"]: print(f"Programming {channel}, Sout") self.client.send(f"{channel}|Sout:1\r\n".encode()) @@ -102,6 +109,8 @@ class TimeBaseWorker(Worker): # If that happens we just use the saved values and try during the next call again. # If that happens during the first check, we need to restart the worker. self.logger.debug(f"Exception in check_remote_values of {ch}, returning values of previous check.") + if "Sout" not in self.smart_cache[ch]: + raise ConnectionError(f"Got no remote values for channel {ch}, is it connected?") # try: # self.client.recv(1000) # except socket.timeout: