Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MessdatenSilo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Kloock
MessdatenSilo
Commits
1cbc8756
Commit
1cbc8756
authored
3 years ago
by
Lennard
Browse files
Options
Downloads
Patches
Plain Diff
Switch to yaml config file for better comments
parent
2c2c66fa
No related branches found
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
config.json
+0
-20
0 additions, 20 deletions
config.json
config.yml
+19
-0
19 additions, 0 deletions
config.yml
main.py
+8
-7
8 additions, 7 deletions
main.py
with
27 additions
and
27 deletions
config.json
deleted
100644 → 0
+
0
−
20
View file @
2c2c66fa
{
"DataLogger"
:
{
"backupCount"
:
28
,
"when"
:
"h"
,
"interval"
:
25
,
"filename"
:
"data"
,
"levels"
:
[
"INFO"
,
"INFO"
]
},
"InfoLogger"
:
{
"backupCount"
:
10
,
"maxBytes"
:
1000000
,
"filename"
:
"log"
,
"levels"
:
[
"INFO"
,
"WARNING"
]
},
"Data"
:
{
"factors"
:
[
1
,
1
,
1
,
1
],
"delta_time"
:
30
,
"smoothing"
:
false
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
config.yml
0 → 100644
+
19
−
0
View file @
1cbc8756
DataLogger
:
backupCount
:
28
# number of datalogs to keep
filename
:
data
# filename for datalogs
levels
:
# log level for outputting to file and to stdout respectivly
-
INFO
-
INFO
InfoLogger
:
backupCount
:
10
# number of logs to keep
maxBytes
:
1000000
# size of single log
filename
:
log
# filename for logs
levels
:
# log level for outputting to file and to stdout respectivly
-
INFO
-
WARNING
Data
:
factors
:
[
1
,
1
,
1
,
0.9
]
# factors for the 4 dms
delta_time
:
30
# time between logging data
smoothing
:
false
# wether to smoothe the logged data
This diff is collapsed.
Click to expand it.
main.py
+
8
−
7
View file @
1cbc8756
import
configparser
import
datetime
import
json
import
yaml
import
time
from
typing
import
Any
,
List
,
Optional
import
serial
...
...
@@ -95,8 +94,8 @@ def setup_loggers(config: Any) -> None:
TimedRotatingFileHandlerWithHeader
(
header
=
f
"
Timestamp,
{
'
,
'
.
join
([
f
'
dms
{
i
+
1
}
'
for i in range(4)])
}
,
{
'
,
'
.
join
([
f
'
temp
{
i
+
1
}
'
for i in range(4)])
}
,n
"
,
filename
=
f
"
{
Path
(
__file__
).
parent
}
/data/
{
config
[
'
DataLogger
'
][
'
filename
'
]
}
"
,
when
=
config
[
"
DataLogger
"
][
"
when
"
]
,
interval
=
config
[
"
DataLogger
"
][
"
interval
"
]
,
when
=
'
h
'
,
interval
=
25
,
backupCount
=
config
[
"
DataLogger
"
][
"
backupCount
"
],
)
)
...
...
@@ -140,7 +139,7 @@ def main(config: Any) -> None:
offsets
=
np
.
hstack
((
get_offset
(),
np
.
zeros
((
4
,))))
logger
.
info
(
f
"
Factors:
{
'
,
'
.
join
(
f
'
{
factor
:
.
3
f
}
'
for factor in factors)
}
, Offset:
{
'
,
'
.
join
(
f
'
{
offset
:
.
3
f
}
'
for offset in offsets[
:
4
])
}
"
f
"
Factors:
{
'
,
'
.
join
(
f
'
{
factor
:
.
3
f
}
'
for factor in factors
[
:
4
]
)
}
, Offset:
{
'
,
'
.
join
(
f
'
{
offset
:
.
3
f
}
'
for offset in offsets[
:
4
])
}
"
)
with
serial
.
Serial
(
"
/dev/ttyACM0
"
,
9600
,
timeout
=
3
)
as
con1
,
serial
.
Serial
(
"
/dev/ttyACM1
"
,
9600
,
timeout
=
3
)
as
con2
:
...
...
@@ -154,7 +153,6 @@ def main(config: Any) -> None:
con1
.
write
(
1
)
con2
.
write
(
2
)
# read data
try
:
new_data
=
data
.
copy
()
...
...
@@ -162,6 +160,7 @@ def main(config: Any) -> None:
off1
=
0
if
int
(
convert
(
con1
.
readline
()))
==
1.0
else
4
off2
=
4
if
int
(
convert
(
con2
.
readline
()))
==
2.0
else
0
# read data
for
i
in
range
(
4
):
recv1
=
con1
.
readline
()
recv2
=
con2
.
readline
()
...
...
@@ -174,7 +173,9 @@ def main(config: Any) -> None:
except
(
TypeError
,
ValueError
):
# may occur if no data was read over serial
logger
.
info
(
f
"
Didn
'
t receive data from arduino, off1:
{
off1
}
, off2:
{
off2
}
, recv1:
{
recv1
}
, recv2:
{
recv2
}
"
)
if
time
.
time
()
-
last_write
>
delta_time
:
# write data
data_logger
.
info
(
"
,
"
.
join
([
f
"
{
value
/
n
*
factors
+
offsets
:
.
5
f
}
"
for
value
in
data
])
+
f
"
,
{
n
}
"
)
logger
.
debug
(
"
Wrote data
"
)
n
=
0
...
...
@@ -187,4 +188,4 @@ def main(config: Any) -> None:
if
__name__
==
"
__main__
"
:
main
(
json
.
load
(
open
(
f
"
{
Path
(
__file__
).
parent
}
/config.
json
"
)))
main
(
yaml
.
safe_
load
(
open
(
f
"
{
Path
(
__file__
).
parent
}
/config.
yml
"
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment