[Up: Download][Next]

DEMO 1: Compositional Events and DLL Dynamic Reconfiguration

NOTE: All the source code are implemented in Microsoft Visual Studio 2005

1. Set the environment:

   Add the additional dependencies in the environment: DCEngine.lib

2. fine the messages and response functions:

    int gnReceiveEventApp = RegisterWindowMessageA(szChangeEvent);

    int gnActionDoneEventApp= RegisterWindowMessageA(szActionDoneEvent);

    ON_REGISTERED_MESSAGE(gnReceiveEventApp, OnReceiveAction)

    ON_REGISTERED_MESSAGE(gnActionDoneEventApp, OnActionDoneAction)

3. Start Engine:

    // create a new decision engine instance

    pdcEngine = new CDCEngine();

    // set the xml file directory

    pdcEngine->SetXMLFile("dc.xml"); //"dc.xml" is the default xml file;

    // set the response application instance

    pdcEngine->SetHWnd(this);

    // start the decision engine

    pdcEngine->Start();

4. Implement the message response functions

    LRESULT CDCTestAppDlg::OnReceiveAction(WPARAM wParam, LPARAM lParam) {

        // when the formatted data is ready, we can get it by GetFormatValue();

        m_strEditOutput += pdcEngine->GetFormatValue();

        m_strEditOutput += "\r\n";

        UpdateData(FALSE);

        return 0;

    }

    LRESULT CDCTestAppDlg::OnActionDoneAction(WPARAM wParam, LPARAM lParam) {

        // If the reconfigurable components processing time is long,

        // we can use a seperate thread to process the data and wait

        // for this message when the data has been processed.

        return TRUE;

    }

5.  Input the data to the decision engine and get the output data from decision engine

    UpdateData(TRUE);

    int input_data = m_nEditInput;

    // input the data, and data size

    pdcEngine->SetMetaObjectInput(&input_data, sizeof(input_data));

    // start to process the data

    pdcEngine->StartMetaObject();

    void *output_data;

    // get the output data, and processed data size

    pdcEngine->GetMetaObjectOutput(&output_data, NULL);

    m_nEditOutput = *(int*)output_data;

    UpdateData(FALSE);

6.  Stop the decision engine

    if (pdcEngine != NULL) {

        // stop the decision engine

        pdcEngine->Stop();

        // release the memory

        delete pdcEngine;

        pdcEngine = NULL;

    }

 Name: “dc.xml” or UserDefinedName

 Users can define their own XML file, but it has to be set to the decision engine before it starts.

 Name: “dc.xsd”

 This file defines the format of XML file and it can not be changed.

 Name: “AwareData.src” or UserDefinedName

 This file provides the real time awareness data to the measurement tools of our decision engine.

 Users can define their own measurement tools, or load data from their own defined trace file.

 Trace file contents:

 [Awareness Name]          // this is the name of awareness data

     Len = i                          // i is the length of value array

     t1  = t1                          // the real time of the application runs (second)

     v1  = v1                         // the value of the awareness data at time t1

     ... ...

     ti  = ti

     vi  = vi

 Required Files:

 Application File: DCTestApp.exe

 Decision Engine: DCEngine.dll

 Components: Grab.dll, Compress.dll, and Send.dll

 Load and Parse Trace File: IniFile.dll

 Decision Configure file: dc.xml and dc.xsd

 Trace File: AwareData.src

 Steps:

 1.       Put all the required files in the same folder.

 2.       Double Click the DCTestApp.exe to start the application (fig 1).

 

Figure. The test application of our Awareware

 3.       Push the “Start” button to start the decision engine. The main output window would show the current awareness  data and components connection

 4.       Set the input data, and push the “Process” button. The upper output area would show the processed result of the  components

 

 

[Introduction][AwareWare][MassWare][Publications][Download][Members][Resources][Contact]

Copyright(c) 2007 Lehigh University. All rights reserved.
Web master: Shengpu Liu (shl204@lehigh.edu)