-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathJScript.Example1.EngineModel.js
283 lines (237 loc) · 5.93 KB
/
JScript.Example1.EngineModel.js
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//=====================================================
// Copyright 2005-2011, Analytical Graphics, Inc.
//=====================================================
//===========================================
// AgEAttrAddFlags Enumeration
//===========================================
var eFlagNone = 0;
var eFlagTransparent = 2;
var eFlagHidden = 4;
var eFlagTransient = 8;
var eFlagReadOnly = 16;
var eFlagFixed = 32;
//==========================================
// AgELogMsgType Enumeration
//==========================================
var eLogMsgDebug = 0;
var eLogMsgInfo = 1;
var eLogMsgForceInfo = 2;
var eLogMsgWarning = 3;
var eLogMsgAlarm = 4;
//==========================================
// AgEUtTimeScale Enumeration
//==========================================
var eUTC = 0;
var eTAI = 1;
var eTDT = 2;
var eUT1 = 3;
var eSTKEpochSec = 4;
var eTDB = 5;
var eGPS = 6;
//==========================================
// Declare Global Variables
//==========================================
var m_AgUtPluginSite = null;
var m_AgAttrScope = null;
var m_InitTime = 0.0;
//======================================
// Declare Global 'Attribute' Variables
//======================================
var m_Name = "JScript.Example1.EngineModel.wsc"
var m_T0 = 0;
var m_T1 = 0.0001;
var m_T2 = 0.0000001;
var m_Ts = 0;
var m_Tc = 0;
var m_Isp = 3000;
var m_gatorPrv = null;
var m_argOfLat = null;
//=======================
// GetPluginConfig method
//=======================
function GetPluginConfig( AgAttrBuilder )
{
if( m_AgAttrScope == null )
{
m_AgAttrScope = AgAttrBuilder.NewScope();
//===========================
// General Plugin attributes
//===========================
AgAttrBuilder.AddStringDispatchProperty( m_AgAttrScope, "PluginName", "Human readable plugin name or alias", "Name", eFlagReadOnly );
//===========================
// Propagation related
//===========================
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "T0", "Initial Thrust", "T0", 0 );
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "T1", "Linear Thrust Coefficient", "T1", 0 );
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "T2", "Quadratic Thrust Coefficient", "T2", 0 );
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "Ts", "Sine Thrust Coefficient", "TS", 0 );
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "Tc", "Cosine Thrust Coefficient", "TC", 0 );
AgAttrBuilder.AddDoubleDispatchProperty ( m_AgAttrScope, "Isp", "Specific Impulse", "ISP", 0 );
}
return m_AgAttrScope;
}
//===========================
// VerifyPluginConfig method
//===========================
function VerifyPluginConfig(AgUtPluginConfigVerifyResult)
{
var Result = true;
var Message = "Ok";
//TODO: Add Yaw and Pitch Maximum and Minimum Checks here
AgUtPluginConfigVerifyResult.Result = Result;
AgUtPluginConfigVerifyResult.Message = Message;
}
//===========================
// Message method
//===========================
function Message( msgType, msg )
{
if( m_AgUtPluginSite != null)
{
m_AgUtPluginSite.Message( msgType, msg );
}
}
//======================
// Init Method
//======================
function Init( AgUtPluginSite )
{
m_AgUtPluginSite = AgUtPluginSite;
if (m_AgUtPluginSite != null)
{
m_gatorPrv = m_AgUtPluginSite.GatorProvider;
if (m_gatorPrv != null)
{
m_argOfLat = m_gatorPrv.ConfigureCalcObject("Argument_of_Latitude");
if (m_argOfLat != null)
{
return true;
}
}
}
return false;
}
//======================
// PrePropagate Method
//======================
function PrePropagate(AgGatorPluginResultState)
{
if (AgGatorPluginResultState != null)
{
var vbArrayTimes = AgGatorPluginResultState.DayCount_Array(eSTKEpochSec);
var jsArrayTimes = vbArrayTimes.toArray();
m_InitTime = jsArrayTimes[0] * 86400.0 + jsArrayTimes[1];
}
return true;
}
//======================
// PreNextStep Function
//======================
function PreNextStep(AgGatorPluginResultState)
{
return true;
}
//=================
// Evaluate Method
//=================
function Evaluate( AgGatorPluginResultEvalEngineModel )
{
if( AgGatorPluginResultEvalEngineModel != null )
{
var time = 0.0;
var thrust = 0.0;
var deltaT = 0.0;
var argOfLat = 0.0;
var vbArrayTimes = AgGatorPluginResultEvalEngineModel.DayCount_Array( eSTKEpochSec );
var jsArrayTimes = vbArrayTimes.toArray();
time = jsArrayTimes[0] * 86400.0 + jsArrayTimes[1];
deltaT = time - m_InitTime;
argOfLat = m_argOfLat.Evaluate(AgGatorPluginResultEvalEngineModel);
thrust = m_T0 + ( m_T1 * deltaT ) + ( m_T2 * deltaT * deltaT ) + ( m_Ts * Math.sin(argOfLat) ) + ( m_Tc * Math.cos(argOfLat) );
AgGatorPluginResultEvalEngineModel.SetThrustAndIsp( thrust , m_Isp);
}
return true;
}
//=================
// Free Method
//=================
function Free()
{
// do nothing
}
//==================
// Name property
//==================
function GetName()
{
return m_Name;
}
//==================
// T0 property
//==================
function GetT0()
{
return m_T0;
}
function SetT0( val )
{
m_T0 = val;
}
//=================
// T1 property
//==================
function GetT1()
{
return m_T1;
}
function SetT1( val )
{
m_T1 = val;
}
//==================
// T2 property
//==================
function GetT2()
{
return m_T2;
}
function SetT2( val )
{
m_T2 = val;
}
//==================
// TS property
//==================
function GetTS()
{
return m_Ts;
}
function SetTS( val )
{
m_Ts = val;
}
//==================
// TC property
//==================
function GetTC()
{
return m_Tc;
}
function SetTC( val )
{
m_Tc = val;
}
//==================
// Isp property
//==================
function GetISP()
{
return m_Isp;
}
function SetISP( val )
{
m_Isp = val;
}
//=====================================================
// Copyright 2005-2011, Analytical Graphics, Inc.
//=====================================================