I'm currently developing a controller for an industrial application which takes data inputs from various sensors and interfaces (ethernet, serial, etc.), does some minimal processing, and adjusts outputs to interfaces and mechanical systems as needed.
The device, a B&R X20 automation controller, uses a simple RTOS operating on a single-core with multi-processing, but not multi-threading support. New processes cannot be spawned during operation. Interrupts are not supported. Rather, to prioritize tasks, each process is assigned during programming a frequency for complete execution of its main loop, and the scheduler does its best to adhere to this real-time schedule, throwing exceptions upon timing violations.
To maximize concurrency between the various functions, each of which have different timing requirements, I have several small processes (e.g., an ethernet reader/ writer, a valve opener/ closer) mostly associated 1-to-1 with input/ output functions. To meet real-time i/o requirements, intensive data processing lives in separate processes prescribed to lower scheduling frequency.
Inter-process communication takes place through variables global to their respective processes, synchronized via semaphores.
The device allow programs to be written in both C and C++. When should I prefer to write with one or the other? Assume no significant difference in performance.
While my instinct is to prefer C++'s encapsulation, each of my processes is sufficiently simple such that using OOP would leave it housing only one object. Coding in C++ then seems to add an extra unnecessary layer of communication from the object to process-global variables that would not exist were the computation object-homeless. Additionally, because the entire process contains one object, there appears to be no encapsulation benefit, as there's nothing left to encapsulate from.
At the same time, I have some instinct that even simple programs should be programmed with OOP when possible to allow for flexibility and growth.
Have I discovered a situation where object-ification introduces unnecessary levels of structure to a simple program? Or is it preferable to adhere to OOP whenever the hardware allows?