Due to some remaining issues with the previous Pcal Guardian system, we have now updated the Pcal Guardian code to address these issues. The specific details are as follows:
Issue 1: Swap the order of HIGH_POWER and HIGH_POWER_RX_MON.
Before: INCREASE_OFFSET → HIGH_POWER_RX_MON → HIGH_POWER ⇄ WAITING_IFO HIGH_POWER_RX_MON → DECREASE_OFFSET HIGH_POWER → DECREASE_OFFSET
class HIGH_POWER(GuardState):
index = 100
request = False
class HIGH_POWER_RX_MON(GuardState):
index = 95
('INCREASE_OFFSET', 'HIGH_POWER_RX_MON'),
('HIGH_POWER_RX_MON', 'HIGH_POWER'),
('HIGH_POWER_RX_MON', 'DECREASE_OFFSET'),
('HIGH_POWER', 'DECREASE_OFFSET'),
('HIGH_POWER','WAITING_IFO'),
('WAITING_IFO', 'HIGH_POWER'),
Update: INCREASE_OFFSET → HIGH_POWER ⇄ HIGH_POWER_RX_MON ⇄ WAITING_IFO HIGH_POWER → DECREASE_OFFSET HIGH_POWER_RX_MON → DECREASE_OFFSET
class HIGH_POWER(GuardState):
index = 95
request = False
class HIGH_POWER_RX_MON(GuardState):
index = 100
('INCREASE_OFFSET', 'HIGH_POWER'),
('HIGH_POWER', 'HIGH_POWER_RX_MON'),
('HIGH_POWER_RX_MON', 'DECREASE_OFFSET'),
('HIGH_POWER_RX_MON', 'HIGH_POWER'),
('HIGH_POWER', 'DECREASE_OFFSET'),
('HIGH_POWER_RX_MON','WAITING_IFO'),
('WAITING_IFO', 'HIGH_POWER_RX_MON'),
2.Issue: Turn on the injection switches in HIGH_POWER, and turn them off automatically when leaving the state.
Update: Added code to automatically turn on the injection switches in the HIGH_POWER state and automatically turn them off when leaving that state (entering HIGH_POWER_RX_MON or DECREASE_OFFSET).
class HIGH_POWER(GuardState):
def main(self):
self.ARM='E'+SYSTEM[10]
ezca['CAL-PCAL_{0}_0_INJ_V_SW'.format(self.ARM)] = 1
class HIGH_POWER_RX_MON(GuardState):
def main(self):
self.ARM='E'+SYSTEM[10]
ezca['CAL-PCAL_{0}_0_INJ_V_SW'.format(self.ARM)] = 0
class DECREASE_OFFSET(GuardState):
def main(self):
ARM='E'+SYSTEM[10]
ezca['CAL-PCAL_{0}_0_INJ_V_SW'.format(ARM)] = 0
3.Issue: Send a Slack notification if Guardian remains in HIGH_POWER for an extended period.
Update: Added the code to send a Slack notification.
class HIGH_POWER(GuardState):
def main(self):
self.slack_time_1h = params[self.ARM]['wait_time_slack_1h']
self.timer['slack'] = self.slack_time_1h
def run(self):
notify('Pcal-{0} is in HIGH_POWER state.'.format(self.ARM))
if self.timer['slack']:
message = f'{self.ARM} PCAL HIGH_POWER state for too long (>{self.slack_time_1h}s)'
kagralib.slackpost("pcal", message, ["U015912SQ5T"])
self.timer['slack'] = self.slack_time_1h
4.Issue: Allow the real-time model to be stopped in the SAFE state.
Update: changed @lpd_check to a comment in the SAFE state.
class SAFE(GuardState):
index = 1
#@lpd_check # -> FAULT
@shutter_check # -> TOSAFE
@loop_check # -> TOSAFE
@injection_check # -> TOSAFE
def main(self):
### safe should be loaded independent on gSDF
if ezca['GRD-CAL_PCAL_{0}_REQUEST_S'.format(gARM)] == self.name:
sdf.restore(gFEC, self.name.lower())
#@lpd_check # -> FAULT
@shutter_check # -> TOSAFE
@loop_check # -> TOSAFE
@injection_check # -> TOSAFE
def run(self):
return True