summaryrefslogtreecommitdiff
path: root/maximus/coreengine/test/src/TestExample.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'maximus/coreengine/test/src/TestExample.cpp')
-rw-r--r--maximus/coreengine/test/src/TestExample.cpp284
1 files changed, 0 insertions, 284 deletions
diff --git a/maximus/coreengine/test/src/TestExample.cpp b/maximus/coreengine/test/src/TestExample.cpp
deleted file mode 100644
index f529f52cd4..0000000000
--- a/maximus/coreengine/test/src/TestExample.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/************************************************************************
- TestExample.cpp - Copyright buret
-
-Here you can write a license for your code, some comments or any other
-information you want to have in your generated code. To to this simply
-configure the "headings" directory in uml to point to a directory
-where you have your heading files.
-
-or you can just replace the contents of this file with your own.
-If you want to do this, this file is located at
-
-/usr/share/apps/umbrello/headings/heading.cpp
-
--->Code Generators searches for heading files based on the file extension
- i.e. it will look for a file name ending in ".h" to include in C++ header
- files, and for a file name ending in ".java" to include in all generated
- java code.
- If you name the file "heading.<extension>", Code Generator will always
- choose this file even if there are other files with the same extension in the
- directory. If you name the file something else, it must be the only one with that
- extension in the directory to guarantee that Code Generator will choose it.
-
-you can use variables in your heading files which are replaced at generation
-time. possible variables are : author, date, time, filename and filepath.
-just write %variable_name%
-
-This file was generated on %date% at %time%
-The original location of this file is /home/buret/eclipse/maximus/coreengine/test/src/TestExample.cpp
-**************************************************************************/
-
-#include "TestExample.h"
-
-#include "FunctionSciMsg.h"
-#include "FunctionCallParameter.h"
-#include "FunctionCallManager.h"
-#include "SystemManager.h"
-#include "NetworkClockProcessor.h"
-#include "PhyProcessor.h"
-
-#include "Error.h"
-#include <iostream> // for 'cout', 'cerr' and 'clog'
-using namespace std;
-
-
-void maximus_function_call_test ( FunctionSciMsg & function_sci_msg )
-{
- clog << "=> maximus_function_call_test" << endl;
-
- unsigned char * pData = NULL;
- unsigned long dataLength = 0;
- function_sci_msg.bindParameter("function_call_parameter", dataLength, pData);
- clog << "\tfunction_call_parameter = ";
- for (unsigned int i=0; i<dataLength; i++)
- {
- clog << pData[i];
- }
- clog << endl;
-}
-
-
-// Constructors/Destructors
-//
-
-
-TestExample::TestExample ( FunctionCallManager * p_function_call_manager,
- SystemManager * p_system_manager,
- NetworkClockProcessor * p_network_clock_processor,
- PhyProcessor * p_phy_processor )
-{
- clog << "TestExample(...)" << endl;
-
- mpFunctionCallManager = p_function_call_manager;
- mpSystemManager = p_system_manager;
- mpNetworkClockProcessor = p_network_clock_processor;
- mpPhyProcessor = p_phy_processor;
-}
-
-
-TestExample::~TestExample ( )
-{
- clog << "~TestExample" << endl;
-
- mpFunctionCallManager = NULL;
- mpSystemManager = NULL;
- mpNetworkClockProcessor = NULL;
- mpPhyProcessor = NULL;
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-int TestExample::run ( )
-{
- clog << "TestExample::run" << endl;
- int testResult = -1;
-
- try
- {
- Sci_Msg_Station_Id stationId1 = mpSystemManager->createStation();
- Sci_Msg_Station_Id stationId2 = mpSystemManager->createStation();
-
- if ((0 != stationId1) && (0 != stationId2))
- {
- while (!mpSystemManager->areAllActiveStationsIdle());
-
- // Test function call
- //
- testResult = testFunctionCall (stationId1);
- process();
-
- // Test probe
- //
- testResult &= testProbe1 (stationId2); // 1. Get parameter
- process();
- testResult &= testProbe2 (stationId2); // 2. Set parameter
- process();
- testResult &= testProbe3 (stationId2); // 3. Get parameter that has been set to check result
- process();
- }
- }
- catch ( Error &e )
- {
- e.display();
- }
-
- return testResult;
-}
-
-
-void TestExample::process ( )
-{
- clog << "TestExample::process" << endl;
-
- while (!mpSystemManager->areAllActiveStationsIdle());
-
- bool b = true;
- unsigned int count = 0;
- while (b && (count < 5))
- {
- b = mpNetworkClockProcessor->processNextEvt();
- count ++;
- }
-
- while (!mpSystemManager->areAllActiveStationsIdle());
-}
-
-
-int TestExample::testFunctionCall ( Sci_Msg_Station_Id station_id )
-{
- int testFc = -1;
-
- FunctionSciMsg * functionSciMsg = mpFunctionCallManager->createMsg();
- mpFunctionCallManager->registerCallback(functionSciMsg->getSpecializedSciMsgId(), &maximus_function_call_test);
- testFc = functionSciMsg->setFunctionName("function_call_test");
- FunctionCallParameter parameter ("function_call_parameter", 27, (unsigned char *)"Maximus function call test\0");
- testFc &= functionSciMsg->addParameter(parameter);
- testFc &= functionSciMsg->setSciMsgStationId(station_id);
- mpFunctionCallManager->sendMsg(functionSciMsg);
-
- // Delete SCI msg
- //
- if (NULL != functionSciMsg)
- {
- delete (functionSciMsg);
- functionSciMsg = NULL;
- }
-
- return testFc;
-}
-
-
-int TestExample::testProbe1 ( Sci_Msg_Station_Id station_id )
-{
- int testProbe1 = -1;
-
- FunctionSciMsg * probeSciMsg1 = mpFunctionCallManager->createMsg();
- testProbe1 = probeSciMsg1->setFunctionName(PROBE_ID);
- FunctionCallParameter probeParameterToGet ("probe_call_parameter_to_get", 0, NULL);
- testProbe1 &= probeSciMsg1->addParameter(probeParameterToGet);
- testProbe1 &= probeSciMsg1->setSciMsgStationId(station_id);
- mpFunctionCallManager->sendMsg(probeSciMsg1);
-
- // Delete SCI msg
- //
- if (NULL != probeSciMsg1)
- {
- delete(probeSciMsg1);
- probeSciMsg1 = NULL;
- }
-
- return testProbe1;
-}
-
-
-int TestExample::testProbe2 ( Sci_Msg_Station_Id station_id )
-{
- int testProbe2 = -1;
-
- FunctionSciMsg * probeSciMsg2 = mpFunctionCallManager->createMsg();
- testProbe2 = probeSciMsg2->setFunctionName(PROBE_ID);
- unsigned char * pValueToSet = new unsigned char [sizeof(int)];
- int valueToSet = 36;
- memcpy(pValueToSet, &valueToSet, sizeof(int));
- FunctionCallParameter probeParameterToSet ("probe_call_parameter_to_set", sizeof(int), pValueToSet);
- testProbe2 &= probeSciMsg2->addParameter(probeParameterToSet);
- testProbe2 &= probeSciMsg2->setSciMsgStationId(station_id);
- mpFunctionCallManager->sendMsg(probeSciMsg2);
-
- // Delete SCI msg
- //
- if (NULL != probeSciMsg2)
- {
- delete(probeSciMsg2);
- probeSciMsg2 = NULL;
- }
-
- // Free allocated memory
- //
- if (NULL != pValueToSet)
- {
- delete [] pValueToSet;
- pValueToSet = NULL;
- }
-
- return testProbe2;
-}
-
-
-int TestExample::testProbe3 ( Sci_Msg_Station_Id station_id )
-{
- int testProbe3 = -1;
-
- FunctionSciMsg * probeSciMsg3 = mpFunctionCallManager->createMsg();
- testProbe3 = probeSciMsg3->setFunctionName(PROBE_ID);
- FunctionCallParameter probeParameterToCheck ("probe_call_parameter_to_set", 0, NULL);
- testProbe3 &= probeSciMsg3->addParameter(probeParameterToCheck);
- testProbe3 &= probeSciMsg3->setSciMsgStationId(station_id);
- testProbe3 &= mpFunctionCallManager->sendMsg(probeSciMsg3);
-
- // Delete SCI msg
- if (NULL != probeSciMsg3)
- {
- delete(probeSciMsg3);
- probeSciMsg3 = NULL;
- }
-
- return testProbe3;
-}
-
-
-// private methods
-//
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-// protected attribute accessor methods
-//
-