The server

We will first look at the server for this integration test. Its role is to run the RPC server and to maintain the state of each of the sensor and actuator devices, as well as the rooms.

The main file, simulation.cpp, sets up the RPC configuration as well as the main loop, as shown in the following code:

#include "config.h"#include "building.h"#include "nodes.h"#include <nymph/nymph.h>#include <thread>#include <condition_variable>#include <mutex>std::condition_variable gCon;std::mutex gMutex;bool gPredicate = false;void signal_handler(int signal) {    gPredicate = true;    gCon.notify_one();}void logFunction(int level, string logStr) {    std::cout << level << " - " << logStr << endl;}

The includes at the top shows us the basic structure ...

Get Hands-On Embedded Programming with C++17 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.