Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
355d9257
Commit
355d9257
authored
Jun 06, 2020
by
Vladislav Rykov
Browse files
device data model implemented and tested from pc, todo:tests from devices
parent
81984a30
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/app/helpers/device_data_model.py
View file @
355d9257
...
...
@@ -96,7 +96,7 @@ def test_done():
print
(
read_data_ddm
(
rdata
,
ddm
))
@
misc
.
with_psql
def
insert
_test
(
cur
):
def
mpack
_test
(
cur
):
import
random
m
=
{
...
...
@@ -113,6 +113,20 @@ def insert_test(cur):
return
(
True
,)
@
misc
.
with_psql
def
raw_test
(
cur
):
import
random
upstr
=
'<fQ20s?h'
m
=
struct
.
pack
(
upstr
,
random
.
random
()
*
1000
,
random
.
randint
(
10000
,
10000000
),
'hello'
.
encode
(
'utf-8'
),
random
.
randint
(
0
,
2
),
random
.
randint
(
0
,
30000
))
query
=
"""
INSERT INTO dev_3b56f3d8_2 VALUES ({}, '{}', {})
"""
.
format
(
misc
.
get_utc
(),
datetime
.
now
().
strftime
(
'%H:%M:%S'
),
Binary
(
m
))
cur
.
execute
(
query
)
return
(
True
,)
def
decode_datum
(
data
,
ddm
):
data
=
[
d
for
d
in
data
]
data
[
2
]
=
read_data
(
data
[
2
].
tobytes
(),
ddm
)
...
...
@@ -154,13 +168,14 @@ def extract(request):
ddmin
[
'format'
][
k
][
'type'
]
=
v
[
'size'
]
+
's'
ddmin
[
'format'
][
k
].
pop
(
'size'
)
# order dict
od
=
collections
.
OrderedDict
(
sorted
(
ddmin
[
'format'
].
items
()))
od
=
OrderedDict
(
sorted
(
ddmin
[
'format'
].
items
()))
ddmin
.
pop
(
'format'
)
ddmin
[
'format'
]
=
collections
.
OrderedDict
()
ddmin
[
'format'
]
=
OrderedDict
()
# give it defined ddm format
for
k
,
v
in
od
.
items
():
ddmin
[
'format'
][
v
[
'name'
]]
=
v
[
'type'
]
return
ddmin
print
(
'insert'
,
insert_test
())
print
(
'mpack insert'
,
mpack_test
())
print
(
'raw insert'
,
raw_test
())
app/app/templates/new/public/device.html
View file @
355d9257
{% extends 'logged_layout.html' %}
{% block title %} HPC
&
A IoT - {{ app[
1
] }} - Devices {% endblock %}
{% block title %} HPC
&
A IoT - {{ app[
0
] }} - Devices {% endblock %}
{% block header %}
<script
type=
"text/javascript"
src=
"https://www.gstatic.com/charts/loader.js"
></script>
...
...
@@ -175,7 +175,7 @@
title
:
'
{{ dev[0] }} >
'
+
dname
,
curveType
:
'
function
'
,
hAxis
:
{
format
:
'
dd/MM
hh
:mm
'
format
:
'
dd/MM
HH
:mm
'
},
vAxis
:
{
format
:
'
decimal
'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment