I want to use a backgroudpool to open a class
Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts.Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts. Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts. backgroundpool, parallel computing, parfeval MATLAB Answers — New Questions