Implement MqttVoter methods

This commit is contained in:
DSTO\pivatom
2018-12-18 10:13:18 +10:30
parent 6efeb5ae05
commit eb9f40bdf1

View File

@@ -1,21 +1,32 @@
from voter import Voter from DecisionSystem.voter import Voter
import Messaging.mqttsession as ms import Messaging.mqttsession as ms
from Messaging.packmessage import PackMessage from Messaging.packmessage import PackMessage
from DecisionSystem.vote import Vote
class MqttVoter(Voter): 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. # Should use a factory here to always get the same session.
# Just going to use a singleton for now, as there should only be # Just going to use a singleton for now, as there should only be
# one session in the program. # one session in the program.
ms.client = ms.Client() ms.client = ms.Client()
ms.host = "10.0.123.11" ms.connect()
def submit_vote(self): def submit_vote(self):
pass pass
def set_vote(self): def set_vote(self, vote):
pass if isinstance(vote, Vote):
self._vote = vote
return True
else:
return False
def get_vote(self): def get_vote(self):
pass 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()