Skip to content

Make setCom virtual?

In !215 (merged) it was seen that some devices (in that case, a chiller) need some special handling of the serial communication and that the properties of the communication are not static but can depend on which commands are being sent.

I wonder if it makes sense to make the setCom method of IChiller a virtual method? As in:

virtual void setCom(std::shared_ptr<ICom> com);

instead of what we have now:

void setCom(std::shared_ptr<ICom> com);

We can leave the default implementation in IChiller's implementation but in those cases where a chiller/device want to enforce a specific implementation of ICom (e.g. enforce TextSerialCom only) it could be beneficial for those chiller/device implementations to add this check in their implementation of setCom.

I see that setCom exists currently in IChiller, IMeter, and IPowerSupply. If we make changes as described above, then we should coherently make them across all three interfaces.

Edited by Daniel Joseph Antrim