I'm working on project, connected to hardware, especially sensors and actuators. Both sensors and actuators can be digital and analog. Example of all four types:
- digital sensor: returns one of several possible states (i.e. "presence"/"absence"/"can't find out")
- analog sensor: returns any value from range, but results are round according to scale interval (i.e. temperature sensor returns any value from 0 to 60 Celsius, with one digit precision, for example 18.5 C)
- digital actuator: can get one of several possible states (i.e. motor, that opens window, can set window "open"/"half-open"/"closed")
- analog actuator: can gat any value from range, and value is also rounded according to scale interval (i.e. fan rotations per second can be from 0 to 10, for example 9.5)
The question is, how I can represent these classes, without violating OOP principles, at least make design clear and logical.
One of my solutions is on the picture: uml_diagram_solution_1 But I think this solution is "ugly"
Next solution is here: uml_diagram_solution_2 This solution is also bad, because of redundant attributes and not uniform methods' names.
What do you suggest? Maybe there exists design pattern that solves my problem? Thanks for help!
Aucun commentaire:
Enregistrer un commentaire