Simulation Tool - Plugin Development

Preview:

DESCRIPTION

In this presentation I give a brief overview of C# and introduce plugin development for the SBW Simulation Tool.

Citation preview

Simulation Tool Plug-in Development

Frank T. Bergmann

Bloomington, 2010

C# INTRO

C#

• Managed Language• Designed by: Microsoft, appeared in 2001• Influenced by: Java, C++, Object Pascal

.NET Framework

Hello World

using System;

class Hello{ static void Main() { Console.WriteLine

("Hello world"); }}

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

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();

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

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;

Events (sourcing)

public class Button{ public event EventHandler Click;

protected void OnClick(EventArgs e) { if (Click != null) Click(this, e); }}

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"); }}

More Information

• Wikibooks: http://en.wikibooks.org/wiki/C_Sharp_Programming

OVERVIEW SIMULATION TOOL API

SETTING UP VISUAL STUDIO

The Template

http://sourceforge.net/projects/sbwsimtool/files/visual-studio-templates/v1

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#

Open Visual Studio

Project\Simula… Properties

Project\Simula… Properties

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>

Debug\Run

Debug\Run

C O D E

RECAP

Hello World

SBML Viewer

Jarnac Editor

Access to the BioModels Database

Basic Stochastic Simulation

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”).

Recommended