Object Oriented - SmartHome Project
- Remi Bettan

- 7 באוג׳ 2016
- זמן קריאה 2 דקות
This project was about designing and implementing a smarthome, which main components are Controllers and Sensors. The Sensors would send signals to the relevant Controllers.
The main Design Pattern used in this Project has been the Mediator Design Pattern, which role is to store the published messages – in this project, the signals from the Sensors – and to send those to the ones which had subscribed to the topic of these messages – in this project, the Controllers, which had subscribed to the location of the Sensors.
Below is the Executive Diagram:

For the initialization of the system, a configuration file has been provided, in which each line described a Sensor or a Controller. This file has been parsed and the information has been stored while the Sensors and Controllers are created by a Factory.
Then a test program has been computed by our team in order to test the system: signals are sent by Sensors and the relevant Controllers react to those.
This project has been designed with OOD tools and implemented in C++, with mutithreading.
The main modules are:
- Builder: This module includes several classes like Loader (for the loading of the configuration file), Parser and Factory. Each class of the Sensors types and Controllers types which had their objects instantiated by the Factory were implemented in Shared Objects and the Factory loaded those only if their type appear in the configuration file (extern “C” has been used in order to permit the loading function – dlsym in linux – to find the Creation function of the device).
- Event: This class encapsulates the message, its topic and its other details which were stored from the configuration file.
- Device: Abstract Base Class for all the devices – Sensors and Controllers. The main functions in this class are:
-Notify: pushes an Event in a (multithreading) Safe Priority Queue,
-GetNotification: pops an Event from the Queue.
- Mediator: Its main functions are:
-Publish: used by the Sensors in order to publish their Events to the Controllers.
-Subscribe: used by the Controllers in order to get only the Events relevant for them.
- Live Log: One was able to connect to the system by TCP/IP Protocol and get all the messages from the system.
See below the Class Diagrams of this project.


תגובות