def main(): signal.signal(signal.SIGINT, eee) print("main") pycrow.diagnostic(True) pycrow.create_udpgate(12, 10020) pycrow.start_spin() corenode = pycrow.libcrow.PyNode(incoming_packet, undelivered_packet) corenode.bind(12) #corenode = pycrow.create_node( # incoming_handler = incoming_handler, # undelivered_handler = undelivered_handler #) #corenode.bind(1) pycrow.join_spin()
def incoming(pack): try: msg = pack.message() dct = json.loads(msg) for k, v in dct.items(): s.set_status(k, v == 1) s.update() except Exception as ex: pass print("A") crowker_address = pycrow.address(".12.192.168.1.39:10009") pycrow.create_udpgate(12, 0) pycrow.diagnostic_setup(True, False) print("B") sub = pycrow.subscriber(incoming) sub.subscribe(crowker_address, "system_status", 2, 50, 2, 50) print("C") pycrow.start_spin() pycrow.start_resubscribe_thread(1000) print("D") s = StatusWidget(["aidan", "base", "base-user"], cols=3) s.set_status("base", True)
#!/usr/bin/env python3 import pycrow import json #pycrow.diagnostic_setup(True, True) pycrow.create_udpgate(12, 10042) class AliveRecord: def __init__(self, name, timestamp): alive_list = {} def incom(pack): print("incoming", pack.message()) try: data = json.loads(pack.message()) except: return def undel(pack): print("undeliver") node = pycrow.PyNode(incom, undel) node.bind(42) pycrow.start_spin() pycrow.join_spin()
#!/usr/bin/env python3 import io import numpy as np import cv2 import fcntl, os from PIL import Image import pycrow as crow import threading crow.create_udpgate(12, 10011) crow.set_crowker(".12.192.168.1.93:10009") thr = threading.Thread(target=crow.spin, args=()) thr.start() #crow.diagnostic_enable() data = None def handler(pack): global data data = pack.data() #print(data[-40:-1]) crow.subscribe("video_stream", handler, qos=0, ackquant=200, rqos=0, rackquant=200) while(True): if (data is not None): #print(len(data))
#!/usr/bin/env python3 import pycrow import time def foo(pack): print("hello_python") pycrow.create_udpgate(12, 10010) pycrow.start_spin() pycrow.enable_crowker_subsystem() pycrow.diagnostic_setup(True, False) addr = pycrow.address("") sub = pycrow.subscriber(foo) sub.subscribe(addr, "hello") crowker = pycrow.crowker.instance() crowker.set_info_mode(True) time.sleep(0.1) crowker.publish("hello", "data") pycrow.join_spin()
#!/usr/bin/env python3 #coding: utf-8 import sys import time import pycrow import numpy import threading pycrow.set_crowker(".12.109.173.108.206:10009") pycrow.create_udpgate(12, 10009) thr = threading.Thread(target=pycrow.spin) thr.start() while 1: time.sleep(1) arr = numpy.array([256,24]) arr = arr.astype(numpy.float32) bts = arr.tobytes() pycrow.publish("fltflt", bts)
#!/usr/bin/env python3 import tty import os, sys import pycrow import time import threading import termios import string import signal import random pycrow.create_udpgate(12) pycrow.start_spin() pycrow.diagnostic_setup(True) def sigint(code): pycrow.stop_spin() termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, oldterm) exit(0) signal.signal(signal.SIGINT, sigint) requestor = pycrow.requestor(".12.192.168.1.100:10009", "zippo/ctr", "__noanswer__") print("Connect") requestor.async_request("enable on".encode("utf-8"))