Professional Documents
Culture Documents
VBB DEV CSharpExpress2008
VBB DEV CSharpExpress2008
VBB DEV CSharpExpress2008
C# Express 2008 is the freely available power entry level development tool from Microsoft. Here we use the C# language in C# Express 2008 to create the Lamp component for VBB3. It is assumed you are somewhat familiar with C# Express and VBB3.
Step 3: Rename the default class to MyLamp and enter the following code
What this code actually does will be explained in a future tutorial. First we just want to see how we can build it and plug it into C#
using com.virtualbreadboard.interfaces; using com.virtualbreadboard.sim; using com.virtualbreadboard.graphics.svg; namespace MyVBBComponent { public class MyLamp : OpenVBBComponent { IopenVBBSVGFrame myLampON; IopenVBBSVGFrame myLampOff; IopenVBBXMLDOMNode myPinout; IopenVBBVoltage myInputPin; public override void initSVGRenderer() { IopenVBBSVG svg = getSVG(); myPinout = svg.createGroup(); myPinout.appendChild(svg.createRectangle(0, 0, 5 * SVGDefs.GRIDSIZE, 5 * SVGDefs.GRIDSIZE, "black", "black")); myPinout.appendChild(svg.createPinCircle(2.5F * SVGDefs.GRIDSIZE, 6.0F * SVGDefs.GRIDSIZE, 2, 1)); svg.setActiveGraphic(myPinout); myLampON = svg.createFrame(); myLampON.append(svg.createCircle(2.5F * SVGDefs.GRIDSIZE, 2.5F * SVGDefs.GRIDSIZE, 2 * SVGDefs.GRIDSIZE, "red")); myLampON.setVisible(false); myLampOff = svg.createFrame(); myLampOff.append(svg.createCircle(2.5F * SVGDefs.GRIDSIZE, 2.5F * SVGDefs.GRIDSIZE, 2 * SVGDefs.GRIDSIZE, "darkred")); myLampOff.setVisible(true); } public override void wirePins(IopenVBBPortInterface portInterface, IopenVBBWiringErrors errors) { myInputPin = portInterface.getPin(1); myInputPin.RegisterAsVoltageSink(this); } public override int getPinCount() { return 1; }
Step 4: Save the project and configure the target .net runtime
Next we need to configure the target .net platform. This is needed because VBB3 is currently being developed using VS2005 and the .NET 2.0 runtime. C# Express 2008 presently defaults to .NET 2.5 runtime but it does allow you to target earlier platforms. However before you can target a different platform C# Express requires you to save the project. I Saved the project as MyVBBComponent and C# Express placed this automatically in the default development directory which for me on Vista is C:\Users\James\Documents\Visual Studio 2008\Projects\MyVBBComponent\MyVBBComponent\bin\Debug Keep note of this directory as we will use it later. Now that the project is saved you can configure the runtime. Select the project properties and select the target framework as .NET Framework 2.0
Running the breadboard you can select the DIP high to power the light.
Next select a Windows Form Application Project and call it VBBLauncher or similar
From the VBBLauncher application right click and choose Set as Startup Project option. This configures the solution to launch the VBBLancher application on startup.
namespace VBBLauncher { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { AppDomain vbb = AppDomain.CreateDomain("VBB"); vbb.ExecuteAssembly("C:\\VBB3\\VirtualBreadboard.exe"); } } }
Then you can set debug breakpoints in your component and you are ready to launch
Start the application and you should see the Launch VBB Button. Click this to launch VBB and begin the debugging session. VirtualBreadboard will launch and when your component is placed onto a breadboard the breakpoint will be hit and you can debug your component code.