Parallel timer operation in App Designer

조회 수: 10 (최근 30일)
WENCHIN LIU
WENCHIN LIU 2021년 2월 5일
편집: WENCHIN LIU 2021년 2월 8일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2021년 2월 6일
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
WENCHIN LIU
WENCHIN LIU 2021년 2월 8일
편집: WENCHIN LIU 2021년 2월 8일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by