im01_charge_fault = models.Fault(name="CHARGE", description="IM01B Charge Fault") im01_diff_fault = models.Fault(name="DIFF", description="IM01B/BPM1B Difference Fault") session.add_all([im01_charge_fault, im01_diff_fault]) sol1_int1_fault = models.Fault(name="I0", description="SOL01 Integrator #0 Fault") sol2_int1_fault = models.Fault(name="I0", description="SOL02 Integrator #0 Fault") fc_int1_fault = models.Fault(name="I0", description="FC01 Integrator #0 Fault") session.add_all([sol1_int1_fault, sol2_int1_fault, fc_int1_fault]) # Inputs for the digital faults yag_fault_input = models.FaultInput(bit_position=0, device=screen, fault=yag_fault) gun_temp_fault_input = models.FaultInput(bit_position=0, device=gun_temp, fault=gun_temp_fault) wg_temp_fault_input = models.FaultInput(bit_position=0, device=wg_temp, fault=wg_temp_fault) buncher_temp_fault_input = models.FaultInput(bit_position=0, device=buncher_temp, fault=buncher_temp_fault) sol01_temp_fault_input = models.FaultInput(bit_position=0, device=sol01_temp, fault=sol01_temp_fault) sol02_temp_fault_input = models.FaultInput(bit_position=0, device=sol02_temp,
digital_device=devices[i]) session.add(deviceInput) # Configure faults - each fault is the result of the inputs from neighboring devices # each one has two bits as input numFaults = devicesPerCard - 1 faults = [] faultStates = [] for i in range(0, numCards): for j in range(0, numFaults): fault = models.Fault(name="Fault card #" + str(i) + " devices #" + str(j) + "/" + str(j + 1)) faults.append(fault) session.add(fault) faultInput0 = models.FaultInput(bit_position=0, device=devices[j], fault=fault) # 2 bits for first input faultInput1 = models.FaultInput( bit_position=2, device=devices[j + 1], fault=fault) # 2 bits for the next input session.add_all([faultInput0, faultInput1]) # Add fault states, and allowed beam class - one for each DeviceState for k in range(0, len(faultDeviceStates)): faultState = models.FaultState(device_state=faultDeviceStates[k], fault=fault) faultStates.append(faultState) session.add(faultState) faultState.add_allowed_class( beam_class=beamClasses[k], mitigation_device=mitigationDevices[0])
cp_channel = models.DeviceInput(channel=digital_chans[8], bit_position=0, digital_device=cp_device, fault_value=0) session.add_all([ m1_in_sw, m1_out_sw, slit_in_sw, slit_out_sw, m2_in_sw, m2_out_sw, m3_in_sw, m3_out_sw, cp_channel ]) # Configure faults for the device sxrss_fault = models.Fault(name='SXRSS Fault') session.add(sxrss_fault) # Add fault inputs to SXRSS fault m1_fault_input = models.FaultInput(bit_position=0, device=m1_device, fault=sxrss_fault) slit_fault_input = models.FaultInput(bit_position=2, device=slit_device, fault=sxrss_fault) m2_fault_input = models.FaultInput(bit_position=4, device=m2_device, fault=sxrss_fault) m3_fault_input = models.FaultInput(bit_position=6, device=m3_device, fault=sxrss_fault) cp_fault_input = models.FaultInput(bit_position=8, device=cp_device, fault=sxrss_fault) session.add_all([ m1_fault_input, slit_fault_input, m2_fault_input, m3_fault_input,
description="BPM01 Y Threshold Fault") bpm01_t_fault = models.Fault(name="BPM01_T", description="BPM01 TMIT Threshold Fault") session.add_all([bpm01_x_fault, bpm01_y_fault, bpm01_t_fault]) bpm02_x_fault = models.Fault(name="BPM02_X", description="BPM02 X Threshold Fault") bpm02_y_fault = models.Fault(name="BPM02_Y", description="BPM02 Y Threshold Fault") bpm02_t_fault = models.Fault(name="BPM02_T", description="BPM02 TMIT Threshold Fault") session.add_all([bpm02_x_fault, bpm02_y_fault, bpm02_t_fault]) # Inputs for the faults yag_fault_input = models.FaultInput(bit_position=0, device=screen, fault=yag_fault) gun_temp_fault_input = models.FaultInput(bit_position=0, device=gun_temp, fault=gun_temp_fault) wg_temp_fault_input = models.FaultInput(bit_position=0, device=wg_temp, fault=wg_temp_fault) buncher_temp_fault_input = models.FaultInput(bit_position=0, device=buncher_temp, fault=buncher_temp_fault) sol01_temp_fault_input = models.FaultInput(bit_position=0, device=sol01_temp, fault=sol01_temp_fault) sol02_temp_fault_input = models.FaultInput(bit_position=0, device=sol02_temp,
otr_out_lim_sw.channel = digital_chans[0] otr_out_lim_sw.bit_position = 0 otr_out_lim_sw.digital_device = otr_screen session.add(otr_out_lim_sw) otr_in_lim_sw = models.DeviceInput() otr_in_lim_sw.channel = digital_chans[1] otr_in_lim_sw.bit_position = 1 otr_in_lim_sw.digital_device = otr_screen session.add(otr_in_lim_sw) #Configure a fault for the device otr_fault = models.Fault(name="OTR Fault") session.add(otr_fault) #This fault only has one input: the device state. otr_fault_input = models.FaultInput() otr_fault_input.bit_position = 0 otr_fault_input.device = otr_screen otr_fault_input.fault = otr_fault session.add(otr_fault_input) #This fault's states match up exactly with the device states. #otr_fault_out = models.FaultState(name="Out") #otr_fault_out.fault = otr_fault #otr_fault_out.value = 1 #session.add(otr_fault_out) otr_fault_in = models.FaultState(name="In") otr_fault_in.fault = otr_fault otr_fault_in.value = 2 session.add(otr_fault_in) otr_fault_moving = models.FaultState(name="Moving")