You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I apologize if this question is a little scattered, i trying to muddle my way threw using this in conjunction with guide to make a GUI which will control some canberra NIM modules. I am certainly not the best at coding.
The code works perfectly when its just one function or script, but when i have multiple functions in one file or callbacks from gui elements, i run into trouble.
I had assumed i could create a function that utilized just the
portion of the code with the rest in the opening function, but in practice that did not work. I assume it has something to do with the import ch.psi.jcae.*
not being passed into the callbacks.
My work around was to write a function that simply repeated the various commands, using variable string to control which channel i accessed.
function answer = EPICS_READ(PV,type)
if not(exist('java_classpath_set'))
javaaddpath('ca_matlab-1.0.0.jar')
java_classpath_set = 1;
end
import ch.psi.jcae.*
properties = java.util.Properties();
context = Context(properties);'
channel = Channels.create(context, ChannelDescriptor(type, PV));
answer = channel.get()
channel.close();
context.close();
I can then call this one function from any of my callbacks and easily pass the various PV's and parameters back and forth.
My question is... is this the best way?
It seems like I am calling the same code repeatedly, which takes time and is slowing down the gui.
Is there a way to achieve my desired outcome, Were the bulk of the code, loading the java, etc.
is run once, and then the actual channel creation and closure is all i need to worry about within a callback or subfunction.
something like this
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
if not(exist('java_classpath_set'))
javaaddpath('ca_matlab-1.0.0.jar')
java_classpath_set = 1;
end
import ch.psi.jcae.*
properties = java.util.Properties();
context = Context(properties);
function edit1_Callback(hObject, eventdata, handles)
channel = Channels.create(context, ChannelDescriptor(type, PV));
answer = channel.get()
channel.close();
another question, is it important to close the whole context, after creating and using one channel? context.close();
or is there a way to create the context once, then just leave it open for as long as my gui is open and running passing it like handles and hObject or something?
somehow passing the context and java import into my various callbacks
Does my question even make sense... i barely understand it myself...
-Jay
The text was updated successfully, but these errors were encountered:
Hello,
I apologize if this question is a little scattered, i trying to muddle my way threw using this in conjunction with guide to make a GUI which will control some canberra NIM modules. I am certainly not the best at coding.
The code works perfectly when its just one function or script, but when i have multiple functions in one file or callbacks from gui elements, i run into trouble.
I had assumed i could create a function that utilized just the
portion of the code with the rest in the opening function, but in practice that did not work. I assume it has something to do with the
import ch.psi.jcae.*
not being passed into the callbacks.
My work around was to write a function that simply repeated the various commands, using variable string to control which channel i accessed.
I can then call this one function from any of my callbacks and easily pass the various PV's and parameters back and forth.
My question is... is this the best way?
It seems like I am calling the same code repeatedly, which takes time and is slowing down the gui.
Is there a way to achieve my desired outcome, Were the bulk of the code, loading the java, etc.
is run once, and then the actual channel creation and closure is all i need to worry about within a callback or subfunction.
something like this
another question, is it important to close the whole context, after creating and using one channel?
context.close();
or is there a way to create the context once, then just leave it open for as long as my gui is open and running passing it like handles and hObject or something?
somehow passing the context and java import into my various callbacks
Does my question even make sense... i barely understand it myself...
-Jay
The text was updated successfully, but these errors were encountered: