Esempio n. 1
0
def main():
    global done
    done = False
    # Connect to the central server
    print "\nIPC.IPC_connect(%s)" % MODULE3_NAME
    IPC.IPC_connect(MODULE3_NAME)

    # Subscribe to the messages that this module listens to.
    print "\nIPC_subscribe(%s, %s, %s)" % \
          (MSG1, msg1Handler_3.__name__, MODULE3_NAME)
    IPC.IPC_subscribe(MSG1, msg1Handler_3, MODULE3_NAME)

    # Subscribe to the messages that this module listens to.
    print "\nIPC_subscribe(%s, %s, %s)" % \
          (MSG2, msg2Handler_3.__name__, MODULE3_NAME)
    IPC.IPC_subscribe(MSG2, msg2Handler_3, MODULE3_NAME)

    # Subscribe a handler for tty input. Typing "q" will quit the program.
    print "\nIPC_subscribeFD(%d, stdinHnd_3, %s)" % \
          (sys.stdin.fileno(), MODULE3_NAME)
    IPC.IPC_subscribeFD(sys.stdin.fileno(), stdinHnd_3, MODULE3_NAME)

    print "\nType 'q' to quit"
    while (not done):
        IPC.IPC_listen(250)

    IPC.IPC_disconnect()
Esempio n. 2
0
def main():
    global done
    done = False
    # Connect to the central server
    print "\nIPC.IPC_connect(%s)" % MODULE2_NAME
    IPC.IPC_connect(MODULE2_NAME)

    # Define the messages that this module publishes
    print "\nIPC.IPC_defineMsg(%s, IPC_VARIABLE_LENGTH, %s)" % \
          (MSG2, MSG2_FORMAT)
    IPC.IPC_defineMsg(MSG2, IPC.IPC_VARIABLE_LENGTH, MSG2_FORMAT)

    print "\nIPC.IPC_defineMsg(%s, IPC_VARIABLE_LENGTH, %s)" % \
          (RESPONSE1, RESPONSE1_FORMAT)
    IPC.IPC_defineMsg(RESPONSE1, IPC.IPC_VARIABLE_LENGTH, RESPONSE1_FORMAT)

    # Subscribe to the messages that this module listens to
    print "\nIPC.IPC_subscribeData(%s,%s, %s)" % \
          (MSG1, msg1Handler.__name__, MODULE2_NAME)
    IPC.IPC_subscribeData(MSG1, msg1Handler, MODULE2_NAME)

    print "\nIPC.IPC_subscribeData(%s, %s, %s, %s)" % \
          (QUERY1 , queryHandler.__name__, MODULE2_NAME, T1.__name__)
    IPC.IPC_subscribeData(QUERY1, queryHandler, MODULE2_NAME, T1)

    # Subscribe a handler for tty input. Typing "q" will quit the program.
    print "\nIPC_subscribeFD(%d, stdinHnd, %s)" % \
          (sys.stdin.fileno(), MODULE2_NAME)
    IPC.IPC_subscribeFD(sys.stdin.fileno(), stdinHnd, MODULE2_NAME)

    print "\nType 'q' to quit"
    while (not done):
        IPC.IPC_listen(250)

    IPC.IPC_disconnect()
Esempio n. 3
0
def main():
    global done, first
    done = False
    first = True

    # Connect to the central server
    print "\nIPC.IPC_connect(%s)" % MODULE1_NAME
    print IPC.IPC_connect, sys.stdin, sys.stdin.fileno()
    IPC.IPC_connect(MODULE1_NAME)
    print "HERE1"

    IPC.IPC_subscribeConnect(connect1Hnd, None)
    IPC.IPC_subscribeConnect(connect2Hnd, None)
    IPC.IPC_subscribeDisconnect(disconnect1Hnd, None)

    # Define the named formats that the modules need
    print "\nIPC.IPC_defineFormat(%s, %s)" % (T1_NAME, T1_FORMAT)
    IPC.IPC_defineFormat(T1_NAME, T1_FORMAT)
    print "\nIPC.IPC_defineFormat(%s, %s)" % (T2_NAME, T2_FORMAT)
    IPC.IPC_defineFormat(T2_NAME, T2_FORMAT)

    # Define the messages that this module publishes
    print "\nIPC.IPC_defineMsg(%s, IPC_VARIABLE_LENGTH, %s)" % (MSG1,
                                                                MSG1_FORMAT)
    IPC.IPC_defineMsg(MSG1, IPC.IPC_VARIABLE_LENGTH, MSG1_FORMAT)

    IPC.IPC_subscribeHandlerChange(MSG1, handlerChangeHnd, None)
    IPC.IPC_subscribeHandlerChange(MSG1, handlerChangeHnd2, None)

    print "\nIPC.IPC_defineMsg(%s, IPC_VARIABLE_LENGTH, %s)" % \
          (QUERY1, QUERY1_FORMAT)
    IPC.IPC_defineMsg(QUERY1, IPC.IPC_VARIABLE_LENGTH, QUERY1_FORMAT)
    IPC.IPC_subscribeHandlerChange(QUERY1, handlerChangeHnd, None)

    # Subscribe to the messages that this module listens to.
    # NOTE: No need to subscribe to the RESPONSE1 message, since it is a
    #       response to a query, not a regular subscription!
    print "\nIPC.IPC_subscribeData(%s, msg2Handler, %s)" % (MSG2, MODULE1_NAME)
    IPC.IPC_subscribe(MSG2, msg2Handler, MODULE1_NAME)

    # Subscribe a handler for tty input.
    #  Typing "q" will quit the program; Typing "m" will send MSG1;
    #  Typing "r" will send QUERY1 ("r" for response)
    print "\nIPC.IPC_subscribeFD(%d, stdinHnd, %s)" % \
          (sys.stdin.fileno(), MODULE1_NAME)
    IPC.IPC_subscribeFD(sys.stdin.fileno(), stdinHnd, MODULE1_NAME)

    print "\nType 'm' to send %s; Type 'r' to send %s; Type 'q' to quit" % \
          (MSG1, QUERY1)

    while (not done):
        IPC.IPC_listen(250)

    IPC.IPC_disconnect()