Simio User Code Appendix - User Code
Types of User Code Steps and Elements Dynamic Selection Rules Design Time Add-Ins Table Import/Binding Design or Run Experiments We 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
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 Mention BUG in Visual Studio Express 2008 with our auto installer. Appendix - User Code
Using VS Templates
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
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
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.
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.
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
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 See the OpenStep (and PassThruStep) implementation Appendix - User Code
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
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. See FileElement Appendix - User Code
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
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
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 See LargestValueFirst rule Appendix - User Code
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.
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. See SourceServerSink add-in Appendix - User Code
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. See the CSVGridDataProvider Appendix - User Code
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 See the CSVGridDataProvider Appendix - User Code