summaryrefslogtreecommitdiff
path: root/maximus
diff options
context:
space:
mode:
authorburet2007-05-25 15:12:12 +0000
committerburet2007-05-25 15:12:12 +0000
commit803973c0afbe0897855a2300dd7f0993175a0cf6 (patch)
tree657c692088872d93b9620867b4ff117c44ba83f6 /maximus
parentbc7012f8c7247cbf3d7ee5fd32b3010f10201c53 (diff)
System package
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@172 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus')
-rw-r--r--maximus/common/interfaces/IFunctionCall.h64
-rw-r--r--maximus/common/interfaces/IPhy.h72
-rw-r--r--maximus/common/interfaces/ISystem.h1
-rw-r--r--maximus/functioncall/inc/FunctionCallManager.h135
-rw-r--r--maximus/functioncall/src/FunctionCallManager.cpp119
-rw-r--r--maximus/functioncall/src/FunctionSciMsg.cpp7
-rw-r--r--maximus/networkclock/src/ClockSciMsg.cpp6
-rw-r--r--maximus/networkclock/src/NetworkClockEvt.cpp7
-rw-r--r--maximus/networkclock/src/NetworkClockEvtListTest.cpp2
-rw-r--r--maximus/networkclock/src/NetworkClockProcessor.cpp21
-rw-r--r--maximus/networkclock/src/NetworkClockProcessorTest.cpp2
-rw-r--r--maximus/phy/inc/PhyProcessor.h123
-rw-r--r--maximus/phy/src/PhyProcessor.cpp119
-rw-r--r--maximus/phy/src/PhySciMsg.cpp7
-rw-r--r--maximus/sci/inc/SciServer.h3
-rw-r--r--maximus/sci/src/SciMsg.cpp21
-rw-r--r--maximus/sci/src/SciServer.cpp64
-rw-r--r--maximus/sci/src/SciServerTest.cpp2
-rw-r--r--maximus/system/inc/Station.h156
-rw-r--r--maximus/system/inc/StationConfiguration.h113
-rw-r--r--maximus/system/inc/SystemManager.h2
-rw-r--r--maximus/system/inc/SystemManagerTest.h8
-rw-r--r--maximus/system/src/Station.cpp187
-rw-r--r--maximus/system/src/StationConfiguration.cpp96
-rw-r--r--maximus/system/src/SystemManager.cpp77
-rw-r--r--maximus/system/src/SystemManagerTest.cpp49
-rw-r--r--maximus/system/src/SystemSciMsg.cpp7
27 files changed, 801 insertions, 669 deletions
diff --git a/maximus/common/interfaces/IFunctionCall.h b/maximus/common/interfaces/IFunctionCall.h
index f8e490f547..43b8bf7414 100644
--- a/maximus/common/interfaces/IFunctionCall.h
+++ b/maximus/common/interfaces/IFunctionCall.h
@@ -28,7 +28,6 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/common/interfaces/IFunctionCall.h
**************************************************************************/
-
#ifndef IFUNCTIONCALL_H
#define IFUNCTIONCALL_H
@@ -37,12 +36,14 @@ The original location of this file is /home/buret/eclipse/maximus/common/interfa
class FunctionSciMsg;
class Station;
+
/**
* class IFunctionCall
*/
class IFunctionCall
{
+
public:
// Constructors/Destructors
@@ -51,85 +52,38 @@ public:
/**
* Empty Constructor
*/
- IFunctionCall ( ) { };
+ IFunctionCall ( ) { }
/**
* Empty Destructor
*/
- virtual ~IFunctionCall ( ) { };
+ virtual ~IFunctionCall ( ) { }
-
- // public attribute accessor methods
+ // public methods
//
-
- // public attribute accessor methods
- //
-
-
-
/**
* @return bool
* @param station
* @param function_name
* @param function_sci_msg
*/
- virtual bool createMsg (Station * station, char * function_name, FunctionSciMsg * function_sci_msg ) = 0;
-
+ virtual bool createMsg ( Station * station, char * function_name, FunctionSciMsg * function_sci_msg ) = 0;
/**
* @return bool
* @param function_sci_msg
* @param callback_address
*/
- virtual bool registerCallback (FunctionSciMsg * function_sci_msg, void * callback_address ) = 0;
-
+ virtual bool registerCallback ( FunctionSciMsg * function_sci_msg, void * callback_address ) = 0;
/**
* @return bool
* @param function_sci_msg
*/
- virtual bool sendMsg (FunctionSciMsg * function_sci_msg ) = 0;
-
-protected:
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-
-private:
-
-public:
-
-
- // private attribute accessor methods
- //
-
-private:
-
-public:
-
-
- // private attribute accessor methods
- //
-
-private:
-
-
+ virtual bool sendMsg ( FunctionSciMsg * function_sci_msg ) = 0;
};
+
#endif // IFUNCTIONCALL_H
diff --git a/maximus/common/interfaces/IPhy.h b/maximus/common/interfaces/IPhy.h
index bc28aa1256..e89f9becc3 100644
--- a/maximus/common/interfaces/IPhy.h
+++ b/maximus/common/interfaces/IPhy.h
@@ -28,7 +28,6 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/common/interfaces/IPhy.h
**************************************************************************/
-
#ifndef IPHY_H
#define IPHY_H
@@ -44,6 +43,7 @@ The original location of this file is /home/buret/eclipse/maximus/common/interfa
class IPhy
{
+
public:
// Constructors/Destructors
@@ -52,31 +52,23 @@ public:
/**
* Empty Constructor
*/
- IPhy ( ) { };
+ IPhy ( ) { }
/**
* Empty Destructor
*/
- virtual ~IPhy ( ) { };
-
+ virtual ~IPhy ( ) { }
- // public attribute accessor methods
- //
-
-
- // public attribute accessor methods
+ // public methods
//
-
-
/**
* @return bool
* @param station1
* @param station2
* @param link_quality
*/
- virtual bool checkLinkQuality (Station * station1, Station * station2, Phy_Link_Quality & link_quality ) = 0;
-
+ virtual bool checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const = 0;
/**
* @return bool
@@ -84,8 +76,7 @@ public:
* @param station2
* @param link_quality
*/
- virtual bool manageLinkQuality (Station * station1, Station * station2, Phy_Link_Quality link_quality ) = 0;
-
+ virtual bool manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality ) = 0;
/**
* @return bool
@@ -93,8 +84,7 @@ public:
* @param data_length
* @param data
*/
- virtual bool sendEthernetData (Station * destination_station, short int data_length, unsigned char * data ) = 0;
-
+ virtual bool sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const = 0;
/**
* @return bool
@@ -106,47 +96,15 @@ public:
* @param pb_size
* @param mpdu_payload
*/
- virtual bool sendAvData (Station * destination_station, char mpdu_format, unsigned long fc_10, unsigned long fc_av[4], unsigned char nb_of_pbs, char pb_size, unsigned char * mpdu_payload ) = 0;
-
-protected:
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-
-private:
-
-public:
-
-
- // private attribute accessor methods
- //
-
-private:
-
-public:
-
-
- // private attribute accessor methods
- //
-
-private:
-
-
+ virtual bool sendAvData ( const Station * destination_station,
+ const char mpdu_format,
+ const unsigned long fc_10,
+ const unsigned long fc_av[4],
+ const unsigned char nb_of_pbs,
+ const char pb_size,
+ const unsigned char * mpdu_payload ) const = 0;
};
+
#endif // IPHY_H
diff --git a/maximus/common/interfaces/ISystem.h b/maximus/common/interfaces/ISystem.h
index afbcf8ef2b..926f98be1a 100644
--- a/maximus/common/interfaces/ISystem.h
+++ b/maximus/common/interfaces/ISystem.h
@@ -38,7 +38,6 @@ The original location of this file is /home/buret/eclipse/maximus/common/interfa
typedef std::list<Station*> StationsList;
-
/**
* class ISystem
*/
diff --git a/maximus/functioncall/inc/FunctionCallManager.h b/maximus/functioncall/inc/FunctionCallManager.h
index 9d823113e8..0a17badfd6 100644
--- a/maximus/functioncall/inc/FunctionCallManager.h
+++ b/maximus/functioncall/inc/FunctionCallManager.h
@@ -28,12 +28,13 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/functioncall/inc/FunctionCallManager.h
**************************************************************************/
-
#ifndef FUNCTIONCALLMANAGER_H
#define FUNCTIONCALLMANAGER_H
#include "IFunctionCall.h"
+
class FunctionSciMsg;
+class SciServer;
/**
@@ -42,11 +43,30 @@ class FunctionSciMsg;
class FunctionCallManager : public IFunctionCall
{
+
public:
- // Constructors/Destructors
+ // public attributes
+ //
+
+private:
+
+ // private attributes
//
+ FunctionSciMsg * mpFunctionSciMsg; // list
+ void * mpCallback; // list
+ SciServer * mpSciServer;
+
+protected:
+
+ // protected attributes
+ //
+
+public:
+
+ // Constructors/Destructors
+ //
/**
* Empty Constructor
@@ -54,112 +74,67 @@ public:
FunctionCallManager ( );
/**
+ * Constructor
+ */
+ FunctionCallManager ( SciServer * sci_server );
+
+ /**
* Empty Destructor
*/
virtual ~FunctionCallManager ( );
- // Static public attributes
- //
-
- // public attributes
- //
-
-
- // public attribute accessor methods
- //
-
-
- // public attribute accessor methods
+ // public methods
//
-
-
/**
* @return bool
+ * @param station
+ * @param function_name
* @param function_sci_msg
*/
- bool identifyCallback (FunctionSciMsg * function_sci_msg );
-
-protected:
+ bool createMsg ( Station * station, char * function_name, FunctionSciMsg * function_sci_msg );
- // Static protected attributes
- //
+ /**
+ * @return bool
+ * @param function_sci_msg
+ * @param callback_address
+ */
+ bool registerCallback ( FunctionSciMsg * function_sci_msg, void * callback_address );
- // protected attributes
+ /**
+ * @return bool
+ * @param function_sci_msg
+ */
+ bool sendMsg ( FunctionSciMsg * function_sci_msg );
+
+ // public attribute accessor methods
//
-public:
-
-
- // protected attribute accessor methods
+ // private attribute accessor methods
//
-protected:
-
-public:
-
-
// protected attribute accessor methods
//
-protected:
-
-
-private:
-
- // Static private attributes
- //
-
- // private attributes
- //
-
- FunctionSciMsg * mpFunctionSciMsgList;
- void * mpCallbackList;
-public:
-
-
- // private attribute accessor methods
- //
-
private:
-public:
-
-
- // private attribute accessor methods
+ // private methods
//
-
/**
- * Set the value of mpFunctionSciMsgList
- * @param p_function_sci_msg_list the new value of mpFunctionSciMsgList
- */
- void setFunctionSciMsgList ( FunctionSciMsg * p_function_sci_msg_list );
-
- /**
- * Get the value of mpFunctionSciMsgList
- * @return the value of mpFunctionSciMsgList
- */
- FunctionSciMsg * getFunctionSciMsgList ( );
-
-
- /**
- * Set the value of mpCallbackList
- * @param p_callback_list the new value of mpCallbackList
- */
- void setCallbackList ( void * p_callback_list );
-
- /**
- * Get the value of mpCallbackList
- * @return the value of mpCallbackList
+ * @return bool
+ * @param function_sci_msg
*/
- void * getCallbackList ( );
-
-private:
+ bool identifyCallback ( FunctionSciMsg * function_sci_msg );
+ void initAttributes ( );
+
+protected:
- void initAttributes ( ) ;
+ // protected methods
+ //
};
+
#endif // FUNCTIONCALLMANAGER_H
diff --git a/maximus/functioncall/src/FunctionCallManager.cpp b/maximus/functioncall/src/FunctionCallManager.cpp
index c41318947f..d8b73afbab 100644
--- a/maximus/functioncall/src/FunctionCallManager.cpp
+++ b/maximus/functioncall/src/FunctionCallManager.cpp
@@ -30,89 +30,126 @@ The original location of this file is /home/buret/eclipse/maximus/functioncall/s
#include "FunctionCallManager.h"
#include "FunctionSciMsg.h"
+#include "SciServer.h"
+
+// For 'cout'
+//
+#include <iostream>
+using namespace std;
+
// Constructors/Destructors
//
-FunctionCallManager::FunctionCallManager ( )
+
+FunctionCallManager::FunctionCallManager ( ):
+mpFunctionSciMsg(NULL),
+mpCallback(NULL),
+mpSciServer(NULL)
{
initAttributes();
}
-FunctionCallManager::~FunctionCallManager ( )
+
+FunctionCallManager::FunctionCallManager ( SciServer * sci_server )
{
- delete (mpFunctionSciMsgList);
-// delete (mpCallbackList);
+ if (NULL != sci_server)
+ {
+ mpSciServer = sci_server;
+ }
+ initAttributes();
}
-//
-// Methods
-//
-
-
-// Accessor methods
-//
-
-// public static attribute accessor methods
-//
+void FunctionCallManager::initAttributes ( )
+{
+ cout << "FunctionCallManager::initAttributes" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ mpSciServer->registerSpecializedSciMsg(MAXIMUS_SCI_MSG_TYPE_FUNCTION_CALL, new FunctionSciMsg( ));
+ }
+}
-// public attribute accessor methods
-//
+FunctionCallManager::~FunctionCallManager ( )
+{
+ cout << "FunctionCallManager::~FunctionCallManager" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+ if (NULL != mpFunctionSciMsg)
+ {
+ delete (mpFunctionSciMsg);
+ mpFunctionSciMsg = NULL;
+ }
+ if (NULL != mpCallback)
+ {
+ mpCallback = NULL;
+ }
+}
-// protected static attribute accessor methods
//
-
-
-// protected attribute accessor methods
+// Methods
//
-// private static attribute accessor methods
+// Other methods
//
-// private attribute accessor methods
+// public methods
//
-void FunctionCallManager::setFunctionSciMsgList ( FunctionSciMsg * p_function_sci_msg_list )
+bool FunctionCallManager::createMsg ( Station * station, char * function_name, FunctionSciMsg * function_sci_msg )
{
- mpFunctionSciMsgList = p_function_sci_msg_list;
+ return false;
}
-FunctionSciMsg * FunctionCallManager::getFunctionSciMsgList ( )
-{
- return mpFunctionSciMsgList;
-}
-void FunctionCallManager::setCallbackList ( void * callback_list )
+bool FunctionCallManager::registerCallback ( FunctionSciMsg * function_sci_msg, void * callback_address )
{
- mpCallbackList = callback_list;
+ return false;
}
-void * FunctionCallManager::getCallbackList ( )
+
+bool FunctionCallManager::sendMsg ( FunctionSciMsg * function_sci_msg )
{
- return mpCallbackList;
+ return false;
}
+
-// Other methods
+// private methods
//
-/**
- * @return bool
- * @param function_sci_msg
- */
-bool FunctionCallManager::identifyCallback (FunctionSciMsg * function_sci_msg )
+bool FunctionCallManager::identifyCallback ( FunctionSciMsg * function_sci_msg )
{
return false;
}
-void FunctionCallManager::initAttributes ( )
-{
-}
+// protected methods
+//
+
+
+// Accessor methods
+//
+
+
+// public attribute accessor methods
+//
+
+
+// private attribute accessor methods
+//
+
+
+// protected attribute accessor methods
+//
diff --git a/maximus/functioncall/src/FunctionSciMsg.cpp b/maximus/functioncall/src/FunctionSciMsg.cpp
index d417aa96bf..6b02cfe751 100644
--- a/maximus/functioncall/src/FunctionSciMsg.cpp
+++ b/maximus/functioncall/src/FunctionSciMsg.cpp
@@ -57,7 +57,12 @@ void FunctionSciMsg::initAttributes ( )
FunctionSciMsg::~FunctionSciMsg ( )
{
cout << "FunctionSciMsg::~FunctionSciMsg" << endl;
- delete (mpSpecializedSciMsgHeader);
+
+ if (NULL != mpSpecializedSciMsgHeader)
+ {
+ delete (mpSpecializedSciMsgHeader);
+ mpSpecializedSciMsgHeader = NULL;
+ }
}
diff --git a/maximus/networkclock/src/ClockSciMsg.cpp b/maximus/networkclock/src/ClockSciMsg.cpp
index a07202aa86..fe54468fc3 100644
--- a/maximus/networkclock/src/ClockSciMsg.cpp
+++ b/maximus/networkclock/src/ClockSciMsg.cpp
@@ -59,7 +59,11 @@ void ClockSciMsg::initAttributes ( )
ClockSciMsg::~ClockSciMsg ( )
{
cout << "ClockSciMsg::~ClockSciMsg" << endl;
- delete (mpSpecializedSciMsgHeader);
+ if (NULL != mpSpecializedSciMsgHeader)
+ {
+ delete (mpSpecializedSciMsgHeader);
+ mpSpecializedSciMsgHeader = NULL;
+ }
}
diff --git a/maximus/networkclock/src/NetworkClockEvt.cpp b/maximus/networkclock/src/NetworkClockEvt.cpp
index 02d620896f..e033a15974 100644
--- a/maximus/networkclock/src/NetworkClockEvt.cpp
+++ b/maximus/networkclock/src/NetworkClockEvt.cpp
@@ -125,8 +125,11 @@ NetworkClockEvt::~NetworkClockEvt ( )
}
cout << endl;
//delete (mpStation);
- delete [] mpName;
- mpName = NULL;
+ if (NULL != mpName)
+ {
+ delete [] mpName;
+ mpName = NULL;
+ }
if (NULL != mpData)
{
delete [] mpData;
diff --git a/maximus/networkclock/src/NetworkClockEvtListTest.cpp b/maximus/networkclock/src/NetworkClockEvtListTest.cpp
index 159ffc17fb..ea1992633f 100644
--- a/maximus/networkclock/src/NetworkClockEvtListTest.cpp
+++ b/maximus/networkclock/src/NetworkClockEvtListTest.cpp
@@ -6,7 +6,7 @@
#include <iostream>
using namespace std;
-//CPPUNIT_TEST_SUITE_REGISTRATION (NetworkClockEvtListTest);
+CPPUNIT_TEST_SUITE_REGISTRATION (NetworkClockEvtListTest);
void NetworkClockEvtListTest::setUp (void)
diff --git a/maximus/networkclock/src/NetworkClockProcessor.cpp b/maximus/networkclock/src/NetworkClockProcessor.cpp
index 2bd3d68aef..1143ff36ca 100644
--- a/maximus/networkclock/src/NetworkClockProcessor.cpp
+++ b/maximus/networkclock/src/NetworkClockProcessor.cpp
@@ -93,12 +93,21 @@ bool NetworkClockProcessor::initAttributes ( )
NetworkClockProcessor::~NetworkClockProcessor ( )
{
- delete (mpNetworkClockEvtList);
- mpNetworkClockEvtList = NULL;
- delete (mpSciServer);
- mpSciServer = NULL;
- delete(mpSystemManager);
- mpSystemManager = NULL;
+ if (NULL != mpNetworkClockEvtList)
+ {
+ delete (mpNetworkClockEvtList);
+ mpNetworkClockEvtList = NULL;
+ }
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+ if (NULL != mpSystemManager)
+ {
+ delete(mpSystemManager);
+ mpSystemManager = NULL;
+ }
}
diff --git a/maximus/networkclock/src/NetworkClockProcessorTest.cpp b/maximus/networkclock/src/NetworkClockProcessorTest.cpp
index 450396de3d..c40bd6934c 100644
--- a/maximus/networkclock/src/NetworkClockProcessorTest.cpp
+++ b/maximus/networkclock/src/NetworkClockProcessorTest.cpp
@@ -6,7 +6,7 @@
#include <iostream>
using namespace std;
-//CPPUNIT_TEST_SUITE_REGISTRATION (NetworkClockProcessorTest);
+CPPUNIT_TEST_SUITE_REGISTRATION (NetworkClockProcessorTest);
void NetworkClockProcessorTest::setUp (void)
diff --git a/maximus/phy/inc/PhyProcessor.h b/maximus/phy/inc/PhyProcessor.h
index 508485a012..8b76ff69d1 100644
--- a/maximus/phy/inc/PhyProcessor.h
+++ b/maximus/phy/inc/PhyProcessor.h
@@ -28,7 +28,6 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/phy/inc/PhyProcessor.h
**************************************************************************/
-
#ifndef PHYPROCESSOR_H
#define PHYPROCESSOR_H
#include "IPhy.h"
@@ -36,7 +35,7 @@ The original location of this file is /home/buret/eclipse/maximus/phy/inc/PhyPro
class Station;
class PhySciMsg;
-
+class SciServer;
/**
@@ -46,11 +45,29 @@ class PhySciMsg;
class PhyProcessor : public IPhy
{
+
public:
+
+ // public attributes
+ //
- // Constructors/Destructors
+private:
+
+ // private attributes
//
+ Phy_Link_Quality mLinkQuality; // list
+ SciServer * mpSciServer;
+
+protected:
+
+ // protected attributes
+ //
+
+public:
+
+ // Constructors/Destructors
+ //
/**
* Empty Constructor
@@ -58,32 +75,25 @@ public:
PhyProcessor ( );
/**
+ * Constructor
+ */
+ PhyProcessor ( SciServer * sci_server );
+
+ /**
* Empty Destructor
*/
virtual ~PhyProcessor ( );
- // Static public attributes
+ // public methods
//
- // public attributes
- //
-
-
- // public attribute accessor methods
- //
-
-
- // public attribute accessor methods
- //
-
- /**
+ /**
* @return bool
* @param station1
* @param station2
* @param link_quality
*/
- bool checkLinkQuality (Station * station1, Station * station2, Phy_Link_Quality & link_quality );
-
+ bool checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const;
/**
* @return bool
@@ -91,8 +101,7 @@ public:
* @param station2
* @param link_quality
*/
- bool manageLinkQuality (Station * station1, Station * station2, Phy_Link_Quality link_quality );
-
+ bool manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality );
/**
* @return bool
@@ -100,8 +109,7 @@ public:
* @param data_length
* @param data
*/
- bool sendEthernetData (Station * destination_station, short int data_length, unsigned char * data );
-
+ bool sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const;
/**
* @return bool
@@ -113,82 +121,51 @@ public:
* @param pb_size
* @param mpdu_payload
*/
- bool sendAvData (Station * destination_station, char mpdu_format, unsigned long fc_10, unsigned long fc_av[4], unsigned char nb_of_pbs, char pb_size, unsigned char * mpdu_payload );
-
+ bool sendAvData ( const Station * destination_station,
+ const char mpdu_format,
+ const unsigned long fc_10,
+ const unsigned long fc_av[4],
+ const unsigned char nb_of_pbs,
+ const char pb_size,
+ const unsigned char * mpdu_payload ) const;
-protected:
-
- // Static protected attributes
- //
-
- // protected attributes
+ // public attribute accessor methods
//
-public:
-
-
- // protected attribute accessor methods
+ // private attribute accessor methods
//
-protected:
-
-public:
-
-
// protected attribute accessor methods
//
-protected:
-
-
private:
- // Static private attributes
- //
-
- // private attributes
- //
-
- PhySciMsg * mpPhySciMsgList;
- Phy_Link_Quality * mpLinkQualityList;
-
-public:
-
-
- // private attribute accessor methods
+ // private methods
//
-private:
-
-public:
-
-
- // private attribute accessor methods
- //
-
-
-
-
-private:
-
-
-
/**
+ * @return void
*/
void relayAvData ( );
-
/**
+ * @return void
*/
void decodeFrameControl ( );
-
/**
+ * @return void
*/
void addHeaderInfo ( );
- void initAttributes ( ) ;
+ void initAttributes ( );
+
+protected:
+
+ // protected methods
+ //
};
+
#endif // PHYPROCESSOR_H
diff --git a/maximus/phy/src/PhyProcessor.cpp b/maximus/phy/src/PhyProcessor.cpp
index b958130848..ac563e5176 100644
--- a/maximus/phy/src/PhyProcessor.cpp
+++ b/maximus/phy/src/PhyProcessor.cpp
@@ -31,107 +31,136 @@ The original location of this file is /home/buret/eclipse/maximus/phy/src/PhyPro
#include "PhyProcessor.h"
#include "Station.h"
#include "PhySciMsg.h"
+#include "SciServer.h"
+// For 'cout'
+//
+#include <iostream>
+using namespace std;
// Constructors/Destructors
//
-PhyProcessor::PhyProcessor ( )
+
+PhyProcessor::PhyProcessor ( ):
+mpSciServer(NULL)
{
initAttributes();
}
-PhyProcessor::~PhyProcessor ( )
+
+PhyProcessor::PhyProcessor ( SciServer * sci_server )
{
- delete (mpPhySciMsgList);
- delete (mpLinkQualityList);
+ if (NULL != sci_server)
+ {
+ mpSciServer = sci_server;
+ }
+ initAttributes();
}
-//
-// Methods
-//
-
-
-// Accessor methods
-//
-
-
-// public static attribute accessor methods
-//
-
-// public attribute accessor methods
-//
+void PhyProcessor::initAttributes ( )
+{
+ cout << "PhyProcessor::initAttributes" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ mpSciServer->registerSpecializedSciMsg(MAXIMUS_SCI_MSG_TYPE_PHY, new PhySciMsg( ));
+ }
+}
-// protected static attribute accessor methods
-//
+PhyProcessor::~PhyProcessor ( )
+{
+ cout << "PhyProcessor::~PhyProcessor" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+}
-// protected attribute accessor methods
//
-
-
-// private static attribute accessor methods
+// Methods
//
-// private attribute accessor methods
+// Other methods
//
-
-
-// Other methods
+// public methods
//
-bool PhyProcessor::checkLinkQuality (Station * station1, Station * station2, Phy_Link_Quality & link_quality )
+bool PhyProcessor::checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const
{
- return false;
+ return false;
}
-bool PhyProcessor::manageLinkQuality (Station * station1, Station * station2, Phy_Link_Quality link_quality )
+bool PhyProcessor::manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality )
{
- return false;
+ return false;
}
-bool PhyProcessor::sendEthernetData (Station * destination_station, short int data_length, unsigned char * data )
+bool PhyProcessor::sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const
{
- return false;
+ return false;
}
-bool PhyProcessor::sendAvData (Station * destination_station, char mpdu_format, unsigned long fc_10, unsigned long fc_av[4], unsigned char nb_of_pbs, char pb_size, unsigned char * mpdu_payload )
+bool PhyProcessor::sendAvData ( const Station * destination_station,
+ const char mpdu_format,
+ const unsigned long fc_10,
+ const unsigned long fc_av[4],
+ const unsigned char nb_of_pbs,
+ const char pb_size,
+ const unsigned char * mpdu_payload ) const
{
- return false;
+ return false;
}
-/**
- */
+
+// private methods
+//
+
+
void PhyProcessor::relayAvData ( )
{
}
-/**
- */
void PhyProcessor::decodeFrameControl ( )
{
}
-/**
- */
void PhyProcessor::addHeaderInfo ( )
{
}
-void PhyProcessor::initAttributes ( )
-{
-}
+// protected methods
+//
+
+
+// Accessor methods
+//
+
+
+// public attribute accessor methods
+//
+
+
+// private attribute accessor methods
+//
+
+
+// protected attribute accessor methods
+//
diff --git a/maximus/phy/src/PhySciMsg.cpp b/maximus/phy/src/PhySciMsg.cpp
index 17dde032c5..351a8f3b9b 100644
--- a/maximus/phy/src/PhySciMsg.cpp
+++ b/maximus/phy/src/PhySciMsg.cpp
@@ -58,7 +58,12 @@ void PhySciMsg::initAttributes ( )
PhySciMsg::~PhySciMsg ( )
{
cout << "PhySciMsg::~PhySciMsg" << endl;
- delete (mpSpecializedSciMsgHeader);
+
+ if (NULL != mpSpecializedSciMsgHeader)
+ {
+ delete (mpSpecializedSciMsgHeader);
+ mpSpecializedSciMsgHeader = NULL;
+ }
}
diff --git a/maximus/sci/inc/SciServer.h b/maximus/sci/inc/SciServer.h
index 2217b21804..ac09db30e7 100644
--- a/maximus/sci/inc/SciServer.h
+++ b/maximus/sci/inc/SciServer.h
@@ -68,7 +68,6 @@ private:
SciMsg ** mpSpecializedSciMsgArray;
unsigned int mArraySize;
- SystemManager * mpSystemManager;
StationsList * mpListOfStations;
protected:
@@ -123,6 +122,8 @@ public:
// private attribute accessor methods
//
+ bool setStationsList ( StationsList * stations_list );
+
/**
* @return Sci_Server_Status
*/
diff --git a/maximus/sci/src/SciMsg.cpp b/maximus/sci/src/SciMsg.cpp
index c6cc181fe4..f721fe8c2c 100644
--- a/maximus/sci/src/SciMsg.cpp
+++ b/maximus/sci/src/SciMsg.cpp
@@ -65,11 +65,22 @@ void SciMsg::initAttributes ( )
SciMsg::~SciMsg ( )
{
cout << "SciMsg::~SciMsg" << endl;
- delete (mpSciMsgHeader);
- delete [] mpSciMsgData;
- mpSciMsgData = NULL;
- delete [] mpSpecializedSciMsgData;
- mpSpecializedSciMsgData = NULL;
+
+ if (NULL != mpSciMsgHeader)
+ {
+ delete (mpSciMsgHeader);
+ mpSciMsgHeader = NULL;
+ }
+ if (NULL != mpSciMsgData)
+ {
+ delete [] mpSciMsgData;
+ mpSciMsgData = NULL;
+ }
+ if (NULL != mpSpecializedSciMsgData)
+ {
+ delete [] mpSpecializedSciMsgData;
+ mpSpecializedSciMsgData = NULL;
+ }
}
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 6e9a38624f..2ca0a40fe0 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -52,21 +52,23 @@ using namespace std;
SciServer::SciServer ( ) :
-server_thread(0),
-status(MAXIMUS_SCI_SERVER_STATUS_NONE),
+//server_thread(0),
+//status(MAXIMUS_SCI_SERVER_STATUS_NONE),
//server_mutex(),
mpSpecializedSciMsgArray(NULL),
mArraySize(0),
-mpSystemManager(NULL),
mpListOfStations(NULL)
{
- initAttributes();
+ cout << "SciServer::SciServer" << endl;
+ initAttributes();
+ /*
// start the server thread
int status;
status = pthread_create(&server_thread, NULL, SciServer::serverThread, this);
if(status != 0)
throw new Error(__FUNCTION__, "pthread_create", errno);
+ */
}
@@ -81,16 +83,7 @@ void SciServer::initAttributes ( )
*(mpSpecializedSciMsgArray+i) = NULL;
}
- // TEMPORARY FOR TEST PRUPOSE
- // TO DO: When creating the SciServer, set a pointer to SystemManager or directly to StationsList
- //
- mpSystemManager = new SystemManager ();
- if (NULL != mpSystemManager )
- {
- mpListOfStations = mpSystemManager->getListOfStations();
- }
-
- pthread_mutex_init(&server_mutex, NULL);
+ //pthread_mutex_init(&server_mutex, NULL);
}
/*
@@ -102,19 +95,30 @@ SciServer ( const SciServer & ) throw (Error_Id)
SciServer::~SciServer ( )
{
- // Free array
+ cout << "SciServer::~SciServer" << endl;
+
+ // Do not free stations list
+ // Station list is deleted when SystemManager is deleted
+ // Only set pointer to NULL
//
- for (unsigned int i=0; i<mArraySize; i++)
+ if (NULL != mpListOfStations)
{
- delete(*(mpSpecializedSciMsgArray+i));
+ mpListOfStations = NULL;
}
- delete [] mpSpecializedSciMsgArray;
- mpSpecializedSciMsgArray = NULL;
-
- // Free stations list
+
+ // Free array
//
-
- pthread_mutex_destroy(&server_mutex);
+ if (NULL != mpSpecializedSciMsgArray)
+ {
+ for (unsigned int i=0; i<mArraySize; i++)
+ {
+ delete(*(mpSpecializedSciMsgArray+i));
+ }
+ delete [] mpSpecializedSciMsgArray;
+ mpSpecializedSciMsgArray = NULL;
+ }
+
+ //pthread_mutex_destroy(&server_mutex);
}
//
@@ -399,6 +403,20 @@ void SciServer::setStatus(Sci_Server_Status new_status) throw (Error)
//
+bool SciServer::setStationsList ( StationsList * stations_list )
+{
+ bool bSetList = false;
+
+ if (NULL != stations_list)
+ {
+ mpListOfStations = stations_list;
+ bSetList = true;
+ }
+
+ return bSetList;
+}
+
+
SciMsg ** SciServer::getSpecializedSciMsgArray ( )
{
return mpSpecializedSciMsgArray;
diff --git a/maximus/sci/src/SciServerTest.cpp b/maximus/sci/src/SciServerTest.cpp
index 28b78d8896..779e19931d 100644
--- a/maximus/sci/src/SciServerTest.cpp
+++ b/maximus/sci/src/SciServerTest.cpp
@@ -11,7 +11,7 @@
#include <iostream>
using namespace std;
-//CPPUNIT_TEST_SUITE_REGISTRATION (SciServerTest);
+CPPUNIT_TEST_SUITE_REGISTRATION (SciServerTest);
void SciServerTest::setUp (void)
diff --git a/maximus/system/inc/Station.h b/maximus/system/inc/Station.h
index b626380e77..172c4e1b37 100644
--- a/maximus/system/inc/Station.h
+++ b/maximus/system/inc/Station.h
@@ -28,7 +28,6 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/system/inc/Station.h
**************************************************************************/
-
#ifndef STATION_H
#define STATION_H
@@ -50,161 +49,150 @@ The original location of this file is /home/buret/eclipse/maximus/system/inc/Sta
class StationConfiguration;
+
/**
* class Station
*/
class Station
{
- File_Descriptor input_pipe, output_pipe;
- pid_t pid;
+
+public:
+
+ // public attributes
+ //
+
+private:
+
+ // private attributes
+ //
+
+ File_Descriptor input_pipe, output_pipe;
+ pid_t pid;
+
+ Station_Status mStationStatus;
+ StationConfiguration * mpStationConfiguration;
+
+protected:
+ // protected attributes
+ //
+
public:
// Constructors/Destructors
//
-
/**
* Empty Constructor
*/
- Station ( );
- Station ( char *station_exec );
+
+ /**
+ * Constructor
+ */
+ Station ( char *station_exec = STATION_EXEC_DEFAULT );
/**
* Empty Destructor
*/
virtual ~Station ( );
- // Static public attributes
+ // public methods
//
- // public attributes
- //
+ void display ( ) const;
+ bool operator== ( const Station & station ) const;
+
+ Station & operator= ( const Station & station );
+
+ /**
+ * @return bool
+ */
+ bool deactivate ( );
+ /**
+ * @return bool
+ */
+ bool activate ( );
+
// public attribute accessor methods
//
-
- // public attribute accessor methods
+ // private attribute accessor methods
//
-
-
/**
* @return bool
* @param input_file_descriptor
*/
- File_Descriptor getInputFileDescriptor () const;
-
+ bool setInputFileDescriptor ( const File_Descriptor input_file_descriptor );
/**
* @return bool
* @param output_file_descriptor
*/
- File_Descriptor getOutputFileDescriptor () const;
-
-
+ bool setOutputFileDescriptor ( const File_Descriptor output_file_descriptor );
+
/**
- * @return bool
- * @param station_status
+ * @return File_Descriptor
*/
- bool getStationStatus (Station_Status & station_status ) const;
-
+ File_Descriptor getInputFileDescriptor ( ) const;
/**
- * @return bool
- * @param TBD
+ * @return File_Descriptor
*/
- bool getStationConfiguration ( ) const;
-
- bool setStationConfiguration ( );
+ File_Descriptor getOutputFileDescriptor ( ) const;
/**
* @return bool
+ * @param status
*/
- bool deactivate ( );
-
+ bool setStationStatus ( const Station_Status status );
+
+ /**
+ * @return Station_Status
+ */
+ Station_Status getStationStatus ( ) const;
/**
* @return bool
+ * @param station_configuration
*/
- bool activate ( );
-
-protected:
-
- // Static protected attributes
- //
-
- // protected attributes
- //
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-public:
+ bool setStationConfiguration ( StationConfiguration * configuration );
+ /**
+ * @return StationConfiguration
+ */
+ StationConfiguration * getStationConfiguration ( ) const;
// protected attribute accessor methods
//
-protected:
-
-
-private:
-
- // Static private attributes
- //
-
- // private attributes
- //
-
- File_Descriptor mInputFileDescriptor;
- File_Descriptor mOutputFileDescriptor;
- Station_Status mStationStatus;
- StationConfiguration * mpStationConfiguration;
-
-public:
-
-
- // private attribute accessor methods
- //
-
private:
-public:
-
-
- // private attribute accessor methods
+ // private methods
//
-
-
-
-private:
-
-
-
/**
* @return bool
*/
bool launchEcosProcess ( );
-
/**
* @return bool
* @param new_status
*/
- bool updateStationStatus (Station_Status new_status );
+ bool updateStationStatus ( Station_Status new_status );
+
+ void initAttributes ( );
- void initAttributes ( ) ;
+protected:
+ // protected methods
+ //
+
};
+
#endif // STATION_H
diff --git a/maximus/system/inc/StationConfiguration.h b/maximus/system/inc/StationConfiguration.h
index 9a66fc226d..9a08270099 100644
--- a/maximus/system/inc/StationConfiguration.h
+++ b/maximus/system/inc/StationConfiguration.h
@@ -28,12 +28,9 @@ This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/system/inc/StationConfiguration.h
**************************************************************************/
-
#ifndef STATIONCONFIGURATION_H
#define STATIONCONFIGURATION_H
-
-
#include "system_types.h"
@@ -43,11 +40,31 @@ The original location of this file is /home/buret/eclipse/maximus/system/inc/Sta
class StationConfiguration
{
+
public:
- // Constructors/Destructors
+ // public attributes
+ //
+
+private:
+
+ // private attributes
//
+
+ Cco_Capability mCcoCapability;
+ Bridge_Capability mBridgeCapability;
+ Homeplug_Version mHomeplugVersion;
+ Device_Access_Key mDeviceAccessKey;
+
+protected:
+ // protected attributes
+ //
+
+public:
+
+ // Constructors/Destructors
+ //
/**
* Empty Constructor
@@ -55,113 +72,67 @@ public:
StationConfiguration ( );
/**
+ * Constructor
+ */
+ StationConfiguration ( Device_Access_Key device_access_key,
+ Cco_Capability cco_capability = MAXIMUS_NOT_CCO_CAPABLE,
+ Bridge_Capability bridge_capability = MAXIMUS_NOT_BRIDGE_CAPABLE,
+ Homeplug_Version homeplug_version = MAXIMUS_HOMEPLUG_AV );
+
+ /**
* Empty Destructor
*/
virtual ~StationConfiguration ( );
- // Static public attributes
- //
-
- // public attributes
- //
-
+ // public methods
+ //
// public attribute accessor methods
//
-
- // public attribute accessor methods
+ // private attribute accessor methods
//
-
-
/**
* @return bool
* @param cco_capability
*/
- bool setCcoCapability (Cco_Capability cco_capability );
-
+ bool setCcoCapability ( const Cco_Capability cco_capability );
/**
* @return bool
* @param bridge_capability
*/
- bool setBridgeCapability (Bridge_Capability bridge_capability );
-
+ bool setBridgeCapability ( const Bridge_Capability bridge_capability );
/**
* @return bool
* @param homeplug_version
*/
- bool setHomeplugVersion (Homeplug_Version homeplug_version );
-
+ bool setHomeplugVersion ( const Homeplug_Version homeplug_version );
/**
* @return bool
* @param device_access_key
*/
- bool setDeviceAccessKey (Device_Access_Key device_access_key );
-
-protected:
-
- // Static protected attributes
- //
-
- // protected attributes
- //
-
-public:
-
-
- // protected attribute accessor methods
- //
-
-protected:
-
-public:
-
+ bool setDeviceAccessKey ( const Device_Access_Key device_access_key );
// protected attribute accessor methods
//
-protected:
-
-
-private:
-
- // Static private attributes
- //
-
- // private attributes
- //
-
- Cco_Capability mCcoCapability;
- Bridge_Capability mBridgeCapability;
- Homeplug_Version mHomeplugVersion;
- Device_Access_Key mDeviceAccessKey;
-
-public:
-
-
- // private attribute accessor methods
- //
-
private:
-public:
-
-
- // private attribute accessor methods
+ // private methods
//
-
+ void initAttributes ( );
+protected:
-private:
-
-
- void initAttributes ( ) ;
+ // protected methods
+ //
};
+
#endif // STATIONCONFIGURATION_H
diff --git a/maximus/system/inc/SystemManager.h b/maximus/system/inc/SystemManager.h
index cdae161392..213cf48f02 100644
--- a/maximus/system/inc/SystemManager.h
+++ b/maximus/system/inc/SystemManager.h
@@ -121,6 +121,8 @@ private:
// private methods
//
+ void displayListOfStations ( ) const;
+
void initAttributes ( ) ;
protected:
diff --git a/maximus/system/inc/SystemManagerTest.h b/maximus/system/inc/SystemManagerTest.h
index 846be1ff24..6fa4e322cb 100644
--- a/maximus/system/inc/SystemManagerTest.h
+++ b/maximus/system/inc/SystemManagerTest.h
@@ -14,7 +14,9 @@ class SystemManagerTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE (SystemManagerTest);
- CPPUNIT_TEST (test);
+ CPPUNIT_TEST (createStationTest);
+ CPPUNIT_TEST (removeStationTest);
+ CPPUNIT_TEST (areAllActiveStationsIdleTest);
CPPUNIT_TEST_SUITE_END ();
public:
@@ -24,7 +26,9 @@ public:
protected:
- void test (void);
+ void createStationTest (void);
+ void removeStationTest (void);
+ void areAllActiveStationsIdleTest (void);
private:
diff --git a/maximus/system/src/Station.cpp b/maximus/system/src/Station.cpp
index 2979fec1b0..4a1c733bf8 100644
--- a/maximus/system/src/Station.cpp
+++ b/maximus/system/src/Station.cpp
@@ -32,22 +32,32 @@ The original location of this file is /home/buret/eclipse/maximus/system/src/Sta
#include <unistd.h>
#include <sys/signal.h>
#include <errno.h>
+
#include "Station.h"
#include "StationConfiguration.h"
#include "Error.h"
+// For 'cout'
+//
+#include <iostream>
+using namespace std;
+
+
// Constructors/Destructors
//
-Station::Station()
-{
- Station(STATION_EXEC_DEFAULT);
-}
-Station::Station (char *station_exec)
+Station::Station ( char *station_exec ):
+input_pipe(-1),
+output_pipe(-1),
+pid(0),
+mStationStatus(MAXIMUS_STATION_STATUS_NONE),
+mpStationConfiguration(NULL)
{
+ cout << "Station::Station" << endl;
+
initAttributes();
-
+/*
// start the station process
if(station_exec == NULL)
throw new Error(__FUNCTION__ ,"exec", errno);
@@ -74,45 +84,100 @@ Station::Station (char *station_exec)
sprintf(name_buffer, "%s/%s_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX_IN, pid);
if((output_pipe = open(name_buffer, O_RDONLY)) < 0)
throw errno;
+*/
}
+
+void Station::initAttributes ( )
+{
+ mpStationConfiguration = new StationConfiguration ();
+}
+
+
Station::~Station ( )
{
- delete (mpStationConfiguration);
+ cout << "Station::~Station" << endl;
+
+ if (NULL != mpStationConfiguration)
+ {
+ delete (mpStationConfiguration);
+ mpStationConfiguration = NULL;
+ }
+/*
if(input_pipe >= 0)
close(input_pipe);
if(output_pipe >= 0)
close(output_pipe);
if(pid > 0)
kill(pid, SIGTERM);
+*/
}
+
//
// Methods
//
-// Accessor methods
-//
+// Other methods
+//
-// public static attribute accessor methods
-//
+// public methods
+//
-// public attribute accessor methods
-//
+bool Station::deactivate ( )
+{
+ return false;
+}
-// protected static attribute accessor methods
-//
+bool Station::activate ( )
+{
+ return false;
+}
+
+
+void Station::display ( ) const
+{
+ cout << "input = " << getInputFileDescriptor() << " - output = " << getOutputFileDescriptor() << endl;
+}
+
+
+bool Station::operator== ( const Station & station ) const
+{
+ bool bOperator = false;
+
+ if ( (getStationStatus() == station.getStationStatus())
+ && (getStationConfiguration() == station.getStationConfiguration())
+ && (getInputFileDescriptor() == station.getInputFileDescriptor())
+ && (getOutputFileDescriptor() == station.getOutputFileDescriptor()) )
+ {
+ bOperator = true;
+ }
+
+ cout << "Station::operator== returns " << bOperator << endl;
+ return bOperator;
+}
+
+
+Station & Station::operator= ( const Station & station )
+{
+ setInputFileDescriptor (station.getInputFileDescriptor());
+ setOutputFileDescriptor (station.getOutputFileDescriptor());
+ setStationStatus (station.getStationStatus());
+ setStationConfiguration (station.getStationConfiguration());
+
+ return *this;
+}
-// protected attribute accessor methods
+// Accessor methods
//
-// private static attribute accessor methods
+// public attribute accessor methods
//
@@ -120,92 +185,82 @@ Station::~Station ( )
//
+bool Station::setInputFileDescriptor ( const File_Descriptor input_file_descriptor )
+{
+ input_pipe = input_file_descriptor;
+ return true;
+}
-// Other methods
-//
+bool Station::setOutputFileDescriptor ( const File_Descriptor output_file_descriptor )
+{
+ output_pipe = output_file_descriptor;
+ return true;
+}
-/**
- * @return bool
- * @param input_file_descriptor
- */
-File_Descriptor Station::getInputFileDescriptor () const
+File_Descriptor Station::getInputFileDescriptor ( ) const
{
return input_pipe;
}
-/**
- * @return bool
- * @param output_file_descriptor
- */
-File_Descriptor Station::getOutputFileDescriptor () const
+File_Descriptor Station::getOutputFileDescriptor ( ) const
{
return output_pipe;
}
-/**
- * @return bool
- * @param station_status
- */
-bool Station::getStationStatus (Station_Status & station_status ) const
+bool Station::setStationStatus ( const Station_Status status )
{
- return false;
+ mStationStatus = status;
+ return true;
}
-/**
- * @return bool
- * @param TBD
- */
-bool Station::getStationConfiguration ( ) const
+Station_Status Station::getStationStatus ( ) const
{
- return false;
+ return mStationStatus;
}
-/**
- * @return bool
- */
-bool Station::deactivate ( )
+bool Station::setStationConfiguration ( StationConfiguration * configuration )
{
- return false;
+ bool bSetConfig = false;
+
+ if (NULL != configuration)
+ {
+ mpStationConfiguration = configuration;
+ bSetConfig = true;
+ }
+
+ return bSetConfig;
}
-/**
- * @return bool
- */
-bool Station::activate ( )
+StationConfiguration * Station::getStationConfiguration ( ) const
{
- return false;
+ return mpStationConfiguration;
}
-/**
- * @return bool
- */
+// private methods
+//
+
+
bool Station::launchEcosProcess ( )
{
return false;
}
-/**
- * @return bool
- * @param new_status
- */
-bool Station::updateStationStatus (Station_Status new_status )
+bool Station::updateStationStatus ( Station_Status new_status )
{
- return false;
+ mStationStatus = new_status;
+ return true;
}
-void Station::initAttributes ( )
-{
- input_pipe = -1;
- output_pipe = -1;
- pid = 0;
-}
+
+// protected methods
+//
diff --git a/maximus/system/src/StationConfiguration.cpp b/maximus/system/src/StationConfiguration.cpp
index c6705440dd..433dc84a2d 100644
--- a/maximus/system/src/StationConfiguration.cpp
+++ b/maximus/system/src/StationConfiguration.cpp
@@ -30,45 +30,78 @@ The original location of this file is /home/buret/eclipse/maximus/system/src/Sta
#include "StationConfiguration.h"
+// For 'cout'
+//
+#include <iostream>
+using namespace std;
+
+
// Constructors/Destructors
//
-StationConfiguration::StationConfiguration ( )
+
+StationConfiguration::StationConfiguration ( ):
+mCcoCapability(MAXIMUS_NOT_CCO_CAPABLE),
+mBridgeCapability(MAXIMUS_NOT_BRIDGE_CAPABLE),
+mHomeplugVersion(MAXIMUS_HOMEPLUG_AV),
+mDeviceAccessKey(0)
{
+ cout << "StationConfiguration::StationConfiguration" << endl;
initAttributes();
}
-StationConfiguration::~StationConfiguration ( )
+
+StationConfiguration::StationConfiguration ( Device_Access_Key device_access_key,
+ Cco_Capability cco_capability,
+ Bridge_Capability bridge_capability,
+ Homeplug_Version homeplug_version )
{
+ cout << "StationConfiguration::StationConfiguration" << endl;
+ setDeviceAccessKey (device_access_key);
+ setCcoCapability (cco_capability);
+ setBridgeCapability (bridge_capability);
+ setHomeplugVersion (homeplug_version);
+}
+
+void StationConfiguration::initAttributes ( )
+{
+
+}
+
+
+StationConfiguration::~StationConfiguration ( )
+{
+ cout << "StationConfiguration::~StationConfiguration" << endl;
}
+
//
// Methods
//
-// Accessor methods
+// Other methods
//
-// public static attribute accessor methods
+// public methods
//
-// public attribute accessor methods
+// private methods
//
-// protected static attribute accessor methods
+// protected methods
//
-// protected attribute accessor methods
+// Accessor methods
//
-// private static attribute accessor methods
+// public attribute accessor methods
//
@@ -76,53 +109,34 @@ StationConfiguration::~StationConfiguration ( )
//
-
-
-// Other methods
-//
-
-
-/**
- * @return bool
- * @param cco_capability
- */
-bool StationConfiguration::setCcoCapability (Cco_Capability cco_capability )
+bool StationConfiguration::setCcoCapability ( const Cco_Capability cco_capability )
{
- return false;
+ mCcoCapability = cco_capability;
+ return true;
}
-/**
- * @return bool
- * @param bridge_capability
- */
-bool StationConfiguration::setBridgeCapability (Bridge_Capability bridge_capability )
+bool StationConfiguration::setBridgeCapability ( const Bridge_Capability bridge_capability )
{
- return false;
+ mBridgeCapability = bridge_capability;
+ return true;
}
-/**
- * @return bool
- * @param homeplug_version
- */
-bool StationConfiguration::setHomeplugVersion (Homeplug_Version homeplug_version )
+bool StationConfiguration::setHomeplugVersion ( const Homeplug_Version homeplug_version )
{
- return false;
+ mHomeplugVersion = homeplug_version;
+ return true;
}
-/**
- * @return bool
- * @param device_access_key
- */
-bool StationConfiguration::setDeviceAccessKey (Device_Access_Key device_access_key )
+bool StationConfiguration::setDeviceAccessKey ( const Device_Access_Key device_access_key )
{
- return false;
+ mDeviceAccessKey = device_access_key;
+ return true;
}
-void StationConfiguration::initAttributes ( )
-{
-}
+// protected attribute accessor methods
+//
diff --git a/maximus/system/src/SystemManager.cpp b/maximus/system/src/SystemManager.cpp
index db89b8bfdd..76d0171998 100644
--- a/maximus/system/src/SystemManager.cpp
+++ b/maximus/system/src/SystemManager.cpp
@@ -68,14 +68,32 @@ void SystemManager::initAttributes ( )
if (NULL != mpSciServer)
{
mpSciServer->registerSpecializedSciMsg(MAXIMUS_SCI_MSG_TYPE_SYSTEM, new SystemSciMsg( ));
+ mpSciServer->setStationsList(&mListOfStations);
}
}
SystemManager::~SystemManager ( )
{
- delete (mpSciServer);
- mpSciServer = NULL;
+ cout << "SystemManager::~SystemManager" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+
+ if (!mListOfStations.empty())
+ {
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ delete (*it);
+ }
+ }
+ mListOfStations.clear();
+ }
}
@@ -94,21 +112,52 @@ SystemManager::~SystemManager ( )
Station * SystemManager::createStation ( )
{
+ cout << "SystemManager::createStation" << endl;
Station * createdStation = new Station ();
-
+ mListOfStations.push_back(createdStation);
+ displayListOfStations();
return createdStation;
}
bool SystemManager::removeStation ( Station * station )
{
- return false;
+ cout << "SystemManager::removeStation" << endl;
+ bool bRemove = false;
+
+ if (NULL != station)
+ {
+ mListOfStations.remove(station);
+ delete (station);
+ station = NULL;
+ displayListOfStations();
+ bRemove = true;
+ }
+
+ return bRemove;
}
bool SystemManager::areAllActiveStationsIdle ( ) const
{
- return true;
+ cout << "SystemManager::areAllActiveStationsIdle" << endl;
+ bool bActive = true;
+
+ if (!mListOfStations.empty())
+ {
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ const Station * station = *it;
+ if (MAXIMUS_STATION_STATUS_IDLE != station->getStationStatus())
+ {
+ bActive = false;
+ it = mListOfStations.end();
+ --it;
+ }
+ }
+ }
+
+ return bActive;
}
@@ -116,6 +165,24 @@ bool SystemManager::areAllActiveStationsIdle ( ) const
//
+void SystemManager::displayListOfStations ( ) const
+{
+ if (!mListOfStations.empty())
+ {
+ cout << "Elements in mListOfStations = " << endl;
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ const Station * station = *it;
+ station->display();
+ }
+ }
+ else
+ {
+ cout << "List is empty!" << endl;
+ }
+}
+
+
// protected methods
//
diff --git a/maximus/system/src/SystemManagerTest.cpp b/maximus/system/src/SystemManagerTest.cpp
index 97894c4a12..0283444269 100644
--- a/maximus/system/src/SystemManagerTest.cpp
+++ b/maximus/system/src/SystemManagerTest.cpp
@@ -22,13 +22,54 @@ void SystemManagerTest::tearDown (void)
{
cout << "SystemManagerTest::tearDown" << endl;
delete mpSystemManager;
+ mpSystemManager = NULL;
}
-void SystemManagerTest::test (void)
+void SystemManagerTest::createStationTest (void)
{
- cout << "SystemManagerTest::test" << endl;
- SciServer * sciServer = new SciServer ();
- SystemManager systemManager(sciServer);
+ cout << "SystemManagerTest::createStationTest" << endl;
+ SciServer * pSciServer = new SciServer (); // will be deleted by SciServer
+ SystemManager systemManager(pSciServer);
+ Station * pStation = systemManager.createStation(); // will be deleted by SystemManager
+ pStation->setInputFileDescriptor(1);
+ pStation->setOutputFileDescriptor(1);
+}
+
+
+void SystemManagerTest::removeStationTest (void)
+{
+ cout << "SystemManagerTest::removeStationTest" << endl;
+ SciServer * pSciServer = new SciServer (); // will be deleted by SciServer
+ SystemManager systemManager(pSciServer);
+ Station * pStation1 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation1->setInputFileDescriptor(1);
+ pStation1->setOutputFileDescriptor(1);
+ Station * pStation2 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation2->setInputFileDescriptor(1);
+ pStation2->setOutputFileDescriptor(2);
+ Station * pStation3 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation3->setInputFileDescriptor(1);
+ pStation3->setOutputFileDescriptor(1);
+ CPPUNIT_ASSERT_MESSAGE (CPPUNIT_NS::Message("removeStationTest failed"), systemManager.removeStation (pStation2));
+ CPPUNIT_ASSERT_MESSAGE (CPPUNIT_NS::Message("removeStationTest failed"), systemManager.removeStation (pStation1));
+}
+
+
+void SystemManagerTest::areAllActiveStationsIdleTest (void)
+{
+ cout << "SystemManagerTest::areAllActiveStationsIdleTest" << endl;
+
+ SciServer * pSciServer = new SciServer (); // will be deleted by SciServer
+ SystemManager systemManager(pSciServer);
+ Station * pStation1 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation1->setStationStatus(MAXIMUS_STATION_STATUS_IDLE);
+ Station * pStation2 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation2->setStationStatus(MAXIMUS_STATION_STATUS_IDLE);
+ Station * pStation3 = systemManager.createStation(); // will be deleted by SystemManager
+ pStation3->setStationStatus(MAXIMUS_STATION_STATUS_IDLE);
+ CPPUNIT_ASSERT_MESSAGE (CPPUNIT_NS::Message("areAllActiveStationsIdleTest failed"), systemManager.areAllActiveStationsIdle());
+ pStation2->setStationStatus(MAXIMUS_STATION_STATUS_BUSY);
+ CPPUNIT_ASSERT_MESSAGE (CPPUNIT_NS::Message("areAllActiveStationsIdleTest failed"), !systemManager.areAllActiveStationsIdle());
}
diff --git a/maximus/system/src/SystemSciMsg.cpp b/maximus/system/src/SystemSciMsg.cpp
index 598582aafb..8f320a8024 100644
--- a/maximus/system/src/SystemSciMsg.cpp
+++ b/maximus/system/src/SystemSciMsg.cpp
@@ -57,7 +57,12 @@ void SystemSciMsg::initAttributes ( )
SystemSciMsg::~SystemSciMsg ( )
{
cout << "SystemSciMsg::~SystemSciMsg" << endl;
- delete (mpSpecializedSciMsgHeader);
+
+ if (NULL != mpSpecializedSciMsgHeader)
+ {
+ delete (mpSpecializedSciMsgHeader);
+ mpSpecializedSciMsgHeader = NULL;
+ }
}