The peripheral simulation is a software simulation of the controller based on Docker containers.
The simulation is capable of simulating input from several different hardware peripherals, such as:
It's use case is primarily for running system tests in CI/CD, as the simulation interface used in the peripheral simulation is shared by the KitKat and Ebee Testing Framework.
Additionally, developers are also welcome to use since there is a top level CLI script under https://gitlab.com/ebee_smart/ebee-controller-meta/-/tree/master/controller_software/simulation/simulation.py that allows one to launch and manipulate the simulation in a user friendly manner.
For more information about how to use the simulation, please check https://gitlab.com/ebee_smart/ebee-controller-meta/-/tree/master/controller_software/simulation
The container setup is done via Docker Compose files. It manages the interaction of the containers representing controller instances, a backend and an optional test runner. The `simulation.py` script wraps the usage of docker compose to start/stop the simulation and it also sends JSON-RPC requests to the controller containers to request simulating a certain peripheral input (e.g.: setting the control pilot line to a certain value in the type 2 socket).
Let's say the user wants to set the control pilot line to state B. This JSON-RPC request is sent from the host by the user and reaches the Ebee controller application running inside the simulated controller container. From there the Server Connector component, which runs a small HTTP server, forwards the message to the correct service dispatcher for the socket type 2, in this case, CPPService.cpp. From there, the request is queued to the mocked HW component responsible for reading the control pilot line, so that later when another execution context requests the CP value, it will be returned as B.