/************************************************************************ PhyProcessor.h - Copyright buret Here you can write a license for your code, some comments or any other information you want to have in your generated code. To to this simply configure the "headings" directory in uml to point to a directory where you have your heading files. or you can just replace the contents of this file with your own. If you want to do this, this file is located at /usr/share/apps/umbrello/headings/heading.h -->Code Generators searches for heading files based on the file extension i.e. it will look for a file name ending in ".h" to include in C++ header files, and for a file name ending in ".java" to include in all generated java code. If you name the file "heading.", 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/inc/PhyProcessor.h **************************************************************************/ #ifndef PHYPROCESSOR_H #define PHYPROCESSOR_H #include "IPhy.h" #include "phy_types.h" #include // for 'map' and 'multimap' class ISci; class PhySciMsgNoise; class PhySciMsgPre; struct Expected_Tx { Phy_Tx_Id src_tx_id; // expected transmission ID Sci_Msg_Station_Id src_station_id; // expected transmitting station ID }; struct lttx { bool operator() ( const Expected_Tx tx1, const Expected_Tx tx2 ) const { if (tx1.src_tx_id != tx2.src_tx_id) { return tx1.src_tx_id < tx2.src_tx_id; } else { return tx1.src_station_id < tx2.src_station_id; } } }; typedef std::multimap RxStationsList; // list of destination stations struct Frame_Control { uint32_t fc_10; uint32_t fc_av[4]; }; typedef std::map RxFcList; // list of received Frame Control struct Mpdu_Payload { unsigned short int msg_nb; // number of PHY SCI messages MPDU that have been received unsigned long data_length; unsigned char * p_data; uint32_t pb_header[MAC_MAX_PB_PER_MPDU]; }; typedef std::map RxMpduList; // list of received MPDU /** * class PhyProcessor * Simulates the real HomePlugAV physical interface and data bus. */ class PhyProcessor : public IPhy { public: // public attributes // private: // private attributes // ISci * mpSciServer; INetworkClock * mpNetworkClock; IChannel * mpChannel; bool mIsChannelEnabled; unsigned int mNbOfCarriers; uint8_t * mpTonemask; Phy_Tx_Id mTxId; // unique ID incremented for each transmission // (PREAMBLE, FC, MPDU, and NOISE if enabled). RxStationsList mListOfRxStations; PhyMpduCb mInterfaceCb; RxFcList mListOfRxFc; RxMpduList mListOfRxMpdu; float mFrequency; Network_Clock_Tick mZeroCrossDelay; PhySciMsg * mpZeroCross; // For the wrong preambles transmission feature bool mIsFalseAlarmActivated; PhySciMsgPre * mpWrongPre; Network_Clock_Tick mAverageDuration; float mStdDeviation; protected: // protected attributes // public: // Constructors/Destructors // /** * Constructor */ PhyProcessor ( ISci * p_sci_server ); /** * Empty Destructor */ virtual ~PhyProcessor ( ); // public methods // /** * @param interface_cb * Initialize PHY with an interface callback function for PHY SCI message MPDU reception. */ bool init ( PhyMpduCb interface_cb ); /** * Initialize PHY with the PLC frequency for PHY SCI message of type ZERO_CROSS. * @param frequency * @return bool */ bool init ( const float frequency ); /** * @return PhySciMsg * */ PhySciMsg * createMsg ( ); /** * Creates a PHY SCI message MPDU. * @return PhySciMsgMpdu * */ PhySciMsgMpdu * createMpdu ( ); /** * Sends a PHY SCI message MPDU. * This message has to be configured before transmission. * @param p_mpdu * @return bool */ bool sendMpdu ( PhySciMsgMpdu * p_mpdu ); /** * Sends the PHY SCI message associated to the received Network Clock event. * @return bool * @param received_evt */ bool receiveEvt ( NetworkClockEvt & received_evt ); /** * Processes the received PHY SCI message of type NONE or NOISE. * @return bool * @param received_phy_sci_msg */ bool receiveInvalid ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type PREAMBLE. * @return bool * @param received_phy_sci_msg */ bool receivePre ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type FC_HYBRID_MODE or FC_AV_ONLY_MODE. * @return bool * @param received_phy_sci_msg */ bool receiveFc ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type PRS. * @return bool * @param received_phy_sci_msg */ bool receivePrs ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type MPDU_PAYLOAD. * @return bool * @param received_phy_sci_msg */ bool receiveMpdu ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type TONEMASK. * @return bool * @param received_phy_sci_msg */ bool receiveTonemask ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type TONEMAP. * @return bool * @param received_phy_sci_msg */ bool receiveTonemap ( PhySciMsg & received_phy_sci_msg ); /** * Processes the received PHY SCI message of type RX. * @return bool * @param received_phy_sci_msg */ bool receiveRx ( PhySciMsg & received_phy_sci_msg ); /** * @return bool * @param phy_sci_msg_to_send */ bool sendMsgToAllStations ( PhySciMsg & phy_sci_msg_to_send ) const; /** * Activate the wrong preambles transmission feature. * @param average_duration average number of ticks 25 MHz between two consecutive wrong preambles * @param std_deviation the standard deviation * @return bool */ bool activateFalseAlarm ( const Network_Clock_Tick average_duration, const float std_deviation ); /** * Deactivate the wrong preambles transmission feature. * @return bool */ bool deactivateFalseAlarm ( ); // public attribute accessor methods // // private attribute accessor methods // /** * @return bool * @param p_network_clock the new value of mpNetworkClock */ bool setNetworkClock ( INetworkClock * p_network_clock ); /** * @return bool * @param p_channel the new value of mpChannel */ bool setChannel ( IChannel * p_channel ); /** * Sets the channel perturbation. * @param is_channel_enabled the new value of mIsChannelEnabled */ bool setIsChannelEnabled ( const bool is_channel_enabled ); /** * Gets the TX ID. * @return mTxId */ Phy_Tx_Id getTxId ( ) const; /** * Gets the tonemask. * @return mpTonemask */ const uint8_t * getTonemask ( ) const; /** * Check if the channel perturbation is enabled. * @return mIsChannelEnabled */ bool isChannelEnabled ( ) const; /** * Sets the power line frequency. * @param frequency the new value of mFrequency * @return bool */ bool setFrequency ( const float frequency ); /** * Gets the power line frequency. * @return mFrequency */ float getFrequency ( ) const; // protected attribute accessor methods // private: // private methods // /** * Initializes the PHY processor class attributes. */ void initAttributes ( ); /** * Registers the PHY SCI message creation function to the SCI server. */ void registerPhySciMsg ( ); /** * Computes PREAMBLE transmission duration. * @return preamble delay in ticks */ Network_Clock_Tick calculatePreDelay ( ) const; /** * Computes Frame Control transmission duration. * @return Frame Control delay in ticks */ Network_Clock_Tick calculateFcDelay ( Phy_Fc_Mode fc_mode ) const; /** * Computes MPDU payload transission duration. * @return MPDU payload delay in ticks */ Network_Clock_Tick calculateMpduDelay ( Phy_Mod mod, Phy_Fecrate fecrate, unsigned short int pb_size, Phy_Nb_Of_Pbs pb_nb, Phy_Gil gil ) const; /** * @return bool * @param phy_sci_msg_to_send */ bool fillMsg ( PhySciMsg & phy_sci_msg_to_send ) const; /** * @return a pointer to SCI server */ ISci * getSciServer ( ) const; /** * @return a pointer to Network Clock Processor */ INetworkClock * getNetworkClock ( ) const; /** * Gets a pointer to Channel. * @return mpChannel */ IChannel * getChannel ( ) const; /** * Gets the number of carriers. * @return mNbOfCarriers */ unsigned int getNbOfCarriers ( ) const; /** * Sets the number of carriers. * @return bool * @param nb_of_carriers the new value of mNbOfCarriers */ bool setNbOfCarriers ( const unsigned int nb_of_carriers ); /** * Sets the tonemask. * @return bool * @param length the tonemask length in octets * @param p_tonemask the new value of mpTonemask */ bool setTonemask ( const unsigned int length, const uint8_t * p_tonemask ); /** * Increments the TX ID. * @return bool */ bool incrementTxId ( ); /** * Gets the interface callback function for PHY SCI message MPDU reception. * @return mInterfaceCb */ PhyMpduCb getInterfaceCb ( ) const; /** * Gets the zero-cross delay for PHY SCI message of type ZERO_CROSS transmission. * @return mZeroCrossDelay */ Network_Clock_Tick getZeroCrossDelay ( ) const; /** * Sets the zero-cross delay for PHY SCI message of type ZERO_CROSS transmission. * @param zero_cross_delay the new value of mZeroCrossDelay * @return bool */ bool setZeroCrossDelay ( const Network_Clock_Tick zero_cross_delay ); /** * Gets a pointer to the PHY SCI message of type ZERO_CROSS. * @return mpZeroCross */ PhySciMsg * getZeroCross ( ) const; /** * Schedules an event for next PHY SCI message of type ZERO_CROSS transmission. * @return bool */ bool scheduleZeroCross ( ); /** * Sends a PHY SCI message of type MPDU to destination stations. * @param mpdu the PHY SCI message MPDU to send * @return bool */ bool sendMpduToDestStations ( PhySciMsgMpdu & mpdu ); /** * Sends an empty PHY SCI message of type NOISE to destination stations. * @param noise the empty PHY SCI message NOISE to send * @return bool */ bool sendEmptyNoiseToDestStations ( PhySciMsgNoise & noise ); /** * Sends PHY SCI message(s) of type MPDU * and a PHY SCI message of type NOISE * to destination stations. * @param mpdu the PHY SCI message of type MPDU * @return bool */ bool sendMpduAndNoiseToDestStations ( PhySciMsgMpdu & mpdu ); /** * Update the list of destination stations. * Once a PHY SCI message MPDU has been sent to the destination stations, * remove the destination stations from the reception list. */ void updateListOfRxStations ( PhySciMsgMpdu & mpdu ); /** * Check if the wrong preambles transmission is enabled or not. * @return mIsFalseAlarmActivated */ bool isFalseAlarmActivated ( ) const; /** * Gets a pointer to the PHY SCI message of type PREAMBLE with the flag PHY_FLAG_WRONG_PREAMBLE set. * @return mpWrongPre */ PhySciMsgPre * getWrongPre ( ) const; /** * Gets the average number of ticks 25 MHz between 2 consecutive wrong preambles transmissions. * @return mAverageDuration */ Network_Clock_Tick getAverageDuration ( ) const; /** * Gets the standard deviation (used to calculate date of the next wrong preamble transmission). * @return mStdDeviation */ float getStdDeviation ( ) const; /** * Calculate date of next wrong preamble transmission. * @return the calculated date in ticks 25 MHz */ Network_Clock_Tick calculateNextWrongPreDate ( ) const; /** * Schedules an event for next wrong preamble transmission. * @param tick_wrong_pre the next wrong preamble should be transmitted at current date + tick_wrong_pre (in 25 MHz) * @return bool */ bool scheduleNextWrongPre ( const Network_Clock_Tick tick_wrong_pre ) const; protected: // protected methods // }; #endif // PHYPROCESSOR_H