next up previous contents index
Next: Bibliography Up: Appendix: Building Projects using Previous: Building Simulation Examples in   Contents   Index

Adding Our Own Project

This section shows how to add new project which uses DEVS# library in a step-by-step procedure.
  1. Create a new project. Select File->New->Project... menu. Then we can see a dialog box as shown in Figure 5.3. We assume to create Console Application at DEVSsharp\Examples. The location we want to create new project can be selected by [Browser...] button. The new project is titled as MyProject.

    Figure 5.3: New Project Dialog
    \includegraphics[scale=0.15]{NewPrj}
    Then we can see the window screen of Visual Studio 2005 after creating MyProject as shown in Figure 5.4.

    Figure 5.4: My Project
    \includegraphics[scale=0.2]{MyPrj}

  2. Add DEVSshapr project. Since we need to use DEVSsharp library, we should add it by clicking right mouse button to `MyProject' at Solution Explorer and then select context menu through Add->Existing Project... as shown in Figure 5.5. A file selection dialog will pop up, so we will select DEVSsharp\DEVSsharp.csproj that is the project file of DEVSsharp.

    Figure 5.5: Menu Selection of Add Existing Project...
    Image AddPrj

  3. Add DEVSsharp as a MyProject's reference. Now we need to add DEVSshap project to MyProject as a reference. To do this, first left-button click MyProject at Solution Explorer and then select title menu of Project->Add Reference... or right-button click for context menu of Add Reference....
    Figure 5.6: Menu Selection of Add Reference...
    Image AddRefer

    We can see a dialog box titled as Add Reference as shown in Figure 5.7. We select Projects tab and select DEVSsharp and press OK button. Then MyPoroject's References at Solution Explorer becomes to contain DEVSsharp.

    Figure 5.7: Dialog of Add Reference
    Image AddRfDlg

    The following codes shows a simple example which are mainly copied from Ex_Timer project. Don't forget to add the statement of using DEVSsharp.

        using System;
        using System.Collections.Generic;
        using System.Text;
    
        using DEVSsharp; //<-- Don't forget add this statement
    
        namespace MyProject
        {
            public class Timer : Atomic
            {
                private OutputPort op;
    
                public Timer(string name)
                    : base(name, TimeUnit.Sec)
                { op = AddOP("op"); init(); }
                public override void init() { }
                public override double tau() { return 3.3; }
                public override bool delta_x(PortValue x) { return false; }
                public override void delta_y(ref PortValue y) { y.Set(op); }
                public override string Get_s() { return "Working"; }
            }
    
            class Program
            {
                static void Main(string[] args)
                {
                    Timer timer = new Timer("STimer");
                    SRTEngine Engine = new SRTEngine(timer, 10000, null);
                    Engine.RunConsoleMenu();
                }
            }
        }
    


next up previous contents index
Next: Bibliography Up: Appendix: Building Projects using Previous: Building Simulation Examples in   Contents   Index
MHHwang 2007-05-08