add point methode

This commit is contained in:
Philipp Rauch 2014-03-24 16:27:09 +01:00
parent 1621080721
commit 5caca593f9
5 changed files with 21 additions and 6 deletions

View file

@ -8,6 +8,7 @@ from socket import gethostname
from Config.parser import config
from datetime import datetime
from flask import abort
import time
### json pac ###
from numpy import timedelta64, float64, int64
@ -72,6 +73,16 @@ class Buffer(object):
self.set_href(level, self.gen_start_url(l)) #set all links above
return {l[-1] : level}
def get_point(self, l):
level = l.pop(0)
for i in l:
if isinstance(level, dict) and i in level:
level = level.get(i)
else:
abort(404)
self.set_href(level, self.gen_start_url(l)) #set all links above
return '[%s, %s]' % (int(time.time()*1000), level)
def generate_links(self, dic, url, postfix):
'''
generats a link to dic if dic is a dictionary

View file

@ -6,7 +6,7 @@ Created on 24.10.2013
'''
# from sys import stderr
from datetime import datetime
from flask import Flask, jsonify, make_response, request
from flask import Flask, jsonify, make_response, request, Response
from socket import gethostname
from Config.parser import config
from ems import ems
@ -94,6 +94,10 @@ class REST(object):
# to convert it to a dictionary use to_dict(flat=False)
# to_dict(flat=True) returns the key and the first item of the value list.
out = self.buf.foo(l, args)
elif 'point' == l[-1]:
del l[-1]
tmp = self.buf.get_point(l)
return Response(tmp, content_type='text/json')
else:
#req = add_reqest(path)

View file

@ -21,4 +21,4 @@ can_symfile = Symboldatei_multiport_neu.sym #ems-test.sym
#### PAC ####
pac_ip = 10.2.6.7 # 10.2.6.5, 10.2.6.6, 10.2.6.7, 10.2.6.8
pac_csvfile = pacs.csv # only one file allowed
pac_messages = 797, 1, 3, 5, 13, 15, 17, 25, 27, 29, 31, 33, 35
pac_messages = 797, 1, 3, 5, 13, 15, 17, 25, 27, 29#, 31, 33, 35

View file

@ -83,5 +83,5 @@ class modbus_pac(Thread):
### save one line in res_data, use self.tab as mask###
res_data = self.tab.append(res, ignore_index=True)
res_data[self.col[1::]] = res_data[self.col[1::]].astype(numpy.float) #till now only float support
self.db.writeDatabase('PAC_neu', res_data, bClear = False)
self.db.writeDatabase('PAC', res_data, bClear = False)
#sleep(0.6)

View file

@ -24,9 +24,9 @@ PAC_start(conf)
#############################################################
## startet die CAN Kommunikation
#############################################################
print '>> RUN_CAN <<'
from CAN.Filter import CAN_start
CAN_start(conf)
#print '>> RUN_CAN <<'
#from CAN.Filter import CAN_start
#CAN_start(conf)
#############################################################