www.simio.com| copyright 2010 simio llc | all rights reserved. 1 simio user code
TRANSCRIPT
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
1
Simio User Code
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
2Simio
Types of User Code
Steps and ElementsDynamic Selection RulesDesign Time Add-InsTable Import/BindingDesign or Run ExperimentsWe install the source code to all of
our extensions C:\Users\Public\Documents\Simio\Examples\UserExtensions in
Vista C:\Documents and Settings\All Users\Documents\Simio\
Examples\UserExtensions in XP
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
3Simio
Getting Started
Visual C# (or Visual Basic) 2008 Express Edition can be used to create these DLLs
Simio provides a Visual Studio template for a custom Step and a template for a custom Element
Auto install or manual setup: Start Menu – Simio – Advanced – Install Visual Studio
2008 Templates Place zip files into directory
• MyDocuments\Visual Studio 2008\Item Templates\[language]\SimioUserExtensions
• MyDocuments\Visual Studio 2008\Project Templates\[language]\SimioUserExtensions
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
4Simio
Using VS Templates
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
5Simio
Getting Started
Reference SimioAPI.dll and SimioAPI.Extensions.dll in the Visual Studio project
Implement the appropriate interfaces from SimioAPI.Extensions.dll
Copy your new DLL into the UserExtensions directory under the main Simio directory
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
6Simio
Location of Files
SimioAPI.dll and SimioAPI.Extensions.dll Program Files\Simio
Source code of Custom Extensions (.cs files) C:\Users\Public\Documents\Simio\Examples\
UserExtensions in Vista C:\Documents and Settings\All Users\Documents\
Simio\Examples\UserExtensions in XP
All custom .dll files (Simio provided and your files) Program Files\Simio\User Extensions PLACE YOUR CUSTOM .DLL FILES HERE SO
THEY APPEAR IN THE SIMIO INTERFACE
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
7Simio
Common Considerations
Most User Code extensions have a Name and a UniqueID. The Name is human readable. Simio uses
the UniqueID to identify each extension. Two extensions with the same Name but
different UniqueIDs are treated as different extensions.
The UniqueID is a GUID (Globally Unique IDentifier). You can create one by going to www.guidgen.com.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
8Simio
Steps and Elements
Typically, you will implement one or more related elements and one or more steps that operate on those elements.
For an element, create objects that implement the IElementDefinition and IElement interfaces
For a step, create objects that implement the IStepDefinition and IStep interfaces
IElementDefinition/IStepDefinition is where you describe the properties for the step or element.
IElement/IStep is where you put the runtime behavior.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
9Simio
Creating a step definition
Implement StepName, UniqueID, and NumberOfExits for the definition
Implement DefineSchema, and make calls to the methods on propertyDefinitions to add properties for the step.
Implement CreateStep to return a new instance of your implementation of IStep
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
10Simio
Defining a step’s runtime behavior
When Simio calls your implementation of Execute, you will: Retrieve the current values of your properties Act upon them Return a value indicating the exit for token
departure, or that the token is blocked at the step.
Typically, one of your properties would be an IElementProperty reference to a custom element that Execute manipulates
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
11Simio
Creating an element definition
Implement ElementName and UniqueID for the definition
Implement DefineSchema, and make calls to the routines on schema to add properties, states, or events for the element.
Implement CreateElement to return a new instance of your implementation of IElement
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
12Simio
Defining an element’s runtime behavior
Typically an element stores state at runtime. The logic is determined by steps manipulating the element.
Elements have Initialize and Shutdown routines, which Simio calls at the start and end of a simulation. Implementations could use these calls to
open and close external resources for example.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
13Simio
Dynamic Selection Rules
Dynamic Selection Rules are used to select from a list of things at runtime using some criteria (Smallest Value First, Largest Value First, etc.)
The ISelectionRuleDefinition is where you describe the properties for the rule
The ISelectionRule defines runtime behavior for the rule
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
14Simio
Creating a rule definition
Implement RuleName and UniqueID for the definition
Implement DefineSchema, and make calls to the methods on propertyDefinitions to add properties for the rule
Implement CreateRule to return a new instance of your implementation of ISelectionRule
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
15Simio
Defining a rule’s runtime behavior
Simio calls your Select routine with a collection of IExecutionContext, which represent a series of objects from which you make your selection
Return the IExecutionContext for the selected item
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
16Simio
Design Time Add-Ins
Design Time Add-Ins are executed from the user interface via the “AddIn” button on the “Project Home” tab.
They are used to produce model contents in code rather than using the user interface.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
17Simio
Creating a Design Time Add-In
Create an object that implements the IDesignAddIn interface
Implement Name, Description, and Icon for the add-in. These appear in Simio’s user interface.
When Simio calls the Execute routine, you use the IModel passed in to create and modify things in the model.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
18Simio
Table Import/Binding
Table importers are used to connect Simio’s tables to external data sources
They are executed under two conditions Interactively importing data for a table Automatically importing data for a bound
table at simulation start We ship with two examples, one for
Excel and one for CSV.
www.simio.com| Copyright 2010 Simio LLC | All rights reserved.
19Simio
Links with DB connect info
Oracle http://msdn.microsoft.com/en-us/library/
system.data.oracleclient(v=VS.100).aspx
SQL Server http://msdn.microsoft.com/en-us/library/system.data.sqlclient(v=VS.100).aspx
ODBC http://msdn.microsoft.com/en-us/library/system.data.odbc(v=VS.100).aspx