|
WSF
|
#include <WsfCommMedium.hpp>


Public Types | |
| using | ModeIt = std::vector<std::unique_ptr<Mode>>::iterator |
| using | const_ModeIt = std::vector<std::unique_ptr<Mode>>::const_iterator |
| Public Types inherited from WsfObject | |
| typedef std::vector< WsfStringId > | TypeList |
| The list of types returned by GetTypeList. | |
Public Member Functions | |
| Medium (WsfScenario &aScenario) | |
| ~Medium () override=default | |
| Medium (const Medium &aSrc) | |
| Medium & | operator= (Medium &aRhs) |
| const char * | GetScriptClassName () const override |
| Medium * | Clone () const override=0 |
| bool | ProcessInput (UtInput &aInput) override |
| virtual bool | Initialize (double aSimTime) |
| void | SetSimulation (WsfSimulation *aSimPtr) |
| WsfSimulation * | GetSimulation () const |
| Public Member Functions inherited from WsfObject | |
| WsfObject () | |
| This is the constructor for the WsfObject class. | |
| ~WsfObject () override | |
| This is the destructor for the WsfObject class. | |
| const char * | GetScriptClassName () const override |
| const std::string & | GetType () const |
| WsfStringId | GetTypeId () const |
| Get the string ID of the 'type' of the object. | |
| void | SetType (WsfStringId aType) |
| const std::string & | GetBaseType () const |
| WsfStringId | GetBaseTypeId () const |
| const TypeList & | GetTypeList () const |
| bool | IsA_TypeOf (WsfStringId aType) const |
| WsfObject & | operator= (const WsfObject &aRhs) |
| Assignment operator. | |
| template<typename T> | |
| void | Serialize (T &aBuff) |
| For XIO (de)serialization. | |
| const std::string & | GetName () const |
| WsfStringId | GetNameId () const |
| void | SetName (WsfStringId aName) |
Transmission and Propagation Methods | |
These methods handle the initiation and termination of transmission and propagation of a message/data/signal. They are required for correct implementation of medium types. | |
| std::unordered_map< Message::Identifier, MessageStatus > | mMessages {} |
| std::vector< ut::CloneablePtr< Mode > > | mModes {} |
| bool | mShared {false} |
| bool | mDebug {false} |
| Debug flag. | |
| std::shared_ptr< int > | mEventPtr {nullptr} |
| virtual TransmissionResult | TransmitMessage (double aSimTime, Layer *aLayerPtr, Message &aMessage, Comm &aXmtr)=0 |
| virtual void | EndTransmission (double aSimTime, const Message::Identifier &aIdentifier)=0 |
| virtual void | PropagateMessage (double aSimTime, const Message::Identifier &aIdentifier)=0 |
| virtual void | EndPropagation (double aSimTime, const Message::Identifier &aIdentifier)=0 |
| virtual TypeIdentifier | GetMediumIdentifier () const =0 |
| size_t | GetNumModes () const |
| size_t | GetCurrentModeIndex () const |
| std::pair< size_t, bool > | GetModeIndex (const std::string &aModeName) const |
| size_t | GetNumChannels () const |
| const std::string & | GetActiveModeName () const |
| bool | IsMediumShared () const |
| bool | UserDirectedSharing () const |
| size_t | GetCurrentTransmissions () const |
| size_t | GetNumMessageStatuses () const |
| bool | SetActiveMode (const std::string &aModeName) |
| bool | SetActiveMode (size_t aIndex) |
| void | SetActiveModeDelayed (const std::string &aModeName) |
| void | SetActiveModeDelayed (size_t aIndex) |
| void | SetIsShared (bool aIsShared) |
| MessageStatus * | GetMessageStatus (const Message::Identifier &aIdentifier) |
| MessageStatus * | GetMessageStatusByIndex (size_t aIndex) |
| virtual std::unique_ptr< Mode > | CreateDefaultMode () const =0 |
| Mode * | GetMode (const std::string &aModeName) const |
| Mode * | GetMode (size_t aModeIndex) const |
| std::string | ExecuteModeOnTransmit (double aSimTime, const Message &aMessage, const Comm &aXmtr, const Comm &aRcvr) |
| void | RemoveMessageStatus (const Message::Identifier &aIdentifier) |
| void | SetNumChannels (size_t aNumChannels) |
| Mode * | GetModeForTransmission (double aSimTime, Comm &aXmtr, Comm &aRcvr, Message &aMessage) |
Additional Inherited Members | |
| WsfObject (const WsfObject &aSrc) | |
| Copy constructor (for Clone()). | |
The medium class is an interface for a generic object used to determine the capability, capacity, and duration of messages being passed between comm objects. It may handle one or more messages simultaneously (multiplex), and may have multiple defined Modes to change the behavior of the medium.
A single medium is associated with a utilizing object. However, multiple objects may share a medium, s.t. all users of the medium use the same object to facilitate message propagation.
| using wsf::comm::medium::Medium::const_ModeIt = std::vector<std::unique_ptr<Mode>>::const_iterator |
| using wsf::comm::medium::Medium::ModeIt = std::vector<std::unique_ptr<Mode>>::iterator |
| wsf::comm::medium::Medium::Medium | ( | WsfScenario & | aScenario | ) |
Referenced by Clone(), wsf::comm::medium::Guided::Guided(), Medium(), operator=(), and ~Medium().
|
overridedefault |
References Medium(), and operator=().
| wsf::comm::medium::Medium::Medium | ( | const Medium & | aSrc | ) |
|
overridepure virtual |
Return a copy of this object. Must be implemented by all derived types. If cloning is impossible, a WsfUncloneableException should be thrown.
Implements WsfObject.
Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.
References Initialize(), Medium(), and ProcessInput().
|
pure virtual |
Returns a default constructed mode of the type associated with this medium implementation.
Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.
References ExecuteModeOnTransmit(), GetMode(), and RemoveMessageStatus().
Referenced by ProcessInput().
|
pure virtual |
Implemented in wsf::comm::medium::Guided.
|
pure virtual |
Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.
| std::string wsf::comm::medium::Medium::ExecuteModeOnTransmit | ( | double | aSimTime, |
| const Message & | aMessage, | ||
| const Comm & | aXmtr, | ||
| const Comm & | aRcvr ) |
Optional user defined script method overload for mode selection at the time of transmission.
Referenced by CreateDefaultMode(), and GetModeForTransmission().
| const std::string & wsf::comm::medium::Medium::GetActiveModeName | ( | ) | const |
References mModes.
Referenced by GetModeForTransmission().
|
inline |
| size_t wsf::comm::medium::Medium::GetCurrentTransmissions | ( | ) | const |
References mMessages.
Referenced by wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
|
pure virtual |
Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.
Referenced by wsf::comm::medium::Types::AddDefaultMedium(), and wsf::comm::medium::Types::DeleteMedium().
| MessageStatus * wsf::comm::medium::Medium::GetMessageStatus | ( | const Message::Identifier & | aIdentifier | ) |
Gets a currently handled message and its status by provision of the message serial number or by index.
References mMessages.
Referenced by wsf::comm::medium::Guided::EndPropagation(), wsf::comm::medium::Guided::EndTransmission(), and wsf::comm::medium::Guided::PropagateMessage().
| MessageStatus * wsf::comm::medium::Medium::GetMessageStatusByIndex | ( | size_t | aIndex | ) |
References mMessages.
| Mode * wsf::comm::medium::Medium::GetMode | ( | const std::string & | aModeName | ) | const |
References mModes.
Referenced by CreateDefaultMode(), GetModeForTransmission(), Initialize(), and ProcessInput().
|
protected |
Returns the mode to be used with a message transmission, either by getting the currently active mode, or from a user defined script method overload.
References ExecuteModeOnTransmit(), GetActiveModeName(), and GetMode().
Referenced by wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
| std::pair< size_t, bool > wsf::comm::medium::Medium::GetModeIndex | ( | const std::string & | aModeName | ) | const |
References mModes.
Referenced by wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
|
inline |
|
inline |
References mMessages.
|
inline |
References mModes.
|
inlineoverride |
|
inline |
Referenced by wsf::comm::medium::Guided::EndPropagation(), wsf::comm::medium::Unguided::EndPropagation(), wsf::comm::medium::Guided::EndTransmission(), wsf::comm::medium::Unguided::EndTransmission(), Initialize(), wsf::comm::medium::Guided::PropagateMessage(), SetActiveModeDelayed(), SetActiveModeDelayed(), wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
|
virtual |
References GetMode(), WsfObject::GetName(), GetSimulation(), mModes, ok, and SetActiveMode().
Referenced by Clone().
|
inline |
References mShared.
|
overridevirtual |
Process input from a generic source.
Examine the current input command. If it is NOT one of the commands recognized by this class then it simply returns 'false'. If it is one of the commands recognized by this class then it processes the command and returns 'true'.
| aInput | a reference to a UtInput object. |
| UtInput::ExceptionBase | (or an object derived from it) if the command was recognized but contains some sort of error. |
Reimplemented from WsfObject.
Reimplemented in wsf::comm::medium::Unguided.
References CreateDefaultMode(), GetMode(), WsfObject::GetType(), mDebug, mModes, ProcessInput(), WsfObject::ProcessInput(), and SetNumChannels().
Referenced by Clone(), wsf::comm::medium::Guided::ProcessInput(), and ProcessInput().
|
pure virtual |
Implemented in wsf::comm::medium::Guided.
|
protected |
References mMessages.
Referenced by CreateDefaultMode(), wsf::comm::medium::Guided::EndPropagation(), and wsf::comm::medium::Unguided::EndPropagation().
| bool wsf::comm::medium::Medium::SetActiveMode | ( | const std::string & | aModeName | ) |
Mode Set Methods These methods change the current active mode of the medium. The SetActiveMode methods execute immediately, where the delayed versions execute via simulation event scheduling. The delayed calls allow processing the order of calls also delayed by event scheduling (such as call to send a message), where multiple calls to change the mode in a single time frame with the non-delayed methods would just result in the last called method being applied (as multiple calls would resolve prior to a non-scheduled event).
References mModes.
Referenced by Initialize(), SetActiveModeDelayed(), and SetActiveModeDelayed().
| bool wsf::comm::medium::Medium::SetActiveMode | ( | size_t | aIndex | ) |
References mModes.
| void wsf::comm::medium::Medium::SetActiveModeDelayed | ( | const std::string & | aModeName | ) |
References WsfSimulation::AddEvent(), WsfSimulation::GetSimTime(), GetSimulation(), mEventPtr, SetActiveMode(), and simTime.
| void wsf::comm::medium::Medium::SetActiveModeDelayed | ( | size_t | aIndex | ) |
References WsfSimulation::AddEvent(), WsfSimulation::GetSimTime(), GetSimulation(), mEventPtr, SetActiveMode(), and simTime.
|
inline |
References mShared.
|
inlineprotected |
Referenced by ProcessInput().
|
inline |
|
pure virtual |
Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.
Referenced by wsf::comm::PhysicalLayer::Send().
|
inline |
|
protected |
|
protected |
A shared pointer for correct termination of events when the owning medium is removed from the simulation prior to event execution, using wsf::comm::GenericEvent.
Referenced by Medium(), operator=(), wsf::comm::medium::Guided::PropagateMessage(), SetActiveModeDelayed(), SetActiveModeDelayed(), wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
|
protected |
This container holds all messages currently being handled by this medium, along with their status and relevant bookkeeping.
Referenced by GetCurrentTransmissions(), GetMessageStatus(), GetMessageStatusByIndex(), GetNumMessageStatuses(), RemoveMessageStatus(), wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().
|
protected |
The modes associated with this medium. The base class adds the base Mode object as the "default" mode. Pointers are used for potential polymorphism of the Mode object.
Referenced by GetActiveModeName(), GetMode(), GetMode(), GetModeIndex(), GetNumModes(), wsf::comm::medium::Guided::Guided(), Initialize(), Medium(), operator=(), ProcessInput(), SetActiveMode(), SetActiveMode(), and wsf::comm::medium::Unguided::Unguided().
|
protected |
This is a special flag for indicating the origin of this medium. When set to true, it indicates the medium is of a type that was explicitly added to its owner based on user input (such as "add medium"), and can potentially be shared among multiple containers. If set to false, it indicates this medium is added as a default instance, and unique to this container.
This is necessary in order to support legacy input, and to provide useful feedback to users to avoid confusion when providing input at varying scopes for medium usage.
Referenced by IsMediumShared(), Medium(), operator=(), and SetIsShared().