Formalize read/write to shared variables
Reason for issue: do()
in Keyboard writes the shared variables intermittently, this needs to be reprogrammed using the read_from_shared_values
and write_to_shared_values
functions in module_process.
We need to better structure/enforce when SV's can be read and written to. Possible approaches:
-
Through written 'agreements', but we all know that people are not going to adhere to this and will access shared_variables willy-nilly -
Return a dataclass (Python equivalent of C++ structs) with copies of the shared_variables. Same thing for writing: only through the dataclass. Ideally people only write once to the shared_variable. -
The second point works, however this still does not solve the problem that we only want to write to shared variables within its own module, I was thinking of making a seperate function for writing which will call the setter only when that condition is met
Niek and I (joris) discussed this today and we think we should keep it the way it is just make really clear that you have to copy the variables, then do your calcullations and set them again. Also want to implement the last point above (a check if you ar setting it in the appropriate module)