-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAS_LogFileObj__Define.pro
More file actions
186 lines (137 loc) · 5.47 KB
/
AS_LogFileObj__Define.pro
File metadata and controls
186 lines (137 loc) · 5.47 KB
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
;---------------------------------------------------------------------------
; Init method.
; Called when the AS_LogFileObj object is created.
FUNCTION AS_LogFileObj::Init
@as_scatterheader.macro
void = {void, $
INHERITS IDLffXMLSAX, $
charBuffer : '' , $
numFields : '' $
}
self.numFields[0] = N_Tags(void)
void = {AS_LogFileObj}
self.numFields[1] = N_Tags(void)
FOR i = self.numFields[0], self.numFields[1] - 1 DO BEGIN
self.(i) = PTR_NEW(/ALLOCATE_HEAP)
END
RETURN, self->IDLffXMLSAX::Init()
END
;---------------------------------------------------------------------------
; Cleanup method.
; Called when the AS_LogFileObj object is destroyed.
PRO AS_LogFileObj::Cleanup
@as_scatterheader.macro
; Release pointer
FOR i = self.numFields[0], self.numFields[1] - 1 DO BEGIN
IF Ptr_Valid(self.(i)) THEN Ptr_Free, self.(i)
END
; Call superclass cleanup method
self->IDLffXMLSAX::Cleanup
END
;---------------------------------------------------------------------------
; StartDocument method for reading XML
; Called when parsing of the document data begins.
; If the arrays pointed contain data, reinitialise them.
PRO AS_LogFileObj::StartDocument
@as_scatterheader.macro
FOR i = self.numFields[0], self.numFields[1] - 1 DO BEGIN
IF (N_Elements(*self.(i)) GT 0) THEN void = Temporary(*self.(i))
END
END
;---------------------------------------------------------------------------
; Characters method for XML
; Called when parsing character data within an element.
; Adds data to the charBuffer field.
PRO AS_LogFileObj::characters, data
@as_scatterheader.macro
self.charBuffer = self.charBuffer + data
END
;---------------------------------------------------------------------------
; StartElement for XML
; Called when the parser encounters the start of an element.
PRO AS_LogFileObj::startElement, URI, local, strName, attName, attValue
@as_scatterheader.macro
void = { AS_LogFileObj }
tags = Tag_Names(void)
SWITCH strName OF
"transmission" :
"saxsshot" : BEGIN
IF N_Elements(attName) NE 0 THEN attName = StrUpCase(attName)
self.charBuffer = ''
IF N_Elements(attName) GT 0 THEN BEGIN
IF N_Elements(*self.(self.numFields[0])) EQ 0 THEN BEGIN
FOR i = self.numFields[0] + 1, self.numFields[1] - 1 DO BEGIN
IF Where(attName EQ Tags[i]) NE -1 THEN *self.(i) = attValue[Where(attName EQ Tags[i])] ELSE *self.(i) = ''
ENDFOR
ENDIF ELSE BEGIN
FOR i = self.numFields[0] + 1, self.numFields[1] - 1 DO BEGIN
IF Where(attName EQ Tags[i]) NE -1 THEN *self.(i) = [*self.(i),attValue[Where(attName EQ Tags[i])]] ELSE *self.(i) = [*self.(i),'']
ENDFOR
ENDELSE
ENDIF
END
"Experiment" :
"Sample" :
ENDSWITCH
END
;---------------------------------------------------------------------------
; EndElement method for XML
; Called when the parser encounters the end of an element.
PRO AS_LogFileObj::EndElement, URI, Local, strName
@as_scatterheader.macro
CASE strName OF
"Experiment":
"Sample" :
"transmission": BEGIN
IF (N_ELEMENTS(*self.fname) EQ 0) THEN $
*self.fname = "transmission" $
; If the array pointed at by pArray contains data
; already, extend the array.
ELSE $
*self.fname = [*self.fname,"transmission"]
END
"saxsshot": BEGIN
; If the array pointed at by pArray has no elements,
; set it equal to the current data.
IF (N_ELEMENTS(*self.fname) EQ 0) THEN $
*self.fname = "saxsshot" $
; If the array pointed at by pArray contains data
; already, extend the array.
ELSE $
*self.fname = [*self.fname,"saxsshot"]
END
ENDCASE
END
;---------------------------------------------------------------------------
; GetArray method for XML.
; Returns the current array stored internally. If
; no data is available, returns -1.
FUNCTION AS_LogFileObj::GetArray, attribute
@as_scatterheader.macro
attribute = StrUpCase(attribute)
void = { AS_LogFileObj }
tags = Tag_Names(void)
FOR i = self.numFields[0], self.numFields[1] - 1 DO BEGIN
IF tags(i) EQ attribute THEN IF (N_Elements(*self.(i)) GT 0) THEN RETURN, *self.(i)
ENDFOR
END
;FUNCTION As_LogFileObj::NewLine, data
;---------------------------------------------------------------------------
PRO AS_LogFileObj__Define
void = {AS_LogFileObj , $
INHERITS IDLffXMLSAX, $
charBuffer : '' , $
numFields : [0,0], $
fname : Ptr_New(), $
exptime : Ptr_New(), $
i0counts : Ptr_New(), $
i0bgcounts : Ptr_New(), $
itcounts : Ptr_New(), $
itbgcounts : Ptr_New(), $
ibscounts : Ptr_New(), $
ibsbgcounts: Ptr_New(), $
timestamp : Ptr_New(), $
opticstr : Ptr_New(), $
sdata : Ptr_New() $
}
END