How fortiphyd/grficsv2 works
GRFICSv2 is an industrial-control training environment spanning a chemical-process simulation, remote I/O, an OpenPLC soft PLC, an operator HMI, and network isolation. The principal loop is process state → remote I/O over Modbus → PLC logic → remote-I/O commands → process state; operators monitor measurements and issue commands through the HMI. The repository also includes OpenPLC’s IEC 61131-3 compiler and runtime. The README documents system-level links; sampled source supports simulation and selected runtime/compiler internals, so unverified connections are omitted or marked dashed.
Main entry points: main.cpp PLC scan loop · modbus Remote I/O devices · simulation/main.cc Simulation JSON API · matiec_src/main.cc IEC compiler driver
Components 18
Process simulation
- Chemical process
simulation_vm/simulation/TE_process.cc - Simulation JSON API
simulation_vm/simulation/main.cc - Remote I/O devices
simulation_vm/simulation/remote_io/modbus - Tank I/O
simulation_vm/simulation/remote_io/modbus/tank.py - Product I/O
simulation_vm/simulation/remote_io/modbus/product.py - Feed I/O
simulation_vm/simulation/remote_io/modbus/feed2.py - 3D visualization
simulation_vm/web_visualization
PLC runtime
- PLC scan loop
plc_vm/OpenPLC_v2-master/core/main.cpp - PLC I/O image
plc_vm/OpenPLC_v2-master/core/ladder.h - Modbus server
plc_vm/OpenPLC_v2-master/core/server.cpp - Persistent memory
plc_vm/OpenPLC_v2-master/core/persistent_storage.cpp
IEC compiler
- IEC compiler driver
plc_vm/OpenPLC_v2-master/matiec_src/main.cc - Semantic analysis
plc_vm/OpenPLC_v2-master/matiec_src/stage3/constant_folding.cc - C code generation
plc_vm/OpenPLC_v2-master/matiec_src/stage4/generate_c/generate_c.cc
Operator network
- Engineering workstation
- ScadaBR HMI
- pfSense router
Other components
- Operator
Connections 21
- Chemical process → Simulation JSON API: updates state
simulation_vm/simulation/main.cc - Simulation JSON API → Chemical process: updates process
simulation_vm/simulation/main.cc - Simulation JSON API → Remote I/O devices: serves JSON API
- Remote I/O devices → Chemical process: reads and actuates
- PLC scan loop → Remote I/O devices: Modbus I/O
- ScadaBR HMI → PLC scan loop: monitors and commands
- Operator → ScadaBR HMI: operates
- Engineering workstation → IEC compiler driver: programs PLC
- Engineering workstation → PLC scan loop: deploys logic
- pfSense router → ScadaBR HMI: routes DMZ traffic
- pfSense router → PLC scan loop: routes ICS traffic
- Operator → 3D visualization: views process
- PLC scan loop → Modbus server: starts server
plc_vm/OpenPLC_v2-master/core/main.cpp - Modbus server → PLC I/O image: maps protocol data
plc_vm/OpenPLC_v2-master/core/server.cpp - PLC scan loop → PLC I/O image: scans I/O
plc_vm/OpenPLC_v2-master/core/main.cpp - PLC scan loop → Persistent memory: persists state
- IEC compiler driver → Semantic analysis: runs stage three
plc_vm/OpenPLC_v2-master/matiec_src/main.cc - IEC compiler driver → C code generation: runs stage four
plc_vm/OpenPLC_v2-master/matiec_src/main.cc - Tank I/O → Remote I/O devices: implements device
- Product I/O → Remote I/O devices: implements device
- Feed I/O → Remote I/O devices: implements device