diff --git a/DecisionSystem/mqttvoter.py b/DecisionSystem/mqttvoter.py index 0c0ccb5..c6e8dd3 100644 --- a/DecisionSystem/mqttvoter.py +++ b/DecisionSystem/mqttvoter.py @@ -1,21 +1,32 @@ -from voter import Voter +from DecisionSystem.voter import Voter import Messaging.mqttsession as ms from Messaging.packmessage import PackMessage +from DecisionSystem.vote import Vote class MqttVoter(Voter): - def __init__(self): + def __init__(self, host = "10.0.123.11"): # Should use a factory here to always get the same session. # Just going to use a singleton for now, as there should only be # one session in the program. ms.client = ms.Client() - ms.host = "10.0.123.11" + ms.connect() def submit_vote(self): + pass - def set_vote(self): - pass + def set_vote(self, vote): + if isinstance(vote, Vote): + self._vote = vote + return True + else: + return False def get_vote(self): - pass \ No newline at end of file + return self._vote + + # This is meant to be the mqtt callback... Should've documented this earlier. + def request_vote(self, client, userdata, message): + # Perhaps do some checking to see what is being voted on... + self.submit_vote() \ No newline at end of file