bit_position=0, digital_device=vvr1, fault_value=0) vvr2_channel = models.DeviceInput(channel=digital_chans[8], bit_position=0, digital_device=vvr2, fault_value=0) session.add_all([ yag_out_lim_sw, yag_in_lim_sw, gun_temp_channel, wg_temp_channel, buncher_temp_channel, sol01_temp_channel, sol02_temp_channel, vvr1_channel, vvr2_channel ]) #Configure faults for the digital devices yag_fault = models.Fault(name="TGT", description="YAG01 Profile Monitor Screen Fault") gun_temp_fault = models.Fault(name="TEMP_SUM", description="Gun Temperature Fault") wg_temp_fault = models.Fault(name="WG_TEMP", description="Waveguide Temperature Fault") buncher_temp_fault = models.Fault(name="TEMP_SUM", description="Buncher Temperature Fault") sol01_temp_fault = models.Fault(name="TEMP_SUM", description="SOL01 Temperature Fault") sol02_temp_fault = models.Fault(name="TEMP_SUM", description="SOL02 Temperature Fault") vvr1_fault = models.Fault(name="VVR01", description="VVR01 Vacuum Valve Fault") vvr2_fault = models.Fault(name="VVR02", description="VVR02 Vacuum Valve Fault") session.add_all([ yag_fault, gun_temp_fault, wg_temp_fault, buncher_temp_fault, sol01_temp_fault, sol02_temp_fault, vvr1_fault, vvr2_fault
for i in range(0, len(devices)): for j in range(0, channelsPerDevice): deviceInput = models.DeviceInput( channel=channels[i * channelsPerDevice + j], bit_position=j, 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)
fault_value=0) m3_out_sw = models.DeviceInput(channel=digital_chans[7], bit_position=1, digital_device=m3_device, fault_value=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)
bit_position=0, digital_device=vvr1, fault_value=0) vvr2_channel = models.DeviceInput(channel=digital_chans[8], bit_position=0, digital_device=vvr2, fault_value=0) session.add_all([ yag_out_lim_sw, yag_in_lim_sw, gun_temp_channel, wg_temp_channel, buncher_temp_channel, sol01_temp_channel, sol02_temp_channel, vvr1_channel, vvr2_channel ]) #Configure faults for the digital devices yag_fault = models.Fault(name="YAG01", description="YAG01 Profile Monitor Fault") gun_temp_fault = models.Fault(name="GUN_TEMP", description="Gun Temperature Fault") wg_temp_fault = models.Fault(name="WG_TEMP", description="Waveguide Temperature Fault") buncher_temp_fault = models.Fault(name="BUNCH_TEMP", description="Buncher Temperature Fault") sol01_temp_fault = models.Fault(name="SOL01_TEMP", description="SOL01 Temperature Fault") sol02_temp_fault = models.Fault(name="SOL02_TEMP", description="SOL02 Temperature Fault") vvr1_fault = models.Fault(name="VVR01", description="VVR01 Vacuum Valve Fault") vvr2_fault = models.Fault(name="VVR02", description="VVR02 Vacuum Valve Fault") session.add_all([ yag_fault, gun_temp_fault, wg_temp_fault, buncher_temp_fault, sol01_temp_fault, sol02_temp_fault, vvr1_fault, vvr2_fault
#Give the device some inputs. It has in and out limit switches. #Connect these limit switches to channels 0 and 1 of our link node card. otr_out_lim_sw = models.DeviceInput() 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")