summaryrefslogtreecommitdiff
path: root/cesar/maximus/phy/src
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/phy/src')
-rw-r--r--cesar/maximus/phy/src/PhyProcessor.cpp1533
-rw-r--r--cesar/maximus/phy/src/PhyProcessorTest.cpp583
-rw-r--r--cesar/maximus/phy/src/PhySciMsg.cpp956
-rw-r--r--cesar/maximus/phy/src/PhySciMsgFc.cpp189
-rw-r--r--cesar/maximus/phy/src/PhySciMsgFcTest.cpp131
-rw-r--r--cesar/maximus/phy/src/PhySciMsgMpdu.cpp529
-rw-r--r--cesar/maximus/phy/src/PhySciMsgMpduTest.cpp321
-rw-r--r--cesar/maximus/phy/src/PhySciMsgNoise.cpp86
-rw-r--r--cesar/maximus/phy/src/PhySciMsgNoiseTest.cpp64
-rw-r--r--cesar/maximus/phy/src/PhySciMsgPre.cpp124
-rw-r--r--cesar/maximus/phy/src/PhySciMsgPreTest.cpp72
-rw-r--r--cesar/maximus/phy/src/PhySciMsgTest.cpp77
12 files changed, 0 insertions, 4665 deletions
diff --git a/cesar/maximus/phy/src/PhyProcessor.cpp b/cesar/maximus/phy/src/PhyProcessor.cpp
deleted file mode 100644
index ff42ea10bd..0000000000
--- a/cesar/maximus/phy/src/PhyProcessor.cpp
+++ /dev/null
@@ -1,1533 +0,0 @@
-/************************************************************************
- PhyProcessor.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/PhyProcessor.cpp
-**************************************************************************/
-
-#include "PhyProcessor.h"
-
-#include "PhySciMsg.h"
-#include "PhySciMsgMpdu.h"
-#include "PhySciMsgNoise.h"
-#include "PhySciMsgPre.h"
-#include "ISci.h"
-#include "NetworkClockEvt.h"
-#include "INetworkClock.h"
-#include "IChannel.h"
-
-#include "Error.h"
-#include "Logger.h"
-
-#include "hal/phy/maximus/dur/inc/maximus_dur.h"
-#include "hal/phy/maximus/inc/maximus_defs.h" // for 'MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK' and 'MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK'
-#include "mac/common/timings.h" // for 'MAC_PREAMBLE_TCK', 'MAC_PREAMBLE_HYBRID_TCK', 'MAC_FC_10_TCK', and 'MAC_FC_AV_TCK'
-
-#include <string> // for 'memset()' and 'memcpy()'
-#include <netinet/in.h> // for 'htonl()' and 'htons()'
-#include <boost/random/mersenne_twister.hpp> // for random
-#include <boost/random/normal_distribution.hpp>
-#include <boost/random/variate_generator.hpp>
-using namespace std;
-
-
-// Constructors/Destructors
-//
-
-
-PhyProcessor::PhyProcessor ( ISci * p_sci_server ):
-mpSciServer(NULL),
-mpNetworkClock(NULL),
-mpChannel(NULL),
-mIsChannelEnabled(false),
-mNbOfCarriers(0),
-mpTonemask(NULL),
-mTxId(0),
-mInterfaceCb(NULL),
-mFrequency(0),
-mZeroCrossDelay(0),
-mpZeroCross(NULL),
-mIsFalseAlarmActivated(false),
-mpWrongPre(NULL),
-mAverageDuration(0),
-mStdDeviation(0)
-{
- logFunction();
-
- if (NULL != p_sci_server)
- {
- mpSciServer = p_sci_server;
- registerPhySciMsg();
- }
- else
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "SCI server pointer is NULL", errno);
- }
-
- initAttributes();
-}
-
-
-void PhyProcessor::initAttributes ( )
-{
- logFunction();
-}
-
-
-PhyProcessor::~PhyProcessor ( )
-{
- logFunction();
-
- if (NULL != mpSciServer)
- {
- mpSciServer = NULL;
- }
- if (NULL != mpNetworkClock)
- {
- mpNetworkClock = NULL;
- }
- if (NULL != mpChannel)
- {
- mpChannel = NULL;
- }
- if (NULL != mpTonemask)
- {
- delete [] mpTonemask;
- mpTonemask = NULL;
- }
- mListOfRxStations.clear();
- mListOfRxFc.clear();
- if (NULL != mpZeroCross)
- {
- delete(mpZeroCross);
- mpZeroCross = NULL;
- }
- for (RxMpduList::iterator it = mListOfRxMpdu.begin(); it != mListOfRxMpdu.end();)
- {
- RxMpduList::iterator pos = it;
- ++it;
- if (NULL != pos->second.p_data)
- {
- delete [] pos->second.p_data;
- }
- }
- mListOfRxMpdu.clear();
-
- if (NULL != mpWrongPre)
- {
- delete(mpWrongPre);
- mpWrongPre = NULL;
- }
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-bool PhyProcessor::init ( PhyMpduCb interface_cb )
-{
- logFunction();
- bool bInit = false;
-
- if (NULL != interface_cb)
- {
- mInterfaceCb = interface_cb;
- bInit = true;
- }
- else
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "Callback function address is NULL", errno);
- }
-
- return bInit;
-}
-
-
-bool PhyProcessor::init ( const float frequency )
-{
- logFunction();
- bool bInit = false;
-
- // Create a PHY SCI message of type ZERO_CROSS
- mpZeroCross = new PhySciMsg(this);
- bInit = mpZeroCross->setSpecializedSciMsgType(PHY_TYPE_ZERO_CROSS);
- bInit &= mpZeroCross->setFlags(PHY_FLAG_CRC_OK);
- bInit &= mpZeroCross->setSciMsgStationId(getpid());
-
- // Set power line frequency
- bInit = setFrequency(frequency);
-
- if (0 != frequency)
- {
- // Calculate zero-cross delay, and set it
- Network_Clock_Tick zeroCrossDelay = (Network_Clock_Tick)(25000000/(2*frequency));
- bInit &= setZeroCrossDelay(zeroCrossDelay);
-
- // Schedules a PHY SCI message of type ZERO_CROSS
- bInit &= scheduleZeroCross();
- }
-
- return bInit;
-}
-
-
-PhySciMsg * PhyProcessor::createMsg ( )
-{
- logFunction();
-
- return new PhySciMsg(this);
-}
-
-
-PhySciMsgMpdu * PhyProcessor::createMpdu ( )
-{
- logFunction();
-
- return new PhySciMsgMpdu(this);
-}
-
-
-bool PhyProcessor::sendMpdu ( PhySciMsgMpdu * p_mpdu )
-{
- logFunction();
- bool bSendMpdu = false;
-
- if (NULL == p_mpdu)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message MPDU pointer is NULL", errno);
- }
-
- // Schedule PREAMBLE message
- Network_Clock_Tick tickPre = getNetworkClock()->getCurrentTickValue() + calculatePreDelay();
- NetworkClockEvt evtPre ( 0, // station_id
- NETWORK_CLOCK_TYPE_PHY,
- 0, // id = 0 for PREAMBLE
- (void *)p_mpdu->getPre() );
- bSendMpdu = getNetworkClock()->insertEvt(tickPre, evtPre);
-
- // Schedule FC message
- Network_Clock_Tick tickFc = getNetworkClock()->getCurrentTickValue() + calculateFcDelay(p_mpdu->getFcMode());
- NetworkClockEvt evtFc ( 0, // station_id
- NETWORK_CLOCK_TYPE_PHY,
- 0, // id = 0 for FC
- (void *)p_mpdu->getFc() );
- bSendMpdu &= getNetworkClock()->insertEvt(tickFc, evtFc);
-
- // Schedule MPDU message(s)
- if (!p_mpdu->getShortPpdu())
- {
- // segmentation in PBs
- bSendMpdu &= p_mpdu->segment();
-
- Network_Clock_Tick tickMpdu = getNetworkClock()->getCurrentTickValue() \
- + calculateMpduDelay(p_mpdu->getMod(), \
- p_mpdu->getFecrate(), \
- p_mpdu->getPbSize(), \
- p_mpdu->getNbOfPbs(), \
- p_mpdu->getGil());
-
- // insert a Network Clock event
- NetworkClockEvt evtMpdu ( 0, // station_id
- NETWORK_CLOCK_TYPE_PHY,
- p_mpdu->getNbOfMsgs(), // id = message number for MPDU
- (void *)p_mpdu );
- bSendMpdu &= getNetworkClock()->insertEvt(tickMpdu, evtMpdu);
- }
-
- if (!bSendMpdu)
- {
- throw Error(__PRETTY_FUNCTION__, "cannot send MPDU", errno);
- }
-
- return bSendMpdu;
-}
-
-
-bool PhyProcessor::receiveEvt ( NetworkClockEvt & received_evt )
-{
- logFunction();
- bool bReceiveEvt = true;
-
- PhySciMsg * pPhySciMsgToSend = (PhySciMsg *)received_evt.getData();
- if (NULL == pPhySciMsgToSend)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message pointer is NULL", errno);
- }
-
- if (PHY_TYPE_PREAMBLE == pPhySciMsgToSend->getSpecializedSciMsgType())
- {
- // Increment TX ID at the beginning of each transmission
- bReceiveEvt &= incrementTxId();
- }
-
- if (PHY_TYPE_MPDU_PAYLOAD == pPhySciMsgToSend->getSpecializedSciMsgType())
- {
- PhySciMsgMpdu * pMpdu = (PhySciMsgMpdu *)received_evt.getData();
-
- // Set TX ID
- bReceiveEvt &= pMpdu->setTxId(getTxId());
-
- // Set station ID to Maximus PID
- bReceiveEvt &= pMpdu->setSciMsgStationId(getpid());
-
- if (!isChannelEnabled())
- {
- // For each PHY SCI message composing the MPDU
- for (int n=1; n<=pMpdu->getNbOfMsgs(); n++)
- {
- // Prepare PHY SCI message before transmission
- bReceiveEvt &= pMpdu->prepare(n);
-
- // Set PHY SCI message PB Header
- bReceiveEvt &= pMpdu->setPbHeader(pMpdu->getPbsHeaders(n-1));
-
- // Send PHY SCI message MPDU
- bReceiveEvt &= sendMpduToDestStations(*pMpdu);
- }
-
- // Send empty PHY SCI message NOISE
- PhySciMsgNoise noise(this);
- bReceiveEvt &= noise.setTxId(pMpdu->getTxId()); // set TX ID
- bReceiveEvt &= noise.setSciMsgStationId(pMpdu->getSciMsgStationId()); // set station ID to Maximus PID
- bReceiveEvt &= sendEmptyNoiseToDestStations(noise);
-
- // Update list of destination stations
- if (pMpdu->isSent())
- {
- updateListOfRxStations(*pMpdu);
- }
- else
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message MPDU has not been correctly sent");
- }
- }
- else
- {
- bReceiveEvt &= sendMpduAndNoiseToDestStations(*pMpdu);
- }
- }
- else if (PHY_TYPE_ZERO_CROSS == pPhySciMsgToSend->getSpecializedSciMsgType())
- {
- if (0 != getFrequency())
- {
- bReceiveEvt &= scheduleZeroCross();
- bReceiveEvt &= sendMsgToAllStations(*pPhySciMsgToSend);
- }
- }
- else if ( (PHY_TYPE_PREAMBLE == pPhySciMsgToSend->getSpecializedSciMsgType())
- && (PHY_FLAG_WRONG_PREAMBLE == (pPhySciMsgToSend->getFlags() & PHY_FLAG_WRONG_PREAMBLE)) )
- {
- if (isFalseAlarmActivated())
- {
- // Prepare PHY SCI message before transmission
- bReceiveEvt &= pPhySciMsgToSend->prepare(received_evt.getNetworkClockId());
-
- bReceiveEvt &= sendMsgToAllStations(*pPhySciMsgToSend);
-
- bReceiveEvt &= scheduleNextWrongPre(calculateNextWrongPreDate());
- }
- }
- else
- {
- // Prepare PHY SCI message before transmission
- bReceiveEvt &= pPhySciMsgToSend->prepare(received_evt.getNetworkClockId());
-
- bReceiveEvt &= sendMsgToAllStations(*pPhySciMsgToSend);
- }
-
- return bReceiveEvt;
-}
-
-
-bool PhyProcessor::receiveInvalid ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
-
- errno = ENOMSG;
- throw Error(__PRETTY_FUNCTION__, "receive PHY SCI message of invalid type", errno);
-
- return false;
-}
-
-
-bool PhyProcessor::receivePre ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
-
- if (isChannelEnabled())
- {
- getChannel()->receivePre(received_phy_sci_msg.getSciMsgStationId(), getNetworkClock()->getCurrentTickValue());
- }
-
- return sendMsgToAllStations(received_phy_sci_msg);
-}
-
-
-bool PhyProcessor::receiveFc ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
-
- // Check PHY SCI message data length
- if ( ((PHY_TYPE_FC_HYBRID_MODE == received_phy_sci_msg.getSpecializedSciMsgType())
- && (5*sizeof(uint32_t) != received_phy_sci_msg.getSpecializedSciMsgDataLength()))
- || ((PHY_TYPE_FC_AV_ONLY_MODE == received_phy_sci_msg.getSpecializedSciMsgType())
- && (4*sizeof(uint32_t) != received_phy_sci_msg.getSpecializedSciMsgDataLength()))
- || (NULL == received_phy_sci_msg.getSpecializedSciMsgData()) )
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "received PHY SCI message FC is incorrect", errno);
- }
-
- if (NULL != getInterfaceCb())
- {
- Frame_Control fc;
- unsigned char * pDataIndex = received_phy_sci_msg.getSpecializedSciMsgData();
- if (PHY_TYPE_FC_HYBRID_MODE == received_phy_sci_msg.getSpecializedSciMsgType())
- {
- memcpy(&fc.fc_10, pDataIndex, sizeof(uint32_t));
- pDataIndex += sizeof(uint32_t);
- }
- else
- {
- fc.fc_10 = 0;
- }
- memcpy(fc.fc_av, pDataIndex, 4*sizeof(uint32_t));
-
- Expected_Tx tx;
- tx.src_tx_id = received_phy_sci_msg.getTxId();
- tx.src_station_id = received_phy_sci_msg.getSciMsgStationId();
- mListOfRxFc[tx] = fc;
- }
-
- if (isChannelEnabled())
- {
- getChannel()->receiveFc(received_phy_sci_msg.getSciMsgStationId(), getNetworkClock()->getCurrentTickValue());
- }
-
- return sendMsgToAllStations(received_phy_sci_msg);
-}
-
-
-bool PhyProcessor::receivePrs ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
-
- return sendMsgToAllStations(received_phy_sci_msg);
-}
-
-
-bool PhyProcessor::receiveMpdu ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
- bool bReceiveMpdu = true;
-
- PhySciMsgMpdu mpdu(received_phy_sci_msg);
-
- // Check PHY SCI message data length
- if ( (0 == mpdu.getSpecializedSciMsgDataLength())
- || (NULL == mpdu.getSpecializedSciMsgData()) )
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "received PHY SCI message MPDU is incorrect", errno);
- }
-
- /**
- * Lots of things to do in this function...
- * Not optimized at all, but easier to understand!
- * Following order has to be respected:
- * 1. IF there is a reception callback
- * OR IF the channel perturbation is enabled,
- * THEN update list of received MPDU.
- * 2. IF there is a reception callback
- * AND IF the entire MPDU has been received,
- * THEN call the reception callback.
- * 3. IF the channel perturbation is disabled
- * AND IF there is no reception callback
- * OR IF there is a reception callback AND IF the entire MPDU has been received,
- * THEN re-send the received MPDU and an empty NOISE at the end of the MPDU transmission
- * to destination stations.
- * 4. IF the channel perturbation is enabled
- * AND IF the entire MPDU has been received,
- * THEN send the entire MPDU (with PB measurement) and the NOISE to destination stations
- * (noise must be sent only at the end of the MPDU transmission).
- * 5. IF the entire MPDU has been received,
- * THEN update RX lists.
- */
-
- // Create Expected_Tx for the list of received MPDU and the list of received FC
- Expected_Tx tx;
- tx.src_tx_id = mpdu.getTxId();
- tx.src_station_id = mpdu.getSciMsgStationId();
-
-
- /* 1. Update list of received MPDU. */
-
- if ((NULL != getInterfaceCb()) || isChannelEnabled())
- {
- // Create Mpdu_Payload for the list of received MPDU
- Mpdu_Payload payload;
- memset(&payload, '\0', sizeof(struct Mpdu_Payload));
-
- // Check if a PHY SCI message MPDU with the same transmission ID
- // has already been received from this transmitting station
- bool bFound = false;
- for (RxMpduList::iterator it = mListOfRxMpdu.begin(); it != mListOfRxMpdu.end(); ++it)
- {
- if ((tx.src_tx_id == it->first.src_tx_id)
- && (tx.src_station_id == it->first.src_station_id))
- {
- // If a PHY SCI message MPDU has already been received,
- // update the Mpdu_Payload
- unsigned long dataLength = mListOfRxMpdu[tx].data_length + mpdu.getSpecializedSciMsgDataLength();
- unsigned char * pData = new unsigned char[dataLength];
- memcpy(pData, mListOfRxMpdu[tx].p_data, mListOfRxMpdu[tx].data_length);
- delete [] mListOfRxMpdu[tx].p_data;
- memcpy(pData + mListOfRxMpdu[tx].data_length, mpdu.getSpecializedSciMsgData(), mpdu.getSpecializedSciMsgDataLength());
- payload.msg_nb = mListOfRxMpdu[tx].msg_nb + 1;
- payload.data_length = dataLength;
- payload.p_data = pData;
- memcpy(&payload.pb_header[mListOfRxMpdu[tx].msg_nb * PHY_PB_MAX_NB], mpdu.getPbHeader(), PHY_PB_MAX_NB * sizeof(uint32_t));
-
- bFound = true;
- break;
- }
- }
-
- // It is the 1st PHY SCI message MPDU with the same transmission ID
- // received from this transmitting station
- if (!bFound)
- {
- payload.msg_nb = 1;
- payload.data_length = mpdu.getSpecializedSciMsgDataLength();
- payload.p_data = new unsigned char[payload.data_length];
- memcpy(payload.p_data, mpdu.getSpecializedSciMsgData(), payload.data_length);
- memcpy(payload.pb_header, mpdu.getPbHeader(), PHY_PB_MAX_NB * sizeof(uint32_t));
- }
-
- // Update list of received MPDU
- mListOfRxMpdu[tx] = payload;
- }
- else // update number of received MPDU
- {
- if (0 != mListOfRxMpdu.count(tx))
- {
- mListOfRxMpdu[tx].msg_nb++;
- }
- else
- {
- Mpdu_Payload payload;
- memset(&payload, '\0', sizeof(struct Mpdu_Payload));
- payload.msg_nb = 1;
- mListOfRxMpdu[tx] = payload;
- }
- }
-
-
- /* 2. Call the reception callback. */
-
- if ((NULL != getInterfaceCb()) && mpdu.isReceived(mListOfRxMpdu[tx].msg_nb))
- {
- // Check if a PHY SCI message FC with the same transmission ID
- // has already been received from this transmitting station
- bReceiveMpdu = false;
- for (RxFcList::iterator it = mListOfRxFc.begin(); it != mListOfRxFc.end(); ++it)
- {
- if ((tx.src_tx_id == it->first.src_tx_id)
- && (tx.src_station_id == it->first.src_station_id))
- {
- // Create a PHY SCI message MPDU and configure it
- PhySciMsgMpdu rxMpdu(this);
- bReceiveMpdu = rxMpdu.setSpecializedSciMsgDataLength(mListOfRxMpdu[tx].data_length);
- bReceiveMpdu &= rxMpdu.setSpecializedSciMsgData(mListOfRxMpdu[tx].p_data);
- bReceiveMpdu &= rxMpdu.setFc10((it->second).fc_10);
- bReceiveMpdu &= rxMpdu.setFcAv((it->second).fc_av);
-
- // Call the reception callback
- getInterfaceCb()(rxMpdu);
-
- // Update list of received FC
- mListOfRxFc.erase(it);
-
- break;
- }
- }
-
- // If no PHY SCI message FC with the same transmission ID
- // has been received from this transmitting station,
- // raise an error
- if (!bReceiveMpdu)
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "an MPDU has been received but its FC has not been retrieved", errno);
- }
- }
-
-
- /* 3. Re-send the received MPDU and an empty NOISE at the end of the MPDU transmission
- * to destination stations. */
-
- if (!isChannelEnabled())
- {
- if (NULL == getInterfaceCb())
- {
- sendMpduToDestStations(mpdu);
-
- if (mpdu.isReceived(mListOfRxMpdu[tx].msg_nb))
- {
- // Send empty PHY SCI message NOISE
- PhySciMsgNoise noise(this);
- bReceiveMpdu &= noise.setTxId(mpdu.getTxId());
- bReceiveMpdu &= noise.setSciMsgStationId(mpdu.getSciMsgStationId());
- bReceiveMpdu &= sendEmptyNoiseToDestStations(noise);
-
- // Update list of received MPDU
- mListOfRxMpdu.erase(tx);
-
- // Update list of destination stations
- updateListOfRxStations(mpdu);
- }
- }
- else if (mpdu.isReceived(mListOfRxMpdu[tx].msg_nb))
- {
- // Update PHY SCI message data length and data
- bReceiveMpdu &= mpdu.setMpdu(mListOfRxMpdu[tx].data_length, mListOfRxMpdu[tx].p_data);
-
- // Segmentation in PBs
- bReceiveMpdu &= mpdu.segment();
-
- // For each PHY SCI message composing the MPDU
- for (int n=1; n<=mpdu.getNbOfMsgs(); n++)
- {
- // Prepare PHY SCI message before transmission
- bReceiveMpdu &= mpdu.prepare(n);
-
- bReceiveMpdu &= sendMpduToDestStations(mpdu);
- }
- // Send empty PHY SCI message NOISE
- PhySciMsgNoise noise(this);
- bReceiveMpdu &= noise.setTxId(mpdu.getTxId());
- bReceiveMpdu &= noise.setSciMsgStationId(mpdu.getSciMsgStationId());
- bReceiveMpdu &= sendEmptyNoiseToDestStations(noise);
-
- // Update list of destination stations
- updateListOfRxStations(mpdu);
- }
- }
-
-
- /* 4. Send the entire MPDU (with PB measurement) and the NOISE to destination stations. */
-
- else if (mpdu.isReceived(mListOfRxMpdu[tx].msg_nb))
- {
- // Update PHY SCI message data length and data
- bReceiveMpdu &= mpdu.setMpdu(mListOfRxMpdu[tx].data_length, mListOfRxMpdu[tx].p_data);
-
- // Segmentation in PBs
- bReceiveMpdu &= mpdu.segment();
-
- bReceiveMpdu &= sendMpduAndNoiseToDestStations(mpdu);
- }
-
-
- /* 5. Update RX lists. */
-
- if (((NULL != getInterfaceCb()) || isChannelEnabled()) && mpdu.isReceived(mListOfRxMpdu[tx].msg_nb))
- {
- // Update list of received MPDU
- delete [] mListOfRxMpdu[tx].p_data;
- mListOfRxMpdu.erase(tx);
-
- // Update list of destination stations
- updateListOfRxStations(mpdu);
- }
-
-
- return bReceiveMpdu;
-}
-
-
-bool PhyProcessor::receiveTonemask ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
- bool bReceiveTonemask = false;
-
- // Check PHY SCI message data length
- if ( ((sizeof(unsigned int) + (PHY_CARRIER_NB+7)/8) != received_phy_sci_msg.getSpecializedSciMsgDataLength())
- || (NULL == received_phy_sci_msg.getSpecializedSciMsgData()) )
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "received PHY SCI message TONEMASK is incorrect", errno);
- }
-
- // Set number of active carriers
- unsigned int nbOfCarriers;
- memcpy(&nbOfCarriers, received_phy_sci_msg.getSpecializedSciMsgData(), sizeof(unsigned int));
- setNbOfCarriers(nbOfCarriers);
-
- // Set tonemask
- bReceiveTonemask = setTonemask(received_phy_sci_msg.getSpecializedSciMsgDataLength()-sizeof(unsigned int),
- received_phy_sci_msg.getSpecializedSciMsgData()+sizeof(unsigned int));
-
- if (isChannelEnabled())
- {
- bReceiveTonemask &= getChannel()->setTonemask(getTonemask());
- }
-
- return bReceiveTonemask;
-}
-
-
-bool PhyProcessor::receiveTonemap ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
- bool bReceiveTonemap = true;
-
- if (isChannelEnabled())
- {
- bReceiveTonemap = getChannel()->setTonemap(received_phy_sci_msg.getSciMsgStationId(),
- received_phy_sci_msg.getSpecializedSciMsgDataLength(),
- received_phy_sci_msg.getSpecializedSciMsgData());
- }
-
- return bReceiveTonemap;
-}
-
-
-bool PhyProcessor::receiveRx ( PhySciMsg & received_phy_sci_msg )
-{
- logFunction();
-
- // Check PHY SCI message data length
- if ( (sizeof(Sci_Msg_Station_Id) != received_phy_sci_msg.getSpecializedSciMsgDataLength())
- || (NULL == received_phy_sci_msg.getSpecializedSciMsgData()) )
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "received PHY SCI message RX is incorrect", errno);
- }
-
- // Update list of destination stations
- Expected_Tx tx;
- tx.src_tx_id = received_phy_sci_msg.getTxId();
- tx.src_station_id = *((Sci_Msg_Station_Id *)received_phy_sci_msg.getSpecializedSciMsgData());
- mListOfRxStations.insert(RxStationsList::value_type(tx, received_phy_sci_msg.getSciMsgStationId()));
-
- return true;
-}
-
-
-bool PhyProcessor::sendMsgToAllStations ( PhySciMsg & phy_sci_msg_to_send ) const
-{
- logFunction();
- bool bSendToAll = false;
-
- if (fillMsg(phy_sci_msg_to_send))
- {
- bSendToAll = getSciServer()->sendSciMsgToAllActiveStations(phy_sci_msg_to_send);
- }
- else
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message cannot be sent because it is not correctly filled in", errno);
- }
-
- return bSendToAll;
-}
-
-
-bool PhyProcessor::activateFalseAlarm ( const Network_Clock_Tick average_duration,
- const float std_deviation )
-{
- logFunction();
- bool bActivate = true;
-
- // Check input values
- if ((0 == average_duration) || (0 > std_deviation))
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "average duration and/or standard deviation are out-of-range", errno);
- }
-
- // Set false alarm activated, average duration and standard deviation
- mIsFalseAlarmActivated = true;
- mAverageDuration = average_duration;
- mStdDeviation = std_deviation;
-
- if (NULL == mpWrongPre)
- {
- // Create a PHY SCI message of type PREAMBLE and set the flag PHY_FLAG_WRONG_PREAMBLE
- mpWrongPre = new PhySciMsgPre(this);
- bActivate &= mpWrongPre->setFlags(PHY_FLAG_CRC_OK + PHY_FLAG_WRONG_PREAMBLE);
- }
-
- // Schedules the first PHY SCI message of type PREAMBLE with the flag PHY_FLAG_WRONG_PREAMBLE set
- bActivate &= scheduleNextWrongPre(MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK);
-
- return bActivate;
-}
-
-
-bool PhyProcessor::deactivateFalseAlarm ( )
-{
- mIsFalseAlarmActivated = false;
-
- return true;
-}
-
-
-bool PhyProcessor::setFrequency ( const float frequency )
-{
- bool bFreq = false;
-
- if (0 > frequency)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "frequency is negative", errno);
- }
- else
- {
- if (0 != frequency)
- {
- // Calculate zero-cross delay, and set it
- Network_Clock_Tick zeroCrossDelay = (Network_Clock_Tick)(25000000/(2*frequency));
- bFreq = setZeroCrossDelay(zeroCrossDelay);
-
- if (0 == getFrequency())
- {
- // Schedules a PHY SCI message of type ZERO_CROSS
- bFreq &= scheduleZeroCross();
- }
- }
- else
- {
- mZeroCrossDelay = 0;
- bFreq = true;
- }
-
- mFrequency = frequency;
- }
-
- if (isChannelEnabled())
- {
- // Set beacon period to Channel
- getChannel()->setBeaconPeriod(getFrequency());
- }
-
- return bFreq;
-}
-
-
-float PhyProcessor::getFrequency ( ) const
-{
- if (0 > mFrequency)
- {
- throw Error(__PRETTY_FUNCTION__, "frequency is negative");
- }
-
- return mFrequency;
-}
-
-
-// private methods
-//
-
-
-void PhyProcessor::registerPhySciMsg ( )
-{
- logFunction();
-
- if (!getSciServer()->registerSpecializedSciMsg(SCI_MSG_TYPE_PHY, new PhySciMsg((IPhy*)this)))
- {
- throw Error(__PRETTY_FUNCTION__, "cannot register PHY SCI message to SCI server");
- }
-}
-
-
-Network_Clock_Tick PhyProcessor::calculatePreDelay ( ) const
-{
- logFunction();
-
- return MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK;
-}
-
-
-Network_Clock_Tick PhyProcessor::calculateFcDelay ( Phy_Fc_Mode fc_mode ) const
-{
- logFunction();
- Network_Clock_Tick fcDelay = 0;
-
- // For frame control transmission/reception time
- unsigned int preDuration = MAC_PREAMBLE_TCK; // in AV mode
- unsigned int fcDuration = MAC_FC_AV_TCK; // in AV mode
-
- // Calculate frame control transimission time
- if ((PHY_FC_MODE_HYBRID_2 == fc_mode)
- || (PHY_FC_MODE_AV_2 == fc_mode))
- {
- fcDuration *= 2; // 2 symbols
- }
- if ((PHY_FC_MODE_HYBRID_1 == fc_mode)
- || (PHY_FC_MODE_HYBRID_2 == fc_mode))
- {
- preDuration = MAC_PREAMBLE_HYBRID_TCK; // in Hybrid mode
- fcDuration += MAC_FC_10_TCK; // in Hybrid mode
- }
- fcDelay = (preDuration - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK) \
- + fcDuration \
- + MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK;
-
- return fcDelay;
-}
-
-
-Network_Clock_Tick PhyProcessor::calculateMpduDelay ( Phy_Mod mod,
- Phy_Fecrate fecrate,
- unsigned short int pb_size,
- Phy_Nb_Of_Pbs pb_nb,
- Phy_Gil gil ) const
-{
- logFunction();
- Network_Clock_Tick mpduDelay = 0;
-
- /* MPDU delay depends on tonemask, modulation, fecrate, PB size, number of PBs, guard interval,
- * number of bits per symbol, and number of symbols. */
-
- // Calculate MPDU payload transimission time
- //
- unsigned int bitsPerSymbol = maximus_dur_bits_per_symbol(mod,
- getTonemask(),
- NULL,
- getNbOfCarriers());
- phy_pb_size_t pbSize = (MAC_PB520_BYTES == pb_size) ? PHY_PB_SIZE_520 : PHY_PB_SIZE_136;
- unsigned int symbolNb = maximus_dur_symbol_nb(mod,
- fecrate,
- pbSize,
- bitsPerSymbol,
- pb_nb);
- unsigned int durationInTicks = maximus_dur_data_tck(gil,
- symbolNb);
-
- mpduDelay = durationInTicks - MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK + MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK;
-
- return mpduDelay;
-}
-
-
-bool PhyProcessor::fillMsg ( PhySciMsg & phy_sci_msg_to_send ) const
-{
- logFunction();
- bool bFill = false;
-
- // Fill specialized SCI msg header
- //
- struct Phy_Header phySciMsgHeader;
- phySciMsgHeader.version = phy_sci_msg_to_send.getSpecializedSciMsgHeader().version;
- phySciMsgHeader.type = static_cast<uint8_t>(phy_sci_msg_to_send.getSpecializedSciMsgType());
- phySciMsgHeader.mpdu_format = static_cast<uint8_t>(phy_sci_msg_to_send.getMpduFormat());
- phySciMsgHeader.pb_nb = phy_sci_msg_to_send.getNbOfPbs();
- if (PHY_TYPE_MPDU_PAYLOAD == phySciMsgHeader.type)
- {
- phySciMsgHeader.msg_nb = static_cast<uint8_t>(((PhySciMsgMpdu *)&phy_sci_msg_to_send)->getNbOfMsgs());
- }
- else
- {
- phySciMsgHeader.msg_nb = 1;
- }
- phySciMsgHeader.fc_mode = phy_sci_msg_to_send.getFcMode();
- phySciMsgHeader.short_ppdu = phy_sci_msg_to_send.getShortPpdu();
- phySciMsgHeader.mod = phy_sci_msg_to_send.getMod();
- phySciMsgHeader.fecrate = phy_sci_msg_to_send.getFecrate();
- phySciMsgHeader.gil = phy_sci_msg_to_send.getGil();
- phySciMsgHeader.tonemap_index = phy_sci_msg_to_send.getTonemapIndex();
- phySciMsgHeader.tx_id = htons(phy_sci_msg_to_send.getTxId());
- phySciMsgHeader.flags = htons(phy_sci_msg_to_send.getFlags());
- phySciMsgHeader.reserved = htons(phy_sci_msg_to_send.getReserved());
- phySciMsgHeader.symbol_nb = htonl(phy_sci_msg_to_send.getNbOfSymbols());
- for (unsigned int i=0; i<3; i++)
- {
- phySciMsgHeader.iv[i] = htonl(phy_sci_msg_to_send.getIv()[i]);
- }
- for (unsigned int i=0; i<4; i++)
- {
- phySciMsgHeader.nek[i] = htonl(phy_sci_msg_to_send.getNek()[i]);
- }
- for (unsigned int i=0; i<PHY_PB_MAX_NB; i++)
- {
- phySciMsgHeader.pb_measurement[i] = htonl(phy_sci_msg_to_send.getPbMeasurement()[i]);
- phySciMsgHeader.pb_header[i] = htonl(phy_sci_msg_to_send.getPbHeader()[i]);
- }
-
- // Set specialized SCI msg header
- //
- bFill = phy_sci_msg_to_send.setSpecializedSciMsgHeader(phySciMsgHeader);
-
- // Fill specialized SCI msg attributes:
- // - header size
- //
- bFill &= phy_sci_msg_to_send.setSpecializedSciMsgHeaderSize(sizeof(struct Phy_Header));
-
- // Fill SCI msg attributes:
- // - type
- //
- bFill &= phy_sci_msg_to_send.setSciMsgType(SCI_MSG_TYPE_PHY);
-
- return bFill;
-}
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-ISci * PhyProcessor::getSciServer ( ) const
-{
- if (NULL == mpSciServer)
- {
- throw Error(__PRETTY_FUNCTION__, "SCI server pointer is NULL");
- }
-
- return mpSciServer;
-}
-
-
-bool PhyProcessor::setNetworkClock ( INetworkClock * p_network_clock )
-{
- bool bSetNetworkClock = false;
-
- if (NULL == p_network_clock)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "Network Clock pointer is NULL", errno);
- }
- else
- {
- mpNetworkClock = p_network_clock;
- bSetNetworkClock = true;
- }
-
- return bSetNetworkClock;
-}
-
-
-INetworkClock * PhyProcessor::getNetworkClock ( ) const
-{
- if (NULL == mpNetworkClock)
- {
- throw Error(__PRETTY_FUNCTION__, "Network Clock pointer is NULL");
- }
-
- return mpNetworkClock;
-}
-
-
-bool PhyProcessor::setChannel ( IChannel * p_channel )
-{
- bool bSetChannel = true;
-
- if (NULL == p_channel)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "Channel pointer is NULL", errno);
- }
-
- mpChannel = p_channel;
- if (NULL != mpTonemask)
- {
- bSetChannel = p_channel->setTonemask(getTonemask());
- }
-
- return bSetChannel;
-}
-
-
-IChannel * PhyProcessor::getChannel ( ) const
-{
- if (NULL == mpChannel)
- {
- throw Error(__PRETTY_FUNCTION__, "Channel pointer is NULL");
- }
-
- return mpChannel;
-}
-
-
-bool PhyProcessor::setIsChannelEnabled ( const bool is_channel_enabled )
-{
- mIsChannelEnabled = is_channel_enabled;
-
- return true;
-}
-
-
-bool PhyProcessor::isChannelEnabled ( ) const
-{
- return mIsChannelEnabled;
-}
-
-
-unsigned int PhyProcessor::getNbOfCarriers ( ) const
-{
- if ((PHY_CARRIER_NB < mNbOfCarriers) || (0 == mNbOfCarriers))
- {
- throw Error(__PRETTY_FUNCTION__, "number of carriers has not been correctly set");
- }
-
- return mNbOfCarriers;
-}
-
-
-bool PhyProcessor::setNbOfCarriers ( const unsigned int nb_of_carriers )
-{
- if ((PHY_CARRIER_NB < nb_of_carriers) || (0 == nb_of_carriers))
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "number of carriers is out-of-range", errno);
- }
-
- mNbOfCarriers = nb_of_carriers;
- return true;
-}
-
-
-const uint8_t * PhyProcessor::getTonemask ( ) const
-{
- if (NULL == mpTonemask)
- {
- throw Error(__PRETTY_FUNCTION__, "tonemask pointer is NULL");
- }
-
- return mpTonemask;
-}
-
-
-bool PhyProcessor::setTonemask ( const unsigned int length, const uint8_t * p_tonemask )
-{
- if (((PHY_CARRIER_NB+7)/8 != length) || (NULL == p_tonemask))
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "tonemask length is incorrect and/or tonemask pointer is NULL", errno);
- }
-
- // If tonemask has already been set, delete it before setting the new one
- if (NULL != mpTonemask)
- {
-#if CONFIG_LOG
- clog << logger(LOG_INFO) << "tonemask already set" << endl;
-#endif /* CONFIG_LOG */
- delete [] mpTonemask;
- mpTonemask = NULL;
- }
-
- // Allocate memory and set tonemask
- mpTonemask = new uint8_t[length];
- return (NULL != memcpy(mpTonemask, p_tonemask, length));
-}
-
-
-Phy_Tx_Id PhyProcessor::getTxId ( ) const
-{
- return mTxId;
-}
-
-
-bool PhyProcessor::incrementTxId ( )
-{
- mTxId++;
-
- return true;
-}
-
-
-PhyMpduCb PhyProcessor::getInterfaceCb ( ) const
-{
- return mInterfaceCb;
-}
-
-
-Network_Clock_Tick PhyProcessor::getZeroCrossDelay ( ) const
-{
- if (0 == mZeroCrossDelay)
- {
- throw Error(__PRETTY_FUNCTION__, "zero cross delay equals 0");
- }
-
- return mZeroCrossDelay;
-}
-
-
-bool PhyProcessor::setZeroCrossDelay ( const Network_Clock_Tick zero_cross_delay )
-{
- if (0 == zero_cross_delay)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "zero cross delay equals 0", errno);
- }
-
- mZeroCrossDelay = zero_cross_delay;
-
- return true;
-}
-
-
-PhySciMsg * PhyProcessor::getZeroCross ( ) const
-{
- if (NULL == mpZeroCross)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message of type ZERO_CROSS pointer is NULL");
- }
-
- return mpZeroCross;
-}
-
-
-bool PhyProcessor::scheduleZeroCross ( )
-{
- // Schedule ZERO_CROSS message
- Network_Clock_Tick tickZeroCross = getNetworkClock()->getCurrentTickValue() + getZeroCrossDelay();
- NetworkClockEvt evtZeroCross ( 0, // station_id
- NETWORK_CLOCK_TYPE_PHY,
- 0, // id = 0 for ZERO_CROSS
- (void *)getZeroCross() );
- return getNetworkClock()->insertEvt(tickZeroCross, evtZeroCross);
-}
-
-
-bool PhyProcessor::sendMpduToDestStations ( PhySciMsgMpdu & mpdu )
-{
- logFunction();
- bool bSendToDest = false;
-
- if (fillMsg(mpdu))
- {
- Expected_Tx tx;
- tx.src_tx_id = mpdu.getTxId();
- tx.src_station_id = mpdu.getSciMsgStationId();
-
- // Build list of destination stations
- DestStationsList listOfDestStations;
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end(); ++it)
- {
- if ((tx.src_tx_id == it->first.src_tx_id)
- && (tx.src_station_id == it->first.src_station_id))
- {
- listOfDestStations.push_back(it->second);
- }
- }
-
- bSendToDest = getSciServer()->sendSciMsgToDestStations(mpdu, listOfDestStations);
- }
- else
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message MPDU cannot be sent because it is not correctly filled in", errno);
- }
-
- return bSendToDest;
-}
-
-
-bool PhyProcessor::sendEmptyNoiseToDestStations ( PhySciMsgNoise & noise )
-{
- logFunction();
- bool bSendEmptyNoise = noise.prepare();
-
- if (fillMsg(noise))
- {
- // Build list of destination stations
- DestStationsList listOfDestStations;
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end(); ++it)
- {
- if ((noise.getTxId() == it->first.src_tx_id)
- && (noise.getSciMsgStationId() == it->first.src_station_id))
- {
- listOfDestStations.push_back(it->second);
- }
- }
-
- bSendEmptyNoise &= getSciServer()->sendSciMsgToDestStations(noise, listOfDestStations);
- }
- else
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "Empty PHY SCI message NOISE cannot be sent because it is not correctly filled in", errno);
- }
-
- return bSendEmptyNoise;
-}
-
-
-bool PhyProcessor::sendMpduAndNoiseToDestStations ( PhySciMsgMpdu & mpdu )
-{
- logFunction();
- bool bSendMpduAndNoise = true;
-
- /**
- * Lots of things to do in this function...
- * Following order has to be respected:
- * 1. Compute PB measurement and NOISE for each destination station.
- * 2. Set PB measurement and send MPDU to each destination station.
- * 3. Send NOISE to each destination station.
- * 4. Update list of destination stations.
- */
-
- map<Sci_Msg_Station_Id, uint32_t *> listOfPbMeasurements;
- map<Sci_Msg_Station_Id, PhySciMsgNoise *> listOfNoises;
-
-
- /* 1. Compute PB measurement and NOISE for each destination station. */
- Expected_Tx tx;
- tx.src_tx_id = mpdu.getTxId();
- tx.src_station_id = mpdu.getSciMsgStationId();
-
- // Duplicate MPDU payload
- bSendMpduAndNoise &= getChannel()->duplicateMpduPayload(mpdu);
-
- // For each destination station
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end(); ++it)
- {
- if ((tx.src_tx_id == it->first.src_tx_id)
- && (tx.src_station_id == it->first.src_station_id))
- {
- // Create empty PB measurement and empty NOISE
- uint32_t * pbMeasurementArray = new uint32_t[MAC_MAX_PB_PER_MPDU];
- PhySciMsgNoise * pNoise = new PhySciMsgNoise(this);
- bSendMpduAndNoise &= pNoise->setTxId(mpdu.getTxId());
- bSendMpduAndNoise &= pNoise->setSciMsgStationId(mpdu.getSciMsgStationId());
-
- // Let the Channel package fill in the PB measurement and the NOISE
- bSendMpduAndNoise &= getChannel()->addPerturbation(pbMeasurementArray,
- *pNoise,
- mListOfRxMpdu[tx].pb_header,
- mpdu,
- mpdu.getSciMsgStationId(), // ID of the transmitting station
- it->second, // ID of the destination station
- getNetworkClock()->getCurrentTickValue());
-
- // Save the PB measurement and the NOISE for the current destination station
- listOfPbMeasurements[it->second] = pbMeasurementArray;
- listOfNoises[it->second] = pNoise;
- }
- }
-
- // Check number of destination stations
- if (listOfPbMeasurements.size() != listOfNoises.size())
- {
- throw Error(__PRETTY_FUNCTION__, "number of elements in PB measurement and NOISE lists are different");
- }
-
-
- /* 2. Set PB measurement and send MPDU to each destination station. */
-
- // Create an empty list of destination station,
- // that will be composed of one element only
- DestStationsList listOfDestStation;
-
- // For each PHY SCI message composing the MPDU
- for (int n = 0; n < mpdu.getNbOfMsgs(); n++)
- {
- // Prepare PHY SCI message before transmission
- bSendMpduAndNoise &= mpdu.prepare(n+1);
-
- // For each destination station
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end(); ++it)
- {
- if ((mpdu.getTxId() == it->first.src_tx_id)
- && (mpdu.getSciMsgStationId() == it->first.src_station_id))
- {
- // Set PB measurement of the current destination station
- bSendMpduAndNoise &= mpdu.setPbMeasurement(listOfPbMeasurements[it->second] + n * PHY_PB_MAX_NB);
-
- if (fillMsg(mpdu))
- {
- // Send the (n+1)th PHY SCI message MPDU to the current destination station
- listOfDestStation.push_back(it->second);
- bSendMpduAndNoise &= getSciServer()->sendSciMsgToDestStations(mpdu, listOfDestStation);
-
- listOfDestStation.clear();
- }
- else
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message MPDU cannot be sent because it is not correctly filled in", errno);
- }
- }
- }
- }
-
-
- /* 3. Send NOISE to each destination station. */
-
- // For each destination station
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end(); ++it)
- {
- if ((mpdu.getTxId() == it->first.src_tx_id)
- && (mpdu.getSciMsgStationId() == it->first.src_station_id))
- {
- // Clear list of PB measurements
- delete [] listOfPbMeasurements[it->second];
- listOfPbMeasurements.erase(it->second);
-
- // Prepare PHY SCI message before transmission
- bSendMpduAndNoise &= (listOfNoises[it->second])->prepare();
-
- // Send NOISE to the current destination station
- if (fillMsg(*(listOfNoises[it->second])))
- {
- listOfDestStation.push_back(it->second);
- bSendMpduAndNoise &= getSciServer()->sendSciMsgToDestStations(*(listOfNoises[it->second]), listOfDestStation);
-
- // Clear list of noises
- delete (listOfNoises[it->second]);
- listOfNoises.erase(it->second);
-
- listOfDestStation.clear();
- }
- else
- {
- errno = EPROTO;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message NOISE cannot be sent because it is not correctly filled in", errno);
- }
- }
- }
-
-
- /* 4. Update list of destination stations. */
-
- if (mpdu.isSent())
- {
- updateListOfRxStations(mpdu);
- }
- else
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message MPDU has not been correctly sent");
- }
-
-
- return bSendMpduAndNoise;
-}
-
-
-void PhyProcessor::updateListOfRxStations ( PhySciMsgMpdu & mpdu )
-{
- logFunction();
-
- for (RxStationsList::iterator it = mListOfRxStations.begin(); it != mListOfRxStations.end();)
- {
- RxStationsList::iterator pos = it;
- ++it;
- if ((mpdu.getTxId() == pos->first.src_tx_id)
- && (mpdu.getSciMsgStationId() == pos->first.src_station_id))
- {
- mListOfRxStations.erase(pos);
- }
- }
-}
-
-
-bool PhyProcessor::isFalseAlarmActivated ( ) const
-{
- return mIsFalseAlarmActivated;
-}
-
-
-PhySciMsgPre * PhyProcessor::getWrongPre ( ) const
-{
- if (NULL == mpWrongPre)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message of type PREAMBLE pointer is NULL");
- }
-
- return mpWrongPre;
-}
-
-
-Network_Clock_Tick PhyProcessor::getAverageDuration ( ) const
-{
- return mAverageDuration;
-}
-
-
-float PhyProcessor::getStdDeviation ( ) const
-{
- return mStdDeviation;
-}
-
-
-Network_Clock_Tick PhyProcessor::calculateNextWrongPreDate ( ) const
-{
- logFunction();
-
- boost::mt19937 engine;
- engine.seed(static_cast<unsigned int>(time(0)));
- boost::normal_distribution<double> norm(getAverageDuration(), getStdDeviation());
- boost::variate_generator<boost::mt19937, boost::normal_distribution<double> > normal(engine, norm);
-
- return static_cast<Network_Clock_Tick>(normal());
-}
-
-
-bool PhyProcessor::scheduleNextWrongPre ( const Network_Clock_Tick tick_wrong_pre ) const
-{
- logFunction();
-
- // Schedule next wrong PREAMBLE message
- NetworkClockEvt evtWrongPre ( 0, // station_id
- NETWORK_CLOCK_TYPE_PHY,
- 0, // id = 0 for PREAMBLE
- (void *)getWrongPre() );
-
- return getNetworkClock()->insertEvt(getNetworkClock()->getCurrentTickValue() + tick_wrong_pre, evtWrongPre);
-}
-
-
-// protected attribute accessor methods
-//
-
diff --git a/cesar/maximus/phy/src/PhyProcessorTest.cpp b/cesar/maximus/phy/src/PhyProcessorTest.cpp
deleted file mode 100644
index 0936ebb7b3..0000000000
--- a/cesar/maximus/phy/src/PhyProcessorTest.cpp
+++ /dev/null
@@ -1,583 +0,0 @@
-
-#include "PhyProcessorTest.h"
-
-#include "PhyProcessor.h"
-#include "CoreEngine.h"
-#include "SystemManager.h"
-#include "PhySciMsg.h"
-#include "PhySciMsgPre.h"
-#include "PhySciMsgFc.h"
-#include "PhySciMsgMpdu.h"
-#include "NetworkClockEvt.h"
-#include "ChannelComputer.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-#include "Error.h"
-
-#include <iostream>
-#include <netinet/in.h> // for 'htons()'
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhyProcessorTest);
-
-bool isCbCalledTest = false;
-
-void interfaceCbTest ( PhySciMsgMpdu & mpdu )
-{
- logTest();
-
- isCbCalledTest = true;
-}
-
-
-void PhyProcessorTest::setUp (void)
-{
- logTest();
-
- mpCoreEngine = new CoreEngine();
- mpPhyProcessor = (PhyProcessor*)mpCoreEngine->getPhy();
- CPPUNIT_ASSERT_MESSAGE ( "PHY processor pointer is NULL", NULL != mpPhyProcessor );
-}
-
-
-void PhyProcessorTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhyProcessor)
- {
- mpPhyProcessor = NULL;
- }
- if (NULL != mpCoreEngine)
- {
- delete (mpCoreEngine);
- mpCoreEngine = NULL;
- }
-}
-
-
-void PhyProcessorTest::initTest (void)
-{
- logTest();
-
- CPPUNIT_ASSERT_MESSAGE ( "init failed", mpPhyProcessor->init(&interfaceCbTest) );
- CPPUNIT_ASSERT_MESSAGE ( "init failed", mpPhyProcessor->init(50) );
-}
-
-
-void PhyProcessorTest::createMsgTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message not correctly created",
- mpPhyProcessor == pPhySciMsg->getPhyProcessor() );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::createMpduTest (void)
-{
- logTest();
-
- unsigned long length = 5;
- unsigned char payload[length];
- memset(payload, 'M', length);
-
- PhySciMsgMpdu * pPhySciMsgMpdu = mpPhyProcessor->createMpdu();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU pointer is NULL", NULL != pPhySciMsgMpdu );
-
- pPhySciMsgMpdu->setMpdu(length, payload);
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU not correctly created",
- (mpPhyProcessor == pPhySciMsgMpdu->getPhyProcessor())
- && (length == pPhySciMsgMpdu->getPayloadLength())
- && (0 == memcmp(payload, pPhySciMsgMpdu->getPayload(), length))
- );
-
- if (NULL != pPhySciMsgMpdu)
- {
- delete (pPhySciMsgMpdu);
- pPhySciMsgMpdu = NULL;
- }
-}
-
-
-void PhyProcessorTest::sendMsgTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- // create the transmitting station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set the destination station
- pPhySciMsg->setSciMsgStationId(stationId);
-
- // set the type
- pPhySciMsg->setSpecializedSciMsgType(PHY_TYPE_ZERO_CROSS);
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message has not been sent", mpPhyProcessor->sendMsgToAllStations(*pPhySciMsg) );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::sendMpduTest (void)
-{
- logTest();
-
- // create MPDU
- PhySciMsgMpdu * pPhySciMsgMpdu = mpPhyProcessor->createMpdu();
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU pointer is NULL", NULL != pPhySciMsgMpdu );
-
- // configure MPDU
- unsigned long length = 5;
- unsigned char payload[length];
- memset(payload, 'M', length);
- pPhySciMsgMpdu->setMpdu(length, payload);
-
- // set modulation
- pPhySciMsgMpdu->setMod(PHY_MOD_ROBO);
-
- // set carrier number and tonemask
- unsigned int carrierNb = PHY_CARRIER_NB;
- uint8_t tonemaskData[sizeof(unsigned int) + ((PHY_CARRIER_NB+7)/8)*sizeof(uint8_t)];
- memcpy(tonemaskData, &carrierNb, sizeof(unsigned int));
- memset(tonemaskData + sizeof(unsigned int), 0xCC, (PHY_CARRIER_NB+7)/8*sizeof(uint8_t));
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
- pPhySciMsg->setSpecializedSciMsgDataLength(sizeof(unsigned int) + ((PHY_CARRIER_NB+7)/8)*sizeof(uint8_t));
- pPhySciMsg->setSpecializedSciMsgData((unsigned char *)tonemaskData);
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message TONEMASK reception error",
- mpPhyProcessor->receiveTonemask(*pPhySciMsg) );
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-
- // set FEC rate
- pPhySciMsgMpdu->setFecrate(PHY_FEC_RATE_1_2);
-
- // set PB number
- pPhySciMsgMpdu->setNbOfPbs(1);
-
- // set Guard Interval
- pPhySciMsgMpdu->setGil(PHY_GIL_417);
-
- // set PB size
- pPhySciMsgMpdu->setPbSize(MAC_PB136_BYTES);
-
- // set FC mode
- pPhySciMsgMpdu->setFcMode(PHY_FC_MODE_HYBRID_1);
-
- // set FC
- uint32_t fc_av[4];
- memset(fc_av, 'A', 4*sizeof(uint32_t));
- uint32_t fc_10 = 10;
- pPhySciMsgMpdu->setFc10(fc_10);
- pPhySciMsgMpdu->setFcAv(fc_av);
-
- // create the transmitting station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set the destination station
- pPhySciMsgMpdu->setSciMsgStationId(stationId);
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU not sent",
- mpPhyProcessor->sendMpdu(pPhySciMsgMpdu) );
-
- if (NULL != pPhySciMsgMpdu)
- {
- delete (pPhySciMsgMpdu);
- pPhySciMsgMpdu = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveEvtTest (void)
-{
- logTest();
-
- PhySciMsgMpdu * pPhySciMsgMpdu = mpPhyProcessor->createMpdu(); // will be deleted by 'receiveEvt'
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU pointer is NULL", NULL != pPhySciMsgMpdu);
-
- unsigned long length = 5;
- unsigned char payload[length];
- memset(payload, 'M', length);
- pPhySciMsgMpdu->setMpdu(length, payload);
-
- pPhySciMsgMpdu->segment();
-
- // create the destination station
- Sci_Msg_Station_Id rxStationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // send an RX message
- PhySciMsg rx(mpPhyProcessor);
- rx.setSciMsgStationId(rxStationId);
- rx.setSpecializedSciMsgDataLength(sizeof(Sci_Msg_Station_Id));
- Sci_Msg_Station_Id txStationId = getpid();
- rx.setSpecializedSciMsgData((unsigned char *)&txStationId);
- CPPUNIT_ASSERT_MESSAGE ( "receiveRx failed", mpPhyProcessor->receiveRx(rx) );
-
- NetworkClockEvt evt(0 /* station_id */, NETWORK_CLOCK_TYPE_PHY, 1 /* id */, (void *)pPhySciMsgMpdu);
-
- CPPUNIT_ASSERT_MESSAGE ( "Event received but not correctly processed",
- mpPhyProcessor->receiveEvt(evt) );
-
- if (NULL != pPhySciMsgMpdu)
- {
- delete (pPhySciMsgMpdu);
- pPhySciMsgMpdu = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveInvalidTest (void)
-{
- logTest();
- bool bTest = false;
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- try
- {
- CPPUNIT_ASSERT_MESSAGE ( "receiveInvalid failed", !mpPhyProcessor->receiveInvalid(*pPhySciMsg) );
- }
- catch (Error & e)
- {
- bTest = true;
- }
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveInvalid failed", bTest);
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::receivePreTest (void)
-{
- logTest();
-
- PhySciMsgPre preamble(mpPhyProcessor);
-
- // create the transmitting station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set station id
- preamble.setSciMsgStationId(stationId);
-
- CPPUNIT_ASSERT_MESSAGE ( "receivePre failed", mpPhyProcessor->receivePre(preamble) );
-}
-
-
-void PhyProcessorTest::receiveFcTest (void)
-{
- logTest();
-
- PhySciMsgFc frameControl(mpPhyProcessor);
-
- // create the transmitting station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set station id
- frameControl.setSciMsgStationId(stationId);
-
- // set PHY SCI message data length and data
- uint32_t fcAv[4];
- memset(fcAv, 'F', 4*sizeof(uint32_t));
- frameControl.setSpecializedSciMsgDataLength(4*sizeof(uint32_t));
- frameControl.setSpecializedSciMsgData((unsigned char *)fcAv);
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveMsg failed", mpPhyProcessor->receiveFc(frameControl) );
-}
-
-
-void PhyProcessorTest::receivePrsTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- // create the transmitting station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set station id
- pPhySciMsg->setSciMsgStationId(stationId);
-
- // set the type
- pPhySciMsg->setSpecializedSciMsgType(PHY_TYPE_PRS);
-
- CPPUNIT_ASSERT_MESSAGE ( "receivePrs failed", mpPhyProcessor->receivePrs(*pPhySciMsg) );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveMpduTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- // create the transmitting station
- Sci_Msg_Station_Id txStationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- Sci_Msg_Station_Id rxStationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set station id
- Sci_Msg_Header sciHdr;
- memset(&sciHdr, '\0', sizeof(struct Sci_Msg_Header));
- sciHdr.station_id = txStationId;
- pPhySciMsg->setSciMsgHeader(sciHdr);
-
- // set type, msg nb and tx id
- Phy_Header phyHdr;
- memset(&phyHdr, '\0', sizeof(struct Phy_Header));
- phyHdr.type = PHY_TYPE_MPDU_PAYLOAD;
- phyHdr.msg_nb = 1;
- phyHdr.tx_id = htons(33);
- pPhySciMsg->setSpecializedSciMsgHeader(phyHdr);
-
- // set PHY SCI message data length and data
- unsigned long dataLength = MAC_PB520_BYTES;
- unsigned char data[dataLength];
- memset(data, 'D', dataLength);
- pPhySciMsg->setSpecializedSciMsgDataLength(dataLength);
- pPhySciMsg->setSpecializedSciMsgData(data);
-
- // set the interface callback function for PHY SCI message MPDU reception
- CPPUNIT_ASSERT_MESSAGE ( "init failed", mpPhyProcessor->init(&interfaceCbTest) );
-
- // send a FC message
- PhySciMsgFc frameControl(mpPhyProcessor);
- frameControl.setSciMsgStationId(txStationId);
- frameControl.setTxId(33);
- uint32_t fcAv[4];
- for (int i=0; i<4; i++)
- {
- fcAv[i] = i;
- }
- frameControl.setSpecializedSciMsgDataLength(4*sizeof(uint32_t));
- frameControl.setSpecializedSciMsgData((unsigned char *)fcAv);
- CPPUNIT_ASSERT_MESSAGE ( "receiveMsg failed", mpPhyProcessor->receiveFc(frameControl) );
-
- // send an RX message
- PhySciMsg rx(mpPhyProcessor);
- rx.setSciMsgStationId(rxStationId);
- rx.setTxId(33);
- rx.setSpecializedSciMsgDataLength(sizeof(Sci_Msg_Station_Id));
- rx.setSpecializedSciMsgData((unsigned char *)&txStationId);
- CPPUNIT_ASSERT_MESSAGE ( "receiveRx failed", mpPhyProcessor->receiveRx(rx) );
-
- // send the MPDU
- CPPUNIT_ASSERT_MESSAGE ( "receiveMpdu failed", mpPhyProcessor->receiveMpdu(*pPhySciMsg)
- && isCbCalledTest );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveTonemaskTest (void)
-{
- logTest();
-
- // set carrier number and tonemask
- unsigned int tonemaskLength = (PHY_CARRIER_NB+7)/8;
- unsigned int carrierNb = PHY_CARRIER_NB-3;
- uint8_t tonemaskData[sizeof(unsigned int) + tonemaskLength];
- memcpy(tonemaskData, &carrierNb, sizeof(unsigned int));
- memset(tonemaskData + sizeof(unsigned int), 0xDD, tonemaskLength);
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg);
- pPhySciMsg->setSpecializedSciMsgDataLength(sizeof(unsigned int) + tonemaskLength);
- pPhySciMsg->setSpecializedSciMsgData((unsigned char *)tonemaskData);
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message TONEMASK reception error",
- mpPhyProcessor->receiveTonemask(*pPhySciMsg));
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveTonemapTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- // create the transmitting station
- Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set station id
- pPhySciMsg->setSciMsgStationId(stationId);
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveTonemap failed", mpPhyProcessor->receiveTonemap(*pPhySciMsg) );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::receiveRxTest (void)
-{
- logTest();
-
- PhySciMsg * pPhySciMsg = mpPhyProcessor->createMsg();
-
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message pointer is NULL", NULL != pPhySciMsg );
-
- // create the transmitting station
- Sci_Msg_Station_Id txStationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // create the destination station
- Sci_Msg_Station_Id rxStationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());
-
- // set the destination station
- pPhySciMsg->setSciMsgStationId(rxStationId);
-
- // set PHY SCI message data length and data
- pPhySciMsg->setSpecializedSciMsgDataLength(sizeof(Sci_Msg_Station_Id));
- pPhySciMsg->setSpecializedSciMsgData((unsigned char *)&txStationId);
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveRx failed", mpPhyProcessor->receiveRx(*pPhySciMsg) );
-
- if (NULL != pPhySciMsg)
- {
- delete (pPhySciMsg);
- pPhySciMsg = NULL;
- }
-}
-
-
-void PhyProcessorTest::setNetworkClockTest (void)
-{
- logTest();
-
- CPPUNIT_ASSERT_MESSAGE ( "setNetworkClock failed",
- mpPhyProcessor->setNetworkClock(mpCoreEngine->getNetworkClock()) );
-}
-
-
-void PhyProcessorTest::setChannelTest (void)
-{
- logTest();
-
- SciServer sci;
- SystemManager system((ISci *)&sci);
- ChannelComputer channel(mpPhyProcessor, (ISystem *)&system);
- CPPUNIT_ASSERT_MESSAGE ( "setChannel failed",
- mpPhyProcessor->setChannel((IChannel *)&channel) );
-}
-
-
-void PhyProcessorTest::setIsChannelEnabledTest (void)
-{
- logTest();
-
- CPPUNIT_ASSERT_MESSAGE ( "setIsChannelEnabled failed",
- mpPhyProcessor->setIsChannelEnabled(true) );
-}
-
-
-void PhyProcessorTest::setFrequencyTest (void)
-{
- logTest();
-
- float freq = 52.5; // in Hz
- CPPUNIT_ASSERT_MESSAGE ( "setFrequency failed",
- mpPhyProcessor->init(50)
- && mpPhyProcessor->setFrequency(freq)
- && (freq == mpPhyProcessor->getFrequency()) );
-}
-
-
-void PhyProcessorTest::activateFalseAlarmTest (void)
-{
- logTest();
-
- Network_Clock_Tick averageDuration = 10;
- float stdDeviation = 0.1;
- CPPUNIT_ASSERT_MESSAGE ( "activateFalseAlarm failed",
- mpPhyProcessor->activateFalseAlarm(averageDuration, stdDeviation) );
- CPPUNIT_ASSERT_MESSAGE ( "activateFalseAlarm failed",
- mpPhyProcessor->activateFalseAlarm(averageDuration, stdDeviation) );
-}
-
-
-void PhyProcessorTest::deactivateFalseAlarmTest (void)
-{
- logTest();
-
- Network_Clock_Tick averageDuration = 10;
- float stdDeviation = 0.1;
- CPPUNIT_ASSERT_MESSAGE ( "deactivateFalseAlarm failed", mpPhyProcessor->deactivateFalseAlarm() );
- CPPUNIT_ASSERT_MESSAGE ( "activateFalseAlarm failed",
- mpPhyProcessor->activateFalseAlarm(averageDuration, stdDeviation) );
- CPPUNIT_ASSERT_MESSAGE ( "deactivateFalseAlarm failed", mpPhyProcessor->deactivateFalseAlarm() );
-}
-
diff --git a/cesar/maximus/phy/src/PhySciMsg.cpp b/cesar/maximus/phy/src/PhySciMsg.cpp
deleted file mode 100644
index 0b8bae74b1..0000000000
--- a/cesar/maximus/phy/src/PhySciMsg.cpp
+++ /dev/null
@@ -1,956 +0,0 @@
-/************************************************************************
- PhySciMsg.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/PhySciMsg.cpp
-**************************************************************************/
-
-#include "PhySciMsg.h"
-#include "IPhy.h"
-
-#include "Error.h"
-#include "Logger.h"
-
-#include "mac/common/tonemap.h" // for 'TONEMAP_INDEX_NB'
-
-#include <iomanip> // for 'setfill()' and 'setw()'
-#include <netinet/in.h> // for 'ntohl()' and 'ntohs()'
-#include <iostream> // for 'cout', 'cerr' and 'clog'
-#include <sstream> // for 'ostringstream'
-#include <string> // for 'memset()' and 'memcpy()'
-#include <boost/function.hpp> // for 'ReceiveFunction'
-using namespace std;
-
-typedef boost::function <bool (IPhy *, PhySciMsg &)> ReceiveFunction;
-ReceiveFunction receiveFunction[PHY_TYPE_NB] = { &IPhy::receiveInvalid, // NONE
- &IPhy::receivePre, // PREAMBLE
- &IPhy::receiveFc, // FC_HYBRID_MODE
- &IPhy::receiveFc, // FC_AV_ONLY_MODE
- &IPhy::receivePrs, // PRS
- &IPhy::receiveMpdu, // MPDU_PAYLOAD
- &IPhy::receiveTonemask, // TONEMASK
- &IPhy::receiveTonemap, // TONEMAP
- &IPhy::receiveInvalid, // NOISE
- &IPhy::receiveRx, // RX
- &IPhy::receiveInvalid }; // ZERO_CROSS
-
-
-// Constructors/Destructors
-//
-
-
-PhySciMsg::PhySciMsg ( IPhy * p_phy_processor ):
-mSpecializedSciMsgType(PHY_TYPE_NONE),
-mMpduFormat(PHY_MPDU_FORMAT_NONE),
-mNbOfPbs(0),
-mNbOfMsgs(1),
-mFcMode(PHY_FC_MODE_NONE),
-mShortPpdu(false),
-mMod(PHY_MOD_NONE),
-mFecrate(PHY_FEC_RATE_NONE),
-mGil(PHY_GIL_NONE),
-mTonemapIndex(0),
-mTxId(0),
-mFlags(PHY_FLAG_NONE),
-mIsEncrypted(false),
-mIsCrcOk(false),
-mPbSize(0),
-mReserved(0),
-mNbOfSymbols(0),
-mpPhyProcessor(NULL),
-mIsSent(false)
-{
- logFunction();
-
- if (NULL != p_phy_processor)
- {
- mpPhyProcessor = p_phy_processor;
- }
- else
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY processor pointer is NULL", errno);
- }
-
- initAttributes ();
-}
-
-
-void PhySciMsg::initAttributes ( )
-{
- logFunction();
-
- memset(mIvArray, '\0', 3*sizeof(uint32_t));
- memset(mNekArray, '\0', 4*sizeof(uint32_t));
- memset(mPbMeasurementArray, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
- memset(mPbHeaderArray, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
-
- mSpecializedSciMsgHeader.version = PHY_VERSION;
- mSpecializedSciMsgHeader.type = PHY_TYPE_NONE;
- mSpecializedSciMsgHeader.mpdu_format = PHY_MPDU_FORMAT_NONE;
- mSpecializedSciMsgHeader.pb_nb = 0x00;
- mSpecializedSciMsgHeader.msg_nb = 0x01;
- mSpecializedSciMsgHeader.fc_mode = PHY_FC_MODE_NONE;
- mSpecializedSciMsgHeader.short_ppdu = 0x00;
- mSpecializedSciMsgHeader.mod = PHY_MOD_NONE;
- mSpecializedSciMsgHeader.fecrate = PHY_FEC_RATE_NONE;
- mSpecializedSciMsgHeader.gil = PHY_GIL_NONE;
- mSpecializedSciMsgHeader.tonemap_index = 0x00;
- mSpecializedSciMsgHeader.reserved = 0x00;
- mSpecializedSciMsgHeader.tx_id = 0x0000;
- mSpecializedSciMsgHeader.flags = PHY_FLAG_NONE;
- mSpecializedSciMsgHeader.symbol_nb = 0x00000000;
- memset(mSpecializedSciMsgHeader.iv, '\0', 3*sizeof(uint32_t));
- memset(mSpecializedSciMsgHeader.nek, '\0', 4*sizeof(uint32_t));
- memset(mSpecializedSciMsgHeader.pb_measurement, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
- memset(mSpecializedSciMsgHeader.pb_header, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
-}
-
-
-PhySciMsg::~PhySciMsg ( )
-{
- logFunction();
-
- if (NULL != mpPhyProcessor)
- {
- mpPhyProcessor = NULL;
- }
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-SciMsg * PhySciMsg::create ( ) const
-{
- logFunction();
-
- return new PhySciMsg (getPhyProcessor());
-}
-
-
-bool PhySciMsg::dispatchMsg ( )
-{
- logFunction();
-
- bool bDispatch = (receiveFunction[getSpecializedSciMsgType()])(getPhyProcessor(), *this);
-
- if (!bDispatch)
- {
- throw Error(__PRETTY_FUNCTION__, "error while receiving PHY SCI message");
- }
-
- return bDispatch;
-}
-
-
-bool PhySciMsg::identifySpecializedSciMsgHeader ( )
-{
- logFunction();
- bool bIdentifyHeader = false;
-
- if (NULL != SciMsg::getSciMsgData())
- {
- // Set specialized SCI msg header size
- //
- SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Phy_Header));
-
- // Get specialized SCI message header contents
- //
- if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
- {
- bIdentifyHeader = setSpecializedSciMsgHeader(*((Phy_Header*)SciMsg::getSciMsgData()));
- }
- else
- {
- errno = ENODATA;
- throw Error(__PRETTY_FUNCTION__, "Not enough data to get the specialized SCI message header", errno);
- }
- }
- else
- {
- throw Error(__PRETTY_FUNCTION__, "SCI message data pointer is NULL");
- }
-
- return bIdentifyHeader;
-}
-
-
-bool PhySciMsg::checkCompatibility ( ) const
-{
- logFunction();
- bool bCheck = false;
-
- if (PHY_VERSION == getSpecializedSciMsgHeader().version)
- {
- bCheck = SciMsg::checkCompatibility();
- }
-
- return bCheck;
-}
-
-
-bool PhySciMsg::checkValidity ( ) const
-{
- logFunction();
- bool bCheck = false;
-
- // Check header values ranges
- //
- if ((PHY_TYPE_NB > getSpecializedSciMsgHeader().type) && (PHY_TYPE_NONE < getSpecializedSciMsgHeader().type)
- && (PHY_MPDU_FORMAT_NB > getSpecializedSciMsgHeader().mpdu_format)
- && (PHY_PB_MAX_NB >= getSpecializedSciMsgHeader().pb_nb)
- && (0 != getSpecializedSciMsgHeader().msg_nb) && (PHY_MSG_MAX_NB_PER_MPDU >= getSpecializedSciMsgHeader().msg_nb)
- && (PHY_FC_MODE_NONE >= getSpecializedSciMsgHeader().fc_mode)
- && ((0 == getSpecializedSciMsgHeader().short_ppdu) || (1 == getSpecializedSciMsgHeader().short_ppdu))
- && (PHY_MOD_NONE >= getSpecializedSciMsgHeader().mod)
- && (PHY_FEC_RATE_NONE >= getSpecializedSciMsgHeader().fecrate)
- && (PHY_GIL_NONE >= getSpecializedSciMsgHeader().gil)
- && (TONEMAP_INDEX_NB > getSpecializedSciMsgHeader().tonemap_index)
- && (PHY_FLAG_MAX >= htons(getSpecializedSciMsgHeader().flags))
- && (MAC_MAX_SYMB_PER_MPDU >= htonl(getSpecializedSciMsgHeader().symbol_nb))
- && (NULL != getSpecializedSciMsgHeader().iv)
- && (NULL != getSpecializedSciMsgHeader().nek)
- && (NULL != getSpecializedSciMsgHeader().pb_measurement)
- && (NULL != getSpecializedSciMsgHeader().pb_header))
- {
- // Check header coherence in case of MPDU payload
- //
- if (PHY_TYPE_MPDU_PAYLOAD == getSpecializedSciMsgHeader().type)
- {
- if (
- (
- ((PHY_MPDU_FORMAT_BEACON == getSpecializedSciMsgHeader().mpdu_format)
- || (PHY_MPDU_FORMAT_SOF == getSpecializedSciMsgHeader().mpdu_format)
- || (PHY_MPDU_FORMAT_SOUND == getSpecializedSciMsgHeader().mpdu_format)
- || (PHY_MPDU_FORMAT_RSOF == getSpecializedSciMsgHeader().mpdu_format))
- && (0 != getSpecializedSciMsgHeader().pb_nb)
- )
- ||
- (
- ((PHY_MPDU_FORMAT_SACK == getSpecializedSciMsgHeader().mpdu_format)
- || (PHY_MPDU_FORMAT_RTS_CTS == getSpecializedSciMsgHeader().mpdu_format))
- && (0 == getSpecializedSciMsgHeader().pb_nb)
- )
- )
- {
- bCheck = SciMsg::checkValidity();
- }
- }
- else
- {
- bCheck = SciMsg::checkValidity();
- }
- }
-
- return bCheck;
-}
-
-
-void PhySciMsg::displaySpecializedSciMsgHeader ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- clog << logger(LOG_INFO) << "PHY SCI msg header = " << endl;
- clog << logger(LOG_INFO) << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().version) << endl;
- displaySpecializedSciMsgType(LOG_INFO);
- clog << logger(LOG_INFO) << "\tmpdu format = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().mpdu_format) << endl;
- clog << logger(LOG_INFO) << "\tpb nb = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader().pb_nb) << endl;
- clog << logger(LOG_INFO) << "\tmsg nb = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader().msg_nb) << endl;
- clog << logger(LOG_INFO) << "\tfc mode = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().fc_mode) << endl;
- clog << logger(LOG_INFO) << "\tshort ppdu = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().short_ppdu) << endl;
- clog << logger(LOG_INFO) << "\tmod = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().mod) << endl;
- clog << logger(LOG_INFO) << "\tfecrate = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().fecrate) << endl;
- clog << logger(LOG_INFO) << "\tgil = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().gil) << endl;
- clog << logger(LOG_INFO) << "\ttonemap index = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader().tonemap_index) << endl;
- clog << logger(LOG_INFO) << "\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << ntohs(getSpecializedSciMsgHeader().reserved) << endl;
- clog << logger(LOG_INFO) << "\ttx id = " << dec << ntohs(getSpecializedSciMsgHeader().tx_id) << endl;
- clog << logger(LOG_INFO) << "\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << ntohs(getSpecializedSciMsgHeader().flags) << endl;
- clog << logger(LOG_INFO) << "\tsymbol nb = " << dec << ntohl(getSpecializedSciMsgHeader().symbol_nb) << endl;
- displayIv();
- displayNek();
- displayPbMeasurement();
- displayPbHeader();
-#endif /* CONFIG_LOG */
-}
-
-
-bool PhySciMsg::prepare ( Network_Clock_Id clock_id )
-{
- logFunction();
-
- return false;
-}
-
-
-void PhySciMsg::displaySpecializedSciMsgType ( int log_level ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- switch (getSpecializedSciMsgHeader().type)
- {
- case 0:
- clog << logger(log_level) << "\ttype = PHY_TYPE_NONE" << endl;
- break;
- case 1:
- clog << logger(log_level) << "\ttype = PHY_TYPE_PREAMBLE" << endl;
- break;
- case 2:
- clog << logger(log_level) << "\ttype = PHY_TYPE_FC_HYBRID_MODE" << endl;
- break;
- case 3:
- clog << logger(log_level) << "\ttype = PHY_TYPE_FC_AV_ONLY_MODE" << endl;
- break;
- case 4:
- clog << logger(log_level) << "\ttype = PHY_TYPE_PRS" << endl;
- break;
- case 5:
- clog << logger(log_level) << "\ttype = PHY_TYPE_MPDU_PAYLOAD" << endl;
- break;
- case 6:
- clog << logger(log_level) << "\ttype = PHY_TYPE_TONEMASK" << endl;
- break;
- case 7:
- clog << logger(log_level) << "\ttype = PHY_TYPE_TONEMAP" << endl;
- break;
- case 8:
- clog << logger(log_level) << "\ttype = PHY_TYPE_NOISE" << endl;
- break;
- case 9:
- clog << logger(log_level) << "\ttype = PHY_TYPE_RX" << endl;
- break;
- case 10:
- clog << logger(log_level) << "\ttype = PHY_TYPE_ZERO_CROSS" << endl;
- break;
- default:
- clog << logger(log_level) << "\ttype = unknown!" << endl;
- break;
- }
-#endif /* CONFIG_LOG */
-}
-
-
-// private methods
-//
-
-
-void PhySciMsg::displayIv ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- ostringstream oss;
- oss << "\tiv = 0x ";
- for (unsigned int i=0; i<3; i++)
- {
- oss << setfill('0') << setw(8) << uppercase << hex << htonl(getSpecializedSciMsgHeader().iv[i]) << " ";
- }
- oss << endl;
- oss.flush();
- clog << logger(LOG_INFO) << oss.str();
-#endif /* CONFIG_LOG */
-}
-
-
-void PhySciMsg::displayNek ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- ostringstream oss;
- oss << "\tnek = 0x ";
- for (unsigned int i=0; i<4; i++)
- {
- oss << setfill('0') << setw(8) << uppercase << hex << htonl(getSpecializedSciMsgHeader().nek[i]) << " ";
- }
- oss << endl;
- oss.flush();
- clog << logger(LOG_INFO) << oss.str();
-#endif /* CONFIG_LOG */
-}
-
-
-void PhySciMsg::displayPbMeasurement ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- ostringstream oss;
- oss << "\tpb_measurement = 0x ";
- for (unsigned int i=0; i<PHY_PB_MAX_NB; i++)
- {
- oss << setfill('0') << setw(8) << uppercase << hex << htonl(getSpecializedSciMsgHeader().pb_measurement[i]) << " ";
- }
- oss << endl;
- oss.flush();
- clog << logger(LOG_INFO) << oss.str();
-#endif /* CONFIG_LOG */
-}
-
-
-void PhySciMsg::displayPbHeader ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- ostringstream oss;
- oss << "\tpb_header = 0x ";
- for (unsigned int i=0; i<PHY_PB_MAX_NB; i++)
- {
- oss << setfill('0') << setw(8) << uppercase << hex << htonl(getSpecializedSciMsgHeader().pb_header[i]) << " ";
- }
- oss << endl;
- oss.flush();
- clog << logger(LOG_INFO) << oss.str();
-#endif /* CONFIG_LOG */
-}
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-void * PhySciMsg::returnSpecializedSciMsgHeader ( ) const
-{
- return (void*)&mSpecializedSciMsgHeader;
-}
-
-
-const Phy_Header & PhySciMsg::getSpecializedSciMsgHeader ( ) const
-{
- return mSpecializedSciMsgHeader;
-}
-
-
-bool PhySciMsg::setSpecializedSciMsgHeader ( const Phy_Header & specialized_sci_msg_header )
-{
- logFunction();
- bool bSetHdr = false;
-
- mSpecializedSciMsgHeader = specialized_sci_msg_header;
-
- // Set specialized SCI msg attributes from specialized SCI msg header
- //
- bSetHdr = setSpecializedSciMsgType (static_cast<Phy_Type>(getSpecializedSciMsgHeader().type));
- bSetHdr &= setMpduFormat (static_cast<Phy_Mpdu_Format>(getSpecializedSciMsgHeader().mpdu_format));
- bSetHdr &= setNbOfPbs (static_cast<Phy_Nb_Of_Pbs>(getSpecializedSciMsgHeader().pb_nb));
- bSetHdr &= setNbOfMsgs (static_cast<unsigned short int>(getSpecializedSciMsgHeader().msg_nb));
- bSetHdr &= setFcMode (static_cast<Phy_Fc_Mode>(getSpecializedSciMsgHeader().fc_mode));
- bSetHdr &= setShortPpdu (static_cast<Phy_Short_Ppdu>(getSpecializedSciMsgHeader().short_ppdu));
- bSetHdr &= setMod (static_cast<Phy_Mod>(getSpecializedSciMsgHeader().mod));
- bSetHdr &= setFecrate (static_cast<Phy_Fecrate>(getSpecializedSciMsgHeader().fecrate));
- bSetHdr &= setGil (static_cast<Phy_Gil>(getSpecializedSciMsgHeader().gil));
- bSetHdr &= setTonemapIndex (static_cast<Phy_Tonemap_Index>(getSpecializedSciMsgHeader().tonemap_index));
- bSetHdr &= setTxId (static_cast<Phy_Tx_Id>(ntohs(getSpecializedSciMsgHeader().tx_id)));
- bSetHdr &= setFlags (static_cast<Phy_Flags>(ntohs(getSpecializedSciMsgHeader().flags)));
- bSetHdr &= setIsEncrypted (PHY_FLAG_ENCRYPTED == (getFlags() & PHY_FLAG_ENCRYPTED));
- bSetHdr &= setIsCrcOk (PHY_FLAG_CRC_OK == (getFlags() & PHY_FLAG_CRC_OK));
- bSetHdr &= setPbSize ((PHY_FLAG_PB512 == (getFlags() & PHY_FLAG_PB512)) ? 512 : 128);
- bSetHdr &= setReserved ((ntohs(getSpecializedSciMsgHeader().reserved)));
- bSetHdr &= setNbOfSymbols (static_cast<Phy_Nb_Of_Symbols>(ntohl(getSpecializedSciMsgHeader().symbol_nb)));
- uint32_t iv[3];
- for (unsigned int i=0; i<3; i++)
- {
- iv[i] = ntohl(getSpecializedSciMsgHeader().iv[i]);
- }
- bSetHdr &= setIv (iv);
- uint32_t nek[4];
- for (unsigned int i=0; i<4; i++)
- {
- nek[i] = ntohl(getSpecializedSciMsgHeader().nek[i]);
- }
- bSetHdr &= setNek (nek);
- uint32_t pbMeasurement[PHY_PB_MAX_NB];
- uint32_t pbHeader[PHY_PB_MAX_NB];
- for (unsigned int i=0; i<PHY_PB_MAX_NB; i++)
- {
- pbMeasurement[i] = ntohl(getSpecializedSciMsgHeader().pb_measurement[i]);
- pbHeader[i] = ntohl(getSpecializedSciMsgHeader().pb_header[i]);
- }
- bSetHdr &= setPbMeasurement (pbMeasurement);
- bSetHdr &= setPbHeader (pbHeader);
-
- displaySpecializedSciMsgHeader();
-
- return bSetHdr;
-}
-
-
-IPhy * PhySciMsg::getPhyProcessor ( ) const
-{
- if (NULL == mpPhyProcessor)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY processor pointer is NULL");
- }
-
- return mpPhyProcessor;
-}
-
-
-Phy_Type PhySciMsg::getSpecializedSciMsgType ( ) const
-{
- return mSpecializedSciMsgType;
-}
-
-
-bool PhySciMsg::setSpecializedSciMsgType ( const Phy_Type type )
-{
- bool bSetType = false;
-
- if ((PHY_TYPE_NB <= type) || (PHY_TYPE_NONE >= type))
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header type is out-of-range", errno);
- }
- else
- {
- mSpecializedSciMsgType = type;
- bSetType = true;
- }
-
- return bSetType;
-}
-
-
-Phy_Mpdu_Format PhySciMsg::getMpduFormat ( ) const
-{
- return mMpduFormat;
-}
-
-
-bool PhySciMsg::setMpduFormat ( const Phy_Mpdu_Format mpdu_format )
-{
- bool bSetMpduFormat = false;
-
- if (PHY_MPDU_FORMAT_NB <= mpdu_format)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header MPDU format is out-of-range", errno);
- }
- else
- {
- mMpduFormat = mpdu_format;
- bSetMpduFormat = true;
- }
-
- return bSetMpduFormat;
-}
-
-
-Phy_Nb_Of_Pbs PhySciMsg::getNbOfPbs ( ) const
-{
- return mNbOfPbs;
-}
-
-
-bool PhySciMsg::setNbOfPbs ( const Phy_Nb_Of_Pbs nb_of_pbs )
-{
- bool bSetPbNb = false;
-
- if (PHY_PB_MAX_NB < nb_of_pbs)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header PB number is out-of-range", errno);
- }
- else
- {
- mNbOfPbs = nb_of_pbs;
-
- bSetPbNb = true;
- }
-
- return bSetPbNb;
-}
-
-
-unsigned short int PhySciMsg::getNbOfMsgs ( ) const
-{
- if ((0 == mNbOfMsgs) || (PHY_MSG_MAX_NB_PER_MPDU < mNbOfMsgs))
- {
- throw Error(__PRETTY_FUNCTION__, "Number of PHY SCI messages is out-of-range");
- }
-
- return mNbOfMsgs;
-}
-
-
-bool PhySciMsg::setNbOfMsgs ( const unsigned short int nb_of_msgs )
-{
- if ( (0 == nb_of_msgs) || (PHY_MSG_MAX_NB_PER_MPDU < nb_of_msgs))
- {
- throw Error(__PRETTY_FUNCTION__, "Number of PHY SCI messages is out-of-range");
- }
-
- mNbOfMsgs = nb_of_msgs;
- return true;
-}
-
-
-Phy_Fc_Mode PhySciMsg::getFcMode ( ) const
-{
- return mFcMode;
-}
-
-
-bool PhySciMsg::setFcMode ( const Phy_Fc_Mode fc_mode )
-{
- bool bSetFcMode = false;
-
- if (PHY_FC_MODE_NONE < fc_mode)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header FC mode is out-of-range", errno);
- }
- else
- {
- mFcMode = fc_mode;
- bSetFcMode = true;
- }
-
- return bSetFcMode;
-}
-
-
-Phy_Short_Ppdu PhySciMsg::getShortPpdu ( ) const
-{
- return mShortPpdu;
-}
-
-
-bool PhySciMsg::setShortPpdu ( const Phy_Short_Ppdu short_ppdu )
-{
- mShortPpdu = short_ppdu;
-
- return true;
-}
-
-
-Phy_Mod PhySciMsg::getMod ( ) const
-{
- return mMod;
-}
-
-
-bool PhySciMsg::setMod ( const Phy_Mod mod )
-{
- bool bSetMod = false;
-
- if (PHY_MOD_NONE < mod)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header modulation is out-of-range", errno);
- }
- else
- {
- mMod = mod;
- bSetMod = true;
- }
-
- return bSetMod;
-}
-
-
-Phy_Fecrate PhySciMsg::getFecrate ( ) const
-{
- return mFecrate;
-}
-
-
-bool PhySciMsg::setFecrate ( const Phy_Fecrate fecrate )
-{
- bool bSetFecrate = false;
-
- if (PHY_FEC_RATE_NONE < fecrate)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header FEC rate is out-of-range", errno);
- }
- else
- {
- mFecrate = fecrate;
- bSetFecrate = true;
- }
-
- return bSetFecrate;
-}
-
-
-Phy_Gil PhySciMsg::getGil ( ) const
-{
- return mGil;
-}
-
-
-bool PhySciMsg::setGil ( const Phy_Gil gil )
-{
- bool bSetGil = false;
-
- if (PHY_GIL_NONE < gil)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header Guard Interval is out-of-range", errno);
- }
- else
- {
- mGil = gil;
- bSetGil = true;
- }
-
- return bSetGil;
-}
-
-
-Phy_Tonemap_Index PhySciMsg::getTonemapIndex ( ) const
-{
- return mTonemapIndex;
-}
-
-
-bool PhySciMsg::setTonemapIndex ( const Phy_Tonemap_Index tonemap_index )
-{
- bool bSetTonemapIndex = false;
-
- if (TONEMAP_INDEX_NB <= tonemap_index)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header tonemap index is out-of-range", errno);
- }
- else
- {
- mTonemapIndex = tonemap_index;
- bSetTonemapIndex = true;
- }
-
- return bSetTonemapIndex;
-}
-
-
-Phy_Tx_Id PhySciMsg::getTxId ( ) const
-{
- return mTxId;
-}
-
-
-bool PhySciMsg::setTxId ( const Phy_Tx_Id tx_id )
-{
- mTxId = tx_id;
-
- return true;
-}
-
-
-Phy_Flags PhySciMsg::getFlags ( ) const
-{
- return mFlags;
-}
-
-
-bool PhySciMsg::setFlags ( const Phy_Flags flags )
-{
- bool bSetFlags = false;
-
- if (PHY_FLAG_MAX < flags)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header flags is out-of-range", errno);
- }
- else
- {
- mFlags = flags;
- bSetFlags = true;
- }
-
- return bSetFlags;
-}
-
-
-bool PhySciMsg::isEncrypted ( ) const
-{
- return mIsEncrypted;
-}
-
-
-bool PhySciMsg::setIsEncrypted ( const bool is_encrypted )
-{
- mIsEncrypted = is_encrypted;
-
- return true;
-}
-
-
-bool PhySciMsg::isCrcOk ( ) const
-{
- return mIsCrcOk;
-}
-
-
-bool PhySciMsg::setIsCrcOk ( const bool is_crc_ok )
-{
- mIsCrcOk = is_crc_ok;
-
- return true;
-}
-
-
-unsigned short int PhySciMsg::getPbSize ( ) const
-{
- return mPbSize;
-}
-
-
-bool PhySciMsg::setPbSize ( const unsigned short int pb_size )
-{
- bool bSetPbSize = false;
-
- if ( (MAC_PB136_BYTES != pb_size) && (MAC_PB520_BYTES != pb_size) )
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PB size is out-of-range", errno);
- }
- else
- {
- mPbSize = pb_size;
- bSetPbSize = true;
- }
-
- return bSetPbSize;
-}
-
-Phy_Nb_Of_Symbols PhySciMsg::getNbOfSymbols ( ) const
-{
- return mNbOfSymbols;
-}
-
-
-bool PhySciMsg::setNbOfSymbols ( const Phy_Nb_Of_Symbols nb_of_symbols )
-{
- bool bSetSymbolNb = false;
-
- if (MAC_MAX_SYMB_PER_MPDU < nb_of_symbols)
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message header symbol number is out-of-range", errno);
- }
- else
- {
- mNbOfSymbols = nb_of_symbols;
- bSetSymbolNb = true;
- }
-
- return bSetSymbolNb;
-}
-
-
-const uint32_t * PhySciMsg::getIv ( ) const
-{
- return mIvArray;
-}
-
-
-bool PhySciMsg::setIv ( const uint32_t iv[3] )
-{
- return (NULL != memcpy(mIvArray, iv, 3*sizeof(uint32_t)));
-}
-
-
-const uint32_t * PhySciMsg::getNek ( ) const
-{
- return mNekArray;
-}
-
-
-bool PhySciMsg::setNek ( const uint32_t nek[4] )
-{
- return (NULL != memcpy(mNekArray, nek, 4*sizeof(uint32_t)));
-}
-
-
-const uint32_t * PhySciMsg::getPbMeasurement ( ) const
-{
- return mPbMeasurementArray;
-}
-
-
-bool PhySciMsg::setPbMeasurement ( const uint32_t pb_measurement[PHY_PB_MAX_NB] )
-{
- return (NULL != memcpy(mPbMeasurementArray, pb_measurement, PHY_PB_MAX_NB*sizeof(uint32_t)));
-}
-
-
-const uint32_t * PhySciMsg::getPbHeader ( ) const
-{
- return mPbHeaderArray;
-}
-
-
-bool PhySciMsg::setPbHeader ( const uint32_t pb_header[PHY_PB_MAX_NB] )
-{
- return (NULL != memcpy(mPbHeaderArray, pb_header, PHY_PB_MAX_NB*sizeof(uint32_t)));
-}
-
-
-bool PhySciMsg::isSent ( ) const
-{
- return mIsSent;
-}
-
-
-bool PhySciMsg::setIsSent ( const bool is_sent )
-{
- logFunction();
-
- mIsSent = is_sent;
- return true;
-}
-
-
-// protected attribute accessor methods
-//
-
diff --git a/cesar/maximus/phy/src/PhySciMsgFc.cpp b/cesar/maximus/phy/src/PhySciMsgFc.cpp
deleted file mode 100644
index 6210fabea3..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgFc.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/************************************************************************
- 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
-//
-
-
-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
-//
-
diff --git a/cesar/maximus/phy/src/PhySciMsgFcTest.cpp b/cesar/maximus/phy/src/PhySciMsgFcTest.cpp
deleted file mode 100644
index f0bd22fe8f..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgFcTest.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-
-#include "PhySciMsgFcTest.h"
-
-#include "PhySciMsgFc.h"
-#include "PhyProcessor.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhySciMsgFcTest);
-
-
-void PhySciMsgFcTest::setUp (void)
-{
- logTest();
-
- mpSci = new SciServer();
- mpPhy = new PhyProcessor(mpSci);
- mpPhySciMsgFc = new PhySciMsgFc(mpPhy);
- uint32_t fcAv[4];
- memset(fcAv, '\0', 4*sizeof(uint32_t));
- CPPUNIT_ASSERT_MESSAGE ( "creation failed",
- (mpPhy == mpPhySciMsgFc->getPhyProcessor())
- && (PHY_TYPE_FC_AV_ONLY_MODE == mpPhySciMsgFc->getSpecializedSciMsgType())
- && (0 == mpPhySciMsgFc->getFc10())
- && (0 == memcmp(fcAv, mpPhySciMsgFc->getFcAv(), 4*sizeof(uint32_t))) );
-}
-
-
-void PhySciMsgFcTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgFc)
- {
- delete (mpPhySciMsgFc);
- mpPhySciMsgFc = NULL;
- }
- if (NULL != mpPhy)
- {
- delete (mpPhy);
- mpPhy = NULL;
- }
- if (NULL != mpSci)
- {
- delete (mpSci);
- mpSci = NULL;
- }
-}
-
-
-void PhySciMsgFcTest::prepareTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgFc)
- {
- const uint32_t fc10 = 123;
- uint32_t fcAv[4];
- memset(fcAv, '1', 4*sizeof(uint32_t));
- mpPhySciMsgFc->setFcAv(fcAv);
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgFc->prepare(0 /* clock_id */ ))
- && (0 == mpPhySciMsgFc->getTxId())
- && (getpid() == mpPhySciMsgFc->getSciMsgStationId())
- && (4*sizeof(uint32_t) == mpPhySciMsgFc->getSpecializedSciMsgDataLength())
- && (0 == memcmp((unsigned char *)fcAv, mpPhySciMsgFc->getSpecializedSciMsgData(), 4*sizeof(uint32_t)))
- && (!mpPhySciMsgFc->isSent()) );
-
- mpPhySciMsgFc->setFc10(fc10);
- mpPhySciMsgFc->setShortPpdu(true);
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgFc->prepare(0 /* clock_id */ ))
- && (0 == mpPhySciMsgFc->getTxId())
- && (getpid() == mpPhySciMsgFc->getSciMsgStationId())
- && (5*sizeof(uint32_t) == mpPhySciMsgFc->getSpecializedSciMsgDataLength())
- && (0 == memcmp((unsigned char *)&fc10, mpPhySciMsgFc->getSpecializedSciMsgData(), sizeof(uint32_t)))
- && (0 == memcmp((unsigned char *)fcAv, mpPhySciMsgFc->getSpecializedSciMsgData()+sizeof(uint32_t), 4*sizeof(uint32_t)))
- && (mpPhySciMsgFc->isSent()) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message FC pointer is NULL");
- }
-}
-
-
-void PhySciMsgFcTest::fc10Test (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgFc)
- {
- const uint32_t fc10 = 789;
- CPPUNIT_ASSERT_MESSAGE ( "fc10 failed",
- (mpPhySciMsgFc->setFc10(fc10))
- && (fc10 == mpPhySciMsgFc->getFc10())
- && (PHY_TYPE_FC_HYBRID_MODE == mpPhySciMsgFc->getSpecializedSciMsgType()) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message FC pointer is NULL");
- }
-}
-
-
-void PhySciMsgFcTest::fcAvTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgFc)
- {
- uint32_t fcAv[4];
- memset(fcAv, '2', 4*sizeof(uint32_t));
- CPPUNIT_ASSERT_MESSAGE ( "fcAv failed",
- (mpPhySciMsgFc->setFcAv(fcAv))
- && (0 == memcmp((unsigned char *)fcAv, mpPhySciMsgFc->getFcAv(), 4*sizeof(uint32_t))) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message FC pointer is NULL");
- }
-}
-
diff --git a/cesar/maximus/phy/src/PhySciMsgMpdu.cpp b/cesar/maximus/phy/src/PhySciMsgMpdu.cpp
deleted file mode 100644
index c8a57d17ff..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgMpdu.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-/************************************************************************
- PhySciMsgMpdu.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/PhySciMsgMpdu.cpp
-**************************************************************************/
-
-#include "PhySciMsgMpdu.h"
-#include "PhySciMsgPre.h"
-#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
-//
-
-
-PhySciMsgMpdu::PhySciMsgMpdu ( IPhy * p_phy_processor ) : PhySciMsg ( p_phy_processor ),
-mPayloadLength(0),
-mpPayload(NULL),
-mpPre(NULL),
-mpFc(NULL),
-mNbOfPbsInLastMsg(0)
-{
- logFunction();
-
- initAttributes(p_phy_processor);
-}
-
-
-PhySciMsgMpdu::PhySciMsgMpdu ( PhySciMsg & phy_sci_msg ) : PhySciMsg ( phy_sci_msg.getPhyProcessor() ),
-mPayloadLength(0),
-mpPayload(NULL),
-mpPre(NULL),
-mpFc(NULL),
-mNbOfPbsInLastMsg(0)
-{
- logFunction();
-
- // Initialize PHY SCI message MPDU attributes
- initAttributes(phy_sci_msg.getPhyProcessor());
-
- // Copy SCI message attributes
- SciMsg::setSciMsgHeader(*phy_sci_msg.getSciMsgHeader());
-
- // Copy PHY SCI message attributes
- PhySciMsg::setSpecializedSciMsgHeader(phy_sci_msg.getSpecializedSciMsgHeader());
- PhySciMsg::setSpecializedSciMsgDataLength(phy_sci_msg.getSpecializedSciMsgDataLength());
- PhySciMsg::setSpecializedSciMsgData(phy_sci_msg.getSpecializedSciMsgData());
-
- // Copy PHY SCI message MPDU attributes
- setMpdu(PhySciMsg::getSpecializedSciMsgDataLength(), PhySciMsg::getSpecializedSciMsgData());
-}
-
-
-void PhySciMsgMpdu::initAttributes ( IPhy * p_phy_processor )
-{
- logFunction();
-
- // Create PREAMBLE message
- mpPre = new PhySciMsgPre(p_phy_processor);
- if (NULL == mpPre)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message PREAMBLE pointer is NULL");
- }
-
- // Create FC message
- mpFc = new PhySciMsgFc(p_phy_processor);
- if (NULL == mpFc)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message FC pointer is NULL");
- }
-
- memset(mPbsArray, '\0', MAC_MAX_PB_PER_MPDU*MAC_PB520_BYTES);
- memset(mPbsHeadersArray, '\0', MAC_MAX_PB_PER_MPDU * sizeof(uint32_t));
-
- // Set PHY SCI message type
- PhySciMsg::setSpecializedSciMsgType(PHY_TYPE_MPDU_PAYLOAD);
-}
-
-
-PhySciMsgMpdu::~PhySciMsgMpdu ( )
-{
- logFunction();
-
- if (NULL != mpPayload)
- {
- delete [] mpPayload;
- mpPayload = NULL;
- }
- if (NULL != mpPre)
- {
- delete (mpPre);
- mpPre = NULL;
- }
- if (NULL != mpFc)
- {
- delete (mpFc);
- mpFc = NULL;
- }
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-bool PhySciMsgMpdu::segment ( )
-{
- logFunction();
- bool bSegment = false;
-
- if ( MAC_PB136_BYTES < getPayloadLength() ) // MPDU is composed of 512-octet PBs
- {
- // Set PB size
- bSegment = PhySciMsg::setPbSize(MAC_PB520_BYTES);
-
- /* Calculate total number of PBs. */
-
- unsigned short int totalNbOfPbs = getPayloadLength() / PhySciMsg::getPbSize();
- if ( 0 != getPayloadLength() % PhySciMsg::getPbSize() )
- {
- totalNbOfPbs++;
- }
- if (MAC_MAX_PB_PER_MPDU < totalNbOfPbs)
- {
- throw Error(__PRETTY_FUNCTION__, "Total number of PBs exceeds maximum number of PBs per MPDU");
- }
-
- /* Calculate number of PHY SCI messages needed to transmit all PBs,
- * and number of PBs to transmit in each PHY SCI message. */
-
- unsigned short int nbOfMsgs = 1;
- unsigned short int nbOfPbs = totalNbOfPbs;
- unsigned short int nbOfPbsInLastMsg = totalNbOfPbs;
-
- if ( PHY_PB_MAX_NB < totalNbOfPbs ) // MPDU is composed of several PHY SCI messages
- {
- nbOfMsgs = totalNbOfPbs / PHY_PB_MAX_NB;
- nbOfPbs = PHY_PB_MAX_NB;
- nbOfPbsInLastMsg = totalNbOfPbs % PHY_PB_MAX_NB;
- if ( 0 != nbOfPbsInLastMsg )
- {
- nbOfMsgs++;
- }
- else
- {
- nbOfPbsInLastMsg = nbOfPbs;
- }
- }
-
- // Set number of PHY SCI messages
- bSegment &= PhySciMsg::setNbOfMsgs(nbOfMsgs);
-
- // Set number of PBs
- bSegment &= PhySciMsg::setNbOfPbs(nbOfPbs);
-
- // Set number of PBs into the last PHY SCI message
- bSegment &= setNbOfPbsInLastMsg(nbOfPbsInLastMsg);
-
- // Reset PBs array
- memset(mPbsArray, '\0', MAC_MAX_PB_PER_MPDU*MAC_PB520_BYTES);
-
- // Set PBs array
- for (int i = 0; i < nbOfMsgs-1; i++)
- {
- memcpy(&mPbsArray[i*PHY_PB_MAX_NB*MAC_PB520_BYTES], getPayload()+i*PHY_PB_MAX_NB*MAC_PB520_BYTES, PHY_PB_MAX_NB*MAC_PB520_BYTES);
- }
- memcpy(&mPbsArray[(nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES], getPayload()+(nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES, getPayloadLength()-((nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES));
- }
-
- else // MPDU is composed of one 128-octet PB
- {
- // Set PB size
- bSegment = PhySciMsg::setPbSize(MAC_PB136_BYTES);
-
- // Set number of PHY SCI messages
- bSegment &= PhySciMsg::setNbOfMsgs(1);
-
- // Set number of PBs
- bSegment &= PhySciMsg::setNbOfPbs(1);
-
- // Set number of PBs into the last PHY SCI message
- bSegment &= setNbOfPbsInLastMsg(1);
-
- // Set PBs array
- memcpy(mPbsArray, getPayload(), getPayloadLength());
- }
-
- return bSegment;
-}
-
-
-bool PhySciMsgMpdu::prepare ( Network_Clock_Id clock_id )
-{
- logFunction();
- bool bPrepare = false;
-
- if ((0 == clock_id) || (PhySciMsg::getNbOfMsgs() < clock_id))
- {
- throw Error(__PRETTY_FUNCTION__, "Network Clock ID is out-of-range");
- }
- else if (PhySciMsg::getNbOfMsgs() == clock_id) // This is the last PHY SCI message composing the MPDU
- {
- // Set number of PBs
- bPrepare = PhySciMsg::setNbOfPbs(getNbOfPbsInLastMsg());
-
- // Indicate that MPDU transmission is finished
- bPrepare &= PhySciMsg::setIsSent(true);
- }
-
- /* For a PHY message of type MPDU_PAYLOAD,
- * PHY SCI message data only contain MPDU payload
- * ('nb_of_pbs' PBs of 128 or 512 octets depending on PHY_FLAG_PB512). */
-
- // Set length of PHY SCI message data = PB number * PB size
- bPrepare = SciMsg::setSpecializedSciMsgDataLength(PhySciMsg::getNbOfPbs()*PhySciMsg::getPbSize());
-
- // Set PHY SCI message data
- bPrepare &= SciMsg::setSpecializedSciMsgData(getPbs(clock_id-1));
-
- return bPrepare;
-}
-
-
-// private methods
-//
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-unsigned long PhySciMsgMpdu::getPayloadLength ( ) const
-{
- return mPayloadLength;
-}
-
-
-const unsigned char * PhySciMsgMpdu::getPayload ( ) const
-{
- if (NULL == mpPayload)
- {
- throw Error(__PRETTY_FUNCTION__, "MPDU payload pointer is NULL");
- }
-
- return mpPayload;
-}
-
-
-bool PhySciMsgMpdu::setMpdu ( const unsigned long length, const unsigned char * p_payload )
-{
- logFunction();
- bool bSetMpdu = false;
-
- /* If MPDU payload has already been set,
- * delete the previous MPDU payload. */
-
- if (NULL != mpPayload)
- {
- delete [] mpPayload;
- mpPayload = NULL;
- }
-
- if ((0 != length) && (NULL != p_payload))
- {
- // Set MPDU payload length
- mPayloadLength = length;
-
- // Allocate and set MPDU payload
- mpPayload = new unsigned char [length];
- bSetMpdu = (NULL != memcpy(mpPayload, p_payload, length));
- }
- else
- {
- mPayloadLength = 0;
- mpPayload = NULL;
- }
-
- return bSetMpdu;
-}
-
-
-PhySciMsgPre * PhySciMsgMpdu::getPre ( ) const
-{
- if (NULL == mpPre)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message PREAMBLE pointer is NULL");
- }
-
- return mpPre;
-}
-
-
-PhySciMsgFc * PhySciMsgMpdu::getFc ( ) const
-{
- if (NULL == mpFc)
- {
- throw Error(__PRETTY_FUNCTION__, "PHY SCI message FC pointer is NULL");
- }
-
- return mpFc;
-}
-
-
-unsigned short int PhySciMsgMpdu::getNbOfPbsInLastMsg ( ) const
-{
- if ((0 == mNbOfPbsInLastMsg) || (PHY_PB_MAX_NB < mNbOfPbsInLastMsg))
- {
- throw Error(__PRETTY_FUNCTION__, "Number of PBs into the last PHY SCI message is out-of-range");
- }
-
- return mNbOfPbsInLastMsg;
-}
-
-
-bool PhySciMsgMpdu::setNbOfPbsInLastMsg ( const unsigned short int nb_of_pbs_in_last_msg )
-{
- if ( (0 == nb_of_pbs_in_last_msg) || (PHY_PB_MAX_NB < nb_of_pbs_in_last_msg))
- {
- throw Error(__PRETTY_FUNCTION__, "Number of PBs into the last PHY SCI message is out-of-range");
- }
-
- mNbOfPbsInLastMsg = nb_of_pbs_in_last_msg;
- return true;
-}
-
-
-const unsigned char * PhySciMsgMpdu::getPbs ( const unsigned short int n ) const
-{
- if (PHY_MSG_MAX_NB_PER_MPDU <= n)
- {
- throw Error(__PRETTY_FUNCTION__, "PBs array index exceeds PBs array size");
- }
-
- return &mPbsArray[n*PHY_PB_MAX_NB*MAC_PB520_BYTES];
-}
-
-
-bool PhySciMsgMpdu::isSent ( ) const
-{
- return (PhySciMsg::isSent() || getFc()->isSent());
-}
-
-
-bool PhySciMsgMpdu::isReceived ( const unsigned short int nb_of_received_msgs ) const
-{
- return (nb_of_received_msgs == PhySciMsg::getNbOfMsgs());
-}
-
-
-bool PhySciMsgMpdu::setFcMode ( const Phy_Fc_Mode fc_mode )
-{
- bool bSetFcMode = false;
-
- bSetFcMode = getPre()->setFcMode(fc_mode);
- bSetFcMode &= getFc()->setFcMode(fc_mode);
- bSetFcMode &= PhySciMsg::setFcMode(fc_mode);
-
- return bSetFcMode;
-}
-
-
-bool PhySciMsgMpdu::setShortPpdu ( const Phy_Short_Ppdu short_ppdu )
-{
- bool bSetShort;
-
- bSetShort = getPre()->setShortPpdu(short_ppdu);
- bSetShort &= getFc()->setShortPpdu(short_ppdu);
- bSetShort &= PhySciMsg::setShortPpdu(short_ppdu);
-
- return bSetShort;
-}
-
-
-bool PhySciMsgMpdu::setMod ( const Phy_Mod mod )
-{
- bool bSetMod = false;
-
- bSetMod = getPre()->setMod(mod);
- bSetMod &= getFc()->setMod(mod);
- bSetMod &= PhySciMsg::setMod(mod);
-
- return bSetMod;
-}
-
-
-bool PhySciMsgMpdu::setFecrate ( const Phy_Fecrate fecrate )
-{
- bool bSetFecrate = false;
-
- bSetFecrate = getPre()->setFecrate(fecrate);
- bSetFecrate &= getFc()->setFecrate(fecrate);
- bSetFecrate &= PhySciMsg::setFecrate(fecrate);
-
- return bSetFecrate;
-}
-
-
-bool PhySciMsgMpdu::setGil ( const Phy_Gil gil )
-{
- bool bSetGil = false;
-
- bSetGil = getPre()->setGil(gil);
- bSetGil &= getFc()->setGil(gil);
- bSetGil &= PhySciMsg::setGil(gil);
-
- return bSetGil;
-}
-
-
-bool PhySciMsgMpdu::setFlags ( const Phy_Flags flags )
-{
- bool bSetFlags = false;
-
- bSetFlags = getPre()->setFlags(flags);
- bSetFlags &= getFc()->setFlags(flags);
- bSetFlags &= PhySciMsg::setFlags(flags);
-
- return bSetFlags;
-}
-
-
-uint32_t PhySciMsgMpdu::getFc10 ( ) const
-{
- return getFc()->getFc10();
-}
-
-
-bool PhySciMsgMpdu::setFc10 ( const uint32_t fc_10 )
-{
- return getFc()->setFc10(fc_10);
-}
-
-
-const uint32_t * PhySciMsgMpdu::getFcAv ( ) const
-{
- return getFc()->getFcAv();
-}
-
-
-bool PhySciMsgMpdu::setFcAv ( const uint32_t fc_av[4] )
-{
- return getFc()->setFcAv(fc_av);
-}
-
-
-const uint32_t * PhySciMsgMpdu::getPbsHeaders ( const unsigned short int n ) const
-{
- if (PHY_MSG_MAX_NB_PER_MPDU <= n)
- {
- throw Error(__PRETTY_FUNCTION__, "PBs Headers array index exceeds PBs Headers array size");
- }
-
- return &mPbsHeadersArray[n*PHY_PB_MAX_NB];
-}
-
-
-bool PhySciMsgMpdu::setPbsHeaders ( const unsigned short int n, const uint32_t pb_header )
-{
- if (MAC_MAX_PB_PER_MPDU <= n)
- {
- throw Error(__PRETTY_FUNCTION__, "PB number is out-of-range");
- }
- else
- {
- mPbsHeadersArray[n] = pb_header;
- }
-
- return true;
-}
-
-
-// protected attribute accessor methods
-//
-
diff --git a/cesar/maximus/phy/src/PhySciMsgMpduTest.cpp b/cesar/maximus/phy/src/PhySciMsgMpduTest.cpp
deleted file mode 100644
index 534d495d9d..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgMpduTest.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-
-#include "PhySciMsgMpduTest.h"
-
-#include "PhySciMsgMpdu.h"
-#include "PhyProcessor.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhySciMsgMpduTest);
-
-
-void PhySciMsgMpduTest::setUp (void)
-{
- logTest();
-
- mpSci = new SciServer();
- mpPhy = new PhyProcessor(mpSci);
- mpPhySciMsgMpdu = new PhySciMsgMpdu(mpPhy);
- unsigned char pbs[MAC_MAX_PB_PER_MPDU*MAC_PB520_BYTES];
- memset(pbs, '\0', MAC_MAX_PB_PER_MPDU*MAC_PB520_BYTES);
- CPPUNIT_ASSERT_MESSAGE ( "creation failed",
- (mpPhy == mpPhySciMsgMpdu->getPhyProcessor())
- && (0 == mpPhySciMsgMpdu->getPayloadLength())
- && (NULL != mpPhySciMsgMpdu->getPre())
- && (NULL != mpPhySciMsgMpdu->getFc())
- && (0 == memcmp(pbs, mpPhySciMsgMpdu->getPbs(0), MAC_MAX_PB_PER_MPDU*MAC_PB520_BYTES))
- && (PHY_TYPE_MPDU_PAYLOAD == mpPhySciMsgMpdu->getSpecializedSciMsgType()) );
-}
-
-
-void PhySciMsgMpduTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- delete (mpPhySciMsgMpdu);
- mpPhySciMsgMpdu = NULL;
- }
- if (NULL != mpPhy)
- {
- delete (mpPhy);
- mpPhy = NULL;
- }
- if (NULL != mpSci)
- {
- delete (mpSci);
- mpSci = NULL;
- }
-}
-
-
-void PhySciMsgMpduTest::segmentTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- /* Test with one PB of 128 octet. */
-
- unsigned char pb[MAC_PB136_BYTES];
- for (unsigned char i=0; i<MAC_PB136_BYTES; i++)
- {
- pb[i] = i;
- }
- mpPhySciMsgMpdu->setMpdu(MAC_PB136_BYTES, pb);
-
- CPPUNIT_ASSERT_MESSAGE ( "segment failed",
- (mpPhySciMsgMpdu->segment())
- && (MAC_PB136_BYTES == mpPhySciMsgMpdu->getPbSize())
- && (1 == mpPhySciMsgMpdu->getNbOfPbs())
- && (1 == mpPhySciMsgMpdu->getNbOfPbsInLastMsg())
- && (1 == mpPhySciMsgMpdu->getNbOfMsgs())
- && (0 == memcmp(pb, mpPhySciMsgMpdu->getPbs(), MAC_PB136_BYTES)) );
-
- /* Test with n PBs of 512 octets. */
-
- unsigned short int nbOfPbsInLastMsg = 0;
- unsigned short int nbOfMsgs = 0;
- unsigned char c = 'A';
-
- for (int nb=1; nb<100; nb++)
- {
- unsigned short int nbOfPbs;
- if (PHY_PB_MAX_NB < nb)
- {
- nbOfPbs = PHY_PB_MAX_NB;
- }
- else
- {
- nbOfPbs = nb;
- }
- nbOfPbsInLastMsg = nb % PHY_PB_MAX_NB;
- nbOfMsgs = nb / PHY_PB_MAX_NB;
- if (0 != nbOfPbsInLastMsg)
- {
- nbOfMsgs++;
- }
- else
- {
- nbOfPbsInLastMsg = nbOfPbs;
- }
- const unsigned long length = nb*MAC_PB520_BYTES;
- unsigned char payload[length];
- for (unsigned int i=0; i<length; i++)
- {
- payload[i] = c;
- }
- mpPhySciMsgMpdu->setMpdu(length, payload);
-
- CPPUNIT_ASSERT_MESSAGE ( "segment failed",
- (mpPhySciMsgMpdu->segment())
- && (MAC_PB520_BYTES == mpPhySciMsgMpdu->getPbSize())
- && (nbOfPbs == (unsigned short int)mpPhySciMsgMpdu->getNbOfPbs())
- && (nbOfPbsInLastMsg == mpPhySciMsgMpdu->getNbOfPbsInLastMsg())
- && (nbOfMsgs == mpPhySciMsgMpdu->getNbOfMsgs())
- && (0 == memcmp(payload, mpPhySciMsgMpdu->getPbs(), length))
- );
-
- for (int j=0; j<nbOfMsgs-1; j++)
- {
- CPPUNIT_ASSERT_MESSAGE ( "segment failed",
- 0 == memcmp(&payload[j*PHY_PB_MAX_NB*MAC_PB520_BYTES], mpPhySciMsgMpdu->getPbs(j), nbOfPbs*MAC_PB520_BYTES) );
- }
- CPPUNIT_ASSERT_MESSAGE ( "segment failed",
- 0 == memcmp(&payload[(nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES], mpPhySciMsgMpdu->getPbs(nbOfMsgs-1), nbOfPbsInLastMsg*MAC_PB520_BYTES) );
-
- c++;
- }
-
- /* Test with random data length. */
-
- const unsigned long dataLength = 20007; // an odd number
- const unsigned short int nbOfPbs = dataLength/MAC_PB520_BYTES + 1;
- nbOfPbsInLastMsg = nbOfPbs % PHY_PB_MAX_NB;
- nbOfMsgs = nbOfPbs / PHY_PB_MAX_NB;
- if (0 != nbOfPbsInLastMsg)
- {
- nbOfMsgs++;
- }
- else
- {
- nbOfPbsInLastMsg = PHY_PB_MAX_NB;
- }
- unsigned char data[nbOfPbs*MAC_PB520_BYTES];
- memset(data, '7', dataLength);
- memset(&data[dataLength], '\0', nbOfPbs*MAC_PB520_BYTES-dataLength);
- mpPhySciMsgMpdu->setMpdu(dataLength, data);
-
- CPPUNIT_ASSERT_MESSAGE ( "segment failed",
- (mpPhySciMsgMpdu->segment())
- && (MAC_PB520_BYTES == mpPhySciMsgMpdu->getPbSize())
- && (PHY_PB_MAX_NB == mpPhySciMsgMpdu->getNbOfPbs())
- && (nbOfPbsInLastMsg == mpPhySciMsgMpdu->getNbOfPbsInLastMsg())
- && (nbOfMsgs == mpPhySciMsgMpdu->getNbOfMsgs())
- && (0 == memcmp(data, mpPhySciMsgMpdu->getPbs(0), (nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES))
- && (0 == memcmp(&data[(nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES], mpPhySciMsgMpdu->getPbs(nbOfMsgs-1), nbOfPbsInLastMsg*MAC_PB520_BYTES))
- );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
-
-void PhySciMsgMpduTest::prepareTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- const unsigned short int nbOfPbs = 50;
- unsigned short int nbOfPbsInLastMsg = nbOfPbs % PHY_PB_MAX_NB;
- unsigned short int nbOfMsgs = nbOfPbs / PHY_PB_MAX_NB;
- if (0 != nbOfPbsInLastMsg)
- {
- nbOfMsgs++;
- }
- else
- {
- nbOfPbsInLastMsg = PHY_PB_MAX_NB;
- }
- const unsigned long length = nbOfPbs*MAC_PB520_BYTES;
- unsigned char payload[length];
- unsigned char c = 'A';
- for (int i=0; i<nbOfPbs; i++)
- {
- for (int j=0; j<MAC_PB520_BYTES; j++)
- {
- payload[i*MAC_PB520_BYTES+j] = c;
- }
- c++;
- }
- mpPhySciMsgMpdu->setMpdu(length, payload);
- mpPhySciMsgMpdu->segment();
-
- // Test the PHY SCI messages
- for (int i=1; i<nbOfMsgs; i++)
- {
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgMpdu->prepare((Network_Clock_Id)i))
- && (PHY_PB_MAX_NB == mpPhySciMsgMpdu->getNbOfPbs())
- && (!mpPhySciMsgMpdu->isSent())
- && (PHY_PB_MAX_NB*MAC_PB520_BYTES == mpPhySciMsgMpdu->getSpecializedSciMsgDataLength())
- && (0 == memcmp(&payload[(i-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES], mpPhySciMsgMpdu->getSpecializedSciMsgData(), PHY_PB_MAX_NB*MAC_PB520_BYTES))
- );
- }
- // Test second (and last) PHY SCI message
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgMpdu->prepare((Network_Clock_Id)nbOfMsgs))
- && (nbOfPbsInLastMsg == mpPhySciMsgMpdu->getNbOfPbs())
- && (mpPhySciMsgMpdu->isSent())
- && ((unsigned long)nbOfPbsInLastMsg*MAC_PB520_BYTES == mpPhySciMsgMpdu->getSpecializedSciMsgDataLength())
- && (0 == memcmp(&payload[(nbOfMsgs-1)*PHY_PB_MAX_NB*MAC_PB520_BYTES], mpPhySciMsgMpdu->getSpecializedSciMsgData(), nbOfPbsInLastMsg*MAC_PB520_BYTES))
- );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
-
-void PhySciMsgMpduTest::setMpduTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- unsigned long length1 = 10;
- unsigned char payload1[length1];
- memcpy(payload1, "1234567890", length1);
-
- CPPUNIT_ASSERT_MESSAGE ( "setMpdu failed",
- (mpPhySciMsgMpdu->setMpdu(length1, payload1))
- && (length1 == mpPhySciMsgMpdu->getPayloadLength())
- && (0 == memcmp(payload1, mpPhySciMsgMpdu->getPayload(), length1)) );
-
- unsigned long length2 = 5;
- unsigned char payload2[length2];
- memcpy(payload2, "abcde", length2);
-
- CPPUNIT_ASSERT_MESSAGE ( "setMpdu failed",
- (mpPhySciMsgMpdu->setMpdu(length2, payload2))
- && (length2 == mpPhySciMsgMpdu->getPayloadLength())
- && (0 == memcmp(payload2, mpPhySciMsgMpdu->getPayload(), length2)) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
-
-void PhySciMsgMpduTest::setNbOfMsgsTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- const unsigned short int n = 8;
- CPPUNIT_ASSERT_MESSAGE ( "setNbOfMsgs failed",
- (mpPhySciMsgMpdu->setNbOfMsgs(n))
- && (n == mpPhySciMsgMpdu->getNbOfMsgs()) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
-
-void PhySciMsgMpduTest::setNbOfPbsInLastMsgTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- const unsigned short int n = PHY_PB_MAX_NB;
- CPPUNIT_ASSERT_MESSAGE ( "setNbOfPbsInLastMsg failed",
- (mpPhySciMsgMpdu->setNbOfPbsInLastMsg(n))
- && (n == mpPhySciMsgMpdu->getNbOfPbsInLastMsg()) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
-
-void PhySciMsgMpduTest::setPbsHeadersTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgMpdu)
- {
- const unsigned short int n = 31;
- const uint32_t pbHeader = 0x02000000;
- uint32_t expectedPbHeader[PHY_PB_MAX_NB];
- memset(expectedPbHeader, '\0', PHY_PB_MAX_NB * sizeof(uint32_t));
- expectedPbHeader[n] = pbHeader;
- CPPUNIT_ASSERT_MESSAGE ( "setPbsHeaders failed",
- mpPhySciMsgMpdu->setPbsHeaders(n, pbHeader) );
- CPPUNIT_ASSERT_MESSAGE ( "getPbsHeaders failed",
- (0 == memcmp(expectedPbHeader, mpPhySciMsgMpdu->getPbsHeaders(0), PHY_PB_MAX_NB * sizeof(uint32_t))) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message MPDU pointer is NULL");
- }
-}
-
diff --git a/cesar/maximus/phy/src/PhySciMsgNoise.cpp b/cesar/maximus/phy/src/PhySciMsgNoise.cpp
deleted file mode 100644
index eb57ccb2a1..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgNoise.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-
-#include "PhySciMsgNoise.h"
-#include "IPhy.h"
-
-#include "Error.h"
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-using namespace std;
-
-
-// Constructors/Destructors
-//
-
-
-PhySciMsgNoise::PhySciMsgNoise ( IPhy * p_phy ) : PhySciMsg ( p_phy )
-{
- logFunction();
-
- initAttributes ();
-}
-
-
-void PhySciMsgNoise::initAttributes ( )
-{
- logFunction();
-
- // Set PHY SCI message type
- PhySciMsg::setSpecializedSciMsgType(PHY_TYPE_NOISE);
-}
-
-
-PhySciMsgNoise::~PhySciMsgNoise ( )
-{
- logFunction();
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-bool PhySciMsgNoise::prepare ( )
-{
- logFunction();
-
- // Set flags
- return PhySciMsg::setFlags(PHY_FLAG_CRC_OK);
-}
-
-
-// private methods
-//
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-// protected attribute accessor methods
-//
-
diff --git a/cesar/maximus/phy/src/PhySciMsgNoiseTest.cpp b/cesar/maximus/phy/src/PhySciMsgNoiseTest.cpp
deleted file mode 100644
index 521e0feef9..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgNoiseTest.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-
-#include "PhySciMsgNoiseTest.h"
-
-#include "PhySciMsgNoise.h"
-#include "PhyProcessor.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-using namespace std;
-
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhySciMsgNoiseTest);
-
-
-void PhySciMsgNoiseTest::setUp (void)
-{
- logTest();
-
- mpSci = new SciServer();
- mpPhy = new PhyProcessor(mpSci);
- mpPhySciMsgNoise = new PhySciMsgNoise(mpPhy);
- CPPUNIT_ASSERT_MESSAGE ( "creation failed",
- (mpPhy == mpPhySciMsgNoise->getPhyProcessor())
- && (NULL != mpPhySciMsgNoise)
- && (PHY_TYPE_NOISE == mpPhySciMsgNoise->getSpecializedSciMsgType()) );
-}
-
-
-void PhySciMsgNoiseTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgNoise)
- {
- delete (mpPhySciMsgNoise);
- mpPhySciMsgNoise = NULL;
- }
- if (NULL != mpPhy)
- {
- delete (mpPhy);
- mpPhy = NULL;
- }
- if (NULL != mpSci)
- {
- delete (mpSci);
- mpSci = NULL;
- }
-}
-
-
-void PhySciMsgNoiseTest::prepareTest (void)
-{
- logTest();
-
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgNoise->prepare())
- && (PHY_FLAG_CRC_OK == mpPhySciMsgNoise->getFlags()) );
-}
-
diff --git a/cesar/maximus/phy/src/PhySciMsgPre.cpp b/cesar/maximus/phy/src/PhySciMsgPre.cpp
deleted file mode 100644
index 70089340ad..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgPre.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/************************************************************************
- PhySciMsgPre.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/PhySciMsgPre.cpp
-**************************************************************************/
-
-#include "PhySciMsgPre.h"
-#include "IPhy.h"
-
-#include "Error.h"
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-using namespace std;
-
-
-// Constructors/Destructors
-//
-
-
-PhySciMsgPre::PhySciMsgPre ( IPhy * p_phy_processor ) : PhySciMsg ( p_phy_processor )
-{
- logFunction();
-
- initAttributes ();
-}
-
-
-void PhySciMsgPre::initAttributes ( )
-{
- logFunction();
-
- // Set PHY SCI message type
- PhySciMsg::setSpecializedSciMsgType(PHY_TYPE_PREAMBLE);
-}
-
-
-PhySciMsgPre::~PhySciMsgPre ( )
-{
- logFunction();
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-bool PhySciMsgPre::prepare ( Network_Clock_Id clock_id )
-{
- logFunction();
- bool bPrepare = false;
-
- /* For a PHY message of type PREAMBLE,
- * PHY SCI message data are empty. */
-
- // Set TX ID
- bPrepare = PhySciMsg::setTxId(PhySciMsg::getPhyProcessor()->getTxId());
-
- // Set station ID to Maximus PID
- bPrepare &= SciMsg::setSciMsgStationId(getpid());
-
- return bPrepare;
-}
-
-
-// private methods
-//
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-// protected attribute accessor methods
-//
-
diff --git a/cesar/maximus/phy/src/PhySciMsgPreTest.cpp b/cesar/maximus/phy/src/PhySciMsgPreTest.cpp
deleted file mode 100644
index 9c3fff554d..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgPreTest.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-
-#include "PhySciMsgPreTest.h"
-
-#include "PhySciMsgPre.h"
-#include "PhyProcessor.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-
-// for 'getpid()'
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhySciMsgPreTest);
-
-
-void PhySciMsgPreTest::setUp (void)
-{
- logTest();
-
- mpSci = new SciServer();
- mpPhy = new PhyProcessor(mpSci);
- mpPhySciMsgPre = new PhySciMsgPre(mpPhy);
- CPPUNIT_ASSERT_MESSAGE ( "creation failed",
- (mpPhy == mpPhySciMsgPre->getPhyProcessor())
- && (NULL != mpPhySciMsgPre)
- && (PHY_TYPE_PREAMBLE == mpPhySciMsgPre->getSpecializedSciMsgType()) );
-}
-
-
-void PhySciMsgPreTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgPre)
- {
- delete (mpPhySciMsgPre);
- mpPhySciMsgPre = NULL;
- }
- if (NULL != mpPhy)
- {
- delete (mpPhy);
- mpPhy = NULL;
- }
- if (NULL != mpSci)
- {
- delete (mpSci);
- mpSci = NULL;
- }
-}
-
-
-void PhySciMsgPreTest::prepareTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsgPre)
- {
- CPPUNIT_ASSERT_MESSAGE ( "prepare failed",
- (mpPhySciMsgPre->prepare(0 /* clock_id */ ))
- && (0 == mpPhySciMsgPre->getTxId())
- && (getpid() == mpPhySciMsgPre->getSciMsgStationId()) );
- }
- else
- {
- CPPUNIT_FAIL ("PHY SCI message PREAMBLE pointer is NULL");
- }
-}
-
diff --git a/cesar/maximus/phy/src/PhySciMsgTest.cpp b/cesar/maximus/phy/src/PhySciMsgTest.cpp
deleted file mode 100644
index 2292a06f5b..0000000000
--- a/cesar/maximus/phy/src/PhySciMsgTest.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-
-#include "PhySciMsgTest.h"
-
-#include "PhySciMsg.h"
-#include "PhyProcessor.h"
-#include "SciServer.h"
-
-#include "Logger.h"
-#include "Error.h"
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (PhySciMsgTest);
-
-
-void PhySciMsgTest::setUp (void)
-{
- logTest();
-
- mpSciServer = new SciServer();
- mpPhyProcessor = new PhyProcessor (mpSciServer);
- mpPhySciMsg = new PhySciMsg (mpPhyProcessor);
-}
-
-
-void PhySciMsgTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsg)
- {
- delete (mpPhySciMsg);
- mpPhySciMsg = NULL;
- }
- if (NULL != mpPhyProcessor)
- {
- delete (mpPhyProcessor);
- mpPhyProcessor = NULL;
- }
- if (NULL != mpSciServer)
- {
- delete (mpSciServer);
- mpSciServer = NULL;
- }
-}
-
-
-void PhySciMsgTest::dispatchMsgTest (void)
-{
- logTest();
-
- if (NULL != mpPhySciMsg)
- {
- int type = PHY_TYPE_TONEMASK;
- unsigned int carrierNb = (PHY_CARRIER_NB+7)/8;
- unsigned char tonemask[sizeof(unsigned int) + carrierNb];
- memcpy(tonemask, &carrierNb, sizeof(unsigned int));
- memset(tonemask + sizeof(unsigned int), 'T', carrierNb);
- mpPhySciMsg->setSpecializedSciMsgDataLength(sizeof(unsigned int) + (PHY_CARRIER_NB+7)/8);
- mpPhySciMsg->setSpecializedSciMsgData(tonemask);
- CPPUNIT_ASSERT_MESSAGE("setSpecializedSciMsgType failed", mpPhySciMsg->setSpecializedSciMsgType((Phy_Type)type));
- CPPUNIT_ASSERT_MESSAGE("dispatchMsg failed", mpPhySciMsg->dispatchMsg());
-
- type = PHY_TYPE_RX;
- Sci_Msg_Station_Id txStationId = 123;
- mpPhySciMsg->setSpecializedSciMsgDataLength(sizeof(Sci_Msg_Station_Id));
- mpPhySciMsg->setSpecializedSciMsgData((unsigned char *)&txStationId);
- CPPUNIT_ASSERT_MESSAGE("setSpecializedSciMsgType failed", mpPhySciMsg->setSpecializedSciMsgType((Phy_Type)type));
- CPPUNIT_ASSERT_MESSAGE("dispatchMsg failed", mpPhySciMsg->dispatchMsg());
- }
- else
- {
- CPPUNIT_FAIL ("PhySciMsg pointer is NULL");
- }
-}
-