Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Calorimetry_Laboratory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Ramirez Saldana, Santiago
Calorimetry_Laboratory
Commits
9a4d7dff
Commit
9a4d7dff
authored
1 year ago
by
Xia, Ning
Browse files
Options
Downloads
Patches
Plain Diff
update check user input
parent
ef129063
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+26
-12
26 additions, 12 deletions
main.py
with
26 additions
and
12 deletions
main.py
+
26
−
12
View file @
9a4d7dff
...
@@ -25,8 +25,7 @@ path_json = "./datasheets"
...
@@ -25,8 +25,7 @@ path_json = "./datasheets"
path_setup
=
""
path_setup
=
""
# path_setup = ""
# path_setup = ""
# Ask for the type of experiment to be performed
# Ask for the type of experiment to be performed until the user gives a valid answer.
# until the user gives a valid answer.
is_log_heater
=
None
is_log_heater
=
None
while
is_log_heater
!=
0
and
is_log_heater
!=
1
:
while
is_log_heater
!=
0
and
is_log_heater
!=
1
:
if
is_log_heater
is
None
:
if
is_log_heater
is
None
:
...
@@ -46,22 +45,37 @@ while is_log_heater != 0 and is_log_heater != 1:
...
@@ -46,22 +45,37 @@ while is_log_heater != 0 and is_log_heater != 1:
# Read the metadata necessary to control test rig from the setup file.
# Read the metadata necessary to control test rig from the setup file.
metadata
=
m_json
.
get_metadata_from_setup
(
path_setup
)
metadata
=
m_json
.
get_metadata_from_setup
(
path_setup
)
# Read the sensor's serial number from the sensor's datasheets
# Read the sensor's serial number from the sensor's datasheets and add it to the dictionary that holds the metadata.
# and add it to the dictionary that holds the metadata.
m_json
.
add_temperature_sensor_serials
(
path_json
,
metadata
)
m_json
.
add_temperature_sensor_serials
(
path_json
,
metadata
)
# Reads sensor measurements and saves the data to a variable.
# Reads sensor measurements and saves the data to a variable.
data
=
m_pck
.
get_meas_data_calorimetry
(
metadata
)
data
=
m_pck
.
get_meas_data_calorimetry
(
metadata
)
# Read the name of the logging file to be created
# List of valid characters.
# from stdin (standard input/output).
valued_char
=
"
-_.() abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
"
name_logging
=
input
(
"
logging file name =
"
)
# Initialize empty filename.
# The folder containing the logging files will be
name_logging
=
""
# created in the data folder in the root directory
# Loop until the user enters a valid filename.
# of the program.
while
name_logging
==
""
:
# Read the name of the logging file to be created from stdin (standard input/output).
name_logging
=
input
(
"
logging file name =
"
)
# Remove spaces at the beginning and end of the filename.
name_logging
=
name_logging
.
strip
()
# If the filename entered is empty then re-enter it.
if
name_logging
==
""
:
print
(
"
File name can not be empty.
"
)
continue
# Iterate over all characters of the filename.
for
c
in
name_logging
:
# Requires retyping if invalid characters are present.
if
c
not
in
valued_char
:
print
(
"
{} is not a valid name. ({} invalid)
"
.
format
(
name_logging
,
c
))
name_logging
=
""
break
# The folder containing the logging files will be created in the data folder in the root directory of the program.
path_logging
=
"
{}/{}
"
.
format
(
"
data
"
,
name_logging
)
path_logging
=
"
{}/{}
"
.
format
(
"
data
"
,
name_logging
)
# Save the datasets and datasheets used in the experiment
# Save the datasets and datasheets used in the experiment to the logging directory.
# to the logging directory.
m_pck
.
logging_calorimetry
(
data
,
metadata
,
path_logging
,
path_json
)
m_pck
.
logging_calorimetry
(
data
,
metadata
,
path_logging
,
path_json
)
if
is_log_heater
:
if
is_log_heater
:
...
...
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