Certain commands need to be sent out to sensors. I want to have one sensor class that represents a group of sensors. The idea is, during instantiation to link this sensor object with the set of commands that it should use. Eg. Two temperature sensors from different vendor would be represented by the same class but linked to different sets of commands.
I want to hide the complexity of the command from the user so the user only calls a method like getTemp() or setMaxTemp(20) without passing the command.
Challenge:
Let’s say there is a new temp sensor that only supports setMaxTemp(). In this case I will use a different sensor class but I still want to use the set max temperature command that is already stored. And/or maybe the same command set with different manipulation on the data.
So we have: 1. Sensor class 2. Command set 3. Data 4. Data manipulation
Question:
Linking dynamically these to form the correct request String and sending it to the correct sensor class took me a couple of days and I have not yet come up with a good approach with the conventional Java approach.
Do I need to go for rule engines? (Since the application will run in Raspberry Pi I’m not sure if it can handle it). Or is there a certain pattern to handle this kind of scenario? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire