diff --git a/projects/OneGPIO/launch_scripts/h_a.csv b/projects/OneGPIO/launch_scripts/h_a.csv index 8c58a32..7608b6d 100644 --- a/projects/OneGPIO/launch_scripts/h_a.csv +++ b/projects/OneGPIO/launch_scripts/h_a.csv @@ -1,4 +1,4 @@ command_string,spawn,topic,append_bp_address,auto_restart,wait -python3 ../arduino_uno/arduino_gateway.py,no,local,no,no,4 +python3 ../arduino_uno/arduino_gateway.py,no,local,no,no,5 python3 ../shared/ws_gateway.py,no,local,no,no,1 python3 ../shared/open_browser.py,no,local,no,no,5 diff --git a/projects/OneGPIO/launch_scripts/h_e.csv b/projects/OneGPIO/launch_scripts/h_e.csv index 98c8766..28ceaaf 100644 --- a/projects/OneGPIO/launch_scripts/h_e.csv +++ b/projects/OneGPIO/launch_scripts/h_e.csv @@ -1,4 +1,4 @@ command_string,spawn,topic,append_bp_address,auto_restart,wait -python3 ../esp_8266/esp8266_gateway.py -i 192.168.2.185,no,local,no,no,4 +python3 ../esp_8266/esp8266_gateway.py -i 192.168.2.183,no,local,no,no,4 python3 ../shared/ws_gateway.py,no,local,no,no,1 python3 ../shared/open_browser.py esp8266,no,local,no,no,5 diff --git a/projects/OneGPIO/launch_scripts/tk_a.csv b/projects/OneGPIO/launch_scripts/tk_a.csv index 28f7a7f..bcecd1f 100644 --- a/projects/OneGPIO/launch_scripts/tk_a.csv +++ b/projects/OneGPIO/launch_scripts/tk_a.csv @@ -1,3 +1,3 @@ command_string,spawn,topic,append_bp_address,auto_restart,wait -python3 ../arduino_uno/arduino_gateway.py,no,local,no,no,4 +python3 ../arduino_uno/arduino_gateway.py,no,local,no,no,5 python3 ../shared/banyan_tkinter_demo.py -d arduino,no,local,no,no,0 diff --git a/projects/OneGPIO/launch_scripts/tk_e.csv b/projects/OneGPIO/launch_scripts/tk_e.csv index b8c78df..6a50cd2 100644 --- a/projects/OneGPIO/launch_scripts/tk_e.csv +++ b/projects/OneGPIO/launch_scripts/tk_e.csv @@ -1,3 +1,3 @@ command_string,spawn,topic,append_bp_address,auto_restart,wait -python3 ../esp_8266/esp8266_gateway.py -i 192.168.2.185,no,local,no,no,0 +python3 ../esp_8266/esp8266_gateway.py -i 192.168.2.183,no,local,no,no,0 python3 ../shared/banyan_tkinter_demo.py -d esp8266,no,local,no,no,0 diff --git a/projects/OneGPIO/launch_scripts_for_windows/h_r.csv b/projects/OneGPIO/launch_scripts_for_windows/h_r.csv deleted file mode 100644 index 4b4bf48..0000000 --- a/projects/OneGPIO/launch_scripts_for_windows/h_r.csv +++ /dev/null @@ -1,3 +0,0 @@ -command_string,spawn,topic,append_bp_address,auto_restart,wait -python rpi_gateway.py,no,rpi,yes,no,4 -python ../shared/ws_gateway.py,no,local,no,no,1 diff --git a/projects/OneGPIO/launch_scripts_for_windows/tk_r.csv b/projects/OneGPIO/launch_scripts_for_windows/tk_r.csv deleted file mode 100644 index 3b2dac2..0000000 --- a/projects/OneGPIO/launch_scripts_for_windows/tk_r.csv +++ /dev/null @@ -1,3 +0,0 @@ -command_string,spawn,topic,append_bp_address,auto_restart,wait -python ../raspberry_pi/bg4rpi.py,no,local,no,no,0 -python ../shared/banyan_tkinter_demo.py -d rpi,no,local,no,no,0 diff --git a/pypi_desc.md b/pypi_desc.md index 81f11e9..d17e08a 100644 --- a/pypi_desc.md +++ b/pypi_desc.md @@ -1,13 +1,15 @@ # The Python Banyan Framework -![](https://github.com/MrYsLab/python_banyan/blob/master/images/BanyanTree.png) The Python Banyan Framework is a lightweight, reactive framework used to create flexible, non-blocking, event driven, asynchronous applications. -It was designed primarily to aid in the implementation of real-time physical computing applications - for devices such as - the Raspberry Pi, ESP8266, and Arduino, -but may easily be applied to projects outside of the physical programming domain. + +Python Banyan comes with [full documentation](https://mryslab.github.io/python_banyan/#) + that includes a [User's Guide](https://mryslab.github.io/python_banyan/#users_guide/) + with hands-on examples, as well documentation for the + [OneGPIO Project](https://mryslab.github.io/python_banyan/#gpio_intro/) + that allows you to quickly and easily build reusable GPIO projects for the + Arduino, ESP-8266, and Raspberry Pi. It is being used by [Palace Games](https://www.raspberrypi.org/blog/raspberry-pi-escape-room/) to concurrently monitor hundreds of real-time sensors and actuators. @@ -21,10 +23,104 @@ multiple computers without having to change source code. [Java](https://github.com/MrYsLab/javabanyan). Components written in any of these languages can interact with components of a differing language without modification. * Runs on Python 2 or Python 3 (recommended). -New Features Introduced in 3.0 -* An MQTT Gateway to interconnect MQTT and Banyan networks so that data may be shared. -* A new "learn by example" [User's Guide](https://mryslab.github.io/python_banyan/) is provided. -* A component launcher that will allows you to launch Banyan components on a single -computer or multiple computers, all from a single command. -Use pip to install. View the full [installation instructions](https://mryslab.github.io/python_banyan/install/#installing-python-banyan_1) +To install, view the full [installation instructions.](https://mryslab.github.io/python_banyan/install/#installing-python-banyan_1) + +A Simple Banyan Echo Server: + +``` +import sys +from python_banyan.banyan_base import BanyanBase + + +class EchoServer(BanyanBase): + """ + This class is a simple Banyan echo server + """ + def __init__(self, ): + + # initialize the parent + super(EchoServer, self).__init__(process_name='EchoServer') + + # subscribe to receive 'echo' messages from the client + self.set_subscriber_topic('echo') + + # wait for messages to arrive + try: + self.receive_loop() + except KeyboardInterrupt: + self.clean_up() + sys.exit(0) + + def incoming_message_processing(self, topic, payload): + """ + Process incoming messages from the client + :param topic: message topic + :param payload: message payload + """ + # republish the message with a topic of reply + self.publish_payload(payload, 'reply') + + # extract the message number from the payload + print('Message number:', payload['message_number']) + +``` + +A Simple Banyan Echo Client: + +``` +import sys +from python_banyan.banyan_base import BanyanBase + + +class EchoClient(BanyanBase): + """ + This is a simple echo client derived from the BanyanBase class. + It sends out a series of messages and expects an + echo reply from the server. + """ + + def __init__(self): + + # initialize the parent + super(EchoClient, self).__init__(process_name='EchoClient') + + # accept banyan messages with the topic of reply + self.set_subscriber_topic('reply') + + # sequence number of messages and total number of messages to send + self.message_number = self.number_of_messages = 10 + + # send the first message - make sure that the server is already started + self.publish_payload({'message_number': self.message_number}, 'echo') + + # get the reply messages + try: + self.receive_loop() + except KeyboardInterrupt: + self.clean_up() + sys.exit(0) + + def incoming_message_processing(self, topic, payload): + """ + Process incoming messages received from the echo client + :param topic: Message Topic string + :param payload: Message Data + """ + + # When a message is received and its number is zero, finish up. + if payload['message_number'] == 0: + print(str(self.number_of_messages) + ' messages sent and received. ') + input('Press enter to exit.') + self.clean_up() + sys.exit(0) + # bump the message number and send the message out + else: + self.message_number -= 1 + if self.message_number >= 0: + self.publish_payload({'message_number': self.message_number}, 'echo') + + +``` + +This project was developed with [Pycharm](https://www.jetbrains.com/pycharm/) ![logo](https://github.com/MrYsLab/python_banyan/blob/master/images/icon_PyCharm.png)