summaryrefslogtreecommitdiff
path: root/cesar/maximus/phy/src/PhySciMsgFc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/phy/src/PhySciMsgFc.cpp')
-rw-r--r--cesar/maximus/phy/src/PhySciMsgFc.cpp189
1 files changed, 189 insertions, 0 deletions
diff --git a/cesar/maximus/phy/src/PhySciMsgFc.cpp b/cesar/maximus/phy/src/PhySciMsgFc.cpp
new file mode 100644
index 0000000000..759808da5f
--- /dev/null
+++ b/cesar/maximus/phy/src/PhySciMsgFc.cpp
@@ -0,0 +1,189 @@
+/************************************************************************
+ PhySciMsgFc.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/phy/src/PhySciMsgFc.cpp
+**************************************************************************/
+
+#include "PhySciMsgFc.h"
+#include "IPhy.h"
+
+#include "Error.h"
+#include "Logger.h"
+
+// for 'getpid()'
+#include <sys/types.h>
+#include <unistd.h>
+
+using namespace std;
+
+
+// Constructors/Destructors
+//
+
+
+PhySciMsgFc::PhySciMsgFc ( IPhy * p_phy_processor ) : PhySciMsg ( p_phy_processor ),
+mFc10(0)
+{
+ logFunction();
+
+ initAttributes ();
+}
+
+
+void PhySciMsgFc::initAttributes ( )
+{
+ logFunction();
+
+ memset(mFcAvArray, '\0', 4*sizeof(uint32_t));
+
+ // Set PHY SCI message type
+ PhySciMsg::setSpecializedSciMsgType(PHY_TYPE_FC_AV_ONLY_MODE);
+}
+
+
+PhySciMsgFc::~PhySciMsgFc( )
+{
+ logFunction();
+}
+
+
+//
+// Methods
+//
+
+
+// Other methods
+//
+
+
+// public methods
+//
+
+
+bool PhySciMsgFc::prepare ( Network_Clock_Id clock_id )
+{
+ logFunction();
+ bool bPrepare = false;
+
+ /* For a PHY message of type FC_AV_ONLY_MODE,
+ * PHY SCI message data only contain AV Frame Control (128 bits). */
+
+ if (PHY_TYPE_FC_AV_ONLY_MODE == PhySciMsg::getSpecializedSciMsgType())
+ {
+ // Set length of PHY SCI message data
+ bPrepare = SciMsg::setSpecializedSciMsgDataLength(4*sizeof(uint32_t));
+
+ // Set PHY SCI message data
+ bPrepare &= SciMsg::setSpecializedSciMsgData((unsigned char *)getFcAv());
+ }
+
+ /* For a PHY message of type FC_HYBRID_MODE,
+ * PHY SCI message data contain HP1.0.1 Frame Control (25 bits => on 4 octets)
+ * and AV Frame Control (128 bits). */
+
+ else if (PHY_TYPE_FC_HYBRID_MODE == PhySciMsg::getSpecializedSciMsgType())
+ {
+ // Set length of PHY SCI message data
+ bPrepare = SciMsg::setSpecializedSciMsgDataLength(5*sizeof(uint32_t));
+
+ // Set PHY SCI message data
+ unsigned char data[5*sizeof(uint32_t)];
+ memcpy(data, (unsigned char *)&mFc10, sizeof(uint32_t));
+ memcpy(data+sizeof(uint32_t), (unsigned char *)getFcAv(), 4*sizeof(uint32_t));
+ bPrepare &= SciMsg::setSpecializedSciMsgData(data);
+ }
+ else
+ {
+ throw Error(__PRETTY_FUNCTION__, "PHY SCI message type is not FC");
+ }
+
+ // Set TX ID
+ bPrepare &= PhySciMsg::setTxId(PhySciMsg::getPhyProcessor()->getTxId());
+
+ // Set station ID to Maximus PID
+ bPrepare &= SciMsg::setSciMsgStationId(getpid());
+
+ if (PhySciMsg::getShortPpdu())
+ {
+ // Indicate that MPDU transmission is finished
+ PhySciMsg::setIsSent(true);
+ }
+
+ return bPrepare;
+}
+
+
+// private methods
+//
+
+
+// protected methods
+//
+
+
+// Accessor methods
+//
+
+
+// public attribute accessor methods
+//
+
+
+// private attribute accessor methods
+//
+
+
+const uint32_t PhySciMsgFc::getFc10 ( ) const
+{
+ return mFc10;
+}
+
+
+bool PhySciMsgFc::setFc10 ( const uint32_t fc_10 )
+{
+ mFc10 = fc_10;
+
+ // Set PHY SCI message type
+ return PhySciMsg::setSpecializedSciMsgType(PHY_TYPE_FC_HYBRID_MODE);
+}
+
+
+const uint32_t * PhySciMsgFc::getFcAv ( ) const
+{
+ return mFcAvArray;
+}
+
+
+bool PhySciMsgFc::setFcAv ( const uint32_t fc_av[4] )
+{
+ return (NULL != memcpy(mFcAvArray, fc_av, 4*sizeof(uint32_t)));
+}
+
+
+// protected attribute accessor methods
+//
+