|
| 1 | +# zmq_banyan_local_station_simulator.py |
| 2 | + |
| 3 | +# requires Banyan 'backplane' |
| 4 | + |
| 5 | +""" |
| 6 | +Python-Banyan Providence: |
| 7 | +
|
| 8 | +Copyright (c) 2018-2019 Alan Yorinks All right reserved. |
| 9 | +
|
| 10 | +Python Banyan is free software; you can redistribute it and/or |
| 11 | +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
| 12 | +Version 3 as published by the Free Software Foundation; either |
| 13 | +or (at your option) any later version. |
| 14 | +This library is distributed in the hope that it will be useful, |
| 15 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | +General Public License for more details. |
| 18 | +
|
| 19 | +You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
| 20 | +along with this library; if not, write to the Free Software |
| 21 | +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 | +
|
| 23 | +""" |
| 24 | + |
| 25 | +import time |
| 26 | + |
| 27 | +from python_banyan.banyan_base import BanyanBase |
| 28 | + |
| 29 | + |
| 30 | +class Bpub(BanyanBase): |
| 31 | + |
| 32 | + def __init__(self): |
| 33 | + |
| 34 | + # initialize the base class |
| 35 | + super(Bpub, self).__init__(process_name='Bpub') |
| 36 | + self.set_subscriber_topic('from_pico') |
| 37 | + |
| 38 | + # send a message |
| 39 | + # self.publish_payload({'from_banyan': 'hello_world'}, 'figura') |
| 40 | + # self.count = 0 |
| 41 | + |
| 42 | + # get the reply messages |
| 43 | + try: |
| 44 | + self.receive_loop() |
| 45 | + except KeyboardInterrupt: |
| 46 | + self.clean_up() |
| 47 | + sys.exit(0) |
| 48 | + |
| 49 | + while True: |
| 50 | + # send command to turn Led_0 ON |
| 51 | + # self.publish_payload({'Led_0': self.count}, 'figura') |
| 52 | + # self.count += 1 |
| 53 | + time.sleep(0.01) |
| 54 | + # print('published ON') |
| 55 | + |
| 56 | + # send command to turn Led_0 OFF |
| 57 | + # self.publish_payload({'Led_0': self.count}, 'figura') |
| 58 | + # self.count += 1 |
| 59 | + |
| 60 | + # time.sleep(0.01) |
| 61 | + # print('published OFF') |
| 62 | + |
| 63 | + def incoming_message_processing(self, topic, payload): |
| 64 | + """ |
| 65 | + Process incoming messages received from the echo client |
| 66 | + :param topic: Message Topic string |
| 67 | + :param payload: Message Data |
| 68 | + """ |
| 69 | + |
| 70 | + # When a message is received and its number is zero, finish up. |
| 71 | + print(f'topic: {topic} payload: {payload}') |
| 72 | + |
| 73 | + |
| 74 | +b = Bpub() |
0 commit comments