Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Datalogger UI
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
Scientific Computing and Engineering Group
LippunerAG
WABEsense
Datalogger UI
Commits
ebbb9a64
Commit
ebbb9a64
authored
3 years ago
by
JuanPi Carbajal
Browse files
Options
Downloads
Patches
Plain Diff
serial and html: get logger configuration as serial command, adapt html ui to use it.
parent
30fe2759
No related branches found
No related tags found
No related merge requests found
Pipeline
#238411
passed
3 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dataloggerui/htmlui.py
+6
-29
6 additions, 29 deletions
dataloggerui/htmlui.py
dataloggerui/logger.py
+32
-0
32 additions, 0 deletions
dataloggerui/logger.py
dataloggerui/serialui.py
+47
-14
47 additions, 14 deletions
dataloggerui/serialui.py
with
85 additions
and
43 deletions
dataloggerui/htmlui.py
+
6
−
29
View file @
ebbb9a64
...
...
@@ -22,20 +22,14 @@ import pandas as pd
try
:
from
.
import
serialui
as
sui
from
.logger
import
channel_idx
except
ImportError
:
import
serialui
as
sui
from
logger
import
channel_idx
datetime_fmt
=
'
%a %b %d %H:%M:%S.%f %Y %Z
'
"""
Date and Time format on the UI
"""
channel_idx
=
dict
(
adc_in8_name
=
0
,
adc_in9_name
=
1
,
adc_in10_name
=
2
,
adc_in11_name
=
3
)
"""
Mapping from internal channel name to channel index
"""
defaults
=
dict
(
sampling_interval
=
10
,
interval_units
=
'
T
'
,
...
...
@@ -177,27 +171,10 @@ def get_config_logger():
if
not
sui
.
wbsLogger
.
is_open
:
sui
.
wbsLogger
.
open
()
# get data
volt
,
count
=
sui
.
get_battery_configuration
()
interval
,
units
=
sui
.
get_sampling_interval
()
config_dict
=
dict
(
device_name
=
sui
.
get_device_name
(),
sampling_interval
=
str
(
interval
),
interval_units
=
units
,
auto_sampleStatus
=
sui
.
get_auto_sampling
(),
samples_count
=
sui
.
get_sample_count
(),
battery_cell_voltage
=
volt
,
battery_cell_count
=
count
,
firmware_version
=
sui
.
get_firmware_version
(),
unique_id
=
sui
.
get_unique_id
(),
rtc_now
=
sui
.
get_datetime
().
strftime
(
datetime_fmt
),
# print time in LOCALE
serial_port
=
sui
.
wbsLogger
.
port
,
)
# channel names
ch_name
=
sui
.
get_analog_channel_name
()
for
ch
,
idx
in
channel_idx
.
items
():
config_dict
[
ch
]
=
ch_name
[
idx
]
# get configuration
config_dict
=
sui
.
get_configuration
()
config_dict
[
'
sampling_interval
'
]
=
str
(
config_dict
[
'
sampling_interval
'
])
config_dict
[
'
rtc_now
'
]
=
config_dict
[
'
rtc_now
'
].
strftime
(
datetime_fmt
)
return
config_dict
...
...
This diff is collapsed.
Click to expand it.
dataloggerui/logger.py
0 → 100644
+
32
−
0
View file @
ebbb9a64
"""
Logger basic configuration and other miscellaneous definitions
"""
import
datetime
import
re
import
string
from
pathlib
import
Path
from
collections
import
namedtuple
import
yaml
from
flask
import
Flask
,
flash
,
render_template
,
request
,
url_for
,
redirect
from
werkzeug.utils
import
secure_filename
channel_idx
=
dict
(
adc_in8_name
=
0
,
adc_in9_name
=
1
,
adc_in10_name
=
2
,
adc_in11_name
=
3
)
"""
Mapping from internal channel name to channel index
"""
datetime_fmt_rtc_set
=
'
%Y.%m.%d %u %H:%M:%S
'
datetime_fmt_rtc_get
=
'
%Y.%m.%d %u %H:%M:%S.%f
'
"""
RTC datetime format string
See https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
for information about the format string.
"""
datetime_fmt_sample
=
'
%Y.%m.%d %H:%M:%S.%f
'
"""
Datetime format of logger sample
"""
This diff is collapsed.
Click to expand it.
dataloggerui/serialui.py
+
47
−
14
View file @
ebbb9a64
...
...
@@ -46,14 +46,17 @@ import datetime
import
re
from
pkg_resources
import
packaging
from
string
import
Template
from
time
import
sleep
from
itertools
import
chain
from
collections
import
namedtuple
try
:
from
.commands
import
ActionDict
,
SetterDict
,
GetterDict
from
.logger
import
(
datetime_fmt_rtc_set
,
datetime_fmt_rtc_get
,
datetime_fmt_sample
,
channel_idx
)
except
ImportError
:
from
commands
import
ActionDict
,
SetterDict
,
GetterDict
from
logger
import
(
datetime_fmt_rtc_set
,
datetime_fmt_rtc_get
,
datetime_fmt_sample
,
channel_idx
)
import
serial
import
serial.tools.list_ports
as
slp
...
...
@@ -318,8 +321,9 @@ def get_analog_channel_name(*, channel=None):
Parameters
----------
channel: :class:`int` or :class:`str`
channel: :class:`int` or :class:`str`
or None
Channel number to read. Valid values: 0-3
If None (default) then all channel names are retrieved.
Returns
-------
...
...
@@ -351,15 +355,6 @@ def get_analog_channel_name(*, channel=None):
return
ch_name
datetime_fmt_rtc_set
=
'
%Y.%m.%d %u %H:%M:%S
'
datetime_fmt_rtc_get
=
'
%Y.%m.%d %u %H:%M:%S.%f
'
"""
RTC datetime format string
See https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
for information about the format string.
"""
def
parse_datetime
(
dt_str
,
*
,
fmt
):
"""
Parse datetime string into datetime.
...
...
@@ -387,8 +382,6 @@ LoggerSample = namedtuple('LoggerSample', ['datetime',
'
adc_in9
'
])
"""
Inmutable logger sample container.
"""
datetime_fmt_sample
=
'
%Y.%m.%d %H:%M:%S.%f
'
"""
Datetime format of looger sample
"""
sample_typecast
=
LoggerSample
(
*
([
lambda
u
:
parse_datetime
(
u
,
fmt
=
datetime_fmt_sample
),
lambda
u
:
u
==
'
1
'
]
+
[
float
]
*
6
))
...
...
@@ -458,6 +451,46 @@ def get_datetime():
fmt
=
datetime_fmt_rtc_get
)
def
get_configuration
():
"""
Get current logger configuration.
The current configuration might not be stored to the non-volatile
memory of the logger.
Returns
-------
:class:`dict`
Current logger configurationDate and time
See also
--------
:func:`~.store_configuration()`
Make current configuration permanent (non-volatile).
"""
volt
,
count
=
get_battery_configuration
()
interval
,
units
=
get_sampling_interval
()
config_dict
=
dict
(
device_name
=
get_device_name
(),
sampling_interval
=
interval
,
interval_units
=
units
,
auto_sampleStatus
=
get_auto_sampling
(),
samples_count
=
get_sample_count
(),
battery_cell_voltage
=
volt
,
battery_cell_count
=
count
,
firmware_version
=
get_firmware_version
(),
unique_id
=
get_unique_id
(),
rtc_now
=
get_datetime
(),
# print time in LOCALE
serial_port
=
wbsLogger
.
port
,
)
# channel names
ch_name
=
get_analog_channel_name
()
for
ch
,
idx
in
channel_idx
.
items
():
config_dict
[
ch
]
=
ch_name
[
idx
]
return
config_dict
# -------------
# Setters
# -------------
...
...
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