WSF
WsfNetworkInterface.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFNETWORKINTERFACE_HPP
13#define WSFNETWORKINTERFACE_HPP
14
15#include "wsf_export.h"
16
17#include <string>
18
19class GenNetIO;
20#include "GenTCP_Server.hpp"
21class GenUDP_IO;
22#include "UtCallbackHolder.hpp"
23class UtInput;
24#include "WsfEvent.hpp"
25class WsfScenario;
26
28{
29public:
31 bool ProcessNetworkInput(UtInput& aInput);
32
36 bool mDebug;
37 std::string mUDP_Addr;
38 std::string mUDP_Interface;
39 std::string mTCP_Addr; // address to connect to for TCP clients
40 int mTTL;
45 bool mUpdateOnExternalTimer; // allow the NetworkUpdate to be scheduled by a timing mechanism external to WSF
46};
47
53{
54public:
55 WsfNetworkInterface(WsfSimulation& aSimulation, const std::string& aName, const WsfNetworkInterfaceInput& aNetInput);
56 virtual ~WsfNetworkInterface();
57
58
59 virtual bool Initialize();
60 virtual void NetworkUpdate(double aSimTime) = 0;
61
62 double GetUpdateInterval() const { return mUpdateInterval; }
63 void SetUpdateInterval(double aUpdateInterval) { mUpdateInterval = aUpdateInterval; }
64
65 void SetUpdateOnExternalTimer(bool aUseExternalTimer) { mUpdateOnExternalTimer = aUseExternalTimer; }
66
67 bool IsActive() const;
68
69 bool IsDebug() const { return mDebug; }
70 void SetDebug(bool aIsDebug) { mDebug = aIsDebug; }
71
72 // These methods allow parameters to be set programmatically rather than using ProcessInput
73 void SetUDP_Addr(const std::string& aUDP_Addr) { mUDP_Addr = aUDP_Addr; }
74 void SetSendPort(int aSendPort) { mSendPort = aSendPort; }
75 void SetRecvPort(int aRecvPort) { mReceivePort = aRecvPort; }
76
78
79protected:
81 std::string mName; // identify the name of interface for debug messages
82 GenNetIO* mIOPtr; // common pointer; either of TCP or UDP pointer below.
83 GenTCP_IO* mTCP_IOPtr;
84 GenUDP_IO* mUDP_IOPtr;
85 GenTCP_Server mTCP_Server;
86 UtCallbackHolder mCallbacks;
87
88 virtual void PrivateInitialize() {}
89
90private:
91 class NetworkUpdateEvent : public WsfEvent
92 {
93 public:
94 NetworkUpdateEvent(WsfNetworkInterface* aInterfacePtr);
95 ~NetworkUpdateEvent() override{};
96 EventDisposition Execute() override;
97
98 WsfNetworkInterface* mWsfNetworkInterfacePtr;
99 };
100};
101
102#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfEvent.hpp:29
std::string mUDP_Interface
Definition WsfNetworkInterface.hpp:38
WsfScenario * mScenarioPtr
Definition WsfNetworkInterface.hpp:33
bool mDebug
Definition WsfNetworkInterface.hpp:36
int mTTL
Definition WsfNetworkInterface.hpp:40
bool mUpdateOnAdvanceTime
Definition WsfNetworkInterface.hpp:44
bool mIsDisabled
Definition WsfNetworkInterface.hpp:35
bool mIsRequested
Definition WsfNetworkInterface.hpp:34
int mReceivePort
Definition WsfNetworkInterface.hpp:42
WsfNetworkInterfaceInput(WsfScenario &aScenario)
Definition WsfNetworkInterface.cpp:24
std::string mTCP_Addr
Definition WsfNetworkInterface.hpp:39
bool mUpdateOnExternalTimer
Definition WsfNetworkInterface.hpp:45
bool ProcessNetworkInput(UtInput &aInput)
Definition WsfNetworkInterface.cpp:64
std::string mUDP_Addr
Definition WsfNetworkInterface.hpp:37
int mSendPort
Definition WsfNetworkInterface.hpp:41
double mUpdateInterval
Definition WsfNetworkInterface.hpp:43
Definition WsfNetworkInterface.hpp:53
UtCallbackHolder mCallbacks
Definition WsfNetworkInterface.hpp:86
WsfSimulation & GetSimulation()
Definition WsfNetworkInterface.hpp:77
GenNetIO * mIOPtr
Definition WsfNetworkInterface.hpp:82
void SetUDP_Addr(const std::string &aUDP_Addr)
Definition WsfNetworkInterface.hpp:73
std::string mName
Definition WsfNetworkInterface.hpp:81
void SetSendPort(int aSendPort)
Definition WsfNetworkInterface.hpp:74
void SetDebug(bool aIsDebug)
Definition WsfNetworkInterface.hpp:70
GenUDP_IO * mUDP_IOPtr
Definition WsfNetworkInterface.hpp:84
void SetUpdateInterval(double aUpdateInterval)
Definition WsfNetworkInterface.hpp:63
double GetUpdateInterval() const
Definition WsfNetworkInterface.hpp:62
WsfNetworkInterface(WsfSimulation &aSimulation, const std::string &aName, const WsfNetworkInterfaceInput &aNetInput)
Definition WsfNetworkInterface.cpp:41
virtual void NetworkUpdate(double aSimTime)=0
GenTCP_IO * mTCP_IOPtr
Definition WsfNetworkInterface.hpp:83
virtual bool Initialize()
Definition WsfNetworkInterface.cpp:133
bool IsDebug() const
Definition WsfNetworkInterface.hpp:69
GenTCP_Server mTCP_Server
Definition WsfNetworkInterface.hpp:85
void SetUpdateOnExternalTimer(bool aUseExternalTimer)
Definition WsfNetworkInterface.hpp:65
virtual void PrivateInitialize()
Definition WsfNetworkInterface.hpp:88
void SetRecvPort(int aRecvPort)
Definition WsfNetworkInterface.hpp:75
WsfSimulation * mSimulationPtr
Definition WsfNetworkInterface.hpp:80
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Copyrights Multiple, All Rights Reserved