simulation tool - plugin development
DESCRIPTION
In this presentation I give a brief overview of C# and introduce plugin development for the SBW Simulation Tool.TRANSCRIPT
![Page 1: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/1.jpg)
Simulation Tool Plug-in Development
Frank T. Bergmann
Bloomington, 2010
![Page 2: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/2.jpg)
C# INTRO
![Page 3: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/3.jpg)
C#
• Managed Language• Designed by: Microsoft, appeared in 2001• Influenced by: Java, C++, Object Pascal
![Page 4: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/4.jpg)
.NET Framework
![Page 5: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/5.jpg)
Hello World
using System;
class Hello{ static void Main() { Console.WriteLine
("Hello world"); }}
![Page 6: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/6.jpg)
Program Structure
• Namespaces– Contain types and other namespaces
• Type declarations– Classes, structs, interfaces, enums,
and delegates
• Members– Constants, fields, methods, properties, indexers, events,
operators, constructors, destructors
• Organization– No header files, code written “in-line”– No declaration order dependence
![Page 7: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/7.jpg)
Type System
• Value types– Primitives int i;
– Enums enum State { Off, On }
– Structs struct Point { int x, y; }
• Reference types– Classes class Foo: Bar, IFoo {...}
– Interfaces interface IFoo: IBar {...}
– Arrays string[] a = new string[10];
– Delegates delegate void Empty();
![Page 8: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/8.jpg)
Classes
• Single inheritance• Multiple interface implementation• Class members– Constants, fields, methods, properties, indexers,
events, operators, constructors, destructors– Static and instance members– Nested types
• Member access– public, protected, internal, private
![Page 9: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/9.jpg)
Propertiespublic class Button: Control{ private string caption;
public string Caption { get { return caption; } set { caption = value; Repaint(); } }}
Button b = new Button();b.Caption = "OK";String s = b.Caption;
![Page 10: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/10.jpg)
Events (sourcing)
public class Button{ public event EventHandler Click;
protected void OnClick(EventArgs e) { if (Click != null) Click(this, e); }}
![Page 11: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/11.jpg)
Events (handling)public class MyForm: Form{ Button okButton;
public MyForm() { okButton = new Button(...); okButton.Caption = "OK"; okButton.Click += new EventHandler(OkButtonClick); }
void OkButtonClick(object sender, EventArgs e) { ShowMessage("You pressed the OK button"); }}
![Page 12: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/12.jpg)
More Information
• Wikibooks: http://en.wikibooks.org/wiki/C_Sharp_Programming
![Page 13: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/13.jpg)
OVERVIEW SIMULATION TOOL API
![Page 14: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/14.jpg)
![Page 15: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/15.jpg)
SETTING UP VISUAL STUDIO
![Page 16: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/16.jpg)
The Template
http://sourceforge.net/projects/sbwsimtool/files/visual-studio-templates/v1
![Page 17: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/17.jpg)
Save in My Documents
• The template needs to be saved in:
%USERPROFILE%\My Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual C#Or %USERPROFILE%\My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#
![Page 18: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/18.jpg)
Open Visual Studio
![Page 19: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/19.jpg)
Project\Simula… Properties
![Page 20: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/20.jpg)
Project\Simula… Properties
![Page 21: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/21.jpg)
Visual Studio Express<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> <StartAction>Program</StartAction> <StartProgram>C:\Program Files (x86)\KGI\SBW\roadrunner\SimDriverNET.exe</StartProgram> <StartWorkingDirectory>C:\Program Files (x86)\KGI\SBW\roadrunner</StartWorkingDirectory> </PropertyGroup></Project>
![Page 22: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/22.jpg)
Debug\Run
![Page 23: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/23.jpg)
Debug\Run
![Page 24: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/24.jpg)
C O D E
![Page 25: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/25.jpg)
RECAP
![Page 26: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/26.jpg)
Hello World
![Page 27: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/27.jpg)
SBML Viewer
![Page 28: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/28.jpg)
Jarnac Editor
![Page 29: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/29.jpg)
Access to the BioModels Database
![Page 30: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/30.jpg)
Basic Stochastic Simulation
![Page 31: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/31.jpg)
Source / Binaries
• The Visual Studio Projects + source code & binaries are available from:
http://sourceforge.net/projects/sbwsimtool/files/tutorials/bloomington2010
![Page 32: Simulation Tool - Plugin Development](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f4b4ab4c905524c8b4990/html5/thumbnails/32.jpg)
Acknowledgements
Funded through the generous support of ERATO, DARPA (contract number MIPR 03-M296-01) and the DOE (under Grand No. DE-FG02-04ER63804, “Computational Resources for GTL”).