12#ifndef WSFUCI_MESSAGES_HPP
13#define WSFUCI_MESSAGES_HPP
15#include "wsf_oms_uci_export.h"
17#include "uci/base/accessorType.h"
19#include "UtMemory.hpp"
31#include "uci/type/AMTI_Activity.h"
32#include "uci/type/AMTI_ActivityType.h"
33#include "uci/type/AMTI_Capability.h"
34#include "uci/type/AMTI_CapabilityStatus.h"
35#include "uci/type/AMTI_Command.h"
36#include "uci/type/AMTI_CommandStatus.h"
37#include "uci/type/AMTI_SettingsCommand.h"
38#include "uci/type/AMTI_SettingsCommandStatus.h"
39#include "uci/type/ControlRequest.h"
40#include "uci/type/ControlRequestStatus.h"
41#include "uci/type/ControlStatus.h"
42#include "uci/type/DMPI.h"
43#include "uci/type/DMPI_Status.h"
44#include "uci/type/Entity.h"
45#include "uci/type/ESM_Activity.h"
46#include "uci/type/ESM_ActivityType.h"
47#include "uci/type/ESM_Capability.h"
48#include "uci/type/ESM_CapabilityStatus.h"
49#include "uci/type/ESM_Command.h"
50#include "uci/type/ESM_CommandStatus.h"
51#include "uci/type/ESM_SettingsCommand.h"
52#include "uci/type/ESM_SettingsCommandStatus.h"
53#include "uci/type/POST_Activity.h"
54#include "uci/type/POST_Capability.h"
55#include "uci/type/POST_Command.h"
56#include "uci/type/POST_CommandStatus.h"
57#include "uci/type/POST_SettingsCommand.h"
58#include "uci/type/POST_SettingsCommandStatus.h"
65#include "uci/type/StrikeActivity.h"
66#include "uci/type/StrikeCapability.h"
67#include "uci/type/StrikeCapabilityStatus.h"
68#include "uci/type/StrikeCommand.h"
69#include "uci/type/StrikeCommandStatus.h"
70#include "uci/type/SubsystemStatus.h"
71#include "uci/type/SystemStatus.h"
74#include "uci/factory/AMTI_ActivityFactory.h"
75#include "uci/factory/AMTI_CapabilityFactory.h"
76#include "uci/factory/AMTI_CapabilityStatusFactory.h"
77#include "uci/factory/AMTI_CommandFactory.h"
78#include "uci/factory/AMTI_CommandStatusFactory.h"
79#include "uci/factory/AMTI_SettingsCommandFactory.h"
80#include "uci/factory/AMTI_SettingsCommandStatusFactory.h"
81#include "uci/factory/ControlRequestFactory.h"
82#include "uci/factory/ControlRequestStatusFactory.h"
83#include "uci/factory/ControlStatusFactory.h"
84#include "uci/factory/DMPIFactory.h"
85#include "uci/factory/DMPI_StatusFactory.h"
86#include "uci/factory/EntityFactory.h"
87#include "uci/factory/ESM_ActivityFactory.h"
88#include "uci/factory/ESM_CapabilityFactory.h"
89#include "uci/factory/ESM_CapabilityStatusFactory.h"
90#include "uci/factory/ESM_CommandFactory.h"
91#include "uci/factory/ESM_CommandStatusFactory.h"
92#include "uci/factory/ESM_SettingsCommandFactory.h"
93#include "uci/factory/ESM_SettingsCommandStatusFactory.h"
94#include "uci/factory/POST_ActivityFactory.h"
95#include "uci/factory/POST_CapabilityFactory.h"
96#include "uci/factory/POST_CapabilityStatusFactory.h"
97#include "uci/factory/POST_CommandFactory.h"
98#include "uci/factory/POST_CommandStatusFactory.h"
99#include "uci/factory/POST_SettingsCommandFactory.h"
100#include "uci/factory/POST_SettingsCommandStatusFactory.h"
106#include "uci/factory/StrikeActivityFactory.h"
107#include "uci/factory/StrikeCapabilityFactory.h"
108#include "uci/factory/StrikeCapabilityStatusFactory.h"
109#include "uci/factory/StrikeCommandFactory.h"
110#include "uci/factory/StrikeCommandStatusFactory.h"
111#include "uci/factory/SubsystemStatusFactory.h"
112#include "uci/factory/SystemStatusFactory.h"
115#include "uci/reader/EntityReader.h"
116#include "uci/reader/ESM_CapabilityReader.h"
117#include "uci/reader/POST_ActivityReader.h"
118#include "uci/reader/POST_CapabilityReader.h"
119#include "uci/reader/POST_CommandReader.h"
120#include "uci/reader/SubsystemStatusReader.h"
123#include "uci/writer/EntityWriter.h"
124#include "uci/writer/ESM_CapabilityWriter.h"
125#include "uci/writer/ESM_CapabilityStatusWriter.h"
126#include "uci/writer/POST_ActivityWriter.h"
127#include "uci/writer/POST_CapabilityWriter.h"
128#include "uci/writer/POST_CommandWriter.h"
129#include "uci/writer/SubsystemStatusWriter.h"
135template<
typename Type,
140 uci::base::accessorType::AccessorType TypeName>
158 static uci::base::accessorType::AccessorType
GetUCI_TypeId() {
return TypeName; }
161 Type&
Get()
const {
return *mTypePtr; }
167 return &(mTypePtr->getSequenceGroup().getMessageHeader());
171 void Send(
const uci::type::DateTimeTypeValue& aSimTime)
const override;
176 void PopulateHeader()
const;
178 Type* mTypePtr {
nullptr };
179 const UCI_FactoryService<Type, Factory>* mTypeFactoryPtr {
nullptr };
180 const UCI_MessageService<Type, Factory, Reader, Writer, Listener>* mTypeServicePtr {
nullptr };
183template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener,
typename uci::base::accessorType::AccessorType TypeName>
188 mTypePtr = &(mTypeFactoryPtr->GetFactory().create());
193template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener, uci::base::accessorType::AccessorType TypeName>
198 mTypePtr = &(mTypeFactoryPtr->GetFactory().create());
203template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener, uci::base::accessorType::AccessorType TypeName>
208 mTypePtr = &(mTypeFactoryPtr->GetFactory().create(aType));
212template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener,
typename uci::base::accessorType::AccessorType TypeName>
215 mTypeFactoryPtr(aSrc.mTypeFactoryPtr),
216 mTypeServicePtr(aSrc.mTypeServicePtr)
218 mTypePtr = &(mTypeFactoryPtr->GetFactory().create(*aSrc.mTypePtr));
221template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener,
typename uci::base::accessorType::AccessorType TypeName>
224 mTypeFactoryPtr->GetFactory().destroy(*mTypePtr);
227template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener,
typename uci::base::accessorType::AccessorType TypeName>
232 GetInterface().PopulateHeader(aSimTime,
Get().getSequenceGroup().getMessageHeader());
233 mTypeServicePtr->GetWriter().write(
Get());
235 catch (
const uci::base::UCIException& ex)
237 auto error = ut::log::error() <<
"Cannot send UCI Message.";
238 error.AddNote() << ex.what();
242template<
typename Type,
typename Factory,
typename Reader,
typename Writer,
typename Listener, uci::base::accessorType::AccessorType TypeName>
243inline void UCI_MessageType<Type, Factory, Reader, Writer, Listener, TypeName>::PopulateHeader()
const
246 GetInterface().GetSimulation().GetSimTime());
247 GetInterface().
PopulateHeader(absoluteTime, Get().getSequenceGroup().getMessageHeader());
283#define DEFINE_UCI_MESSAGE_TYPE(WSF_MESSAGE_TYPE, UCI_MESSAGE_TYPE, WSF_TYPE_NAME, UCI_ACCESSOR_NAME) \
284 using WSF_MESSAGE_TYPE##Service = UCI_MessageService<uci::type::UCI_MESSAGE_TYPE, \
285 uci::factory::UCI_MESSAGE_TYPE##Factory, \
286 uci::reader::UCI_MESSAGE_TYPE##Reader, \
287 uci::writer::UCI_MESSAGE_TYPE##Writer, \
288 uci::reader::UCI_MESSAGE_TYPE##Listener>; \
290class WSF_MESSAGE_TYPE : public UCI_MessageType<uci::type::UCI_MESSAGE_TYPE, \
291 uci::factory::UCI_MESSAGE_TYPE##Factory, \
292 uci::reader::UCI_MESSAGE_TYPE##Reader, \
293 uci::writer::UCI_MESSAGE_TYPE##Writer, \
294 uci::reader::UCI_MESSAGE_TYPE##Listener, \
295 uci::type::accessorType::UCI_ACCESSOR_NAME> \
298 explicit WSF_MESSAGE_TYPE(WsfPlatform* aPlatformPtr) : UCI_MessageType(aPlatformPtr) { SetType(GetTypeId()); } \
299 explicit WSF_MESSAGE_TYPE(UCI_Interface& aInterface) : UCI_MessageType(aInterface) { SetType(GetTypeId()); } \
300 WSF_MESSAGE_TYPE(UCI_Interface& aInterface, const uci::type::UCI_MESSAGE_TYPE& aType) : UCI_MessageType(aInterface, aType) { SetType(GetTypeId()); } \
301 WSF_MESSAGE_TYPE(const WSF_MESSAGE_TYPE& aSrc) = default; \
302 ~WSF_MESSAGE_TYPE() override = default; \
303 WsfMessage* Clone() const override { return new WSF_MESSAGE_TYPE(*this); } \
304 static std::unique_ptr<WSF_MESSAGE_TYPE##Service> CreateMessageService(UCI_Interface& aInterface, \
305 uci::base::AbstractServiceBusConnection* aAsbPtr, \
306 const char* aTopic) \
307 { return ut::make_unique<WSF_MESSAGE_TYPE##Service>(aInterface, aAsbPtr, aTopic); } \
308 const char* GetScriptClassName() const override { return #WSF_MESSAGE_TYPE; } \
309 static WsfStringId GetTypeId() { return #WSF_TYPE_NAME; } \
310 static WsfStringId GetUCI_TypeName() { return #UCI_MESSAGE_TYPE; } \
315DEFINE_UCI_MESSAGE_TYPE(UCI_AMTI_CapabilityMessage, AMTI_Capability, UCI_AMTI_CAPABILITY_MESSAGE, aMTI_CapabilityMT)
316DEFINE_UCI_MESSAGE_TYPE(UCI_AMTI_CapabilityStatusMessage, AMTI_CapabilityStatus, UCI_AMTI_CAPABILITY_STATUS_MESSAGE, aMTI_CapabilityStatusMT)
318DEFINE_UCI_MESSAGE_TYPE(UCI_AMTI_CommandStatusMessage, AMTI_CommandStatus, UCI_AMTI_COMMAND_STATUS_MESSAGE, aMTI_CommandStatusMT)
319DEFINE_UCI_MESSAGE_TYPE(UCI_AMTI_SettingsCommandMessage, AMTI_SettingsCommand, UCI_AMTI_SETTINGS_COMMAND_MESSAGE, aMTI_SettingsCommandMT)
320DEFINE_UCI_MESSAGE_TYPE(UCI_AMTI_SettingsCommandStatusMessage, AMTI_SettingsCommandStatus, UCI_AMTI_SETTINGS_COMMAND_STATUS_MESSAGE, aMTI_SettingsCommandStatusMT)
321DEFINE_UCI_MESSAGE_TYPE(UCI_ControlRequestMessage, ControlRequest, UCI_CONTROL_REQUEST_MESSAGE, controlRequestMT)
322DEFINE_UCI_MESSAGE_TYPE(UCI_ControlRequestStatusMessage, ControlRequestStatus, UCI_CONTROL_REQUEST_STATUS_MESSAGE, controlRequestStatusMT)
328DEFINE_UCI_MESSAGE_TYPE(UCI_ESM_CapabilityMessage, ESM_Capability, UCI_ESM_CAPABILITY_MESSAGE, eSM_CapabilityMT)
329DEFINE_UCI_MESSAGE_TYPE(UCI_ESM_CapabilityStatusMessage, ESM_CapabilityStatus, UCI_ESM_CAPABILITY_STATUS_MESSAGE, eSM_CapabilityStatusMT)
331DEFINE_UCI_MESSAGE_TYPE(UCI_ESM_CommandStatusMessage, ESM_CommandStatus, UCI_ESM_COMMAND_STATUS_MESSAGE, eSM_CommandStatusMT)
332DEFINE_UCI_MESSAGE_TYPE(UCI_ESM_SettingsCommandMessage, ESM_SettingsCommand, UCI_ESM_SETTINGS_COMMAND_MESSAGE, eSM_SettingsCommandMT)
333DEFINE_UCI_MESSAGE_TYPE(UCI_ESM_SettingsCommandStatusMessage, ESM_SettingsCommandStatus, UCI_ESM_SETTINGS_COMMAND_STATUS_MESSAGE, eSM_SettingsCommandStatusMT)
335DEFINE_UCI_MESSAGE_TYPE(UCI_POST_CapabilityMessage, POST_Capability, UCI_POST_CAPABILITY_MESSAGE, pOST_CapabilityMT)
336DEFINE_UCI_MESSAGE_TYPE(UCI_POST_CapabilityStatusMessage, POST_CapabilityStatus, UCI_POST_CAPABILITY_STATUS_MESSAGE, pOST_CapabilityStatusMT)
338DEFINE_UCI_MESSAGE_TYPE(UCI_POST_CommandStatusMessage, POST_CommandStatus, UCI_POST_COMMAND_STATUS_MESSASGE, pOST_CommandStatusMT)
339DEFINE_UCI_MESSAGE_TYPE(UCI_POST_SettingsCommandMessage, POST_SettingsCommand, UCI_POST_SETTINGS_COMMAND_MESSAGE, pOST_SettingsCommandMT)
340DEFINE_UCI_MESSAGE_TYPE(UCI_POST_SettingsCommandStatusMessage, POST_SettingsCommandStatus, UCI_POST_SETTINGS_COMMAND_STATUS_MESSAGE, pOST_SettingsCommandStatusMT)
346DEFINE_UCI_MESSAGE_TYPE(UCI_StrikeActivityMessage, StrikeActivity, UCI_STRIKE_ACTIVITY_MESSAGE, strikeActivityMT)
347DEFINE_UCI_MESSAGE_TYPE(UCI_StrikeCapabilityMessage, StrikeCapability, UCI_STRIKE_CAPABILITY_MESSAGE, strikeCapabilityMT)
348DEFINE_UCI_MESSAGE_TYPE(UCI_StrikeCapabilityStatusMessage, StrikeCapabilityStatus, UCI_STRIKE_CAPABILITY_STATUS_MESSAGE, strikeCapabilityStatusMT)
350DEFINE_UCI_MESSAGE_TYPE(UCI_StrikeCommandStatusMessage, StrikeCommandStatus, UCI_STRIKE_COMMAND_STATUS_MESSAGE, strikeCommandStatusMT)
351DEFINE_UCI_MESSAGE_TYPE(UCI_SubsystemStatusMessage, SubsystemStatus, UCI_SUBSYSTEM_STATUS_MESSAGE, subsystemStatusMT)
#define DEFINE_UCI_MESSAGE_TYPE(WSF_MESSAGE_TYPE, UCI_MESSAGE_TYPE, WSF_TYPE_NAME, UCI_ACCESSOR_NAME)
Definition WsfUCI_Messages.hpp:283
WsfMessage(WsfStringId aType)
Constructor for XIO (de)serialization.
Definition WsfMessage.cpp:25
WsfSimulation * GetSimulation() const
Get the simulation that owns the message.
Definition WsfMessage.hpp:55
The OMS / UCI Interface Object to the UCI middleware.
Definition WsfUCI_Interface.hpp:118
void GetTypeFactory(uci::base::accessorType::AccessorType aType, const T *&aFactoryPtr)
Definition WsfUCI_Interface.hpp:187
void GetMessageService(uci::base::accessorType::AccessorType aType, const T *&aServicePtr)
Definition WsfUCI_Interface.hpp:174
void PopulateHeader(const uci::type::DateTimeTypeValue &aSimTime, uci::type::HeaderType &aHeader)
Definition WsfUCI_Interface.cpp:269
UCI_MessageBaseType(WsfSimulation &aSimulation, UCI_Interface &aInterface)
Definition WsfUCI_MessageBaseType.hpp:30
UCI_Interface & GetInterface() const
Get the underlying UCI type.
Definition WsfUCI_MessageBaseType.hpp:43
UCI_MessageType(WsfPlatform *aPlatformPtr)
Definition WsfUCI_Messages.hpp:184
const uci::type::HeaderType * GetHeader() const override
Definition WsfUCI_Messages.hpp:165
static uci::base::accessorType::AccessorType GetUCI_TypeId()
Definition WsfUCI_Messages.hpp:158
~UCI_MessageType() override
Definition WsfUCI_Messages.hpp:222
Type & Get() const
Get the underlying UCI type.
Definition WsfUCI_Messages.hpp:161
void Send(const uci::type::DateTimeTypeValue &aSimTime) const override
Send this message using the writer. This method calls PopulateHeader before sending.
Definition WsfUCI_Messages.hpp:228
WsfMessage * Clone() const override
Definition WsfUCI_Messages.hpp:152
Type
Definition P6DofVehicleData.hpp:182
Definition WsfUCI_Utils.cpp:29
uci::type::DateTimeTypeValue GetTimeStamp(WsfSimulation &aSimulation, double aSimTime)
Definition WsfUCI_Utils.cpp:159
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32