Hi!
I´ll try to explain this question through a example.
Well start with three modules, Sensor_Module, Calculate_Module and Master_Module.
In Calculate_Module we have a number of sensors measuring temp, humidity and other environmental values.
Theese values are imported to Calculate_Module
and updated (if the importlib.reload actually updates the values) through
in functions using the values and needs updated values.
The results from Calculate_Module is then imported to Master_Module through
I have a function in Calculate_Module that updates the variables imported:
But when i import the values from Calculate_Module into the Master_Module the values are not updated.
I have searched for guides about how to do this but sofar i have not found anything.
I have tried to test withAnd the Sensor_Module values are updated every cycle but the Calculate_Module-Values are not.
So to sum it up - I would like to import values from Sensor_Module into Calculate_Module and have them updated every cycle.
importlib.reload(Sensor_Module) in functions in Calculate_Module does not do the trick (theese functions are called from Master_Module if this could be the problem.
Does anyone know how to do this in a relative simple way (if there is one)?
I´m new to python so there could be an easy answer.
Best,
Martin
I´ll try to explain this question through a example.
Well start with three modules, Sensor_Module, Calculate_Module and Master_Module.
In Calculate_Module we have a number of sensors measuring temp, humidity and other environmental values.
Theese values are imported to Calculate_Module
Code:
import Calculated Moduleimport importlib
Code:
importlib.reload(Sensor_Module)
The results from Calculate_Module is then imported to Master_Module through
Code:
import Calculate_Moduleimport importlib
Code:
Def Update_Environmental_Variables()Temp1=Sensor_Module.Sensor1.Temperatureand a number of other sensors
But when i import the values from Calculate_Module into the Master_Module the values are not updated.
I have searched for guides about how to do this but sofar i have not found anything.
I have tried to test with
Code:
print(values from Sensor_Module)print(values from Calculate_Module)
So to sum it up - I would like to import values from Sensor_Module into Calculate_Module and have them updated every cycle.
importlib.reload(Sensor_Module) in functions in Calculate_Module does not do the trick (theese functions are called from Master_Module if this could be the problem.
Does anyone know how to do this in a relative simple way (if there is one)?
I´m new to python so there could be an easy answer.
Best,
Martin
Statistics: Posted by Martin1234567 — Sun Jan 07, 2024 5:27 pm