Esempio n. 1
0
 def action(self, action=None):
     """Received action. Parse it and send to correct module."""
     if action in ['play', 'pause', 'next', 'prev', 'stop']:
         controller.send_command(action)
         return json.dumps(controller.get_current())
     elif action in ['volUp', 'volDown']:
         pa_controller.change_volume(10 if action == 'volUp' else -10)
Esempio n. 2
0
    def __init__(self, master):
        super().__init__(master)
        master.protocol("WM_DELETE_WINDOW", self.exit)

        with open('./calib.txt') as f:
            s = f.read()
        c = s.split(',')
        for i, val in enumerate(c):
            send_command([i, 12100 + int(val)])

        self.status = 2
Esempio n. 3
0
 def notify(self, msg):
     """Receive command from client and execute it."""
     try:
         command = msg['command']
         if command in ['PLAY', 'PAUSE', 'NEXT', 'PREV']:
             controller.send_command(command)
         elif command == 'GET_TRACK':
             properties = controller.get_current()
             if properties:
                 self.send(properties)
     except KeyError:
         pass
Esempio n. 4
0
def standardMode():
    """ Renders the Standard Mode Page.

    Performs any tasks that are required, then renders the Standard Mode page.
    """
    if request.method == 'POST':
        if request.form['submit'] == 'Node':
            global node
            node = request.form['node'].upper()
            print '\n\n\n================ {} ===============\n\n\n'.format(node)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Set speed of node
        elif request.form['submit'] == 'Speed':
            global speed
            speed = request.form['speed']
            speed = speed.encode('ascii', 'ignore')
            controller.send_command(coordinator, speed, direction, node)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Make node go forward
        elif request.form['submit'] == 'Forward':
            global direction
            direction = "21"
            if request.form['node']:
                global node
                node = request.form['node'].upper()
                print node
            controller.send_command(coordinator, speed, direction, node)
            print '================ {} ==============='.format(direction)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Make node go backward
        elif request.form['submit'] == 'Backward':
            global direction
            direction = "20"
            if request.form['node']:
                global node
                node = request.form['node'].upper()
                print node
            controller.send_command(coordinator, speed, direction, node)
            print '================ {} ==============='.format(direction)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Start node
        elif request.form['submit'] == 'Start':
            global start
            start = 'disabled'
            global stop
            stop = ''
            # controller.test()
            controller.send_command(coordinator, speed, direction, node)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Stop node
        elif request.form['submit'] == 'Stop':
            global start
            start = ''
            global stop
            stop = 'disabled'
            controller.send_command(coordinator, "0", direction, node)
            return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)
        # Set Floor Plan
        elif request.form['submit'] == 'Set Floor Plan':
            file = request.files['file']
            global filename
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return render_template('standardMode.html', nodes=nodes,
                            sensors=sensors, filename=filename,
                            speed=speed, node=node)
        elif request.form['submit'] == 'Empty Log File':
            controller.emptyLog()
            return render_template('standardMode.html', nodes=nodes,
                            sensors=sensors, filename=filename,
                            speed=speed)
    elif request.method == 'GET':
        return render_template('standardMode.html', nodes=nodes,
                               sensors=sensors, filename=filename,
                               speed=speed, node=node)