-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathVBScript.ConstantThrustRate.EngineModel.vbs
258 lines (184 loc) · 5.66 KB
/
VBScript.ConstantThrustRate.EngineModel.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
'======================================================
' Copyright 2012, Analytical Graphics, Inc.
' =====================================================
'===========================================
' AgEAttrAddFlags Enumeration
'===========================================
Dim eFlagNone, eFlagTransparent, eFlagHidden, eFlagTransient, eFlagReadOnly, eFlagFixed
eFlagNone = 0
eFlagTransparent = 2
eFlagHidden = 4
eFlagTransient = 8
eFlagReadOnly = 16
eFlagFixed = 32
'==================================
' Log Msg Type Enumeration
'==================================
Dim eLogMsgDebug, eLogMsgInfo, eLogMsgForceInfo, eLogMsgWarning, eLogMsgAlarm
eLogMsgDebug = 0
eLogMsgInfo = 1
eLogMsgForceInfo = 2
eLogMsgWarning = 3
eLogMsgAlarm = 4
'==========================================
' AgETimeScale
'==========================================
Dim eSTKEpochSec
eSTKEpochSec = 4
'================================
' Declare Global Variables
'================================
Dim m_AgUtPluginSite
Dim m_AgAttrScope
Dim m_InitTime
Dim m_gatorPrv
Dim m_argOfLat
Set m_AgUtPluginSite = Nothing
Set m_AgAttrScope = Nothing
Set m_gatorPrv = Nothing
Set m_argOfLat = Nothing
'======================================
' Declare Global 'Attribute' Variables
'======================================
Dim m_Name
Dim m_Thrust
Dim m_ThrustRate
Dim m_MassFlowRate
m_Name = "VBScript.ConstantThrustRate.EngineModel.wsc"
m_Thrust = 1000 'N
m_ThrustRate = 5 'N/s
m_MassFlowRate = 10 'kg/sec
'=======================
' GetPluginConfig method
'=======================
Function GetPluginConfig( AgAttrBuilder )
If( m_AgAttrScope is Nothing ) Then
'MsgBox "here1"
Set m_AgAttrScope = AgAttrBuilder.NewScope()
'MsgBox "here2"
'===========================
' General Plugin attributes
'===========================
Call AgAttrBuilder.AddStringDispatchProperty( m_AgAttrScope, "PluginName", "Human readable plugin name or alias", "Name", eFlagReadOnly )
'MsgBox "here3"
'===========================
' Propagation related
'===========================
Call AgAttrBuilder.AddQuantityDispatchProperty2 ( m_AgAttrScope, "Thrust", "Initial Thrust", "Thrust", "ForceUnit", "Newtons", "Newtons", 0 )
Call AgAttrBuilder.AddQuantityDispatchProperty2 ( m_AgAttrScope, "ThrustRate", "Thrust Rate (per sec)", "ThrustRate", "ForceUnit", "Newtons", "Newtons", 0 )
Call AgAttrBuilder.AddQuantityDispatchProperty2 ( m_AgAttrScope, "MassFlowRate", "Mass Flow Rate (kg/sec)", "MassFlowRate", "MassUnit", "Kilograms", "Kilograms", 0 )
End If
Set GetPluginConfig = m_AgAttrScope
End Function
'===========================
' VerifyPluginConfig method
'===========================
Function VerifyPluginConfig(AgUtPluginConfigVerifyResult)
Dim Result
Dim Message
Result = true
Message = "Ok"
AgUtPluginConfigVerifyResult.Result = Result
AgUtPluginConfigVerifyResult.Message = Message
End Function
'===========================
' Message method
'===========================
Sub Message( msgType, msg )
If( Not m_AgUtPluginSite is Nothing) then
Call m_AgUtPluginSite.Message( msgType, msg )
End If
End Sub
'======================
' Init Method
'======================
Function Init( AgUtPluginSite )
Init = 1
End Function
'======================
' PrePropagate Method
'======================
Function PrePropagate( AgGatorPluginResultEvalEngineModel )
If( Not AgGatorPluginResultEvalEngineModel is Nothing) then
Dim dcArray
dcArray = AgGatorPluginResultEvalEngineModel.DayCount_Array( eStkEpochSec )
If(IsArray(dcArray) and UBound(dcArray) > 0) Then
m_InitTime = dcArray(0) * 86400.0 + dcArray(1)
End If
End If
PrePropagate = 1
End Function
'======================
' PreNextStep Function
'======================
Function PreNextStep( AgGatorPluginResultEvalEngineModel )
PreNextStep = 1
End Function
'=================
' Evaluate Method
'=================
Function Evaluate( AgGatorPluginResultEvalEngineModel )
If( Not AgGatorPluginResultEvalEngineModel is Nothing) then
Dim time
Dim Thrust
Dim deltaT
Dim dcArray
time = m_InitTime
dcArray = AgGatorPluginResultEvalEngineModel.DayCount_Array( eStkEpochSec )
If(IsArray(dcArray) and UBound(dcArray) > 0) Then
time = dcArray(0) * 86400.0 + dcArray(1)
End If
deltaT = time - m_InitTime
Thrust = m_Thrust + m_ThrustRate * deltaT
Call AgGatorPluginResultEvalEngineModel.SetThrustAndMassFlowRate(Thrust, m_MassFlowRate)
End If
Evaluate = 1
End Function
'======================
' PostPropagate Method
'======================
Function PostPropagate(resultInterface)
PostPropagate = 0
End Function
'=================
' Free Method
'=================
Sub Free()
' do nothing
End Sub
'==================
' Name property
'==================
Function GetName()
GetName = m_Name
End function
'==================
' Thrust property
'==================
Function GetThrust()
GetThrust = m_Thrust
End Function
Function SetThrust( thrust )
m_Thrust = thrust
End Function
'==================
' ThrustRate property
'==================
Function GetThrustRate()
GetThrustRate = m_ThrustRate
End Function
Function SetThrustRate( thrustRate )
m_ThrustRate = thrustRate
End Function
'==================
' MassFlowRate property
'==================
Function GetMassFlowRate()
GetMassFlowRate = m_MassFlowRate
End Function
Function SetMassFlowRate( massFlowRate )
m_MassFlowRate = massFlowRate
End Function
'======================================================
' Copyright 2012, Analytical Graphics, Inc.
' =====================================================