Exemple #1
0
 def setAutoStart(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             req = request.get_json()
             controller.setAutoStart(req['state'])
             return Response(status=200, response=json.dumps(req))
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #2
0
 def consoleOutput(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             WebsocketConsole.setSource(controller.log_file)
             time.sleep(0.5)
             return Response(status=200)
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #3
0
 def getPlot(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             data = controller.getPlotData()
             if data:
                 return Response(status=200,
                                 response=json.dumps({'res': data}))
             return Response(status=404)
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #4
0
 def getBoundaries(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             event = DeviceEvent()
             controller.findBoundaries(
                 functools.partial(__class__.callbk, event))
             event.wait(timeout=15)
             return Response(status=event.status,
                             response=json.dumps(event.message))
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #5
0
 def device(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             if request.method == 'POST':
                 sett = request.get_json()
                 controller.setSettings(sett['rpkwh'], sett['tkwh'],
                                        sett['name'])
             if request.method == 'GET':
                 sett = controller.getSettings()
             return Response(status=200, response=json.dumps(sett))
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #6
0
 def getHistogram(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             event = DeviceEvent()
             conf = request.get_json()
             controller.buildHistogram(
                 functools.partial(__class__.callbk, event), conf['lb'],
                 conf['rb'], conf['res'])
             event.wait(timeout=15)
             return Response(status=event.status,
                             response=json.dumps(event.message))
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)
Exemple #7
0
 def conf(d_id):
     try:
         controller = SerialManager.getController(d_id)
         if controller:
             event = DeviceEvent()
             if request.method == 'POST':
                 conf = request.get_json()
                 controller.setConf(
                     functools.partial(__class__.callbk,
                                       event), conf['mode'], conf['conf_a'],
                     conf['conf_b'], conf['dt'], conf['ndt'])
             if request.method == 'GET':
                 conf = controller.getConf()
                 event.set()
             event.wait(timeout=15)
             return Response(status=event.status, response=json.dumps(conf))
     except Exception as ex:
         logger.error(ex)
     return Response(status=500)