WSF
WsfTask.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 WSFTASK_HPP
13#define WSFTASK_HPP
14
15#include "wsf_export.h"
16
17#include "UtScriptAccessible.hpp"
18#include "UtScriptBasicTypes.hpp"
19#include "UtScriptClass.hpp"
20#include "UtScriptTypes.hpp"
21class WsfPlatform;
22class WsfProcessor;
23#include "WsfTaskData.hpp"
25
27class WSF_EXPORT WsfTask : public UtScriptAccessible, public WsfTaskData
28{
29public:
31 WsfTask(const WsfTask& aSrc)
32 : WsfTaskData(aSrc)
33 {
34 }
35 WsfTask(const WsfTaskResource& aTaskResource)
36 : WsfTaskData(aTaskResource)
37 {
38 }
40 {
42 return *this;
43 }
44
45 ~WsfTask() override = default;
46
47 bool operator==(const WsfTask& aRhs) const
48 {
50 }
51
52 bool operator!=(const WsfTask& aRhs) const { return !operator==(aRhs); }
53
54 const char* GetScriptClassName() const override { return "WsfTask"; }
55 static void RegisterScriptTypes(UtScriptTypes* aScriptTypesPtr);
56
57 // static UtScriptClass* CreateScriptClass(const std::string& aClassName,
58 // UtScriptTypes* aScriptTypesPtr);
59
60 void Initialize(double aSimTime, unsigned long aTaskId, WsfProcessor* aAssignerPtr);
61
63 unsigned int GetTaskId() const { return mTaskId; }
64
65 const WsfTrackId& GetTrackId() const { return mTrackId; }
66 void SetTrackId(const WsfTrackId& aTrackId) { mTrackId = aTrackId; }
67
68 const WsfTrackId& GetLocalTrackId() const { return mLocalTrackId; }
69 void SetLocalTrackId(const WsfTrackId& aLocalTrackId) { mLocalTrackId = aLocalTrackId; }
70
71 WsfStringId GetTaskType() const { return mTaskType; }
72 void SetTaskType(WsfStringId aTaskType) { mTaskType = aTaskType; }
73
77
79 void SetTargetName(WsfStringId aTargetName) { mTargetName = aTargetName; }
80
82
83 void SetAssigner(const WsfTask& aTask);
84
89
91
92 void SetAssignee(WsfPlatform* aAssigneePtr);
93
97 void SetAssigneeProcessorName(WsfStringId aAssigneeProcessorName)
98 {
99 mAssigneeProcessorName = aAssigneeProcessorName;
100 }
101
102
103
105
107 const WsfTaskResource& GetResource() const { return *mResourcePtr; }
108 void SetResource(const WsfTaskResource& aResource);
109
110 WsfStringId GetResourceName() const { return GetResource().mNameId; }
111 void SetResourceName(WsfStringId aResourceName) { GetResource().mNameId = aResourceName; }
112
113 int GetResourceType() const { return GetResource().GetType(); }
114
115 bool IsResourceTypeOf(const int aResourceType) const { return GetResourceType() == aResourceType; };
116
117 WsfStringId GetResourceMode() const { return GetResource().mModeNameId; }
118 void SetResourceMode(WsfStringId aResourceMode) { GetResource().mModeNameId = aResourceMode; }
120
124
126 void SetCommName(WsfStringId aCommName) { mCommName = aCommName; }
128
131
132 void SetUpdateTime(double aUpdateTime) { mUpdateTime = aUpdateTime; }
133 double GetUpdateTime() const { return mUpdateTime; }
135
138
139 void SetAssignTime(double aAssignTime) { mAssignTime = aAssignTime; }
140 double GetAssignTime() const { return mAssignTime; }
142
145
146 void SetStatus(WsfStringId aStatusId) { mTaskStatus = aStatusId; }
149
152
153 void SetSubStatus(WsfStringId aSubStatusId) { mTaskSubStatus = aSubStatusId; }
156
157
160
161
163 int GetObjectsPending() const { return mObjectsPending; }
164
166 void SetObjectsPending(int aObjectsPending) { mObjectsPending = aObjectsPending; }
168
169 void SetAssignerPlatformIndex(size_t aIndex) { mAssignerPlatformIndex = aIndex; }
170 void SetAssigneePlatformIndex(size_t aIndex) { mAssigneePlatformIndex = aIndex; }
171};
172
174class WSF_EXPORT WsfScriptTaskClass : public UtScriptClass
175{
176public:
177 WsfScriptTaskClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
178
179 std::string ToString(void* /*aObjectPtr*/) const override;
180
181 void Destroy(void* aTaskPtr) override { delete (static_cast<WsfTask*>(aTaskPtr)); }
182
183 void* Clone(void* aTaskPtr) override { return new WsfTask(*static_cast<WsfTask*>(aTaskPtr)); }
184
185 void OnNewScriptRef(UtScriptRef& aReference) override;
186
188
198 UT_DECLARE_SCRIPT_METHOD(ResourceIsSensor);
199 UT_DECLARE_SCRIPT_METHOD(ResourceIsProcessor);
202 UT_DECLARE_SCRIPT_METHOD(ResourceFrequency);
203 UT_DECLARE_SCRIPT_METHOD(ResourceBandwidth);
208 UT_DECLARE_SCRIPT_METHOD(TimeSinceAssigned);
209 UT_DECLARE_SCRIPT_METHOD(TimeSinceUpdated);
210
215
217};
218
219#endif
#define UT_DECLARE_AUX_DATA_SCRIPT_METHODS()
Definition WsfScriptAuxDataUtil.hpp:194
bool operator==(int aId, const WsfStringInt &aRhs)
Equal relational operator for the case of an integer on the LHS and a StringId on the RHS.
Definition WsfStringId.hpp:69
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfProcessor.hpp:39
void Destroy(void *aTaskPtr) override
Definition WsfTask.hpp:181
UT_DECLARE_SCRIPT_METHOD(ResourceName)
UT_DECLARE_SCRIPT_METHOD(Status)
UT_DECLARE_SCRIPT_METHOD(TimeSinceAssigned)
UT_DECLARE_SCRIPT_METHOD(Assigner)
UT_DECLARE_SCRIPT_METHOD(ResourceIsSensor)
void * Clone(void *aTaskPtr) override
Definition WsfTask.hpp:183
UT_DECLARE_SCRIPT_METHOD(ResourceBandwidth)
UT_DECLARE_SCRIPT_METHOD(ResourceFrequency)
UT_DECLARE_SCRIPT_METHOD(SetCommDevice)
std::string ToString(void *) const override
Definition WsfTask.cpp:179
UT_DECLARE_SCRIPT_METHOD(AssignerName)
UT_DECLARE_SCRIPT_METHOD(LocalTrackId)
UT_DECLARE_SCRIPT_METHOD(ResourceCount)
UT_DECLARE_SCRIPT_METHOD(Create)
UT_DECLARE_SCRIPT_METHOD(TimeSinceUpdated)
UT_DECLARE_SCRIPT_METHOD(SetTaskType)
UT_DECLARE_SCRIPT_METHOD(SetAssignee_2)
UT_DECLARE_SCRIPT_METHOD(SubStatus)
UT_DECLARE_SCRIPT_METHOD(SetAssignee_1)
UT_DECLARE_SCRIPT_METHOD(TrackId)
UT_DECLARE_SCRIPT_METHOD(ResourceMode)
UT_DECLARE_SCRIPT_METHOD(Assignee)
UT_DECLARE_SCRIPT_METHOD(AssigneeName)
WsfScriptTaskClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfTask.cpp:144
UT_DECLARE_SCRIPT_METHOD(TimeAssigned)
UT_DECLARE_SCRIPT_METHOD(TaskType)
UT_DECLARE_SCRIPT_METHOD(TaskId)
UT_DECLARE_SCRIPT_METHOD(TimeUpdated)
UT_DECLARE_SCRIPT_METHOD(ResourceIsProcessor)
WsfTaskResource * mResourcePtr
Attributes of the assigned resource.
Definition WsfTaskData.hpp:77
WsfTaskData()
Definition WsfTaskData.cpp:16
WsfStringId mTaskSubStatus
Task sub status reported by assignee. (User Defined).
Definition WsfTaskData.hpp:96
WsfStringId mCommName
Definition WsfTaskData.hpp:81
double mAssignTime
The simulation time when the assignment was made.
Definition WsfTaskData.hpp:84
WsfStringId mTaskStatus
Task status.
Definition WsfTaskData.hpp:93
WsfStringId mTaskType
The task type (string ID).
Definition WsfTaskData.hpp:53
WsfTrackId mTrackId
Definition WsfTaskData.hpp:44
WsfStringId mAssigneePlatformName
The name of the assigned platform (string ID).
Definition WsfTaskData.hpp:68
double mUpdateTime
The simulation time when an update was last sent or received.
Definition WsfTaskData.hpp:87
WsfStringId mTargetName
The name of the target (string ID) IF it is known.
Definition WsfTaskData.hpp:56
unsigned int mTaskId
The serial number of the task.
Definition WsfTaskData.hpp:40
WsfTaskData & operator=(const WsfTaskData &aRhs)
Definition WsfTaskData.cpp:74
int mObjectsPending
The number of objects that are pending (requested but not yet in operation).
Definition WsfTaskData.hpp:90
size_t mAssigneePlatformIndex
The platform index of the assigned platform.
Definition WsfTaskData.hpp:71
WsfStringId mAssignerProcessorName
The name of the processor on the assigning platform (string ID).
Definition WsfTaskData.hpp:65
WsfStringId mAssigneeProcessorName
The name of the processor on the assigned platform (string ID).
Definition WsfTaskData.hpp:74
WsfStringId mAssignerPlatformName
The name of the assigning platform (string ID).
Definition WsfTaskData.hpp:59
size_t mAssignerPlatformIndex
The platform index of the assigning platform.
Definition WsfTaskData.hpp:62
WsfTrackId mLocalTrackId
Definition WsfTaskData.hpp:50
Attributes of a task-able resource.
Definition WsfTaskResource.hpp:30
A class that defines a task to be performed.
Definition WsfTask.hpp:28
size_t GetAssignerPlatformIndex() const
Definition WsfTask.hpp:86
void SetSubStatus(WsfStringId aSubStatusId)
Definition WsfTask.hpp:153
WsfTask(const WsfTaskResource &aTaskResource)
Definition WsfTask.hpp:35
const char * GetScriptClassName() const override
Definition WsfTask.hpp:54
WsfTask(const WsfTask &aSrc)
Definition WsfTask.hpp:31
void SetAssigneePlatformIndex(size_t aIndex)
Definition WsfTask.hpp:170
WsfStringId GetAssignerProcessorName() const
Definition WsfTask.hpp:87
void SetResourceMode(WsfStringId aResourceMode)
Definition WsfTask.hpp:118
WsfStringId GetResourceMode() const
Definition WsfTask.hpp:117
const WsfTaskResource & GetResource() const
Definition WsfTask.hpp:107
void SetTargetName(WsfStringId aTargetName)
Set the name of the target.
Definition WsfTask.hpp:79
int GetObjectsPending() const
Return the number of objects that have been assigned but not yet in operation.
Definition WsfTask.hpp:163
const WsfTrackId & GetLocalTrackId() const
Definition WsfTask.hpp:68
double GetUpdateTime() const
Definition WsfTask.hpp:133
bool operator==(const WsfTask &aRhs) const
Definition WsfTask.hpp:47
void SetAssignTime(double aAssignTime)
Definition WsfTask.hpp:139
WsfStringId GetAssigneePlatformName() const
Definition WsfTask.hpp:94
size_t GetAssigneePlatformIndex() const
Definition WsfTask.hpp:95
WsfStringId GetAssignerPlatformName() const
Definition WsfTask.hpp:85
WsfStringId GetAssigneeProcessorName() const
Definition WsfTask.hpp:96
void SetAssigneeProcessorName(WsfStringId aAssigneeProcessorName)
Definition WsfTask.hpp:97
void SetUpdateTime(double aUpdateTime)
Definition WsfTask.hpp:132
WsfStringId GetStatus() const
Definition WsfTask.hpp:147
WsfStringId GetCommName() const
Definition WsfTask.hpp:125
void SetAssignerPlatformIndex(size_t aIndex)
Definition WsfTask.hpp:169
void SetStatus(WsfStringId aStatusId)
Definition WsfTask.hpp:146
void SetObjectsPending(int aObjectsPending)
Set the number of objects that have been assigned but not yet in operation.
Definition WsfTask.hpp:166
WsfStringId GetTargetName() const
Definition WsfTask.hpp:76
int GetResourceType() const
Definition WsfTask.hpp:113
void SetLocalTrackId(const WsfTrackId &aLocalTrackId)
Definition WsfTask.hpp:69
void SetResourceName(WsfStringId aResourceName)
Definition WsfTask.hpp:111
WsfTask & operator=(const WsfTask &aRhs)
Definition WsfTask.hpp:39
void SetCommName(WsfStringId aCommName)
Definition WsfTask.hpp:126
WsfTaskResource & GetResource()
Definition WsfTask.hpp:106
WsfStringId GetTaskType() const
Definition WsfTask.hpp:71
bool operator!=(const WsfTask &aRhs) const
Definition WsfTask.hpp:52
WsfStringId GetResourceName() const
Definition WsfTask.hpp:110
unsigned int GetTaskId() const
Return the task ID assigned to the task.
Definition WsfTask.hpp:63
void SetTaskType(WsfStringId aTaskType)
Definition WsfTask.hpp:72
const WsfTrackId & GetTrackId() const
Definition WsfTask.hpp:65
double GetAssignTime() const
Definition WsfTask.hpp:140
WsfStringId GetSubStatus() const
Definition WsfTask.hpp:154
WsfTask()
Definition WsfTask.hpp:30
bool IsResourceTypeOf(const int aResourceType) const
Definition WsfTask.hpp:115
void SetTrackId(const WsfTrackId &aTrackId)
Definition WsfTask.hpp:66
~WsfTask() override=default
Definition WsfTrackId.hpp:33
Copyrights Multiple, All Rights Reserved