-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTrkData.CustomErrors.OD6.wsc
383 lines (272 loc) · 11.3 KB
/
TrkData.CustomErrors.OD6.wsc
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<?xml version="1.0"?>
<!-- ====================================================== -->
<!-- This ODTK reader reads measurements in a custom format -->
<!-- and then allows the user to add custom noise -->
<!-- -->
<!-- to create measurements in the expected format, run -->
<!-- the simulator with NoDeviations = true. Then export -->
<!-- the measurements in a custom export style that -->
<!-- consists of comma delimited values of -->
<!-- - MeasurementHistory.Date Time -->
<!-- - MeasurementHistory.TrackerID -->
<!-- - MeasurementHistory.SatelliteID -->
<!-- - MeasurementHistory.Measurement Type -->
<!-- - MeasurementHistory.Value -->
<!-- - MeasurementHistory.Measurement Units -->
<!-- - MeasurementHistory.WN -->
<!-- -->
<!-- author: jens ramrath -->
<!-- date: 18 feb 2019 -->
<!-- ====================================================== -->
<component>
<?component error="true" debug="true"?>
<registration
description="SHAR Format"
progid="TrkData.CustomErrors.OD6.wsc"
version="1.00"
classid="{C119D27B-8609-4E19-A061-470EEE7F5A7D}"
>
</registration>
<public>
<!-- Properties -->
<property name="FileName">
<get internalName="GetFileName"/>
</property>
<property name="SupportsMultipleTrackers">
<get internalName="GetSupportsMultipleTrackers"/>
</property>
<property name="SupportsSave">
<get internalName="GetSupportsSave"/>
</property>
<!-- Methods -->
<method name="Reset"/>
<method name="OpenFile">
<parameter name="newVal"/>
<parameter name="newFile"/>
</method>
<method name="CloseFile"/>
<method name="GetObsSet">
<parameter name="setCollection"/>
</method>
<method name="GetSupportedObsSet">
<parameter name="setColl"/>
</method>
<method name="SaveObs">
<parameter name="pEnum"/>
<parameter name="bAppend"/>
</method>
<method name="GetRegKey"/>
</public>
<script language="VBScript">
<![CDATA[
'-------------------------------------------------------------------------
' Member variables
'-------------------------------------------------------------------------
Option explicit
Dim dict
Set dict = CreateObject("Scripting.Dictionary")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim measDict
Set measDict = CreateObject("Scripting.Dictionary")
measDict.Add "Range", 1
measDict.Add "Doppler", 2
measDict.Add "Azimuth", 11
measDict.Add "Elevation", 12
measDict.Add "Right Ascension", 18
measDict.Add "Declination", 19
measDict.Add "SB Right Ascension", 31
measDict.Add "SB Declination", 32
measDict.Add "SB Range", 33
measDict.Add "SB Azimuth", 34
measDict.Add "SB Elevation", 35
measDict.Add "SB Doppler", 36
Const eGroundReceiveTime = 0
Const eSatelliteTransmitTime = 1
Const eGroundTransmitTime = 2
Const eSatelliteReceiveTime = 3
'-------------------------------------------------------------------------
' define some global variables we'll be using
'-------------------------------------------------------------------------
Dim m_sfileSysObj, m_Stream, m_sFileName, trackerID, targetID, measType, measValue, measUnit, measWN
Set m_sfileSysObj = CreateObject("Scripting.FileSystemObject")
m_sFileName = ""
'-------------------------------------------------------------------------
' Create obsSet and obs objects for use later on
'-------------------------------------------------------------------------
Dim version
version = "6.0"
Dim textFile, ObjectStr, versionStr, regValue, ODDBObjectFile
versionStr = "HKEY_LOCAL_MACHINE\SOFTWARE\AGI\ODTK\" & version & "\InstallHome"
GetRegKey(versionStr)
ODDBObjectFile = m_sfileSysObj.Buildpath(regValue, "\ODTK\AppData\Scripts\MeasProviders\WindowsScriptComponents\" & "CreatODDBObjects.txt")
Set textFile = m_sfileSysObj.OpenTextFile(ODDBObjectFile, ForReading)
Dim pObsSet
ObjectStr = textFile.ReadLine ' ObjectStr = "AgMach10_5.AgODObsSet" or similar
Set pObsSet = CreateObject(ObjectStr)
Dim pObs
ObjectStr = textFile.ReadLine ' ObjectStr = "IAgODProvideTrackingData5.AgODGenericObs" or similar
Set pObs = CreateObject(ObjectStr)
'-------------------------------------------------------------------------
' Function GetFileName()
'-------------------------------------------------------------------------
Function GetFileName()
GetFileName = m_sFileName
End Function
'-------------------------------------------------------------------------
' SupportsSave property [read-only]
'-------------------------------------------------------------------------
Function GetSupportsSave()
GetSupportsSave = False
End Function
'-------------------------------------------------------------------------
' SupportsMultipleTrackers property [read-only]
'-------------------------------------------------------------------------
Function GetSupportsMultipleTrackers()
GetSupportsMultipleTrackers = True
End Function
'-------------------------------------------------------------------------
' Reset method
'-------------------------------------------------------------------------
Function Reset()
if m_sFileName <> "" Then
Dim newVal
newVal = m_sFileName
OpenFile newVal, False
End if
End Function
'-------------------------------------------------------------------------
' OpenFile method
'-------------------------------------------------------------------------
Function OpenFile(newVal, newFile)
dim line
If m_sFileName <> "" Then
m_Stream.Close
m_sFileName = ""
End If
m_sFileName = newVal
If newFile Then
Set m_Stream = m_sfileSysObj.OpenTextFile(m_sFileName, ForWriting, True)
Else
Set m_Stream = m_sfileSysObj.OpenTextFile(m_sFileName, ForReading)
'-------------------------------------------------------------------------
' Read header information to find the satellite ID
'-------------------------------------------------------------------------
' no header in this measurement type
End If
End Function
'-------------------------------------------------------------------------
' CloseFile method
'-------------------------------------------------------------------------
Function CloseFile()
If m_sFileName <> "" Then
m_Stream.Close
m_sFileName = ""
End If
End Function
'-------------------------------------------------------------------------
' GetObsSet method
'-------------------------------------------------------------------------
Function GetObsSet(setColl)
dim line, lineSplit, datetime, prevdatetime, obsval, station
dim groundequip, antenna, calstatus, numObsSets
Dim rg, az, el
prevdatetime = ""
pObsSet.Clear()
numObsSets = 0
' Note that we are going to process the entire file of data and return ALL
' measurements. We sort of have to because we need to be checking all the
' time tags to identify obs sets.
' Date Time,Tracker ID,Satellite ID,Measurement Type,Value,Measurement Units,WN
' 27 Oct 2018 14:00:00.000000, 3507, 1000,Range, 1.6356e+06,m, -0.264571
' 27 Oct 2018 14:00:00.000000, 3507, 1000,Doppler, -6004.49,m/sec, 3.65133
' 27 Oct 2018 14:00:00.000000, 3507, 1000,Azimuth, 337.418,deg, 0.0201678
' 27 Oct 2018 14:00:00.000000, 3507, 1000,Elevation, 10.2797,deg, 0.00471196
' 27 Oct 2018 14:01:00.000000, 3507, 1000,Range, 1.30038e+06,m, -0.527019
Do Until m_Stream.AtEndOfStream or numObsSets > 0
line = m_Stream.ReadLine
lineSplit = Split(line, ",")
' skip header and empty lines
if (UBound(lineSplit) = 6) AND NOT (lineSplit(0) = "Date Time") then
datetime = Trim(lineSplit(0))
trackerID = Trim(lineSplit(1))
targetID = Trim(lineSplit(2))
measType = Trim(lineSplit(3))
measValue = Trim(lineSplit(4))
measUnit = Trim(lineSplit(5))
measWN = Trim(lineSplit(6))
pObsSet.Clear()
pObsSet.Date.unit = "UTCG"
pObsSet.Date = datetime
'-------------------------------------------------------------------------
' Initialize observation
'-------------------------------------------------------------------------
pObs.Date.unit = "UTCG"
pObs.Date = datetime
pObs.TimeOrigin = eGroundReceiveTime
'-------------------------------------------------------------------------
' Set up facility and satellite IDs. Facility must come first for 2-way ranging.
'-------------------------------------------------------------------------
pObs.TrackerIDs.Clear()
pObs.TrackerIDs.Insert 0, trackerID ' Facility must be first item
pObs.TrackerIDs.Insert 1, targetID ' Satellite follows Facility
'-------------------------------------------------------------------------
' update measurement value to include noise/errors/...
'-------------------------------------------------------------------------
Select case measType
case "Range"
measValue = measValue + 1.0
case "Doppler"
measValue = measValue*1.2345
case "Azimuth"
case "Elevation"
case "Right Ascension"
case "Declination"
case "SB Right Ascension"
case "SB Declination"
case "SB Range"
case "SB Azimuth"
case "SB Elevation"
case "SB Doppler"
end select
'-------------------------------------------------------------------------
' push to ODTK
'-------------------------------------------------------------------------
pObs.MeasureType = measDict.Item(measType)
pObs.value.Unit = measUnit
pObs.value = measValue
pObsSet.Add pObs
If pObsSet.Count > 0 Then
setColl.Add pObsSet
numObsSets = numObsSets + 1
End If
End If
Loop
GetObsSet = numObsSets
End Function ' GetObsSet
'-------------------------------------------------------------------------
' GetSupportedObsSet method
'-------------------------------------------------------------------------
Function GetSupportedObsSet(setColl)
Dim numSets
numSets = 0
GetSupportedObsSet = numSets
End Function
'-------------------------------------------------------------------------
' SaveObs method
'-------------------------------------------------------------------------
Function SaveObs(pEnum, bAppend)
Dim nObsSaved
nObsSaved = 0
SaveObs = nObsSaved
End Function
Function GetRegKey (regKey)
Dim objShell
Set objShell = CreateObject("WScript.Shell")
regValue = objShell.RegRead(regKey)
Set objShell = nothing
End Function
]]>
</script>
</component>