-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathluaParseJson.xml
More file actions
210 lines (204 loc) · 10.1 KB
/
luaParseJson.xml
File metadata and controls
210 lines (204 loc) · 10.1 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<project name="luaParseJson" pubsub="auto" threads="1" heartbeat-interval="1">
<description><![CDATA[This project uses a Lua window to parse a JSON opaque string from the message broker RabbitMQ to generate events.]]></description>
<metadata>
<meta id="layout">{"cq_01":{"parseJson":{"x":170,"y":205},"pub_win":{"x":170,"y":80},"train_data":{"x":170,"y":-20}}}</meta>
<meta id="studioModifiedBy">sastest2</meta>
<meta id="studioModified">1648482881279</meta>
<meta id="studioUploadedBy">sastest2</meta>
<meta id="studioUploaded">1648480214835</meta>
</metadata>
<properties>
<property name="RABBITMQ_HOST"><![CDATA[rabbitmq-0.rabbitmq.rabbits.svc.cluster.local]]></property>
<property name="RABBITMQ_PORT"><![CDATA[5672]]></property>
<property name="RABBIT_USERNAME"><![CDATA[guest]]></property>
<property name="RABBIT_PASSWORD"><![CDATA[guest]]></property>
<property name="TEST_LOCATION"><![CDATA[/mnt/data]]></property>
</properties>
<contqueries>
<contquery name="cq_01" include-singletons="true" trace="parseJson">
<windows>
<window-source name="train_data">
<description><![CDATA[This window receives the input data from a CSV file and sends it to RabbitMQ.]]></description>
<schema>
<fields>
<field name="train_id" type="string"/>
<field name="site_id" type="string"/>
<field name="corridor_name" type="string"/>
<field name="direction" type="string"/>
<field name="train_speed" type="string"/>
<field name="cs_id" type="string"/>
<field name="car_id" type="string"/>
<field name="car_name" type="string" key="true"/>
<field name="car_type_alpha" type="string"/>
<field name="car_type_um" type="string"/>
<field name="um_verified" type="string"/>
<field name="lead_end" type="string"/>
<field name="no_axles" type="string"/>
<field name="no_trucks" type="string"/>
<field name="car_ord_no" type="string"/>
<field name="car_wgt_calc" type="string"/>
<field name="pct_load" type="string"/>
<field name="axle_no" type="string" key="true"/>
<field name="axle_seq_no" type="string"/>
<field name="truck" type="string"/>
<field name="car_side" type="string" key="true"/>
<field name="dyn_vert" type="string"/>
<field name="dyn_ratio" type="string"/>
<field name="truncatedCarNameChars" type="string"/>
<field name="alertDesc" type="double"/>
<field name="trainDt" type="int64"/>
<field name="max_vert" type="string"/>
<field name="avg_lat" type="string"/>
<field name="max_lat" type="string"/>
<field name="avg_vert" type="string"/>
<field name="train_date" type="string" key="true"/>
<field name="type" type="double"/>
</fields>
</schema>
<connectors>
<connector class="fs" name="pub">
<properties>
<property name="type"><![CDATA[pub]]></property>
<property name="fstype"><![CDATA[csv]]></property>
<property name="fsname"><![CDATA[@TEST_LOCATION@/espClientInput/trainData.csv]]></property>
<property name="blocksize"><![CDATA[1]]></property>
</properties>
</connector>
<connector class="rmq" name="rmq_sub">
<properties>
<property name="type"><![CDATA[sub]]></property>
<property name="rmquserid"><![CDATA[@RABBIT_USERNAME@]]></property>
<property name="rmqpassword"><![CDATA[@RABBIT_PASSWORD@]]></property>
<property name="rmqhost"><![CDATA[@RABBITMQ_HOST@]]></property>
<property name="rmqport"><![CDATA[@RABBITMQ_PORT@]]></property>
<property name="rmqexchange"><![CDATA[SASEV]]></property>
<property name="rmqtopic"><![CDATA[esp-base:39908/luaParseJson/cq_01/train_data/O]]></property>
<property name="rmqtype"><![CDATA[json]]></property>
<property name="numbufferedmsgs"><![CDATA[50000]]></property>
<property name="urlhostport"><![CDATA[esp-base:39908]]></property>
<property name="buspersistence"><![CDATA[false]]></property>
<property name="snapshot"><![CDATA[false]]></property>
<property name="collapse"><![CDATA[true]]></property>
</properties>
</connector>
</connectors>
</window-source>
<window-source name="pub_win">
<description><![CDATA[This window receives the input data from RabbitMQ.]]></description>
<schema>
<fields>
<field name="id" type="int64" key="true"/>
<field name="sensorinfo" type="string"/>
</fields>
</schema>
<connectors>
<connector class="rmq" name="rmq_pub">
<properties>
<property name="type"><![CDATA[pub]]></property>
<property name="rmquserid"><![CDATA[@RABBIT_USERNAME@]]></property>
<property name="rmqpassword"><![CDATA[@RABBIT_PASSWORD@]]></property>
<property name="rmqhost"><![CDATA[@RABBITMQ_HOST@]]></property>
<property name="rmqport"><![CDATA[@RABBITMQ_PORT@]]></property>
<property name="rmqexchange"><![CDATA[SASEV]]></property>
<property name="rmqtopic"><![CDATA[esp-base:39908/luaParseJson/cq_01/train_data/O]]></property>
<property name="rmqtype"><![CDATA[opaquestring]]></property>
<property name="urlhostport"><![CDATA[esp-base:39908]]></property>
<property name="buspersistence"><![CDATA[false]]></property>
<property name="blocksize"><![CDATA[1]]></property>
</properties>
</connector>
<connector class="fs" name="sub">
<properties>
<property name="type"><![CDATA[sub]]></property>
<property name="fstype"><![CDATA[csv]]></property>
<property name="fsname"><![CDATA[@TEST_LOCATION@/espClientOutput/LuaParseResults.out]]></property>
<property name="snapshot"><![CDATA[true]]></property>
</properties>
</connector>
</connectors>
</window-source>
<window-lua events="create" name="parseJson">
<description><![CDATA[This window uses Lua code to parse the JSON data and generate multiple events.]]></description>
<schema>
<fields>
<field name="train_id" type="string"/>
<field name="site_id" type="string"/>
<field name="corridor_name" type="string"/>
<field name="direction" type="string"/>
<field name="train_speed" type="string"/>
<field name="cs_id" type="string"/>
<field name="car_id" type="string"/>
<field name="car_name" type="string" key="true"/>
<field name="car_type_alpha" type="string"/>
<field name="car_type_um" type="string"/>
<field name="um_verified" type="string"/>
<field name="lead_end" type="string"/>
<field name="no_axles" type="string"/>
<field name="no_trucks" type="string"/>
<field name="car_ord_no" type="string"/>
<field name="car_wgt_calc" type="string"/>
<field name="pct_load" type="string"/>
<field name="axle_no" type="string" key="true"/>
<field name="axle_seq_no" type="string"/>
<field name="truck" type="string"/>
<field name="car_side" type="string" key="true"/>
<field name="dyn_vert" type="string"/>
<field name="dyn_ratio" type="string"/>
<field name="truncatedCarNameChars" type="string"/>
<field name="alertDesc" type="double"/>
<field name="trainDt" type="int64"/>
<field name="max_vert" type="string"/>
<field name="avg_lat" type="string"/>
<field name="max_lat" type="string"/>
<field name="avg_vert" type="string"/>
<field name="train_date" type="string" key="true"/>
<field name="type" type="double"/>
</fields>
</schema>
<copy/>
<code><![CDATA[
function create(data,context)
local events = {}
local sensorinfo = esp_parseJsonFrom("sensorinfo")
local index = 1
for i1,v1 in ipairs(sensorinfo)
do
local e = {}
for i2,v2 in ipairs(v1)
do
for k,v in pairs(v2)
do
e[k] = v
end
end
events[index] = e
index = index + 1
end
return(events)
end]]></code>
</window-lua>
</windows>
<edges>
<edge source="pub_win" target="parseJson"/>
</edges>
</contquery>
</contqueries>
<project-connectors>
<connector-groups>
<connector-group name="sub">
<connector-entry connector="cq_01/train_data/rmq_sub" state="running"/>
<connector-entry connector="cq_01/pub_win/sub" state="running"/>
</connector-group>
<connector-group name="pub1">
<connector-entry connector="cq_01/train_data/pub" state="finished"/>
</connector-group>
<connector-group name="pub2">
<connector-entry connector="cq_01/pub_win/rmq_pub" state="running"/>
</connector-group>
</connector-groups>
<edges>
<edge source="sub" target="pub2"/>
<edge source="pub2" target="pub1"/>
</edges>
</project-connectors>
</project>