Page 795 - ExtendSim User Guide
P. 795

Data Management and Exchange 769
Other internal data storage and management methods
Double-clicking an embedded object activates features of the originating program. For instance, double-clicking an embedded Excel Chart provides access to Excel tools for selecting a chart type and configuring its display.
A typical use of embedded objects would be to insert an Excel worksheet into an ExtendSim model, then use DDE Linking (discussed on page 744) or the Value library’s Read and Write blocks (discussed on page 773) to exchange data between the model and the embedded object. This gives ExtendSim the added capabilities of Excel, without opening the Excel application.
How to embed an object into a worksheet
The example that follows embeds an Excel worksheet into an existing model and uses the Write block to send results to the worksheet.
Open the Reservoir 1 model located in the folder \Examples\Tutorials.
So that you don’t overwrite the original file, save the model as ReservoirEmbed.
Select Edit > Insert Object. The Insert Object dialog appears. It lists the embeddable objects that are available on your machine. The dialog is shown on page 770.
In the dialog, select the button Create New (the default choice) and choose Object Type: Microsoft Office Excel Worksheet. Then click OK to close the dialog and place the embed- ded object in the model.
If the Excel worksheet object is in an inconvenient location, click elsewhere on the model window to deselect it, then click back on the worksheet to select and move it.
Delete the Plotter I/O block on the right side of the model.
Add a Write block (Value library) to the model where the Plotter block was. Then open its
In the “Select destination type” frame, choose Send data to: Excel workbook, check Use embedded workbook, and select Embedded workbook list: Worksheet in Reser- voirEmbed.
In the “Specify Excel coordinates” frame, select Sheet: Sheet 1, Write: one row, and Col end: 4.
Leave the other settings at their defaults and close the Write block’s dialog.
To the left of the Write block, add a Simulation Variable block (Value library) to the model.
In its dialog, select Current time.
Connect the output of the Simulation Variable block to the top input of the Write block. In the finished model, this block will output current simulation time to the Excel work- sheet.
Draw a connection line from the remaining inputs of the Write block to the Contents, Rain- fall, and Stream named connections. (Be sure to make a complete connection; if a line seg- ment is dotted, it is not connected.)
Add a second Simulation Variable block (Value library) to the model. In its dialog, select Current step and specify that it adds 1 to the result.
Adding 1 is necessary because ExtendSim is zero-based and Excel is one-based, as discussed in “The mailslots feature allows communication between two ExtendSim applications run-
How To

   793   794   795   796   797