Example #1
0
def send_all_off(dev):
	cv = [0 for v in range(0, 512)]
	try:
		sent = dev.send_multi_value(1, cv)
	except:
		dev = pyudmx.uDMXDevice()
		dev.open()
Example #2
0
def main():
    """
    How to control a DMX light through an Anyma USB controller
    """

    # Channel value list for channels 1-512
    cv = [0 for v in range(0, 512)]

    # Create an instance of the DMX controller and open it
    print("Opening DMX controller...")
    dev = pyudmx.uDMXDevice()
    # This will automagically find a single Anyma-type USB DMX controller
    dev.open()
    # For informational purpose, display what we know about the DMX controller
    print(dev.Device)

    # Send messages to the light changing it to red, then green, then blue
    # This is the "hard way" to do it, but illustrates how it's done

    print("Setting to red...")
    cv[0] = 255  # red
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to red")
    sleep(3.0)

    print("Setting to green...")
    cv[0] = 0  # red
    cv[1] = 255  # green
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to green")
    sleep(3.0)

    print("Setting to blue...")
    cv[0] = 0  # red
    cv[1] = 0  # green
    cv[2] = 255  # blue
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to blue")
    sleep(3.0)

    # Here's an easier way to do it

    print("And, again the easier way")
    send_rgb(dev, 255, 0, 0, 128)
    sleep(3.0)
    send_rgb(dev, 0, 255, 0, 128)
    sleep(3.0)
    send_rgb(dev, 0, 0, 255, 128)
    sleep(3.0)

    print("Reset all channels and close..")
    # Turns the light off
    cv = [0 for v in range(0, 512)]
    dev.send_multi_value(1, cv)
    dev.close()
Example #3
0
def main():
    """
    How to control a DMX light through an Anyma USB controller
    """

    # Channel value list for channels 1-512
    cv = [0 for v in range(0, 512)]

    # Create an instance of the DMX controller and open it    
    print("Opening DMX controller...")
    dev = pyudmx.uDMXDevice()
    # This will automagically find a single Anyma-type USB DMX controller
    dev.open()
    # For informational purpose, display what we know about the DMX controller
    print(dev.Device)

    # Send messages to the light changing it to red, then green, then blue
    # This is the "hard way" to do it, but illustrates how it's done

    print("Setting to red...")
    cv[0] = 255  # red
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to red")
    sleep(3.0)

    print("Setting to green...")
    cv[0] = 0  # red
    cv[1] = 255  # green
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to green")
    sleep(3.0)

    print("Setting to blue...")
    cv[0] = 0  # red
    cv[1] = 0  # green
    cv[2] = 255  # blue
    cv[6] = 128  # dimmer to half value
    sent = dev.send_multi_value(1, cv)
    print("Set to blue")
    sleep(3.0)

    # Here's an easier way to do it

    print("And, again the easier way")
    send_rgb(dev, 255, 0, 0, 128)
    sleep(3.0)
    send_rgb(dev, 0, 255, 0, 128)
    sleep(3.0)
    send_rgb(dev, 0, 0, 255, 128)
    sleep(3.0)

    print("Reset all channels and close..")
    # Turns the light off
    cv = [0 for v in range(0, 512)]
    dev.send_multi_value(1, cv)
    dev.close()
def main():
    cv = [0 for v in range(0, 512)]
    dev = pyudmx.uDMXDevice()
    dev.open()
    while True:
        send_rgb(dev, 255, 20, 147)
        sleep(3.0)
        send_rgb(dev, 0, 0, 255)
        sleep(3.0)
    dev.close()
Example #5
0
 def __connect(self):
     # Try to close if exists
     if self.udmx is not None:
         try:
             self.udmx.close()
         except Exception:
             pass
     # Get new device
     self.udmx = pyudmx.uDMXDevice()
     self.udmx.open()
Example #6
0
 def __connect(self):
     # Try to close if exists
     if self.__udmx is not None:
         try:
             self.__udmx.close()
         except Exception:
             pass
     # Get new device
     self.__udmx = pyudmx.uDMXDevice()
     self.__udmx.open(self.__udmx_vendor_id, self.__udmx_product_id,
                      self.__udmx_bus, self.__udmx_address)
Example #7
0
def send_all_fade(dev, speed):
	cv = [0 for v in range(0, 512)]
	for x in range(0,31):
		cv[5+(x*8)] = 128
		cv[6+(x*8)] = 255
		cv[4+(x*8)] = speed
	try:
		sent = dev.send_multi_value(1, cv)
	except:
		dev = pyudmx.uDMXDevice()
		dev.open()
Example #8
0
def dmx_init():
    global _dmx
    print('DEBUG:dmx:48 Starting DMX controller')
    _dmx = pyudmx.uDMXDevice()
    if HAVE_DMX_HARDWARE: _dmx.open()

    # Start a separate thread for the USB data transfers (IO bound)
    if not _dmx_transfer:
        transfer_loop = threading.Thread(target=usb_transfer_loop)
        transfer_loop.start() # Start the loop; stop it by setting _dmx_transfer to False

    dmx_blank()
Example #9
0
def send_all_color(dev,r,g,b,bright):
	cv = [0 for v in range(0, 512)]
	for x in range(0,31):
		cv[0+(x*8)] = r
		cv[1+(x*8)] = g
		cv[2+(x*8)] = b
		cv[6+(x*8)] = bright
	try:
		sent = dev.send_multi_value(1, cv)
	except:
		dev = pyudmx.uDMXDevice()
		dev.open()
Example #10
0
def run_multicolor_test():
    udmx = pyudmx.uDMXDevice()
    res = udmx.open()
    print("pyudmx open: ", res)
    spectrometer = SpotReader()
    print("spectrometer open")
    t0 = time.time()

    readings = []
    udmx.send_multi_value(2, [20, 20, 20, 0, 0, 0])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [20, 20, 20, 20, 0, 0])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [20, 20, 20, 20, 0, 20])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [0, 0, 0, 0, 20, 0, 0])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [0, 0, 0, 0, 20, 20, 0])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [20, 20, 20, 20, 20, 0])
    res1 = spectrometer.read()
    print("Sample ({})s: x/255.  LUX: {} CCT: {}K  CRI: {}".format(
        int(time.time() - t0), res1['lux'], res1['cct'], res1['cri']))
    readings.append(res1)

    udmx.send_multi_value(2, [40, 10, 40, 5, 5, 10])

    with open('rgbwauv.json', 'w') as f:
        f.write(json.dumps(readings))
Example #11
0
def send_dmx_message(message_tokens):
    """
    Send the DMX message defined by the command line arguments (message tokens).
    The first argument/token is the DMX channel.
    The remaining argument(s).token(s) are DMX values.
    """

    # Open the uDMX USB device
    dev = pyudmx.uDMXDevice()
    if not dev.open():
        print("Unable to find and open uDMX interface")
        return False

    # Translate the tokens into integers.
    # trans_tokens[0] will be the one-based channel number (1-512) as an integer.
    # The remaining tokens will be zero-based values (0-255) as integers.
    trans_tokens = translate_message_tokens(message_tokens)

    if len(trans_tokens) == 2:
        # Single value message
        if verbose:
            print("Sending single value message channel:", trans_tokens[0],
                  "value:", trans_tokens[1])
        n = dev.send_single_value(trans_tokens[0], trans_tokens[1])
        if verbose:
            print("Sent", n, "value")
    else:
        # Multi-value message
        if verbose:
            print("Sending multi-value message channel:", trans_tokens[0],
                  "values:", trans_tokens[1:])
        n = dev.send_multi_value(trans_tokens[0], trans_tokens[1:])
        if verbose:
            print("Sent", n, "values")

    # This may not be absolutely necessary, but it is safe.
    # It's the closest thing to a close() method.
    dev.close()

    # Returns True if something was sent
    return n > 0
Example #12
0
def send_dmx_message(message_tokens):
    """
    Send the DMX message defined by the command line arguments (message tokens).
    The first argument/token is the DMX channel.
    The remaining argument(s).token(s) are DMX values.
    """

    # Open the uDMX USB device
    dev = pyudmx.uDMXDevice()
    if not dev.open():
        print("Unable to find and open uDMX interface")
        return False

    # Translate the tokens into integers.
    # trans_tokens[0] will be the one-based channel number (1-512) as an integer.
    # The remaining tokens will be zero-based values (0-255) as integers.
    trans_tokens = translate_message_tokens(message_tokens)

    if len(trans_tokens) == 2:
        # Single value message
        if verbose:
            print("Sending single value message channel:", trans_tokens[0], "value:", trans_tokens[1])
        n = dev.send_single_value(trans_tokens[0], trans_tokens[1])
        if verbose:
            print("Sent", n, "value")
    else:
        # Multi-value message
        if verbose:
            print("Sending multi-value message channel:", trans_tokens[0], "values:", trans_tokens[1:])
        n = dev.send_multi_value(trans_tokens[0], trans_tokens[1:])
        if verbose:
            print("Sent", n, "values")

    # This may not be absolutely necessary, but it is safe.
    # It's the closest thing to a close() method.
    dev.close()

    # Returns True if something was sent
    return n > 0
Example #13
0
def handle_dialog(res, req):
    user_id = req['session']['user_id']
    req['request']['original_utterance'] = req['request'][
        'original_utterance'].replace('.', '')
    req['request']['original_utterance'] = req['request'][
        'original_utterance'].replace(',', '')
    req['request']['original_utterance'] = numify(
        req['request']['original_utterance'])
    print(req['request']['original_utterance'])
    if req['session']['new']:
        UserInfo[user_id] = 0
        res['response'][
            'text'] = 'Приветсвую вас, это навык управления Осветительными DMX устройствами в МИЭМе. Чем я могу быть полезна?'
        res['response']['buttons'] = get_suggests(0)
        return
    if UserInfo[user_id] == 0:
        if req['request']['original_utterance'].lower() in [
                'журнал посещений',
        ]:
            f = open("/home/pi/Alisa_DMX/server/log_а.txt", "r")
            journal = f.read()
            journal = [i for i in journal.split('\n')]
            journal = journal[-5:]
            journal = '\n'.join(journal)
            journal = "Последние 5 записей:\n" + journal
            res['response']['text'] = journal
            res['response']['buttons'] = get_suggests(1)
            return
        elif req['request']['original_utterance'].lower() in [
                'список устройств',
                'список подключенных устройств',
        ]:
            num = 0
            while os.path.exists(
                    "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%d" %
                (num + 1)):
                num += 1
            res['response']['text'] = "Найденой устройств: %d" % (int(num))
            res['response']['buttons'] = get_suggests(3)
            return
        elif req['request']['original_utterance'].lower() in [
                'прибор 1',
                'прибор 2',
                'прибор 3',
                'прибор 4',
                'прибор 5',
                'прибор 6',
                'прибор 7',
                'прибор 8',
                'прибор 9',
                'прибор 10',
        ]:
            name = req['request']['original_utterance'].lower()
            if os.path.exists(
                    "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%s" %
                (name[-1:])):
                res['response']['text'] = read_device1(int(name[-1:]))
                res['response']['buttons'] = get_suggests(3)
            else:
                res['response']['text'] = "Устройство не найдено."
                res['response']['buttons'] = get_suggests(3)
            return
        elif req['request']['original_utterance'].lower().find(
                "мастер контроль") >= 0:
            res['response'][
                'text'] = "Для начала, я попрошу вас авторизироваться. Если у вас нет аккаунта, обратитесь к администратору. Введите свои почту/пароль в формате:\[email protected]|password"
            return
        elif req['request']['original_utterance'].lower() in [
                'назад',
                '',
        ]:
            res['response']['text'] = 'Чем я могу быть полезна?'
            res['response']['buttons'] = get_suggests(0)
            return
        elif req['request']['original_utterance'].lower().find(
                "@miemhseru|") >= 0:
            f = open("/home/pi/Alisa_DMX/server/log_pas.txt", "r")
            line = f.readline()
            while line:
                if line == req['request']['original_utterance']:
                    UserInfo[user_id] = 1
                    num = 0
                    User_s[user_id] = []
                    User_val[user_id] = []
                    User_ch[user_id] = []
                    User_dev[user_id] = pyudmx.uDMXDevice()
                    User_dev[user_id].open()
                    while os.path.exists(
                            "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%d" %
                        (num + 1)):
                        num += 1
                    for j in range(num):
                        s, val = scan(j + 1)
                        User_s[user_id].append(s)
                        User_val[user_id].append(val)
                        User_ch[user_id].append(len(val))
                    d = 0
                    for i in User_s[user_id]:
                        d += 1
                    res['response'][
                        'text'] = "Рада вас видеть снова!\nЗагружено устройств: %d\nКонфигурация завершена" % d
                    res['response']['buttons'] = get_suggests(1)
                    f.close()
                    subprocess.call("echo '%s %s %s %s' >> 'log_а.txt'" %
                                    (time.strftime("%H:%M:%S"), date.today(),
                                     user_id, line[:-5]),
                                    shell=True,
                                    cwd='/home/pi/Alisa_DMX/server/')
                    return
                line = f.readline()
            if UserInfo[user_id] == 0:
                res['response'][
                    'text'] = "Простите, такого пользователя не обнаружено. Проверьте правильность ввода или обратитесь к администратору."
            f.close()
            return
        else:
            res['response'][
                'text'] = "Команда не опознана или у вас не полномочий"
            res['response']['buttons'] = get_suggests(1)
    if UserInfo[user_id] == 1:
        if req['request']['original_utterance'].lower() in [
                'назад',
        ]:
            res['response'][
                'text'] = 'Чем я могу быть полезна? (Мастер контроль)'
            res['response']['buttons'] = get_suggests(4)
            return
        elif req['request']['original_utterance'].lower() in [
                'журнал посещений',
        ]:
            f = open("/home/pi/Alisa_DMX/server/log_а.txt", "r")
            journal = f.read()
            journal = [i for i in journal.split('\n')]
            journal = journal[-5:]
            journal = '\n'.join(journal)
            journal = "Последние 5 записей:\n" + journal
            res['response']['text'] = journal
            res['response']['buttons'] = get_suggests(1)
            return
        elif req['request']['original_utterance'].lower() in [
                'журнал действий',
        ]:
            f = open("/home/pi/Alisa_DMX/DMX_Devices/Config/log_online.txt",
                     "r")
            journal = f.read()
            journal = [i for i in journal.split('\n')]
            journal = journal[-5:]
            journal = '\n'.join(journal)
            journal = "Последние 5 записей:\n" + journal
            res['response']['text'] = journal
            res['response']['buttons'] = get_suggests(1)
            return
        elif req['request']['original_utterance'].lower() in [
                'список устройств',
                'список подключенных устройств',
        ]:
            num = 0
            while os.path.exists(
                    "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%d" %
                (num + 1)):
                num += 1
            res['response']['text'] = "Найденой устройств: %d" % (int(num))
            res['response']['buttons'] = get_suggests(3)
            return
        elif req['request']['original_utterance'].lower() in [
                'прибор 1',
                'прибор 2',
                'прибор 3',
                'прибор 4',
                'прибор 5',
                'прибор 6',
                'прибор 7',
                'прибор 8',
                'прибор 9',
                'прибор 10',
        ]:
            name = req['request']['original_utterance'].lower()
            if os.path.exists(
                    "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%s" %
                (name[-1:])):
                res['response']['text'] = read_device1(int(name[-1:]))
                res['response']['buttons'] = get_suggests(3)
            else:
                res['response']['text'] = "Устройство не найдено."
                res['response']['buttons'] = get_suggests(3)
            return
        elif req['request']['original_utterance'].lower().find(
                "все приборы") >= 0 and req['request'][
                    'original_utterance'].lower().find("проверка") >= 0:
            subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                            (time.strftime("%H:%M:%S"), date.today(),
                             req['request']['original_utterance']),
                            shell=True,
                            cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
            check = 0
            text = ''
            flag = False
            for i in range(len(User_s[user_id]) - 1):
                check += User_ch[user_id][i] + User_s[user_id][i]
                if User_s[user_id][i + 1] < check:
                    text += ("Конфликт приборов %d %d\n" % (i + 1, i + 2))
                    flag = True
                check = 0
            if flag:
                text += "Переобозначьте стартовые каналы!"
            else:
                text += "Конфликтов не обнаружено."
            res['response']['text'] = text
            res['response']['buttons'] = get_suggests(1)
            return
        elif req['request']['original_utterance'].lower().find(
                "все приборы") >= 0 and req['request'][
                    'original_utterance'].lower().find("конфигурация") >= 0:
            subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                            (time.strftime("%H:%M:%S"), date.today(),
                             req['request']['original_utterance']),
                            shell=True,
                            cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
            User_s[user_id] = []
            User_val[user_id] = []
            User_ch[user_id] = []
            num = 0
            while os.path.exists(
                    "/home/pi/Alisa_DMX/DMX_Devices/Config/device_%d" %
                (num + 1)):
                num += 1
            for j in range(num):
                s, val = scan(j + 1)
                User_s[user_id].append(s)
                User_val[user_id].append(val)
                User_ch[user_id].append(len(val))
            res['response']['text'] = "Все каналы сброшены"
            res['response']['buttons'] = get_suggests(1)
            return
        elif req['request']['original_utterance'].lower().find(
                "стартовый канал") >= 0 and req['request'][
                    'original_utterance'].lower().find("прибор") >= 0:
            if req['request']['original_utterance'].lower().find("инфо") >= 0:
                subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                                (time.strftime("%H:%M:%S"), date.today(),
                                 req['request']['original_utterance']),
                                shell=True,
                                cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
                resul = [
                    i for i in req['request']
                    ['original_utterance'].lower().split() if i.isdigit()
                ]
                resul = ''.join(resul)
                resul = int(resul)
                if resul >= 1 and resul <= len(User_s[user_id]) + 1:
                    ans, buf = scan(resul)
                    res['response']['text'] = "Стартовый канал прибора: %s" % (
                        str(ans))
                    res['response']['buttons'] = get_suggests(1)
                    return
                else:
                    res['response']['text'] = "Прибор не найден"
                    res['response']['buttons'] = get_suggests(1)
                    return
            elif req['request']['original_utterance'].lower().find(
                    "отправь") >= 0:
                subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                                (time.strftime("%H:%M:%S"), date.today(),
                                 req['request']['original_utterance']),
                                shell=True,
                                cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
                beg = req['request']['original_utterance'].lower().find(
                    "прибор")
                mid = req['request']['original_utterance'].lower().find(
                    "канал")
                res1 = req['request']['original_utterance'].lower()[beg:mid]
                res2 = req['request']['original_utterance'].lower()[-8:]
                res1 = [i for i in res1.split() if i.isdigit()]
                res1 = ''.join(res1)
                res1 = int(res1)
                res2 = [i for i in res2.split() if i.isdigit()]
                res2 = ''.join(res2)
                res2 = int(res2)
                if res1 >= 1 and res1 <= len(User_s[user_id]) + 1:
                    User_s[user_id][res1 - 1] = res2
                    res['response'][
                        'text'] = "Стартовый канал сменен на %d" % res2
                    res['response']['buttons'] = get_suggests(1)
                    return
                else:
                    res['response']['text'] = "Прибор не найден"
                    res['response']['buttons'] = get_suggests(1)
                    return
        elif req['request']['original_utterance'].lower().find(
                "канал") >= 0 and req['request']['original_utterance'].lower(
                ).find("прибор") >= 0:
            if req['request']['original_utterance'].lower().find("инфо") >= 0:
                subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                                (time.strftime("%H:%M:%S"), date.today(),
                                 req['request']['original_utterance']),
                                shell=True,
                                cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
                beg = req['request']['original_utterance'].find("прибор")
                mid = req['request']['original_utterance'].find("канал")
                end = req['request']['original_utterance'].find("инфо")
                res1 = req['request']['original_utterance'][beg:mid]
                res2 = req['request']['original_utterance'][mid:end]
                res1 = [i for i in res1.split() if i.isdigit()]
                res1 = ''.join(res1)
                res1 = int(res1)
                res2 = [i for i in res2.split() if i.isdigit()]
                res2 = ''.join(res2)
                res2 = int(res2)
                if res1 >= 1 and res1 <= len(
                        User_s[user_id]) + 1 and res2 >= 1:
                    res['response']['text'] = find_ch_n(res1, res2)
                    res['response']['buttons'] = get_suggests(1)
                    return
                else:
                    res['response']['text'] = "Канал или устройство не найдены"
                    res['response']['buttons'] = get_suggests(1)
                    return
            elif req['request']['original_utterance'].lower().find(
                    "отправь") >= 0:
                subprocess.call("echo '%s %s %s' >> 'log_online.txt'" %
                                (time.strftime("%H:%M:%S"), date.today(),
                                 req['request']['original_utterance']),
                                shell=True,
                                cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
                beg = req['request']['original_utterance'].lower().find(
                    "прибор")
                mid = req['request']['original_utterance'].lower().find(
                    "канал")
                end = req['request']['original_utterance'].lower().find(
                    "отправь")
                res1 = req['request']['original_utterance'][beg:mid]
                res2 = req['request']['original_utterance'][mid:end]
                res3 = req['request']['original_utterance'].lower()[-8:]
                res1 = [i for i in res1.split() if i.isdigit()]
                res1 = ''.join(res1)
                res1 = int(res1)
                res2 = [i for i in res2.split() if i.isdigit()]
                res2 = ''.join(res2)
                res2 = int(res2)
                res3 = [i for i in res3.split() if i.isdigit()]
                res3 = ''.join(res3)
                res3 = int(res3)
                if res3 >= 0 and res3 <= 255:
                    if res1 >= 1 and res1 <= len(User_s[user_id]) + 1:
                        if res2 >= 0 and res2 <= len(User_ch[user_id]):
                            print(User_s[user_id][res1 - 1] + res2 - 1, res3)
                            print(User_s[user_id][res1 - 1] + res2 - 1, res3)
                            User_dev[user_id].send_single_value(
                                User_s[user_id][res1 - 1] + res2 - 1, res3)
                            res['response']['text'] = 'Сигнал отправлен'
                            res['response']['buttons'] = get_suggests(1)
                            return
                        else:
                            res['response']['text'] = 'Канал не найден'
                            res['response']['buttons'] = get_suggests(1)
                            return
                    else:
                        res['response']['text'] = "Устройство не найдено"
                        res['response']['buttons'] = get_suggests(1)
                        return
                else:
                    res['response']['text'] = "Некорректное значение"
                    res['response']['buttons'] = get_suggests(1)
                    return
        elif req['request']['original_utterance'].lower().find(
                "закончить") >= 0:
            UserInfo[user_id] = 0
            res['response']['text'] = "Заканчиваю работу мастер-контроль"
            res['response']['buttons'] = get_suggests(1)
            User_dev[user_id].close()
            return
        else:
            res['response']['text'] = "Команда не опознана"
            res['response']['buttons'] = get_suggests(1)
            return
    def __init__(self, *args, **kwargs):
        self.udmx = pyudmx.uDMXDevice()
        self.udmx.open()

        super().__init__(*args, **kwargs)
         res2 = line[mid:end]
         res3 = line[-8:]
         res1 = [i for i in res1.split() if i.isdigit()]
         res1 = ''.join(res1)
         res1 = int(res1)
         res2 = [i for i in res2.split() if i.isdigit()]
         res2 = ''.join(res2)
         res2 = int(res2)
         res3 = [i for i in res3.split() if i.isdigit()]
         res3 = ''.join(res3)
         res3 = int(res3)
         print(res1,res2,res3)
         if res3 >= 0 and res3 <=255:
             if res1 >= 1 and res1 <= len(l_s)+1:
                 if res2 >=0 and res2 <=len(l_ch):
                     DMX = pyudmx.uDMXDevice()
                     DMX.open()
                     DMX.send_single_value(l_s[res1-1]+res2-1, res3)
                     DMX.close()
                     #l_val[res-1][res2]=res3
                 else:
                     print("Канал не найден")
             else:
                 print("Устройство не найдено")
         else:
             print("Некорректное значение")
                     
 elif line.find("конфигурация")>=0 and line.find("прибор")>=0:
     print(line)
     subprocess.call("echo '%s %s %s' >> 'log.txt'" % (time.strftime("%H:%M:%S"),date.today(),line[:-1]), shell=True,cwd='/home/pi/Alisa_DMX/DMX_Devices/Config')
     res = [i for i in line.split() if i.isdigit()]
Example #16
0
 def __init__(self):
     self.dmx = pyudmx.uDMXDevice()
     self.dmx.open()
Example #17
0
    
if __name__ == "__main__":

    import time
    import pigpio
    from pyudmx import pyudmx

    pg.init()

    pos = [0,0,0]
    dmx = [2, 3, 4]
    dev = None

    pi = pigpio.pi()
    dev = pyudmx.uDMXDevice()

    if not dev.open():
        raise "Unable to find and open uDMX interface"
    for ch in [1, 2, 3, 4,8]:
        dev.send_single_value(ch, 255)
        
    done = False
    while not done:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                break
            print(event)
            
    encoder.cancel()