summaryrefslogtreecommitdiff
path: root/cesar/maximus/sci/inc
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/sci/inc')
-rw-r--r--cesar/maximus/sci/inc/ISci.h143
-rw-r--r--cesar/maximus/sci/inc/SciMsg.h333
-rw-r--r--cesar/maximus/sci/inc/SciMsgTest.h50
-rw-r--r--cesar/maximus/sci/inc/SciServer.h248
-rw-r--r--cesar/maximus/sci/inc/SciServerTest.h62
5 files changed, 836 insertions, 0 deletions
diff --git a/cesar/maximus/sci/inc/ISci.h b/cesar/maximus/sci/inc/ISci.h
new file mode 100644
index 0000000000..cea7f4b954
--- /dev/null
+++ b/cesar/maximus/sci/inc/ISci.h
@@ -0,0 +1,143 @@
+/************************************************************************
+ ISci.h - 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.h
+
+-->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/sci/inc/ISci.h
+**************************************************************************/
+
+#ifndef ISCI_H
+#define ISCI_H
+
+#include "ISystem.h"
+
+#include "networkclock_types.h"
+#include "sci_types.h"
+
+#include <string>
+#include <vector>
+
+class SciMsg;
+
+typedef std::vector<Sci_Msg_Station_Id> DestStationsList;
+
+
+/**
+ * class ISci
+ */
+
+class ISci
+{
+
+public:
+
+ // Constructors/Destructors
+ //
+
+ /**
+ * Empty Constructor
+ */
+ ISci ( ) { }
+
+ /**
+ * Empty Destructor
+ */
+ virtual ~ISci ( ) { }
+
+ // public methods
+ //
+
+ /**
+ * @return bool
+ * @param station_log_file
+ */
+ virtual bool init ( const std::string station_log ) = 0;
+
+ /**
+ * @return bool
+ */
+ virtual bool process ( ) = 0;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ virtual bool fillSciMsg ( SciMsg & sci_msg_to_send ) const = 0;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ virtual bool sendSciMsg ( const SciMsg & sci_msg_to_send ) const = 0;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ virtual bool sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const = 0;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ * @param list_of_dest_stations
+ */
+ virtual bool sendSciMsgToDestStations ( SciMsg & sci_msg_to_send, DestStationsList & list_of_dest_stations ) const = 0;
+
+ /**
+ * Set a value into mpSpecializedSciMsgArray
+ * @return bool
+ * @param sci_msg_type the array position to set
+ * @param sci_msg the new value of mpSpecializedSciMsgArray[sci_msg_type]
+ */
+ virtual bool registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, SciMsg * sci_msg ) = 0;
+
+ /**
+ * @return bool
+ * @param header
+ * @param data_length
+ * @param received_data
+ */
+ virtual bool receiveMsg ( const Sci_Msg_Header * header,
+ const unsigned long data_length,
+ const unsigned char * received_data ) const = 0;
+
+ virtual void displaySpecializedSciMsgArray ( ) const = 0;
+
+ /**
+ * @return bool
+ * @param p_list_of_stations
+ */
+ virtual bool setStationsList ( StationsList * p_list_of_stations ) = 0;
+
+ /**
+ * @return bool
+ * @param current_tick_value
+ */
+ virtual bool updateTickValue ( const Network_Clock_Tick current_tick_value ) = 0;
+
+};
+
+
+#endif // ISCI_H
diff --git a/cesar/maximus/sci/inc/SciMsg.h b/cesar/maximus/sci/inc/SciMsg.h
new file mode 100644
index 0000000000..7ed2608be5
--- /dev/null
+++ b/cesar/maximus/sci/inc/SciMsg.h
@@ -0,0 +1,333 @@
+/************************************************************************
+ SciMsg.h - 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.h
+
+-->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/sci/inc/SciMsg.h
+**************************************************************************/
+
+#ifndef SCIMSG_H
+#define SCIMSG_H
+
+#include "sci_types.h"
+
+
+/**
+ * class SciMsg
+ */
+
+class SciMsg
+{
+
+public:
+
+ // public attributes
+ //
+
+private:
+
+ // private attributes
+ //
+
+ Sci_Msg_Status mSciMsgStatus; // NOT USED YET
+
+ // Values of SCI message header
+ //
+ Sci_Msg_Type mSciMsgType;
+ Sci_Msg_Station_Id mSciMsgStationId;
+ static Sci_Msg_Id mSciMsgId; // to send to station
+ Sci_Msg_Flag mSciMsgFlag;
+
+ // SCI message header, SCI message data length, and SCI message data
+ //
+ Sci_Msg_Header mSciMsgHeader;
+ unsigned long mSciMsgDataLength;
+ unsigned char * mpSciMsgData;
+
+protected:
+
+ // protected attributes
+ //
+
+ // Specialized SCI message header size, specialized SCI message data length, and specialized SCI message data
+ //
+ unsigned long mSpecializedSciMsgHeaderSize;
+ unsigned long mSpecializedSciMsgDataLength;
+ unsigned char * mpSpecializedSciMsgData;
+
+public:
+
+ // Constructors/Destructors
+ //
+
+ /**
+ * Empty Constructor
+ */
+ SciMsg ( );
+
+ /**
+ * Copy Constructors
+ */
+ SciMsg ( const SciMsg & sci_msg );
+ SciMsg ( const SciMsg * p_sci_msg );
+
+ /**
+ * Empty Destructor
+ */
+ virtual ~SciMsg ( );
+
+ // public methods
+ //
+
+ /**
+ * @return SciMsg *
+ */
+ virtual SciMsg * create ( ) const = 0;
+
+ /**
+ * @return bool
+ */
+ virtual bool dispatchMsg ( ) = 0;
+
+ /**
+ * @return bool
+ */
+ virtual bool identifySpecializedSciMsgHeader ( ) = 0;
+
+ /**
+ * @return bool
+ */
+ virtual bool checkCompatibility ( ) const;
+
+ /**
+ * @return bool
+ */
+ virtual bool checkValidity ( ) const;
+
+ /**
+ * @return bool
+ */
+ bool identifySpecializedSciMsgData ( );
+
+ void displaySciMsgHeader ( ) const;
+
+ void displaySciMsgData ( ) const;
+
+ virtual void displaySpecializedSciMsgHeader ( ) const = 0;
+
+ /**
+ * Display the specialized SCI message type.
+ */
+ virtual void displaySpecializedSciMsgType ( int log_level ) const = 0;
+
+ void displaySpecializedSciMsgData ( ) const;
+
+ /**
+ * @return SCI_MSG_MAGIC converted to uint32_t
+ */
+ uint32_t getDefinedSciMsgMagicId ( ) const;
+
+ /**
+ * @return SCI_MSG_VERSION
+ */
+ uint8_t getDefinedSciMsgVersion ( ) const;
+
+ // public attribute accessor methods
+ //
+
+ // private attribute accessor methods
+ //
+
+ /**
+ * @return mSciMsgStatus
+ */
+ Sci_Msg_Status getSciMsgStatus ( ) const;
+
+ /**
+ * @return bool
+ * @param status the new value of mSciMsgStatus
+ */
+ bool setSciMsgStatus ( const Sci_Msg_Status status );
+
+ /**
+ * @return the value of mSciMsgType
+ */
+ Sci_Msg_Type getSciMsgType ( ) const;
+
+ /**
+ * @return bool
+ * @param type the new value of mSciMsgType
+ */
+ bool setSciMsgType ( const Sci_Msg_Type type );
+
+ /**
+ * Get the value of mSciMsgStationId
+ * @return the value of mSciMsgStationId
+ */
+ Sci_Msg_Station_Id getSciMsgStationId ( ) const;
+
+ /**
+ * Set the value of mSciMsgStationId
+ * @return bool
+ * @param station_id the new value of mSciMsgStationId
+ */
+ bool setSciMsgStationId ( const Sci_Msg_Station_Id station_id );
+
+ /**
+ * Get the value of mSciMsgId
+ * @return the value of mSciMsgId
+ */
+ Sci_Msg_Id getSciMsgId ( ) const;
+
+ /**
+ * Increment the value of mSciMsgId
+ * @return bool
+ */
+ bool incrementSciMsgId ( );
+
+ /**
+ * @return the value of mSciMsgFlag
+ */
+ Sci_Msg_Flag getSciMsgFlag ( ) const;
+
+ /**
+ * @return bool
+ * @param flag the new value of mSciMsgFlag
+ */
+ bool setSciMsgFlag ( const Sci_Msg_Flag flag );
+
+ /**
+ * @return a pointer to mSciMsgHeader
+ */
+ Sci_Msg_Header * getSciMsgHeader ( ) const;
+
+ /**
+ * @return bool
+ * @param sci_msg_header the new value of mSciMsgHeader
+ */
+ bool setSciMsgHeader ( const Sci_Msg_Header & sci_msg_header );
+
+ /**
+ * Get the value of mSciMsgDataLength
+ * @return the value of mSciMsgDataLength
+ */
+ unsigned long getSciMsgDataLength ( ) const;
+
+ /**
+ * Set the value of mSciMsgDataLength
+ * @return bool
+ * @param data_length the new value of mSciMsgDataLength
+ */
+ bool setSciMsgDataLength ( const unsigned long data_length );
+
+ /**
+ * Get the value of mpSciMsgData
+ * @return the value of mpSciMsgData
+ */
+ unsigned char * getSciMsgData ( ) const;
+
+ /**
+ * Set the value of mpSciMsgData
+ * @return bool
+ * @param p_data the new value of mpSciMsgData
+ */
+ bool setSciMsgData ( const unsigned char * p_data );
+
+ // protected attribute accessor methods
+ //
+
+ /**
+ * Get the value of mSpecializedSciMsgHeaderSize
+ * @return the value of mSpecializedSciMsgHeaderSize
+ */
+ virtual unsigned long getSpecializedSciMsgHeaderSize ( ) const;
+
+ /**
+ * Set the value of mSpecializedSciMsgHeaderSize
+ * @return bool
+ * @param header_size the new value of mSpecializedSciMsgHeaderSize
+ */
+ virtual bool setSpecializedSciMsgHeaderSize ( const unsigned long header_size );
+
+ /**
+ * Get the value of mpSpecializedSciMsgHeader
+ * @return the value of mpSpecializedSciMsgHeader into a void pointer
+ */
+ virtual void * returnSpecializedSciMsgHeader ( ) const = 0;
+
+ /**
+ * Get the value of mSpecializedSciMsgDataLength
+ * @return the value of mSpecializedSciMsgDataLength
+ */
+ virtual unsigned long getSpecializedSciMsgDataLength ( ) const;
+
+ /**
+ * Set the value of mSpecializedSciMsgDataLength
+ * @return bool
+ * @param data_length the new value of mSpecializedSciMsgDataLength
+ */
+ virtual bool setSpecializedSciMsgDataLength ( const unsigned long data_length );
+
+ /**
+ * Get the value of mpSpecializedSciMsgData
+ * @return the value of mpSpecializedSciMsgData
+ */
+ virtual unsigned char * getSpecializedSciMsgData ( ) const;
+
+ /**
+ * Set the value of mpSpecializedSciMsgData
+ * @return bool
+ * @param p_data the new value of mpSpecializedSciMsgData
+ */
+ virtual bool setSpecializedSciMsgData ( const unsigned char * p_data );
+
+ void displaySciMsgType ( ) const;
+
+private:
+
+ // private methods
+ //
+
+ void initAttributes ( ) ;
+
+ void displaySciMsgFlag ( ) const;
+
+protected:
+
+ // protected methods
+ //
+
+ /**
+ * @return bool
+ * @param data_length_to_remove
+ * @param data_length
+ * @param pp_data
+ */
+ bool removeData ( const unsigned long data_length_to_remove, unsigned long & data_length, unsigned char ** pp_data );
+
+};
+
+
+#endif // SCIMSG_H
diff --git a/cesar/maximus/sci/inc/SciMsgTest.h b/cesar/maximus/sci/inc/SciMsgTest.h
new file mode 100644
index 0000000000..d588f55ce7
--- /dev/null
+++ b/cesar/maximus/sci/inc/SciMsgTest.h
@@ -0,0 +1,50 @@
+
+#ifndef SCIMSGTEST_H
+#define SCIMSGTEST_H
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class SciMsg;
+class IFunctionCall;
+class ISci;
+class ISystem;
+class IPhy;
+class IEthernet;
+class INetworkClock;
+
+
+class SciMsgTest : public CPPUNIT_NS::TestFixture
+{
+
+ CPPUNIT_TEST_SUITE (SciMsgTest);
+ CPPUNIT_TEST (simpleTest);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp (void);
+ void tearDown (void);
+
+protected:
+
+ void simpleTest (void);
+
+private:
+
+ SciMsg * mpFunctionSciMsg;
+ SciMsg * mpClockSciMsg;
+ SciMsg * mpSystemSciMsg;
+ SciMsg * mpPhySciMsg;
+ SciMsg * mpEtherSciMsg;
+ IFunctionCall * mpFunctionCallManager;
+ ISci * mpSciServer;
+ ISystem * mpSystemManager;
+ IPhy * mpPhyProcessor;
+ IEthernet * mpEthernet;
+ INetworkClock * mpNetworkClock;
+
+};
+
+
+#endif // SCIMSGTEST_H
diff --git a/cesar/maximus/sci/inc/SciServer.h b/cesar/maximus/sci/inc/SciServer.h
new file mode 100644
index 0000000000..1aa49b8964
--- /dev/null
+++ b/cesar/maximus/sci/inc/SciServer.h
@@ -0,0 +1,248 @@
+/************************************************************************
+ SciServer.h - 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.h
+
+-->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/sci/inc/SciServer.h
+**************************************************************************/
+
+#ifndef SCISERVER_H
+#define SCISERVER_H
+
+#include "ISci.h"
+#include "SystemManager.h" // for 'StationsList'
+
+#include "networkclock_types.h"
+#include "system_types.h"
+
+class Station;
+class SciMsg;
+
+
+/**
+ * class SciServer
+ */
+
+class SciServer : public ISci
+{
+
+public:
+
+ // public attributes
+ //
+
+private:
+
+ // private attributes
+ //
+
+ std::string mStationLog;
+ SciMsg ** mpSpecializedSciMsgArray;
+ unsigned int mArraySize;
+ StationsList * mpListOfStations;
+ Network_Clock_Tick mNetworkClockTick;
+
+protected:
+
+ // protected attributes
+ //
+
+public:
+
+ // Constructors/Destructors
+ //
+
+ /**
+ * Empty Constructor
+ */
+ SciServer ( );
+
+ /**
+ * Copy Constructor
+ */
+ SciServer ( const SciServer & );
+
+ /**
+ * Empty Destructor
+ */
+ virtual ~SciServer ( );
+
+ // public methods
+ //
+
+ /**
+ * @return bool
+ * @param station_log_file
+ */
+ bool init ( const std::string station_log );
+
+ /**
+ * @return bool
+ */
+ bool process ( );
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ bool fillSciMsg ( SciMsg & sci_msg_to_send ) const;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ bool sendSciMsg ( const SciMsg & sci_msg_to_send ) const;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ */
+ bool sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const;
+
+ /**
+ * @return bool
+ * @param sci_msg_to_send
+ * @param
+ */
+ bool sendSciMsgToDestStations ( SciMsg & sci_msg_to_send, DestStationsList & list_of_dest_stations ) const;
+
+ /**
+ * Set a value into mpSpecializedSciMsgArray
+ * @return bool
+ * @param sci_msg_type the array position to set
+ * @param sci_msg the new value of mpSpecializedSciMsgArray[sci_msg_type]
+ */
+ bool registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, SciMsg * sci_msg );
+
+ /**
+ * @return bool
+ * @param header
+ * @param data_length
+ * @param received_data
+ */
+ bool receiveMsg ( const Sci_Msg_Header * header,
+ const unsigned long data_length,
+ const unsigned char * received_data ) const;
+
+ void displaySpecializedSciMsgArray ( ) const;
+
+ // public attribute accessor methods
+ //
+
+ // private attribute accessor methods
+ //
+
+ /**
+ * @return StationsList *
+ */
+ StationsList * getStationsList ( ) const;
+
+ /**
+ * @return bool
+ * @param p_list_of_stations
+ */
+ bool setStationsList ( StationsList * p_list_of_stations );
+
+ /**
+ * Get the value of mArraySize
+ * @return the value of mArraySize
+ */
+ unsigned int getArraySize ( ) const;
+
+ /**
+ * Get the value of mpSpecializedSciMsgArray
+ * @return the value of mpSpecializedSciMsgArray
+ */
+ SciMsg ** getSpecializedSciMsgArray ( ) const;
+
+ /**
+ * @return bool
+ * @param current_tick_value
+ */
+ bool updateTickValue ( const Network_Clock_Tick current_tick_value );
+
+ /**
+ * @return Network_Clock_Tick
+ */
+ Network_Clock_Tick getNetworkClockTick ( ) const;
+
+ // protected attribute accessor methods
+ //
+
+private:
+
+ // private methods
+ //
+
+ bool log ( ) const;
+
+ /**
+ * @return bool
+ * @param type
+ * @param received_sci_msg
+ */
+ bool createSciMsg ( const Sci_Msg_Type type, SciMsg ** received_sci_msg ) const;
+
+ /**
+ * @return bool
+ * @param msg_header
+ * @param data_length
+ * @param remaining_data
+ * @param received_sci_msg
+ */
+ bool fillSciMsg ( const Sci_Msg_Header * msg_header,
+ const unsigned long data_length,
+ const unsigned char * received_data,
+ SciMsg ** created_sci_msg ) const;
+
+ /**
+ * @return bool
+ * @param received_sci_msg
+ */
+ bool processSciMsg ( SciMsg * received_sci_msg ) const;
+
+ std::string displaySciMsgType ( uint8_t sci_msg_type ) const;
+
+ void displayStatus ( ) const;
+
+ void initAttributes ( );
+
+ // private attribute accessor methods
+ //
+
+ /**
+ * @return std::string
+ */
+ std::string getStationLog ( ) const;
+
+protected:
+
+ // protected methods
+ //
+
+};
+
+
+#endif // SCISERVER_H
diff --git a/cesar/maximus/sci/inc/SciServerTest.h b/cesar/maximus/sci/inc/SciServerTest.h
new file mode 100644
index 0000000000..e92eac8abc
--- /dev/null
+++ b/cesar/maximus/sci/inc/SciServerTest.h
@@ -0,0 +1,62 @@
+
+#ifndef SCISERVERTEST_H
+#define SCISERVERTEST_H
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "sci_types.h" // for 'Sci_Msg_Header'
+
+class SciServer;
+class FunctionCallManager;
+class SystemManager;
+class PhyProcessor;
+class NetworkClockProcessor;
+class FunctionSciMsg;
+class IEthernet;
+
+void functionSciMsgCallback ( const FunctionSciMsg & function_sci_msg );
+
+
+class SciServerTest : public CPPUNIT_NS::TestFixture
+{
+
+ CPPUNIT_TEST_SUITE (SciServerTest);
+ CPPUNIT_TEST (registerSpecializedSciMsgTest);
+ CPPUNIT_TEST (receiveMsgTest);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp (void);
+ void tearDown (void);
+
+protected:
+
+ void registerSpecializedSciMsgTest (void);
+ void receiveMsgTest (void);
+
+private:
+
+ SciServer * mpSciServer;
+ FunctionCallManager * mpFunctionCallManager;
+ SystemManager * mpSystemManager;
+ PhyProcessor * mpPhyProcessor;
+ NetworkClockProcessor * mpNetworkClockProcessor;
+ IEthernet * mpEthernet;
+
+ void registerClockSciMsgTest (void);
+ void registerPhySciMsgTest (void);
+ void registerSystemSciMsgTest (void);
+ void registerFunctionSciMsgTest (void);
+ void registerEtherSciMsgTest (void);
+ void receiveClockSciMsgTest ( Sci_Msg_Header & msg_header );
+ void receivePhySciMsgTest ( Sci_Msg_Header & msg_header );
+ void receiveSystemSciMsgTest ( Sci_Msg_Header & msg_header );
+ void receiveFunctionSciMsgTest ( Sci_Msg_Header & msg_header );
+ void receiveEtherSciMsgTest ( Sci_Msg_Header & msg_header );
+
+};
+
+
+#endif // SCISERVERTEST_H