- This topic has 7 replies, 2 voices, and was last updated 7 years, 6 months ago by Be Asmaa.
-
AuthorPosts
-
-
May 29, 2017 at 10:01 am #43703Be AsmaaParticipant
Good afternoon,
i am having problem between Optisystem and Matlab.
when i execute a matlabcalloptisystem.m i have this error message
No appropriate method, property, or field GetLayoutMgr for class
Interface.optisystem_application.GetActiveDocument.please help me to solve this issue.
Regards -
May 31, 2017 at 3:35 pm #43792Marc VerreaultParticipant
Hi Asmaa,
I think I know what’s happening. I’ll need to track down one of our examples and I’ll get back to you with a solution as soon as I can. Cheers.
-
May 31, 2017 at 5:09 pm #43795Marc VerreaultParticipant
Hi Asmaa,
I have enclosed an example MATLAB file which is used to call OptiSystem.
I am not sure which version of OptiSystem you are running but the file originates from OptiSystem 14.2 Samples\Software interworking\MATLAB co-simulation\MATLAB call OptiSystem
Hopefully you can re-use portions of this code. Cheers!
-
May 31, 2017 at 5:15 pm #43796Marc VerreaultParticipant
Hi Asmaa,
I’m not sure if my attachment was successfully uploaded.
Here’s a copy and paste of he code just in case:
clearvars;
close all;% create a COM server running OptiSystem
optsys = actxserver(‘optisystem.application’);% Section looks for OptiSystem process and waits for it to start
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Execute the system command
taskToLookFor = ‘OptiSystemx64.exe’;
% Now make up the command line with the proper argument
% that will find only the process we are looking for.
commandLine = sprintf(‘tasklist /FI “IMAGENAME eq %s”‘, taskToLookFor);
% Now execute that command line and accept the result into “result”.
[status, result] = system(commandLine);
% Look for our program’s name in the result variable.
itIsRunning = strfind(lower(result), lower(taskToLookFor));
while isempty(itIsRunning)
% pause(0.1)
[status, result] = system(commandLine);
itIsRunning = strfind(lower(result), lower(taskToLookFor));
end
%%%%%%%%%%%%%%%%%%%%%%%%%% Open the OptiSystem file defined by the path
directory = strcat(pwd,’\Matlab Call OptiSystem.osd’);
optsys.Open(directory);% Specify and define the parameters that will be varied
ParameterName1 = ‘Power’;
SignalPower = -20:5:-10; %dBmParameterName2 = ‘Length’;
FiberLength = 5:5:15; %meters% Specify the results that will be transfered from OptiSystem
ResultName1 = ‘Max. Gain (dB)’;
ResultName2 = ‘Min. Noise Figure (dB)’;
ResultName3 = ‘Output : Max. OSNR (dB)’;Document = optsys.GetActiveDocument;
LayoutMngr = Document.GetLayoutMgr;
CurrentLyt = LayoutMngr.GetCurrentLayout;
Canvas = CurrentLyt.GetCurrentCanvas;% Specify the components that will have the parameters (results) transfered
Component1 = Canvas.GetComponentByName(‘CW Laser’);
Component2 = Canvas.GetComponentByName(‘EDFA’);
Visualizer1 = Canvas.GetComponentByName(‘Dual Port WDM Analyzer’);% vary the parameters, run OptiSystem project and get the results
for i = 1:length(SignalPower)
for k = 1:length(FiberLength)%Set component parameters
Component1.SetParameterValue( ParameterName1, SignalPower(i) );
Component2.SetParameterValue( ParameterName2, FiberLength(k) );%Calculate
Document.CalculateProject( true , true);%Acces visualizer results
Result1 = Visualizer1.GetResult( ResultName1 );
Result2 = Visualizer1.GetResult( ResultName2 );
Result3 = Visualizer1.GetResult( ResultName3 );Gain( (i-1)*length(FiberLength) + k ) = Result1.GetValue( 1 );
NF( (i-1)*length(FiberLength) + k ) = Result2.GetValue( 1 );
OSNR( (i-1)*length(FiberLength) + k ) = Result3.GetValue( 1 );
end
end%plot graphs
figure
subplot(3,1,1); plot(FiberLength,Gain(1:length(FiberLength)),FiberLength,Gain(length(FiberLength)+1:2*length(FiberLength)),FiberLength,Gain(2*length(FiberLength)+1:3*length(FiberLength)) )
title(‘Signal Gain’)
xlabel(‘Fiber length [m]’)
ylabel(‘Gain [dB]’)
subplot(3,1,2); plot(FiberLength,NF(1:length(FiberLength)),FiberLength,NF(length(FiberLength)+1:2*length(FiberLength)),FiberLength,NF(2*length(FiberLength)+1:3*length(FiberLength)) )
title(‘Noise Figure’)
xlabel(‘Fiber length [m]’)
ylabel(‘NF [dB]’)
subplot(3,1,3); plot(FiberLength,OSNR(1:length(FiberLength)),FiberLength,OSNR(length(FiberLength)+1:2*length(FiberLength)),FiberLength,OSNR(2*length(FiberLength)+1:3*length(FiberLength)) )
title(‘OSNR’)
xlabel(‘Fiber length [m]’)
ylabel(‘OSNR [dB]’)% close OptiSystem
optsys.Quit; -
May 31, 2017 at 6:08 pm #43797Be AsmaaParticipant
hello Marc Verreault,
thank you very much for your quick reply,i Use OptiSystem Version 9.0
When i use Computer with Windows7 ( 32bits ), the project Matlabcalloptisystem.osd works perfectly.
but when i use OptiSytem windows7 (64bits) he display this error even if i use the Code that you gave me.No appropriate method, property, or field GetLayoutMgr for class
Interface.optisystem_application.GetActiveDocumentI noticed a difference between the two after running the program,
With Windows7(32)
After execution the line “Document = optsys.GetActiveDocument”Interface.SDKOptiSystem_application_Design_1.0_Type_Library_ISDKOptiSystemDoc
But with windows7(64bits)
After execution the line “Document = optsys.GetActiveDocument”
Interface.optisystem_application.GetActiveDocumentand in the second line “LayoutMngr = Document.GetLayoutMgr;” , he display the error
No appropriate method, property, or field GetLayoutMgr for class
Interface.optisystem_application.GetActiveDocumentRegards
-
June 1, 2017 at 10:08 am #43811Marc VerreaultParticipant
Hi Asmaa,
It looks like for the 64-bit OS, VBscripting is not being recognized (needs to be activated or something). Are you able to run the regular OptiSystem MATLAB component script on your 64-bit OS (MATLAB script call directly within OptiSystem)? Cheers
-
June 2, 2017 at 1:06 pm #43877Be AsmaaParticipant
Hello Marc Verrault ,
Thank you for your reply
I have already used the component Matlab in Optisystem with the 64bits OS and he works perfectly, but the problem is otherwise in “Matlab call OptiSystem”.Regards
-
June 4, 2017 at 6:57 am #43885Be AsmaaParticipant
Good morning Mister Marc Verrault,
Can you help me please to solve this issus
Regards
-
-
AuthorPosts
- You must be logged in to reply to this topic.