From 9a216340520fe1d25f47e870fc8b378d34c415b5 Mon Sep 17 00:00:00 2001 From: Martino Ferrari Date: Tue, 27 Jan 2026 16:47:53 +0100 Subject: [PATCH] Implementing HVON mode --- .../Configurations/src/app_states.marte | 6 +- .../Configurations/src/data/epics.marte | 25 +++++++ .../Configurations/src/data/pxi.marte | 4 ++ .../src/thread1/state_management.marte | 64 +++++++++++++++++ .../src/thread1/thread_data_broker.marte | 58 ++++++++++++++++ .../Configurations/src/thread3/epics.marte | 68 +++++++++++++++++++ 6 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/thread_data_broker.marte create mode 100644 EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte 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 b91035e..c034c91 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 @@ -84,7 +84,6 @@ } } } -/* // Real-Time state for HVPS sequence timing control. +WaitHVON = { Class = RealTimeState @@ -92,7 +91,7 @@ Class = ReferenceContainer +Thread1 = { Class = RealTimeThread - Functions = { Timer1kHzGAM CCPSWaveformGAM FHPSSetpointGAM FHPSRampupGAM InWaitHVONGAM choiseGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM writeBeamONStateGAM writeHVArmedStateGAM writeHVInjectionStateGAM writeRFONStateGAM writeBeamONTimeGAM writeRFONTimeGAM FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } + Functions = { Timer1kHzGAM StateGAM CCPSWaveformGAM FHPSSetpointGAM FHPSRampupGAM ChoiceGAM EPICSOutputGAM PXI6368Error03GAM PXI6368Error04GAM PXI6259ErrorGAM PXIErrorGAM FastStatesSync FromWaitHVONToWaitStandby FromWaitHVONToWaitPermit GoErrorGAM } CPUs = 0x100 } +Thread2 = { @@ -102,11 +101,12 @@ } +Thread3 = { Class = RealTimeThread - Functions = { Timer100kHzGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } + Functions = { FastTimerGAM GAMEPICSCA StopRequestGAM ModeLimitGAM NI6528P3GAM NI6528P4GAM GAMRealTimeStateMachine NI6528P5GAM NI6528P5PV2PortGAM } CPUs = 0x400 } } } +/* +WaitHVON_SDN = { 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 ca06049..10237d2 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 @@ -108,6 +108,31 @@ PVName = "EC-GN-P01-GAF:STAT-PREP-MODE" Type = uint32 } + // Timing settings + MHVPS_DT = { + PVName = "EC-GN-P01-PMF:STAT-DT-HVON" + Type = uint32 + } + APS_HVON_DT = { + PVName = "EC-GN-P01-PA1F:STAT-DT-HVON" + Type = uint32 + } + APS_SWON_DT = { + PVName = "EC-GN-P01-PA1F:STAT-DT-SWON" + Type = uint32 + } + BPS_HVON_DT = { + PVName = "EC-GN-P01-PB1F:STAT-DT-HVON" + Type = uint32 + } + BPS_SWON_DT = { + PVName = "EC-GN-P01-PB1F:STAT-DT-SWON" + Type = uint32 + } + SHOTLEN = { + PVName = "EC-GN-P01-GAF:STAT-DT-SHOTLEN" + 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 b272db3..e1ff8f9 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 @@ -66,6 +66,10 @@ PLC_PERMIT = { Type = uint32 } + //# DI.17 + PLC_ON = { + Type = uint32 + } } } +NI6528_DO_P3 = { diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/state_management.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/state_management.marte index a6d2e4b..8005c00 100644 --- a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/state_management.marte +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/state_management.marte @@ -357,3 +357,67 @@ Function = GoWaitHVON_SDN_PREP } } +//# GAM in WaitHVON_xx states. If PLC_READY is zero, goto WaitStandby. ++FromWaitHVONToWaitStandby = { + Class = JAMessageGAM + Operation = AND + InputSignals = { + PLC_READY = { + DataSource = NI6528_DI + Comparator = EQUALS + Value = 0 + } + } + +Event = { + Class = Message + Destination = StateMachine + Function = GoWaitStandby + } +} +//# GAM in WaitHVON_xx states. If PLC_PERMIT is zero, goto WaitPermit. ++FromWaitHVONToWaitPermit = { + Class = JAMessageGAM + Operation = AND + InputSignals = { + PLC_PERMIT = { + DataSource = NI6528_DI + Comparator = EQUALS + Value = 0 + } + APS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + Comparator = EQUALS + Value = 0 + } + BPS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + Comparator = EQUALS + Value = 0 + } + MHVPS_HVON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + Comparator = EQUALS + Value = 0 + } + BPS_SWON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + Comparator = EQUALS + Value = 0 + } + APS_SWON = { + DataSource = RealTimeThreadAsyncBridge + Type = uint32 + Comparator = EQUALS + Value = 0 + } + } + +Event = { + Class = Message + Destination = StateMachine + Function = GoWaitPermit + } +} diff --git a/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/thread_data_broker.marte b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/thread_data_broker.marte new file mode 100644 index 0000000..5690558 --- /dev/null +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread1/thread_data_broker.marte @@ -0,0 +1,58 @@ +#package jada_gyro.RTApp.Functions + +//# GAM used to sync data from Fast thread (th.3) to slow thread (th.1) ++FastStatesSync = { + Class = IOGAM + InputSignals = { + 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 + } + } + OutputSignals = { + BEAM_ON_STAT = { + DataSource = DDB1 + Type = uint32 + } + HVARMED = { + DataSource = DDB1 + Type = uint32 + } + HVINJECTION = { + DataSource = DDB1 + Type = uint32 + } + RFON = { + DataSource = DDB1 + Type = uint32 + } + ELAPSED_TIME = { + DataSource = DDB1 + Type = uint32 + } + BEAM_ON_TIME = { + DataSource = DDB1 + Type = uint32 + } + } +} 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 new file mode 100644 index 0000000..1460423 --- /dev/null +++ b/EC-GN-JA-PCF-IN/src/main/resources/qst-gyrotron-fast-controller/Configurations/src/thread3/epics.marte @@ -0,0 +1,68 @@ +#package jada_gyro.RTApp + ++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 = { + Class = IOGAM + InputSignals = { + MHVPS_DT = { + DataSource = EPICSCAInput + Type = uint32 + } + APS_HVON_DT = { + DataSource = EPICSCAInput + Type = uint32 + } + APS_SWON_DT = { + DataSource = EPICSCAInput + Type = uint32 + } + BPS_HVON_DT = { + DataSource = EPICSCAInput + Type = uint32 + } + BPS_SWON_DT = { + DataSource = EPICSCAInput + Type = uint32 + } + SHOTLEN = { + DataSource = EPICSCAInput + Type = uint32 + } + PLC_ON = { + DataSource = NI6528_DI + } + } + OutputSignals = { + 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 + } + PLC_ON = { + DataSource = DDB3 + Type = uint32 + } + } + } +}