- Select "DDE Server" from WinWedge "Mode" menu.
When the dialog box appears asking for a DDE Command Target
Application, enter: "Origin" as the DDE Application
Name and then enter "ORG" as the DDE topic.
- Select "Input Record Structure" in the "Define" menu
and define the structure of the input record(s) to WinWedge.
When you get to the final Window entitled "Input Record
Definition Editor", enter the string Get_Wedge_Data
as the Field Postamble DDE Command after the last data
field that you have defined. This is a DDE command that
will be sent to Origin 5.0 after each data record is received
by the Wedge.
- Save this configuration of WinWedge to a file MyConfig.SW3
Launch Origin and open the Script
Window by selecting Window:Script Window from the Origin
menu bar. Enter the following lines of script to launch WinWedge
and Start a conversation. This example assumes that WinWedge.Exe
and the configuration file "MyConfig.SW3" exists
and both are located in a directory named "WinWedge" and
that the config file "MyConfig.SW3", saved from
above, will configure WinWedge for serial port COM1.
| |
//Launch WinWedge with configuration
file
run -e c:\Winwedge\winwedge.exe
c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1 id;
//Initiate conversation
|
Note: There are two ways to execute a script from the Script Window.
One way is to type text into the Script Window and press ENTER.
The text from the beginning of the line to the current cursor
point is sent to the interpreter as a single script. After
pressing ENTER, Origin appends a semicolon to the end of the
line to indicate the script was executed. Another option for
executing script from the Script Window is to Highlight multiple
lines of text (including a semicolon at the end of each line)
to be executed and press ENTER.
Origin 5.0 does not have a "Get_Wedge_Data" DDE command
so the first step is to create one. When you create a macro
in Origin 5.0, the name of the macro automatically becomes
a valid Origin 5.0 DDE command (or script command) for
as long as the project is open. This example assumes that
WinWedge.EXE and the configuration file "MyConfig.SW3" both
exist and are located in a directory named "WinWedge" and
that the config file "MyConfig.SW3", saved from
above, will configure WinWedge for serial port COM1. Each
time data is sent to the wedge the data is entered in a
new row.
| |
//Create
Get_Wedge_Data Macro
def
Get_Wedge_Data {
//Launch
WinWedge with configuration file:
run -e c:\Winwedge\winwedge.exe
c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1
id; //Initiate conversation
dde
-r id field(1); //Request information
plot
-a %H 1 "%Z "; //Enter data into column
1 of the active worksheet
dde
-d id; //terminate dde link
}; |
Note: To define
the above macro, highlight the entire block of text and
hit ENTER.
If you have defined 2 fields in WinWedge
and would like to collect the data into two columns, then
modify the macro above to include a line that collects
data from field 2:
| |
//Create
Get_Wedge_Data Macro
def
Get_Wedge_Data {
//Launch
WinWedge with configuration file:
run -e c:\Winwedge\winwedge.exe
c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1
id; //Initiate conversation
dde
-r id field(1); //Request information from field
1
plot
-a %H 1 "%Z "; //Enter data into column
1 of the active worksheet
dde
-r id field(2); //Request information from field
2
plot
-a %H 2 "%Z "; //Enter data into column
2 of the active worksheet
dde -d id; //terminate
dde link
}; |
|