From 3387a54133818a98d5f54645bcdb2e4d9f8dae16 Mon Sep 17 00:00:00 2001 From: "DSTO\\pivatom" Date: Wed, 19 Dec 2018 16:29:57 +1030 Subject: [PATCH] Remove client from commander object. --- DecisionSystem/commander.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DecisionSystem/commander.py b/DecisionSystem/commander.py index 13e1392..c9258b8 100644 --- a/DecisionSystem/commander.py +++ b/DecisionSystem/commander.py @@ -7,14 +7,14 @@ class Commander: def __init__(self, timeout = 60): self.timeout = timeout self._votes = [] - self._client = ms.Client() + ms.Client() def on_message(client, userdata, message): self._votes.append(umsgpack.unpackb(message.payload)) - self.add_subscription("FakeSwarm/FirstTest", on_message) + ms.client.subscribe("FakeSwarm/FirstTest", on_message) - self._client.loop_start() + ms.client.loop_start() def make_decision(self): votes = self._votes @@ -22,15 +22,14 @@ class Commander: for vote in votes: continue - def get_votes(self, topic, message, qos=0): # Publish a message that votes are needed. ms.client.publish(topic, message, qos) time.sleep(self.timeout) - make_decision() + self.make_decision() def add_subscription(self, topic, callback=None, qos=0): - self._client.subscribe(topic) + ms.client.subscribe(topic) if callback is not None: - self._client.message_callback_add(topic, callback) \ No newline at end of file + ms.client.message_callback_add(topic, callback) \ No newline at end of file