using the simio api · simio api forum (for examples, community help) simio api overview...

46
6/5/2018 Copyright 2018 Simio LLC 1 Using the Simio API Overview and Use Dan Houck Sr. Software Engineer User Group 2018

Upload: doantuyen

Post on 29-Aug-2018

387 views

Category:

Documents


2 download

TRANSCRIPT

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 9

Examples Under Public Documents:

Simio Installation: Examples

6/5/2018 Copyright 2018 Simio LLC 10

TextFileReadWrite

Simio Installation: Example

6/5/2018 Copyright 2018 Simio LLC 11

Where they appear on the UI:

Design Time Add-Ins

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 14

Add-In Fully Built Model

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 16

Where they appear on the UI:

User Step

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 19

Building a DLL

6/5/2018 Copyright 2018 Simio LLC 20

Building an EXE

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 22

Simio API: Know Your Objects

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 25

API Reference Guide

6/5/2018 Copyright 2018 Simio LLC 26

Using the Simio API Reference Guide

Examining the Interface

6/5/2018 Copyright 2018 Simio LLC 27

Examining the Interface

Using the DLL and a Tool like DotPeek

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 30

Place the DLL Where Simio Can Find It:

VS Adjustment #1

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 33

Example Export-Import

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 36

Via Visual Studio: Tools > NuGet Package Manager

Code: 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 40

Overall Structure

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 41

Setup (Main)…

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 42

OnStart (as a service, this would be called automatically)

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 43

Facility Picture:

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 44

Data > Tables > Resources

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 45

Main Code Body:

SDPP with Ending Export

6/5/2018 Copyright 2018 Simio LLC 46

Code to insert WorkPeriodExceptions

SDPP with Ending Export