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: Select all
import Calculated Module
import importlib
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
Code: Select all
import Calculate_Module
import importlib
I have a function in Calculate_Module that updates the variables imported:
Code: Select all
Def Update_Environmental_Variables()
Temp1=Sensor_Module.Sensor1.Temperature
and 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: Select all
print(values from Sensor_Module)
print(values from Calculate_Module)
And 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