How to give "volatile" variables to an addlistener-callback?

3 ビュー (過去 30 日間)
Jan Ruhnau
Jan Ruhnau 2017 年 11 月 9 日
コメント済み: Walter Roberson 2017 年 11 月 23 日
Heyho dear people here...
Straight to the point: I have a GUIDE-made gui-application that is sending data via a A/D-card. Together with the Data Acquisition Toolbox there comes the functions that help me doing so (after initializing etc.):
queueOutputData(ao,data)
That worked fine so far, but what I was trying to achieve now was a continuously output, so I don't have to restart the output all the time and there is a continuous output of the data. For that I used the help of an addlistener kind of like so:
handles.lh = addlistener(handles.ao, 'DataRequired', @(src, event) AddlistenerCallback(src, data, data_2));
My major problem now is, that I have to define the addlistener at some point of the code. But all the data that I'd like to send with the AddlistenerCallback is set at this point as well. But in fact I need to change the data that needs to be queued.
So basically: I initialize the output and the addlistener, go on with the code, change the variables of the addlistenercallback on the fly, go on with the code again...
I have not found a way to change the data of the addlistener. My first attempt was to just reset/redeclare the addlistener-callback in either the callback itself or in its context, but that just lead to very unexpected behavior in which after resetting the callback it immediately started, although it shouldn't...
I have a dirty solution now, that relies on global variables, but would be glad if somebody comes up with a better solution, or can lead my in the right direction...?
Sorry if I couldn't make my problem clear... :)
Greetings Jan
  2 件のコメント
Jan Ruhnau
Jan Ruhnau 2017 年 11 月 23 日
Does nobody know the answer? Or was the question not clear enough?
Greetings

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by