2.7 Working with Origin Com And LabVIEW SubVIsOrigin can function as an automation server whereby other applications communicate with Origin using methods and properties exposed by Origin. LabVIEW can support COM programming, so it can easily communicate with Origin using Origin COM. Origin has equipped with some LabVIEW SubVIs, which can do some basic operations on worksheet, matrix, etc. But they are not enough when you are facing some complicated problems. In these situations, you may need to use Origin Com and the existed LabVIEW SubVIs together. This tutorial will show you how to work with Origin Com and LabVIEW SubVIs.
1. Run Labview, create a new VI and active the Block Diagram window. Then choose OA_ConnectToOrigin VI and place it to the window.
2. Select and place OA_NewWorksheet VI , then wire the Origin.IOApplication and Error IO connectors to the corresponding connectors of the OA_ConnectToOrigin VI.
3.Move the Mouse Cursor to the Origin.Worksheet connector of the OA_NewWorksheet VI. When the shape of the Cursor become to , right click and choose Create/ Property/ Cols to create a Property Node. Then right click on it and choose Change All To Write. After that, the Property Node will be like . Then wire reference connector to Origin.Worksheet connector of OA_NewWorksheet VI. And wire Error IO connector to the corresponding connector of the OA_NewWorksheet VI too.
4. Move the mouse to the Origin.Worksheet connector of the Property Node . When the shape of the mouse cursor is like , right click and choose Create/ Method/ Execute to create another Property Node. The Property Node will be like . Then wire reference connector to Origin.Worksheet connector of previous Property Node. And wire Error IO connector to the corresponding connector too. Then add a string constant and set it to impASC fname:= system.path.program$+"Samples\Import and Export\S15-125-03.dat", and then wire it to the LabTalkStr connector.
5. Select and place OA_NewEmptyGraph VI , then wire the Origin.IOApplication to the corresponding connector of the OA_ConnectToOrigin VI. And wire the Error IO to the corresponding connector of the second Property Node VI.
6. Select and place OA_PlotWksCols VI , then wire the Origin.Worksheet in connector to the corresponding connector of the Second Property Node. Wire the Origin.GraphLayer in and Error IO connectors to the corresponding connector of OA_NewEmptyGraph VI. Then create two integer constant and set them to 0, -1. Connect 0,-1 to c1,c2 connectors separately.
7. When all of these are finished, the Block Diagram should look like:
8. Click Run button to run this VI and then you can turn to Origin to see the result.
|