The fourth generation of the Function Generator/Controller (FGC4) introduces a new communication protocol at CERN's power converter control infrastructure: the FGC Front-End Protocol (FFP), a JSON-over-WebSocket protocol that replaces the Network Command/Response Protocol (NCRP) used by previous generations. FGC4 is planned for deployment during Run~4 of the LHC and, in the longer term, in the proposed Future Circular Collider (FCC). Enabling control software to interact with FGC4 devices requires new protocol and transport support at every layer of the software stack. This thesis presents the design and implementation of the software stack required to communicate with FGC4 devices via FFP. The primary contribution is pyfgc 3.0.0, a complete rewrite of the Python library for FGC device communication, introducing WebSocket transport and FFP support while retaining backward compatibility with FGC2 and FGC3 via NCRP over TCP/IP. The library separates the transport layer from the message serialization layer through generic abstractions, and a \texttt{SyncWrapper} utility generates all synchronous APIs from their asynchronous counterparts, eliminating code duplication. The companion packages pyfgc name, pyfgc rbac, and pyfgc statussrv were rewritten alongside, replacing global mutable state with instance-based designs, introducing typed entity classes, and adopting modern Python type annotations throughout. The web-facing applications that depend on pyfgc were also updated: the FGC~API, FGC~Commander, FRESCO, and PowerSpy were migrated to the new library, and the FGC~API was extensively reworked to adopt the AutoConnectionFactory pattern and a modern CI/CD pipeline. On the firmware side, the C++ FfpClient class was written from scratch for the FGCDv2 gateway, and three cross-cutting clean-up tasks were completed across 141 files covering error handling types and integer type aliases. CI/CD pipelines were introduced or extended for all packages, using the ACC-Py GitLab CI template library and setuptools-scm for automated versioning. Validation was carried out at two levels. The unit test suite comprises 946 tests across six packages, all passing without hardware access, with branch coverage reaching 97% for pyfgc. Integration tests executed against real FGC4 and FGC3 devices at the CERN test bench confirmed correct end-to-end behaviour for both device generations. Robustness tests verified stable operation under 100 concurrent requests and uninterrupted 24-hour sessions with no connection drops or memory growth.

La quarta generazione del Function Generator/Controller (FGC4) introduce un nuovo protocollo di comunicazione nell'infrastruttura di controllo dei convertitori di potenza al CERN: il FGC Front-End Protocol (FFP), un protocollo JSON su WebSocket che sostituisce il Network Command/Response Protocol (NCRP) utilizzato dalle generazioni precedenti. L'FGC4 è previsto per il Run~4 dell'LHC e, in prospettiva futura, per il Future Circular Collider (FCC). Per consentire al software di controllo di interagire con i dispositivi FGC4, è necessario supporto per il nuovo protocollo e trasporto a ogni livello dello stack software. Questa tesi presenta la progettazione e l'implementazione dello stack software necessario per comunicare con i dispositivi FGC4 tramite FFP. Il contributo principale è pyfgc 3.0.0, una riscrittura completa della libreria Python per la comunicazione con i dispositivi FGC, che introduce il trasporto WebSocket e il supporto FFP mantenendo la retrocompatibilità con FGC2 e FGC3 tramite NCRP su TCP/IP. L'architettura della libreria separa il livello di trasporto dal livello di serializzazione dei messaggi tramite astrazioni generiche, e un'utilità SyncWrapper genera tutte le API sincrone a partire dalle controparti asincrone, eliminando la duplicazione del codice. I pacchetti complementari pyfgc name, pyfgc rbac e pyfgc statussrv sono stati riscritti insieme alla libreria principale, sostituendo lo stato globale mutabile con design basati su istanze, introducendo classi tipizzate e adottando annotazioni di tipo Python moderne. Le applicazioni web che dipendono da pyfgc sono state aggiornate: FGC~API, FGC~Commander, FRESCO e PowerSpy sono stati migrati alla nuova libreria, e l'FGC~API è stato ampiamente rielaborato con il pattern AutoConnectionFactory e una pipeline CI/CD moderna. Sul fronte firmware, la classe C++ FfpClient è stata sviluppata da zero per il gateway FGCDv2, e tre interventi trasversali sono stati completati su 141 file, riguardanti la gestione degli errori e gli alias di tipo intero. Pipeline CI/CD sono state introdotte o estese per tutti i pacchetti, utilizzando la libreria di template GitLab CI di ACC-Py e setuptools-scm per la versionatura automatica. La validazione è stata condotta su due livelli. La suite di test unitari comprende 946 test su sei pacchetti, tutti superati senza accesso all'hardware, con una copertura dei rami che raggiunge il 97\% per pyfgc. I test di integrazione eseguiti su dispositivi FGC4 e FGC3 reali al banco di test del CERN hanno confermato il corretto comportamento end-to-end per entrambe le generazioni di dispositivi. I test di robustezza hanno verificato il corretto funzionamento sotto 100 richieste concorrenti e sessioni ininterrotte di 24 ore senza interruzioni di connessione o crescita della memoria.

Pyfgc and the FGC4 software stack: redesign of the Python communication library for the LHC

ROSSI, LORENZO
2025/2026

Abstract

The fourth generation of the Function Generator/Controller (FGC4) introduces a new communication protocol at CERN's power converter control infrastructure: the FGC Front-End Protocol (FFP), a JSON-over-WebSocket protocol that replaces the Network Command/Response Protocol (NCRP) used by previous generations. FGC4 is planned for deployment during Run~4 of the LHC and, in the longer term, in the proposed Future Circular Collider (FCC). Enabling control software to interact with FGC4 devices requires new protocol and transport support at every layer of the software stack. This thesis presents the design and implementation of the software stack required to communicate with FGC4 devices via FFP. The primary contribution is pyfgc 3.0.0, a complete rewrite of the Python library for FGC device communication, introducing WebSocket transport and FFP support while retaining backward compatibility with FGC2 and FGC3 via NCRP over TCP/IP. The library separates the transport layer from the message serialization layer through generic abstractions, and a \texttt{SyncWrapper} utility generates all synchronous APIs from their asynchronous counterparts, eliminating code duplication. The companion packages pyfgc name, pyfgc rbac, and pyfgc statussrv were rewritten alongside, replacing global mutable state with instance-based designs, introducing typed entity classes, and adopting modern Python type annotations throughout. The web-facing applications that depend on pyfgc were also updated: the FGC~API, FGC~Commander, FRESCO, and PowerSpy were migrated to the new library, and the FGC~API was extensively reworked to adopt the AutoConnectionFactory pattern and a modern CI/CD pipeline. On the firmware side, the C++ FfpClient class was written from scratch for the FGCDv2 gateway, and three cross-cutting clean-up tasks were completed across 141 files covering error handling types and integer type aliases. CI/CD pipelines were introduced or extended for all packages, using the ACC-Py GitLab CI template library and setuptools-scm for automated versioning. Validation was carried out at two levels. The unit test suite comprises 946 tests across six packages, all passing without hardware access, with branch coverage reaching 97% for pyfgc. Integration tests executed against real FGC4 and FGC3 devices at the CERN test bench confirmed correct end-to-end behaviour for both device generations. Robustness tests verified stable operation under 100 concurrent requests and uninterrupted 24-hour sessions with no connection drops or memory growth.
ING - Scuola di Ingegneria Industriale e dell'Informazione
22-lug-2026
2025/2026
La quarta generazione del Function Generator/Controller (FGC4) introduce un nuovo protocollo di comunicazione nell'infrastruttura di controllo dei convertitori di potenza al CERN: il FGC Front-End Protocol (FFP), un protocollo JSON su WebSocket che sostituisce il Network Command/Response Protocol (NCRP) utilizzato dalle generazioni precedenti. L'FGC4 è previsto per il Run~4 dell'LHC e, in prospettiva futura, per il Future Circular Collider (FCC). Per consentire al software di controllo di interagire con i dispositivi FGC4, è necessario supporto per il nuovo protocollo e trasporto a ogni livello dello stack software. Questa tesi presenta la progettazione e l'implementazione dello stack software necessario per comunicare con i dispositivi FGC4 tramite FFP. Il contributo principale è pyfgc 3.0.0, una riscrittura completa della libreria Python per la comunicazione con i dispositivi FGC, che introduce il trasporto WebSocket e il supporto FFP mantenendo la retrocompatibilità con FGC2 e FGC3 tramite NCRP su TCP/IP. L'architettura della libreria separa il livello di trasporto dal livello di serializzazione dei messaggi tramite astrazioni generiche, e un'utilità SyncWrapper genera tutte le API sincrone a partire dalle controparti asincrone, eliminando la duplicazione del codice. I pacchetti complementari pyfgc name, pyfgc rbac e pyfgc statussrv sono stati riscritti insieme alla libreria principale, sostituendo lo stato globale mutabile con design basati su istanze, introducendo classi tipizzate e adottando annotazioni di tipo Python moderne. Le applicazioni web che dipendono da pyfgc sono state aggiornate: FGC~API, FGC~Commander, FRESCO e PowerSpy sono stati migrati alla nuova libreria, e l'FGC~API è stato ampiamente rielaborato con il pattern AutoConnectionFactory e una pipeline CI/CD moderna. Sul fronte firmware, la classe C++ FfpClient è stata sviluppata da zero per il gateway FGCDv2, e tre interventi trasversali sono stati completati su 141 file, riguardanti la gestione degli errori e gli alias di tipo intero. Pipeline CI/CD sono state introdotte o estese per tutti i pacchetti, utilizzando la libreria di template GitLab CI di ACC-Py e setuptools-scm per la versionatura automatica. La validazione è stata condotta su due livelli. La suite di test unitari comprende 946 test su sei pacchetti, tutti superati senza accesso all'hardware, con una copertura dei rami che raggiunge il 97\% per pyfgc. I test di integrazione eseguiti su dispositivi FGC4 e FGC3 reali al banco di test del CERN hanno confermato il corretto comportamento end-to-end per entrambe le generazioni di dispositivi. I test di robustezza hanno verificato il corretto funzionamento sotto 100 richieste concorrenti e sessioni ininterrotte di 24 ore senza interruzioni di connessione o crescita della memoria.
File allegati
File Dimensione Formato  
Thesis.pdf

accessibile in internet per tutti

Dimensione 41.83 MB
Formato Adobe PDF
41.83 MB Adobe PDF Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/262077