6/5/2018 Copyright 2018 Simio LLC 1
Using the Simio APIOverview and Use
Dan Houck
Sr. Software Engineer
User Group 2018
6/5/2018 Copyright 2018 Simio LLC 2
Impart a sense of what is possible
Show how Simio is extended by the API
Introduce some software concepts
Demonstrate the workflow
Objectives
6/5/2018 Copyright 2018 Simio LLC 3
Why API? A Brief Overview
How the Simio API is organized and used
What is installed with Simio
What is needed to build an API▪ The Work Flow. Visual Studio and .NET
▪ References, Tools, and Tips
The Future: Plans for the next year
Questions, Answers, Feedback
Topics
6/5/2018 Copyright 2018 Simio LLC 4
A set of clearly defined methods of communications between software components.
Particularly useful to Simio which is data-driven
Allows Simio to extend to more solutions▪ Incorporate existing or complex logic
Allows Simio to communicate with other Software▪ Use for building large / complex / variable models
Examples of API Usage:▪ Import or Export Data
▪ Interface with existing logic
▪ Modify the behavior of Simio objects
▪ Interface with other Systems/Packages/Legacy Logic
▪ Build and modify models from external data
Application Programming Interface
6/5/2018 Copyright 2018 Simio LLC 5
User Extensions▪ Design Time Add-Ins
▪ User Defined Steps (Run-Time)
“Headless” or “Back-End” Simio Engine▪ Controlling the “black box”
API Uses Discussed
6/5/2018 Copyright 2018 Simio LLC 6
Users > {you} > Documents
SimioModels▪ SimioUserExtensions
Users > Public Documents > Documents▪ Simio
▪ Examples
o User Extensions (A folder for each, E.g. TextFileReadWrite)
▪ Reports, Skins, …
Program Files (x86)▪ Simio Executable
Visual Studio Templates
Simio Installation: What You Get
6/5/2018 Copyright 2018 Simio LLC 7
General Programming Knowledge
Modern Programming Concepts: ▪ Objects
▪ Interfaces
Knowledge of .NET Concepts
Familiarity with C#
Familiarity with Visual Studio
General Fearlessness
Simio API: What you Need
6/5/2018 Copyright 2018 Simio LLC 8
Simio API Forum (for examples, community help)
Simio API Overview (referenced on Forum)
StackOverflow (for .NET programming advice)
Simio Examples (from Simio installation)
Simio API Reference Guide
Resources
6/5/2018 Copyright 2018 Simio LLC 12
Usages: Anything that should be done during design▪ Building Models Dynamically
▪ Read/Write Model Data Dynamically
▪ Setting up context for Run-Time
Design-Time Add-Ins
6/5/2018 Copyright 2018 Simio LLC 13
Create Routes Interactively with GIS Web interface (GIF)
Add-In: Real-Time Model Building
6/5/2018 Copyright 2018 Simio LLC 15
Usages: When Special Run-Time Logic is Required▪ Special I/O
▪ Creating Simio Events
▪ Custom Logic (e.g. Routing)
User Steps (Run-Time)
6/5/2018 Copyright 2018 Simio LLC 17
Starting Framework (VS Templates)
Understanding some basic .NET object concepts▪ Object, Inheritance, Collections
▪ What is an Interface
Discovering how to use the Interfaces
A good example as a reference helps… a lot.
Building: Using the API to Create…
6/5/2018 Copyright 2018 Simio LLC 18
Creating a DLL (for User Extensions)
Creating an EXE (for the Headless Simulation
Building: Two Models
6/5/2018 Copyright 2018 Simio LLC 21
A defined way to “see” an object:IEngine might have properties like cubic inches, HP, …
IManufacturer might have Model, Make, Year, …
What is an Interface
6/5/2018 Copyright 2018 Simio LLC 23
How to debug (breakpoints, watch points)
Intellisense
Use included tools: object browser, NuGet, etc..
Simio API: Know your IDE (VS)
6/5/2018 Copyright 2018 Simio LLC 24
Simio API Reference
External Tools to Examine the Simio DLLs
Simio API: Know your Interfaces
6/5/2018 Copyright 2018 Simio LLC 28
DotPeek (JetBrains)
StackOverflow
C# In Depth (Jon Skeet)
API Helper (Simio Forum)
My API Toolbox
6/5/2018 Copyright 2018 Simio LLC 29
Two basic Modes:1. You are building a DLL to be run by Simio
▪ For Steps and Design Add-Ins
2. You are controlling Simio as an EXE▪ Running the Back-End Engine
Visual Studio Workflow
6/5/2018 Copyright 2018 Simio LLC 31
Start Simio.exe (which will find and call your DLL)
VS Adjustment #2
6/5/2018 Copyright 2018 Simio LLC 32
Export-Import Demonstrates Simio Objects:▪ Table Data
▪ Objects and Links
▪ Object Types
▪ Vertices
▪ Networks
▪ Elements
▪ Lists
▪ Model Property Values
▪ Table Property Values
Forum Favorite
6/5/2018 Copyright 2018 Simio LLC 34
Don’t forget to “Unblock” and download (before unzipping)
Run your extensions in the Visual Studio debugger
Use error handling
Don’t reinvent; E.g. NuGet (113K+ unique packages)
Don’t start from scratch; check the examples and forums
Tips and Checklist
6/5/2018 Copyright 2018 Simio LLC 35
There is website, but easiest within Visual Studio…
Code: Use NuGet
6/5/2018 Copyright 2018 Simio LLC 37
Several options are available:▪ 1. Use the Simio error methods
▪ 2. Log to a file
▪ 3. Use a MessageBox
▪ 4. Throw an ApplicationException (Simio will catch it)
Coding: Use Error Handling
6/5/2018 Copyright 2018 Simio LLC 38
Add Tools/Techniques to assist with debugging
More Examples and Improved Search
More Data Interfaces to support Industry 4.0
Evolve with C# and .NET
Simio API: The Future
6/5/2018 Copyright 2018 Simio LLC 39
Discrete Part Prod. with On Run-Ending Export
Contains Several Examples:▪Running “Headless” Simio Engine as a Service
▪Importing Property (WorkPeriodExceptions)
▪Using .NET FileWatcher to look for files
▪Exporting results
Case Study: Complex
6/5/2018 Copyright 2018 Simio LLC 42
OnStart (as a service, this would be called automatically)
SDPP with Ending Export