Author |
Topic  |
|
LukasBurgi
Switzerland
Posts |
Posted - 06/18/2005 : 04:33:30 AM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System: XP
I call Origin from Labview using the following LabView code, which closes Origin at the end of program execution.

(The OriginC code FET.OP used above treats a whole bunch of data, saves the results to pdf files and prints them out on summary sheets.)
This works fine, provided that no one is about to use an instance of Origin at the time LabView calls Origin. The trouble starts, when instances of Origin are already open and someone is working with Origin when Labview calls. The instance of Origin, which was opened latest is then usually closed (with loss of all work) and LabView quite often crashes.
My actual question: Is it possible to launch an additional instance of Origin from LabView, which does not interfere with any other instance of Origin that was already opened before?
Thanks in advance, Lukas
|
|
easwar
USA
1965 Posts |
Posted - 06/20/2005 : 11:11:30 AM
|
Hi Lukas,
In Origin 7.5 SR5, there are three ways to connect to Origin from a client application: Application ApplicationSI ApplicationCOMSI
The first one launches a new instance each time a client initiates this operation.
The second one connects to the oldest running instance of Origin which is available at that point.
The third one connects to the same instance of Origin again and again - this way a client can launch Origin using this third instance and then quit and later connect again to the same instance etc.
Now, in the SubVIs for LabView that we provide with Origin, we only implemented connecting using ApplicationSI, the second method. This is why when you launch Origin from your LabVIEW client, it is connecting to the already existing session (that the user may at that time be running independently) and then your client closes that session etc.
To avoid this, we will need to provide three ways of connecting to Origin following the three automation server methods that we currently support - in other words we need to create more SubVIs for the other two connection types and add them to the library we provide. We will work on doing this in the future.
However, for now, you can yourself do this by using the ActiveX controls available in LabVIEW. So instead of adding the OAOpenCommunication.vi and OACloseCommunication.vi from our SubVI library, you can initiate connecting to Origin yourself using LabVIEW ActiveX controls.
The following steps are what I used: 1> Find the following help topic (I am using LabVIEW 7):
 2> Click the Place button under step 1 of the help file to place the automation refnum object. Then for the steps 2 thru 4, right-click on that object, choose the "Select ActiveX Class->Browse" context menu, then browse to the file Origin.tlb Type Library file which will be located in the main Origin EXE path. In the dialog that pops up, you will see Application, ApplicationSI etc. Select "Application". This will ensure that a new instance of Origin is created by the LabVIEW client. 3> Follow the other steps in the help file to place the Automation Open block etc and then use any other Origin-suppied SubVI to complete your VI.
The image pasted below shows how the Tutorial1.VI example that we ship with Origin has been modified to connect directly using the ActiveX controls in LabVIEW

Hope this helps for now, until we re-create our SubVI library.
Easwar OriginLab
|
 |
|
LukasBurgi
Switzerland
Posts |
Posted - 06/21/2005 : 05:14:34 AM
|
Thanks a lot for your reply. I copied your Tutorial1New 1:1. When I choose "ApplicationSI" as the ActiveX Class, the example works fine. However, when I choose "Application", the program does not work. (I was running the program on a computer on which a standard (not Pro) version of Origin is installed.) I also modified my code, which now looks the following

Again, when I choose "Application SI" the code does all right. However, when I choose "Application", I get the "Reminder Message" "Compiler is busy ..." and the following error message:

Lukas
|
 |
|
easwar
USA
1965 Posts |
Posted - 06/21/2005 : 09:45:59 AM
|
Hi Lukas,
The problem you are facing now with Application is that you are launching a new instance which then does compiling of the system files, and so your command to load and compile the .op file is being sent to Origin while it is still busy compiling the current workspace.
Try the following first: In your LabTalk script that you are sending to load and compile, add a delay in front such as: sec -p 5; // wait 5 secs for compiling to finish err = run.loadoc....etc
If the above does not work, you could try a while loop where you execute the run.loadoc command until it successfully loads and compiles, or quit after a certain number of tries.
Easwar OriginLab
|
 |
|
easwar
USA
1965 Posts |
Posted - 06/21/2005 : 11:18:45 AM
|
Hi Lukas,
First of all, I could reporduce your problem and the solution that I posted of adding a "sec -p 5" which makes Origin wait 5 secs before executing the run.loadoc command worked as a possible solution.
However, with the above solution, the amount of time to wait will really depend on the machine, how many files there are in the current workspace etc and so is not a reliable solution perhaps.
We have another suggestion: You could create an Origin Project where you add your OP file (and any other OC file, other templates associated files etc as well) as attachments to the project itself. You can do this by going to Code Builder and doing a right-click on the Project branch of the tree and add files, or even simply drag-and-drop files from other branches such as the User branch, to the Project branch. Then if you save that project, the files in the Project branch stay with the project. And later when that project is opened, the files in the Project branch get automatically loaded and compiled and will be ready for use.
The benefit of doing the above is that instead of issuing the run.loadoc command, you could simply open the project after Origin is lauched programmatically. In this case, the opening of the OPJ waits for the system files etc to be compiled and so there will be no error generated. And once the opj has been opened, you could call your functions etc.
The image pasted below shows such an example in LabVIEW - here I just open the project, then issue a script command to make Orign visible and call my function from the OC file attached to the OPJ, which just prints a message to script window.
Easwar OriginLab

|
 |
|
|
Topic  |
|
|
|