示例#1
0
def init(HOSTNAME):
    global network
    network = network_init(
        hostname=HOSTNAME,
        role="client",
        discovery_multicastGroup=settings.discovery_multicastGroup,
        discovery_multicastPort=settings.discovery_multicastPort,
        discovery_responsePort=settings.discovery_responsePort,
        pubsub_pubPort=settings.pubsub_pubPort,
        message_callback=network_message_handler,
        status_callback=network_status_handler)
    #global hostname
    #hostname = HOSTNAME
    global main
    main = Main(HOSTNAME, network)
    main.daemon = True
    main.start()

    network.subscribe_to_topic("system")  # subscribe to all system messages
    network.subscribe_to_topic("reboot")
    network.subscribe_to_topic("process_images_and_report")
    network.subscribe_to_topic("capture_image")
    network.subscribe_to_topic("remote_update")
    network.subscribe_to_topic(HOSTNAME)
    network.subscribe_to_topic("client_monitor_request")
    network.subscribe_to_topic("return_raw_images")

    return main
示例#2
0
def init(HOSTNAME):
    global main
    # setup LED control and door sensor
    #io_init()
    wpi.wiringPiSetup()
    # global network
    network = network_init(
        hostname=HOSTNAME,
        role="server",
        discovery_multicastGroup=settings.discovery_multicastGroup,
        discovery_multicastPort=settings.discovery_multicastPort,
        discovery_responsePort=settings.discovery_responsePort,
        pubsub_pubPort=settings.pubsub_pubPort,
        message_callback=network_message_handler,
        status_callback=network_status_handler)
    network.subscribe_to_topic("system")  # subscribe to all system messages
    network.subscribe_to_topic("found_beer")
    network.subscribe_to_topic("update_complete")
    network.subscribe_to_topic("image_capture_from_camera_unit")
    network.subscribe_to_topic("client_monitor_response")
    network.subscribe_to_topic("receive_image_overlay")
    network.subscribe_to_topic("receive_image_data")
    network.subscribe_to_topic("classification_data_to_conductor")

    main = Main(network)
    return main
示例#3
0
 def __init__(self, hostname, network_message_handler, network_status_handler):
     self.hostname = hostname
     self.thirtybirds = network_init(
         hostname=hostname,
         role="server",
         discovery_multicastGroup=settings.discovery_multicastGroup,
         discovery_multicastPort=settings.discovery_multicastPort,
         discovery_responsePort=settings.discovery_responsePort,
         pubsub_pubPort=settings.pubsub_pubPort,
         message_callback=network_message_handler,
         status_callback=network_status_handler
     )
示例#4
0
def init(HOSTNAME):
    global main
    global network
    global utils

    wpi.wiringPiSetup()

    network = network_init(
        hostname=HOSTNAME,
        role="client",
        discovery_multicastGroup=settings.discovery_multicastGroup,
        discovery_multicastPort=settings.discovery_multicastPort,
        discovery_responsePort=settings.discovery_responsePort,
        pubsub_pubPort=settings.pubsub_pubPort,
        message_callback=network_message_handler,
        status_callback=network_status_handler)

    utils = Utils(HOSTNAME)

    main = Main(network)
    #main.daemon = True
    #main.start()

    # TODO: clean this up
    # initialize shelf power control
    wpi.pinMode(27, wpi.OUTPUT)
    wpi.pinMode(28, wpi.OUTPUT)
    wpi.pinMode(29, wpi.OUTPUT)
    wpi.digitalWrite(27, 1)
    wpi.digitalWrite(28, 1)
    wpi.digitalWrite(29, 1)

    network.subscribe_to_topic("system")  # subscribe to all system messages
    network.subscribe_to_topic("set_light_level")
    network.subscribe_to_topic("client_monitor_request")
    network.subscribe_to_topic("reboot")

    #network.subscribe_to_topic("client_monitor_request")

    return main
示例#5
0
    topic = msg[0]
    payload = eval(msg[1])
    if topic == "client_monitor_response":
        if payload == None:
            return
        else:
            client_monitor_server.add_to_queue(payload[0], payload[2],
                                               payload[1])


network = network_init(
    hostname=HOSTNAME,
    role="server",
    discovery_multicastGroup=settings.discovery_multicastGroup,
    discovery_multicastPort=settings.discovery_multicastPort,
    discovery_responsePort=settings.discovery_responsePort,
    pubsub_pubPort=settings.pubsub_pubPort,
    message_callback=network_message_handler,
    status_callback=network_status_handler)


class Thirtybirds_Client_Monitor_Server(threading.Thread):
    def __init__(self, network, hostnames, update_period=45):
        threading.Thread.__init__(self)
        self.update_period = update_period
        self.current_clients = {}
        self.remembered_clients = {}
        self.network = network
        self.hostnames = hostnames
        self.queue = Queue.Queue()