HowTo: Create an Example using Microsoft Visual Studio


This page is a step by step guide to install, compile the Apparatus Framework and set up a demo project on Windows. All you need to run the example is Visual Studio installed and the Apparatus Framework install file.

1. Download and Install the Apparatus Framework

Download the framework from this website, install it by running the msi. The installation is step by step documented in the (Documentation - Installation) section of this page.

2. Compile the Apparatus Framework Library

Open the Apparatus Framework Config tool in the start menu of Windows (Programs - bbv Apparatus Framework - Configuration Tool). Store a project file and name it EXAMPLE_PRJ.acc at some location like z:\EXAMPLE_PATH. Some changes are necessary to build for Windows:

  1. Remove {Build tool gcc} in (Build - Packages)
  2. Add {Build tool cl} in (Build - Packages)
  3. In (Tools - Paths) adjust the path (Build Tools) to C:\Program Files\Microsoft Visual Studio\VC98\Bin or where ever the cl.exe from your visual studio is installed to.
  4. In (Tools - Paths) adjust the path (User Tools) c:\cygwin\bin or where ever cygwin is installed on your machine.

Compile it now.
Sub directories EXAMPLE_PRJ_build and EXAMPLE_PRJ_install will be created along with EXAMPLE_PRJ.acc


The drive letter, z: in this case, must be mounted in cygwin. Use the following command:
mount -t -f z: /z
to mount the drive letter z: to /z in cygwin.

3. Create Files

Create the following files in the same directory as the EXAMPLE_PRJ.acc is located.


        #include "ApparatusFramework/KernelServices/Kernel.h"
        #include "ApparatusFramework/KernelServices/Task.h"
        #include "ApparatusFramework/DiagnosticServices/Logger.h"
        #include "PingPongTask.h"
        #include "PingPongMsg.h"
        int main(int argc, char **argv)
          Logger::Default()->printLogText("PingPongMain Start\n");
          // Create Tasks
          PingPongTask task1(task1Id, task1Priority, taskName1);
          PingPongTask task2(task2Id, task2Priority, taskName2);
          // Start Tasks (Please start all the tasks after you have constructed them.)
          Msg* pMsg = new PingPongMsg;
          pMsg->m_msgId = 0;
          Task::sendMsgToTask(&task1, pMsg);
          for (;;) 
          return 0;


        #ifndef PING_PONG_TASK_H
        #define PING_PONG_TASK_H
        #include "ApparatusFramework/KernelServices/Kernel.h"
        #include "ApparatusFramework/KernelServices/Task.h"
        const TaskId task1Id = 11;
        const TaskPriority task1Priority = 11;
        const char taskName1[] = "task1";
        const TaskId task2Id = 12;
        const TaskPriority task2Priority = 12;
        const char taskName2[] = "task2";
        class PingPongTask : public Task 
            PingPongTask(const TaskId taskId, const TaskPriority taskPriority, const char taskName[]);
            virtual void runBody();
            static int msgCounter;
        #endif //#define PING_PONG_TASK_H  


        #include "ApparatusFramework/KernelServices/Task.h"
        #include "ApparatusFramework/DiagnosticServices/Logger.h"
        #include "ApparatusFramework/KernelServices/apfw_assert.h"
        #include "PingPongTask.h"
        #include "PingPongMsg.h"
        int PingPongTask::msgCounter=0;
        PingPongTask::PingPongTask(const TaskId taskId, const TaskPriority taskPriority, const char taskName[]) : 
          Task(taskId, taskPriority, 0, 10, taskName)
        void PingPongTask::runBody()
          int id=taskId();
          Task* task;
          Msg* pMsg;
            pMsg = waitMsg();
            Logger::Default()->printLogText("PingPong: Task nr. %d receive message nr. %d \n",id,msgCounter);
            pMsg = new PingPongMsg;
            pMsg->m_msgId = ++msgCounter;
            sendMsg(task, pMsg);


        #ifndef PING_PONG_H
        #define PING_PONG_H
        #include "ApparatusFramework/KernelServices/Msg.h"
        class PingPongMsg : public Msg 
          Msg* clone(){return new PingPongMsg(*this);};
          void dump() const {Logger::Default()->printLogText("<PingPongMsg>\n");};
        #endif //PING_PONG_H      

4. Create a Visual Studio Project

Create a dsp and dsw project file for Visual Studio. The easiest way is to open test.cpp in Visual Studio and click build. The build will not succeed because several settings are not yet correct. But at least the project files test.dsp and test.dsw will be created.

5. Add the necessary files

Add the other files to the visual studio project:

  • PingPongTask.cpp
  • PingPongTask.h
  • PingPongMsg.h

6. Settings the include directory

In Visual Studio click (Project - Settings)
Tab (C/C++)
Choose (Preprocessor) in Category
Add .\EXAMPLE_PRJ_install\include in (Additional include directories)

7. Add the ApFw library

In Visual Studio click (Project - Settings)
Tab (Link)
Choose (Input) in Category
Add .\EXAMPLE_PRJ_install\lib in (Additional library path)
Add libApFw.a in (Object/library modules)

8. Compile it

Finally everything is ready to compile and run. Have fun!

8b. Using GCC

Alternatively, you can prepare a gcc build of the Apparatus Framework in step 2 (omit the exchange of the build tools package) and compile the example with something like:

       g++ -mno_cygwin -I./EXAMPLE_PRJ_install/include -o Test.exe PingPongTask.cpp test.cpp ./EXAMPLE_PRJ_install/lib/libApFw.a