Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python ODB watch
#!/usr/bin/env python3
import midas
import midas.frontend
import midas.event
class RunControl(midas.frontend.EquipmentBase):
def __init__(self, client):
equip_name = "odbtest"
default_common = midas.frontend.InitialEquipmentCommon()
default_common.equip_type = midas.EQ_PERIODIC
default_common.buffer_name = "SYSTEM"
default_common.trigger_mask = 0
default_common.event_id = 2
default_common.period_ms = 1000
default_common.read_when = midas.RO_ALWAYS
default_settings = {
"Board startup mode": ["none"] * 19,
"Enable ADC sampling": [False] * 19,
"Power enable": [False] * 19,
"Overcurrent": [False] * 19,
"Channel ratemeter": [0] * 19,
}
midas.frontend.EquipmentBase.__init__(self, client, equip_name, default_common, default_settings)
self.set_status("Initialized")
def readout_func(self):
None
def detailed_settings_changed_func(self, path, idx, new_value):
print(f'detailed_settings_changed_func: {path}[{idx}] - new value {new_value}')
class MyFrontend(midas.frontend.FrontendBase):
def __init__(self):
midas.frontend.FrontendBase.__init__(self, "testfe")
self.add_equipment(RunControl(self.client))
def begin_of_run(self, run_number):
self.set_all_equipment_status("FE running", "greenLight")
self.client.msg("Frontend has seen start of run number %d" % run_number)
return midas.status_codes["SUCCESS"]
def end_of_run(self, run_number):
self.set_all_equipment_status("FE finished", "greenLight")
self.client.msg("Frontend has seen end of run number %d" % run_number)
return midas.status_codes["SUCCESS"]
if __name__ == "__main__":
my_fe = MyFrontend()
my_fe.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment