diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/app_states.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/app_states.marte index c034c91..c260df7 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/app_states.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/app_states.marte @@ -101,19 +101,18 @@ } +Thread3 = { Class = RealTimeThread - Functions = { FastTimerGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } + Functions = { FastTimerGAM FastEpicsInputGAM FastStopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } CPUs = 0x400 } } } -/* +WaitHVON_SDN = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread - Functions = { Timer1kHzGAM CCPSWaveformGAM FHPSRampupGAM InWaitHVON_SDNGAM choiseGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM writeBeamONStateGAM writeHVArmedStateGAM writeHVInjectionStateGAM writeRFONStateGAM writeBeamONTimeGAM writeRFONTimeGAM FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } + Functions = { Timer1kHzGAM StateGAM CCPSWaveformGAM FHPSRampupGAM ChoiceGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM FastStatesSync FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } CPUs = 0x100 } +Thread2 = { @@ -123,7 +122,7 @@ } +Thread3 = { Class = RealTimeThread - Functions = { Timer100kHzGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMSDNRealTimeStateMachine terminalInterfaceGAM NI6528P5GAM NI6528P5PV2PortGAM } + Functions = { FastTimerGAM FastEpicsInputGAM FastStopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMSDNRealTimeStateMachine TerminalInterfaceGAM NI6528P5GAM NI6528P5PV2PortGAM } CPUs = 0x400 } } @@ -134,7 +133,7 @@ Class = ReferenceContainer +Thread1 = { Class = RealTimeThread - Functions = { Timer1kHzGAM CCPSWaveformGAM PreProgrammedGAM FHPSRampupGAM InWaitHVON_PREPGAM choiseGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM writeBeamONStateGAM writeHVArmedStateGAM writeHVInjectionStateGAM writeRFONStateGAM writeBeamONTimeGAM writeRFONTimeGAM FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } + Functions = { Timer1kHzGAM StateGAM CCPSWaveformGAM PreProgrammedGAM FHPSRampupGAM ChoiceGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM FastStatesSync FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } CPUs = 0x100 } +Thread2 = { @@ -144,7 +143,7 @@ } +Thread3 = { Class = RealTimeThread - Functions = { Timer100kHzGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } + Functions = { FastTimerGAM FastEpicsInputGAM FastStopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } CPUs = 0x400 } } @@ -155,7 +154,7 @@ Class = ReferenceContainer +Thread1 = { Class = RealTimeThread - Functions = { Timer1kHzGAM CCPSWaveformGAM PreProgrammedGAM FHPSRampupGAM InWaitHVON_SDN_PREPGAM choiseGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM writeBeamONStateGAM writeHVArmedStateGAM writeHVInjectionStateGAM writeRFONStateGAM writeBeamONTimeGAM writeRFONTimeGAM FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } + Functions = { Timer1kHzGAM StateGAM CCPSWaveformGAM PreProgrammedGAM FHPSRampupGAM ChoiceGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM FastStatesSync FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } CPUs = 0x100 } +Thread2 = { @@ -165,12 +164,11 @@ } +Thread3 = { Class = RealTimeThread - Functions = { Timer100kHzGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMSDNRealTimeStateMachine terminalInterfaceGAM NI6528P5GAM NI6528P5PV2PortGAM } + Functions = { FastTimerGAM FastEpicsInputGAM FastStopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMSDNRealTimeStateMachine TerminalInterfaceGAM NI6528P5GAM NI6528P5PV2PortGAM } CPUs = 0x400 } } } -*/ +Error = { Class = RealTimeState +Threads = { diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/epics.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/epics.marte index 10237d2..1b892f4 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/epics.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/epics.marte @@ -133,6 +133,38 @@ PVName = "EC-GN-P01-GAF:STAT-DT-SHOTLEN" Type = uint32 } + PLC_MODE1 = { + PVName = "EC-GN-P01-GPS:PLC4110-YTS-MD1" + Type = uint32 + } + PLC_MODE2 = { + PVName = "EC-GN-P01-GPS:PLC4110-YTS-MD2" + Type = uint32 + } + PLC_MODE3 = { + PVName = "EC-GN-P01-GPS:PLC4110-YTS-MD3" + Type = uint32 + } + PLC_MODE4 = { + PVName = "EC-GN-P01-GPS:PLC4110-YTS-MD4" + Type = uint32 + } + MD1_SHOTLEN_LIM = { + PVName = "EC-GN-P01-GPF:STAT-MD1-LIM" + Type = uint32 + } + MD2_SHOTLEN_LIM = { + PVName = "EC-GN-P01-GPF:STAT-MD2-LIM" + Type = uint32 + } + MD3_SHOTLEN_LIM = { + PVName = "EC-GN-P01-GPF:STAT-MD3-LIM" + Type = uint32 + } + MD4_SHOTLEN_LIM = { + PVName = "EC-GN-P01-GPF:STAT-MD4-LIM" + Type = uint32 + } } } +EPICSCAOutput = { diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/pxi.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/pxi.marte index e1ff8f9..c5819ad 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/pxi.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/data/pxi.marte @@ -72,6 +72,31 @@ } } } +//# Direct HW accesses. Follwing device/port assignment must be consistent with actual wiring. +//# NI6259.0 +//# APS_SWON BoardId=0, PortId=3.0 ++NI6259_DIO_P0 = { + Class = NI6259::NI6259DIO + DeviceName = "/dev/pxi6259" + BoardId = 1 + Signals = { + NI6259Value = { + Type = uint32 + Mask = 0xFF + PortId = 0 + } + } +} +//# NI6528 digital output has logic low == 0 == close relay. ((See Driver Manual.) +//# When the program send ON signal, this program writes 0 on the data source. +//# P3.0 APS_HVON +//# P3.1 APS_SWON +//# P3.2 APS_Shutdown +//# P3.3 BPS_HVON +//# P3.4 BPS_SWON +//# P3.5 BPS_Shutdown +//# P3.6 GY1_Beam_ON_status +//# P3.7 RV5 _cRIO +NI6528_DO_P3 = { Class = NI6528 DeviceName = "/dev/pxi6528.1" @@ -82,6 +107,14 @@ } } } +//# P4.0 RV6 _cRIO +//# P4.1 RV7 _cRIO +//# P4.2 RV8 _cRIO +//# P4.3 MHVPS_HVON +//# P4.4 MHVPS_Shutdown +//# P4.5 MHVPS_MOD +//# P4.6 PCF_FLT +//# P4.7 HVArmed +NI6528_DO_P4 = { Class = NI6528 DeviceName = "/dev/pxi6528.1" @@ -92,6 +125,14 @@ } } } +//# P5.0 HVInjection +//# P5.1 RFON +//# P5.2 FHPS_Rampup_complete +//# P5.3 SCM_RU_Complete +//# P5.4 SCM_RD_Complete +//# P5.5 CCPS_IN_OPERATION +//# P5.6 None +//# P5.7 None +NI6528_DO_P5 = { Class = NI6528 DeviceName = "/dev/pxi6528.1" diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte index 1460423..91da155 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte @@ -3,7 +3,7 @@ +Functions = { //# Thread3 pulse parameter EPICS PVs read. //# TODO: Should be better to read it in thread 1 and use a async bridge to copy to 3? - +GAMEPICSCA = { + +FastEpicsInputGAM = { Class = IOGAM InputSignals = { MHVPS_DT = { diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/hvon_functions.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/hvon_functions.marte new file mode 100644 index 0000000..bbe6d51 --- /dev/null +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/hvon_functions.marte @@ -0,0 +1,98 @@ +#package jada_gyro.RTApp.Functions + ++FastStopRequestGAM = { + Class = JAConditionalSignalUpdateGAM + Operation = OR + InputSignals = { + GYA_APS_FLT = { + DataSource = NI6528_DI + Type = uint32 + Comparators = EQUALS + Value = 1 + } + GYA_BPS_FLT = { + DataSource = NI6528_DI + Comparators = EQUALS + Value = 1 + } + MHVPS_OV = { + DataSource = NI6528_DI + Comparators = EQUALS + Value = 1 + } + MHVPS_OC = { + DataSource = NI6528_DI + Comparators = EQUALS + Value = 1 + } + MHVPS_FLT = { + DataSource = NI6528_DI + Comparators = EQUALS + Value = 1 + } + MIS_ITL = { + DataSource = EPICSCAInput + Type = uint32 + Comparators = EQUALS + Value = 1 + } + PLC_ITL = { + DataSource = NI6528_DI + Comparators = EQUALS + Value = 1 + } + } + OutputSignals = { + StopRequest = { + DataSource = DDB3 + Type = uint32 + Default = 0 + Value = 1 + } + } +} +//# Check the selected mode, and check maximum pulse length. Use with a StateMachineGAM ++ModeLimitGAM = { + Class = JAModeControlGAM + InputSignals = { + PLC_MODE1 = { + DataSource = EPICSCAInput + } + MD1_SHOTLEN_LIM = { + DataSource = EPICSCAInput + } + PLC_MODE2 = { + DataSource = EPICSCAInput + } + MD2_SHOTLEN_LIM = { + DataSource = EPICSCAInput + } + PLC_MODE3 = { + DataSource = EPICSCAInput + } + MD3_SHOTLEN_LIM = { + DataSource = EPICSCAInput + } + PLC_MODE4 = { + DataSource = EPICSCAInput + } + MD4_SHOTLEN_LIM = { + DataSource = EPICSCAInput + } + RFON = { + DataSource = RealTimeThreadAsyncBridge + } + Time = { + DataSource = RealTimeThreadAsyncBridge + } + HVInjection = { + DataSource = RealTimeThreadAsyncBridge + } + } + OutputSignals = { + MODE_SHOTLEN_FLAG = { + DataSource = DDB3 + Type = uint32 + } + } +} diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/pxi_io_gams.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/pxi_io_gams.marte index 15feaee..dee8a16 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/pxi_io_gams.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/pxi_io_gams.marte @@ -40,7 +40,7 @@ } OutputSignals = { NI6528P3CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -83,7 +83,7 @@ } OutputSignals = { NI6528P4CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -116,18 +116,18 @@ Type = uint32 } PXI_FLT = { - DataSource = DDB1 + DataSource = DDB3 Type = uint32 } NONE2 = { - DataSource = DDB1 + DataSource = DDB3 Type = uint32 Default = 0 } } OutputSignals = { NI6528P5CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -137,13 +137,13 @@ Class = JABitReverseGAM InputSignals = { NI6528P3CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } OutputSignals = { NI6528P3PortValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -152,13 +152,13 @@ Class = JABitReverseGAM InputSignals = { NI6528P4CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } OutputSignals = { NI6528P4PortValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -167,7 +167,7 @@ Class = JABitReverseGAM InputSignals = { NI6528P5CurrentValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -183,7 +183,7 @@ Class = IOGAM InputSignals = { NI6528P3PortValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -198,7 +198,7 @@ Class = IOGAM InputSignals = { NI6528P4PortValue = { - DataSource = DDB1 + DataSource = DDB3 Type = uint8 } } @@ -209,3 +209,68 @@ } } } +//# INPUTs: StateMahine Value, NI6528P3Value and NI6528P4Value +//# OUTPUTs: Each NIxxx data sources. +//# TODO: name is very ambiguos ++TerminalInterfaceGAM = { + Class = JATerminalInterfaceGAM + mhvps_hvon_term = 4 + aps_hvon_term = 1 + aps_swon_term = 16 + bps_hvon_term = 2 + bps_swon_term = 8 + InputSignals = { + MHVPS_HVON = { + DataSource = DDB3 + Type = uint32 + } + APS_HVON = { + DataSource = DDB3 + Type = uint32 + } + APS_SWON = { + DataSource = DDB3 + Type = uint32 + } + BPS_HVON = { + DataSource = DDB3 + Type = uint32 + } + BPS_SWON = { + DataSource = DDB3 + Type = uint32 + } + SHORT_PULSE_MODE = { + DataSource = EPICSCAInput + Type = uint32 + } + // Input signals about HW terminal. + RTSMValue = { + DataSource = DDB3 + Type = uint32 + } + NI6528P3CurrentValue = { + DataSource = DDB3 + Type = uint8 + } + NI6528P4CurrentValue = { + DataSource = DDB3 + Type = uint8 + } + } + OutputSignals = { + NI6259Value = { + DataSource = NI6259_DIO_P0 + Type = uint32 + Trigger = 1 + } + NI6528P3Value = { + DataSource = NI6528_DO_P3 + Type = uint8 + } + NI6528P4Value = { + DataSource = NI6528_DO_P4 + Type = uint8 + } + } +} diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/rt_statemachines.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/rt_statemachines.marte new file mode 100644 index 0000000..699eda8 --- /dev/null +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/rt_statemachines.marte @@ -0,0 +1,224 @@ +#package jada_gyro.RTApp.Functions + ++GAMRealTimeStateMachine = { + Class = JARTStateMachineGAM + ConditionTrigger = 1 + mhvps_hvon = 4 + aps_hvon = 1 + aps_swon = 16 + bps_hvon = 2 + bps_swon = 8 + InputSignals = { + Time = { + DataSource = DDB3 + Type = uint32 + } + PLC_ON = { + DataSource = DDB3 + Type = uint32 + } + MHVPS_DT = { + DataSource = DDB3 + Type = uint32 + } + APS_HVON_DT = { + DataSource = DDB3 + Type = uint32 + } + APS_SWON_DT = { + DataSource = DDB3 + Type = uint32 + } + BPS_HVON_DT = { + DataSource = DDB3 + Type = uint32 + } + BPS_SWON_DT = { + DataSource = DDB3 + Type = uint32 + } + SHOTLEN = { + DataSource = DDB3 + Type = uint32 + } + StopRequest = { + DataSource = DDB3 + Type = uint32 + } + MODE_SHOTLEN_FLAG = { + DataSource = DDB3 + Type = uint32 + } + SHORT_PULSE_MODE = { + DataSource = EPICSCAInput + Type = uint32 + } + MHVPS_MODSW = { + DataSource = EPICSCAInput + Type = uint32 + } + // Add 20210121 + DO_REV6 = { + DataSource = EPICSCAInput + Type = uint32 + } + } + OutputSignals = { + RTSMValue = { + DataSource = DDB3 + Type = uint32 + Trigger = 1 + } + BEAM_ON_STAT = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + HVARMED = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + HVINJECTION = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + RFON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + BeamONTime = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + RFONTime = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + SHOT_ID = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + APS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + APS_SWON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + BPS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + BPS_SWON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + MHVPS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + NI6259Value = { + DataSource = NI6259_DIO_P0 + Type = uint32 + Trigger = 1 + } + NI6528P3Value = { + DataSource = NI6528_DO_P3 + Type = uint8 + } + NI6528P4Value = { + DataSource = NI6528_DO_P4 + Type = uint8 + } + } +} ++GAMSDNRealTimeStateMachine = { + Class = JASDNRTStateMachineGAM + ConditionTrigger = 1 + mhvps_hvon = 4 + aps_hvon = 1 + aps_swon = 16 + bps_hvon = 2 + bps_swon = 8 + InputSignals = { + Time = { + DataSource = DDB3 + Type = uint32 + } + PLC_ON = { + DataSource = DDB3 + Type = uint32 + } + MHVPS_DT = { + DataSource = DDB3 + Type = uint32 + } + APS_HVON_DT = { + DataSource = DDB3 + Type = uint32 + } + APS_SWON_DT = { + DataSource = DDB3 + Type = uint32 + } + BPS_HVON_DT = { + DataSource = DDB3 + Type = uint32 + } + BPS_SWON_DT = { + DataSource = DDB3 + Type = uint32 + } + SHOTLEN = { + DataSource = DDB3 + Type = uint32 + } + StopRequest = { + DataSource = DDB3 + Type = uint32 + } + MODE_SHOTLEN_FLAG = { + DataSource = DDB3 + Type = uint32 + } + Command = { + DataSource = RealTimeThreadAsyncBridge + Type = uint16 + } + } + OutputSignals = { + RTSMValue = { + DataSource = DDB3 + Type = uint32 + Trigger = 1 + } + BeamON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + HVARMED = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + HVINJECTION = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + RFON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + BeamONTime = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + RFONTime = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + SHOT_ID = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + } + } +}