Ejemplo n.º 1
0
    def on_close(self):
        print 'connection closed'
        clients.remove(self)


## check the queue for pending messages, and rely that to all connected clients
def checkQueue():
    if not output_queue.empty():
        message = output_queue.get()
        for c in clients:
            c.write_message(message)


if __name__ == '__main__':
    ## start the serial worker in background (as a deamon)
    sp = serialworker.SerialProcess(input_queue, output_queue)
    sp.daemon = True
    sp.start()
    tornado.options.parse_command_line()
    app = tornado.web.Application(handlers=[(r"/", IndexHandler),
                                            (r"/static/(.*)",
                                             tornado.web.StaticFileHandler, {
                                                 'path': './'
                                             }), (r"/ws", WebSocketHandler)])
    httpServer = tornado.httpserver.HTTPServer(app)
    httpServer.listen(options.port)
    print "Listening on port:", options.port

    mainLoop = tornado.ioloop.IOLoop.instance()
    ## adjust the scheduler_interval according to the frames sent by the serial port
    scheduler_interval = 100
Ejemplo n.º 2
0
        ## close websockets and get out
        node_input_queue.close()
        node_output_queue.close()
        hidden_input_queue.close()
        hidden_output_queue.close()
        chat_input_queue.close()
        chat_output_queue.close()

        print('TARPN Home server closed')
        quit()

if __name__ == '__main__':
    keepRunning = True

    ## start the serial worker in background (as a deamon)
    sp = serialworker.SerialProcess(node_input_queue, node_output_queue,
                                    4)  ## port 4 for node commands
    sp.daemon = True
    sp.start()

    ## wait a second before sending first input
    time.sleep(1)
    node_input_queue.put('conok')
    node_input_queue.put('echo on')
    node_input_queue.put('autolf on')
    node_input_queue.put('mon off')  ## always off
    time.sleep(2)
    node_input_queue.put('c switch')
    blNodeIsAlive = 1

    ## start the hidden serial worker in background (as a deamon)
    sp_hidden = serialworker.SerialProcess(hidden_input_queue,
Ejemplo n.º 3
0
                           [Timestamp] DATETIME NOT NULL PRIMARY KEY, \
                           [SwVer] NVARCHAR NOT NULL, \
                           [Date] DATETIME NOT NULL, \
                           [Mode] INTEGER NOT NULL, \
                           [State] INTEGER NOT NULL, \
                           [Status] INTEGER NOT NULL, \
                           [IgnitionFail] TINYINT NOT NULL, \
                           [PelletJam] TINYINT NOT NULL, \
                           [Tset] INTEGER NOT NULL, \
                           [Tboiler] INTEGER NOT NULL, \
                           [Flame] INTEGER NOT NULL, \
                           [Heater] TINYINT NOT NULL, \
                           [CHPump] TINYINT NOT NULL, \
                           [BF] TINYINT NOT NULL, \
                           [FF] TINYINT NOT NULL, \
                           [Fan] INTEGER NOT NULL, \
                           [Power] INTEGER NOT NULL, \
                           [ThermostatStop] TINYINT NOT NULL, \
                           [FFWorkTime] INTEGER NOT NULL)")
    dbconn.commit()


if __name__ == '__main__':
    ## Initialize database
    initializeDatabase()

    ## start the serial worker in background (as a deamon)
    sp = serialworker.SerialProcess()
    #sp.daemon = True
    sp.start()
Ejemplo n.º 4
0
        print('connection closed')
        clients.remove(self)


# check the queue for pending messages, and rely that to all connected clients
def checkQueue():
    if not output_queue.empty():
        message = output_queue.get()
        for c in clients:
            c.write_message(message)


if __name__ == '__main__':
    # start the serial worker in background (as a deamon)
    tornado.options.parse_command_line()
    sp = serialworker.SerialProcess(input_queue, output_queue, options.serial)
    sp.daemon = True
    sp.start()
    app = tornado.web.Application(handlers=[(r"/", IndexHandler),
                                            (r"/static/(.*)",
                                             tornado.web.StaticFileHandler, {
                                                 'path': './'
                                             }), (r"/ws", WebSocketHandler)])
    httpServer = tornado.httpserver.HTTPServer(app)
    httpServer.listen(options.port)
    print("Listening on port:", options.port)
    print("Connected to device:", options.serial)

    mainLoop = tornado.ioloop.IOLoop.instance()
    # adjust the scheduler_interval according to the frames sent by the serial port
    scheduler_interval = 100