Passing variable from event handler

6 visualizaciones (últimos 30 días)
Filip Dvoracek
Filip Dvoracek el 17 de Mayo de 2013
Hi all,
I would be very grateful for help, advice or suggestion. I have an application to control geodetic instrument using synchoronous interface. However some commands are asynchronous by its nature, e.g. GetReflectors. After this command is triggered I receive as many server answers as is the number of available reflectors. So I have registered an COM event and associate handler function. So far so good. I can display the data coming but I do not know how to pass some variable to the main function. I tried to save variable as .mat file or in .txt file and read it. Actually it works in Matlab but it do not works in compiled .exe aplication (Error firing event). Even "disp" command do not work in compiled aplication (display nothing). So the main question is: how to pass variables from handler to main function. Is there a way?
Thank you very much
Filip
function pushbutton_GetReflectors_Callback(hObject, eventdata, handles)
ltsync = actxserver ('LTControl.LTCommandSync2'); %Act as server: LTConnect2
ltsync.events() %List of all COM events
ltsync.registerevent({'ReflectorsData' 'ReflectorsHandler'}) %Register event
ltsync.GetReflectors() %Ask instrument for reflectors
pause(3) %Time to receive answers
end
function ReflectorsHandler(varargin) %Handler of the event ReflectorsData
%var1,var2,reflectorID,reflectorName,var5,surfaceOffset,reflectorsTotal,var8,var9
disp('Reflector Data:');
disp(varargin{3}) %Reflector ID
disp(varargin{4}) %Reflector name
end

Respuesta aceptada

Filip Dvoracek
Filip Dvoracek el 27 de Mayo de 2013
OK, I will answer my question myself, hope this could help others. The problem was mainly in that there was not compiled file including event hadler in exe application. The file has to be named in the main script like %#function function_name to be properly included in compilation.

Más respuestas (1)

Walter Roberson
Walter Roberson el 19 de Mayo de 2013

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by