Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climate Lab Test Stand
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSK-SW
Low-Level Radio Frequency
Climate Lab
Climate Lab Test Stand
Commits
52657be7
Commit
52657be7
authored
2 years ago
by
Sai Lakhan Ekal
Browse files
Options
Downloads
Patches
Plain Diff
Introduce virtual_clock in climate_chamber_dummy
Added internal function for simulated temperature
parent
389df5d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python_script/climate_chamber_dummy.py
+30
-8
30 additions, 8 deletions
Python_script/climate_chamber_dummy.py
with
30 additions
and
8 deletions
Python_script/climate_chamber_dummy.py
+
30
−
8
View file @
52657be7
#!/usr/bin/python3
import
virtual_time
import
prototype
import
time
import
math
class
ClimateChamberDummy
:
def
__init__
(
self
,
ip_address
,
target_accuracy
):
...
...
@@ -14,20 +18,38 @@ class ClimateChamberDummy:
self
.
__ip_address
=
ip_address
self
.
target_accuracy
=
target_accuracy
# we try to connect to the climate chamber just to see if there is an error
self
.
simulated_temperature
=
25
self
.
virtual_time
=
virtual_time
.
get_clock
(
'
localhost
'
)
# local when simulating self.deltaT = self.target_temperature - self.read_temperature()[0]
self
.
last_simulation_time
=
self
.
virtual_time
.
time
()
self
.
simulated_temperature
=
25
# + self.deltaT *"slope"* self.deltat
self
.
simulated_humidity
=
35
self
.
simulated_mode
=
'
OFF
'
self
.
target_temperature
=
40
self
.
target_humidity
=
50
self
.
target_temperature
=
25
self
.
target_humidity
=
35
self
.
temperature_slope
=
0.1
# 0.1 degrees/second
def
_simulate_temp
(
self
):
max_delta_temp
=
self
.
target_temperature
-
self
.
simulated_temperature
if
max_delta_temp
<
0
:
direction
=
-
1
else
:
direction
=
1
new_time
=
self
.
virtual_time
.
time
()
delta_time
=
new_time
-
self
.
last_simulation_time
max_temp_change_in_delta_time
=
self
.
temperature_slope
*
delta_time
if
abs
(
max_delta_temp
)
<
max_temp_change_in_delta_time
:
self
.
simulated_temperature
=
self
.
target_temperature
else
:
self
.
simulated_temperature
=
self
.
simulated_temperature
+
direction
*
self
.
temperature_slope
*
delta_time
self
.
last_simulation_time
=
new_time
# the communication section
def
read_temperature
(
self
):
if
self
.
simulated_temperature
<
self
.
target_temperature
:
self
.
simulated_temperature
+=
0.1
elif
self
.
simulated_temperature
>
self
.
target_temperature
:
self
.
simulated_temperature
-=
0.1
self
.
_simulate_temp
()
# data format: [current temp, set temp, upper limit, lower limit]
return
[
self
.
simulated_temperature
,
self
.
target_temperature
,
0.
,
100.
]
...
...
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