Пример #1
0
 def do_loadandgo(self, line):
     cmdline = line.split(' ')
     argc = len(cmdline)
     if (argc < 2):
         message = pm_proto_pb2.pmproto()
         message.type = pm_proto_pb2.pmproto.LOAD
         message.go = True
         message.cuestack = 0
         msg = message.SerializeToString()
         msg = transact_message(msg)
         if (msg is not None):
             message.ParseFromString(msg)
             if message.type == pm_proto_pb2.pmproto.ACK:
                 print "ACK"
             else:
                 print "NAK"
     elif (argc == 2):
         message = pm_proto_pb2.pmproto()
         message.type = pm_proto_pb2.pmproto.LOAD
         message.go = True
         message.cuestack = int(cmdline[0])
         message.fixture_id = int(cmdline[1])
         msg = message.SerializeToString()
         msg = transact_message(msg)
         if (msg is not None):
             message.ParseFromString(msg)
             if message.type == pm_proto_pb2.pmproto.ACK:
                 print "ACK"
             else:
                 print "NAK"
     print "Load and Go Cue " + line
Пример #2
0
 def do_go(self, line):
     cmdline = line.split(' ')
     if (line == ""):
         message = pm_proto_pb2.pmproto()
         message.type = pm_proto_pb2.pmproto.GO
         message.go = True
         msg = message.SerializeToString()
         msg = transact_message(msg)
         if (msg is not None):
             message.ParseFromString(msg)
             if message.type == pm_proto_pb2.pmproto.ACK:
                 print "ACK"
             else:
                 print "NAK"
     else:
         message = pm_proto_pb2.pmproto()
         message.type = pm_proto_pb2.pmproto.GO
         message.go = True
         message.cuestack = int(cmdline[0])
         msg = message.SerializeToString()
         msg = transact_message(msg)
         if (msg is not None):
             message.ParseFromString(msg)
             if message.type == pm_proto_pb2.pmproto.ACK:
                 print "ACK"
             else:
                 print "NAK"
Пример #3
0
def create_connection(ip_address):
    global prometheus_ip
    message = pm_proto_pb2.pmproto()
    message.type = pm_proto_pb2.pmproto.PING
    print "Connecting to ", ip_address
    print message
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((str(ip_address), PM_PROTO_PORT))
    msg = message.SerializeToString()
    print "sending", len(msg), "bytes"
    packed_len = varint.encode(len(msg))
    print "sent", s.send(packed_len + msg), "bytes"

    #s.sendto("hello",(ip_address,PM_PROTO_PORT))

    #try:
    if True:
        s.settimeout(1.0)
        msg_len = decode_socket(s)
        msg_buf = socket_read_n(s, msg_len)
        message.ParseFromString(msg_buf)
        print "Got", len(msg_buf), "bytes"
        print "Msg len: ", msg_len
        print message
        print msg_len
        if (message.type != pm_proto_pb2.pmproto.PING):
            prometheus_ip = ip_address

    else:
        print "No response!"
    s.settimeout(None)
Пример #4
0
def ping_pm():
    message = pm_proto_pb2.pmproto()
    message.type = pm_proto_pb2.pmproto.PING
    msg = message.SerializeToString()
    if transact_message(msg) is not None:
        return True
    else:
        return False
Пример #5
0
    def do_fixture(self, line):
        """
        [s]et fixture spec [@ color] [i intensity]
                0           1  2      3   4
        """
        cmdline = line.split(' ')
        argc = len(cmdline)
        has_i = False
        has_at = False
        fix_list = parseIntSet(cmdline[0])
        if (argc == 5):
            if (cmdline[3].lower() == 'i'):
                has_i = True
                intensity = cmdline[4]
            elif (cmdline[1].lower() == 'i'):
                has_i = True
                intensity = cmdline[2]
            if (cmdline[1] == '@'):
                has_at = True
                fix_at = cmdline[2]
            elif (cmdline[3] == '@'):
                has_at = True
                fix_at = cmdline[4]
        if (argc == 3):
            if (cmdline[1].lower() == 'as'):
                has_i = True
                intensity = cmdline[2]
            elif (cmdline[1] == '@'):
                has_at = True
                fix_at = cmdline[2]

        for fix in fix_list:
            message = pm_proto_pb2.pmproto()
            message.type = pm_proto_pb2.pmproto.FIXTURE
            message.fixture_id = int(fix)
            fix_patch[fix].captured = True
            if (has_i):
                fix_patch[fix].intensity = parse_intensity(intensity)
                message.intensity = parse_intensity(intensity)
            if (has_at):
                fix_patch[fix].cRGB = parse_color(fix_at, 0)
                message.colorspec = parse_color(fix_at, 0)
            msg = message.SerializeToString()
            msg = transact_message(msg)
            if (msg is not None):
                message.ParseFromString(msg)
                if message.type == pm_proto_pb2.pmproto.ACK:
                    print "ACK"
                else:
                    print "NAK"

        print "Set " + line