Implementing Multiple Workspaces for groups of functions/scripts

1 visualización (últimos 30 días)
Moritz Ulmer
Moritz Ulmer el 20 de Mzo. de 2015
Comentada: Moritz Ulmer el 20 de Mzo. de 2015
While refurbishing a HIL simulation project, I came across the problem of categorizing the variables used in the different subsystems. These include the Drive Simulation, Energy Management System, Virtual Hardware, and the Interface to the Real Hardware. Now each of these are variants, and thus there are different configurations of which variants are active and which variables these variants load.
A GUI is supposed to allow easy access to all variables. This means that the variables are listed in different list boxes {Auto, Route, EMS, ...}. They are also to be saved as a group, and therefore they are required to be grouped. In addition, a set of functions and scripts will interact with the variables.
There are three ways I see of tackling this problem:
  1. Add a prefix to all variables, i.e. Hio_Rti1103_EStop = Hardware Input/Output (the block) _ Rti1103 (the variant) _ EmergencyStop (the variable). A script is can then use regex or something similar to find the relevant variables. These will then be saved in the 'base' workspace. For functions to access these, they will always have to use the 'evalin' function.
  2. Make a seperate 'workspace' as described here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/255044Using global, it would be possible to always have access to it.
  3. Finally, and IMHO my favorite, use a struct for each workspace. This allows further classification, as in a tree graph. The only problem I foresee is how to iterate through each level, if more than one level is used. The struct could then also be defined as global and be given a unique name as mentioned in 1.
I would love to hear what the recommended method is.
Kind Regards, Moritz Ulmer
  1 comentario
Moritz Ulmer
Moritz Ulmer el 20 de Mzo. de 2015
Upon further investigation of the requirements, I possibly have to resort to using classes to house the variables. The reason behind this is that some variables are indirectly set. Scripts are used to compute their value. This means that it would make sense to use getter/setter functions. Classes reduce the amount of work required to implement this change, since they also create automatically generated setters/getters. This has the result that only those that require a function to be set need to be written.
Another problem might be the access/registration of the instantiation of the class. Through the use of variants, each referenced model would have its own instance of the class.
Is there literature that discusses Matlab relevant system architecture problems as the one stated above. It seems to me that the answer to the question might be beyond the scope of a forum answer.
Kind Regards, Moritz Ulmer

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT Files en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by