funktionsfähige Testimplementierung

*test.py startet den CANFilter, der die Daten vom CAN-BUS in die Datenbank
schreibt. (CAN-msgid = 0x3A4, 2&3 Byte, Multiplikator 0.01)
*API.py startet die API
*Diese kann man unter localhost:5000 erreichen
*der CAN Wert läuft auf "localhost:5000/dc_labor/device/battery/voltage"
auf
This commit is contained in:
Philipp Rauch 2013-11-22 14:25:12 +01:00
parent 59340b5fee
commit cda58b0f2e
7 changed files with 132 additions and 80 deletions

View file

@ -10,10 +10,11 @@ from datetime import datetime
from flask import Flask, jsonify, abort, make_response, request
from socket import gethostname
from threading import Thread
from config import readConf
from config import Config
import ems
conf = readConf()
c = Config()
conf = c.readConf()
api_host = gethostname() if conf['flask_server'] == '0.0.0.0' else conf['flask_server']
api_url = 'http://%s:%s' % (api_host, conf['flask_port'])
@ -163,7 +164,7 @@ class API(object):
self.app.add_url_rule('/<path:path>', 'get_catch_all', get_catch_all, methods = ['GET'])
# def run(self):
self.app.run(host = conf['flask_server'], port = int(conf['flask_port']), debug = True)
# self.app.run(host = conf['flask_server'], port = int(conf['flask_port']), debug = True)
buf = Buffer()
@ -202,7 +203,8 @@ def start():
api = API()
api.app.run(host = conf['flask_server'], port = int(conf['flask_port']), debug = conf['flask_debug'])
emsthread = ems.ems(buf)
print 'EMS-Thread:\t', emsthread
EMS = ems.ems(buf)
emsthread = EMS.start()
print 'EMS-Thread:\t', EMS
print '\tAPI:\t', buf
start()