The ControlUnit class is the main center of activity, it sets up everything.
1 2 3 4 5 6 7 8 9 10 11
class ControlUnit {
public:
ControlUnit(); //no constructor args
{
SerialCom* datastream = new SerialCom(data source);
Buzzer* buffer = new Buffer(datastream); //make a buzzer, which uses the SerialCom
//same for the PulseSensor and TemperatureSensor
//store the references to these somehow in the ControlUnit, as members for instance
}
[...]
};
The SerialCom class is what everything uses to communicate with the external data source
1 2 3 4 5
class SerialCom {
public:
SerialCom(info on where to get data);
[...]
};
The Buffer class listens for requests to do stuff and performs those requests over it's SerialCom
1 2 3 4 5 6 7
class Buffer {
public:
Buffer(SerialCom* datastream);
silence() {
//send some command over the stream
}
};
Same for the other sensors, pass them a datastream to use via constructor, and they use that stream to fulfill the ControlUnit's requests.