Parallel timer operation in App Designer

10 visualizzazioni (ultimi 30 giorni)
WENCHIN LIU
WENCHIN LIU il 5 Feb 2021
Modificato: WENCHIN LIU il 8 Feb 2021
Hi all,
Recently, I try to build a control and monitoring system through App Designer and I need multiple timers running at the same time (parallel). For example, I need a timer for CAN communication transceiving/ receiving data, a timer for MODBUS communication which also transceive/receive data, and a control optimization timer for heavy control optimization calculation. Ideally, I want them to operation parallelly where communication timers are triggered every 0.5s and the control timer is triggered every 5s, but I found the MATLAB is a single thread system, in which each timer is run in series. Therefore, I tried the parallel computing toolbox to make them run parallelly. Unfortunately, the MALTB command window shows that the app objs are not supported by the parallel computing toolbox. Does anyone know another way to achieve this purpose?

Risposte (1)

Walter Roberson
Walter Roberson il 6 Feb 2021
Parallel processes can run timers. They cannot share appdesigner objects with the other processes, but that just means that you have to be more selective about what you pass back and forth, and you cannot have the parallel processes directly change the properties of the app object and children, including not being able to affect user graphics directly.
What you can do is create parallel queues to do message passing between the parallel processes and the controller. For example the MODBUS controller can receive data and queue it back to the controller process, which can then send it to the process that needs to process the data.
There is naturally the question of how efficient those parallel queues are.
You might also be able to use memmap() to have multiple processes talk to the same file, which might be more efficient than memory passing.
There is also a File Exchange contribution for Shared Memory that is designed for Unix systems (Linux, Mac) but should not take much work to adapt to MS Windows.
  1 Commento
WENCHIN LIU
WENCHIN LIU il 8 Feb 2021
Modificato: WENCHIN LIU il 8 Feb 2021
Hi Walter,
In my design, there will be a pushbutton for system enable/disable, which means when I push the bottom, all the timers start operation and if I push the bottom again, the timers just stop operation. In my understanding, in this case, I have no choice but to use start(app.CAN timer), start(app.MODBUS timer), and start(app.Control timer); however, the app objects will inevitably involve in start and stop of the timers and the parallel computing toolbox can not work properly because of the app objects. In my understanding, a local variable can work properly with the parallel computing toolbox but I cannot define timer objects as local variables because other callbacks functions will need to start/stop the timers. Do you know or have an example code to solve this?
Best,
WL

Accedi per commentare.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by