cpee-logging-xes-yaml 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cpee-logging-xes-yaml.gemspec +1 -1
- data/lib/cpee-logging-xes-yaml/tools.rb +54 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a28cb07da1a9501ae42be2daed564edbe2e9c8f19d9b935beae41eb92d9e858
|
4
|
+
data.tar.gz: c0608403c7d0ed382f31bc268c5d6091ab3de1ac27b3be45dab7b7b3474cfbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c0ec086213534780c96fd7ca2da9cc9f4621985876db32c47e061566ded16e3c530e6c28156f1ff49f0955136816ca09b24c0c125218c256c1179db42a8a9b
|
7
|
+
data.tar.gz: a14a71277ee317c3214bda9310cded04c9367d5363a75b8669a1ee67417ec539846e5908e570637c493a01e78b5a53c503c83b20a231e111b23cab665c5e5898
|
@@ -24,6 +24,28 @@ end
|
|
24
24
|
module CPEE
|
25
25
|
module Logging
|
26
26
|
|
27
|
+
def self::val_merge(target,val,tid,tso)
|
28
|
+
if val.is_a? Array
|
29
|
+
val.each do |e|
|
30
|
+
if e.is_a? StreamPoint
|
31
|
+
e.source ||= tso
|
32
|
+
target << e.to_h(tid)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
tp = nil
|
37
|
+
if val.is_a? StreamPoint
|
38
|
+
tp = val
|
39
|
+
tp.source = tso if tp.source.nil?
|
40
|
+
else
|
41
|
+
tp = StreamPoint.new
|
42
|
+
tp.source = tso
|
43
|
+
tp.value = val
|
44
|
+
end
|
45
|
+
target << tp.to_h(tid)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
def self::extract_probes(where,xml)
|
28
50
|
XML::Smart::string(xml) do |doc|
|
29
51
|
doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
|
@@ -36,8 +58,8 @@ module CPEE
|
|
36
58
|
end
|
37
59
|
end
|
38
60
|
|
39
|
-
def self::
|
40
|
-
result.map
|
61
|
+
def self::extract_result(result)
|
62
|
+
ret = result.map do |res|
|
41
63
|
if res['mimetype'].nil?
|
42
64
|
res['value']
|
43
65
|
elsif res['mimetype'] == 'application/json'
|
@@ -64,7 +86,10 @@ module CPEE
|
|
64
86
|
res['data']
|
65
87
|
end
|
66
88
|
end
|
67
|
-
|
89
|
+
ret.length == 1 ? ret[0] : ret
|
90
|
+
end
|
91
|
+
|
92
|
+
def self::extract_sensor(rs,code,result)
|
68
93
|
rs.instance_eval(code)
|
69
94
|
end
|
70
95
|
|
@@ -135,6 +160,21 @@ module CPEE
|
|
135
160
|
event["data"] = content['values'].map do |k,v|
|
136
161
|
{ 'name' => k, 'value' => v }
|
137
162
|
end
|
163
|
+
|
164
|
+
fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
|
165
|
+
dname = File.join(log_dir,instance + '.data.json')
|
166
|
+
|
167
|
+
if File.exists?(fname)
|
168
|
+
rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
|
169
|
+
XML::Smart::open_unprotected(fname) do |doc|
|
170
|
+
doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
|
171
|
+
doc.find('//d:probe[d:extractor_type="intrinsic"]').each do |p|
|
172
|
+
event['stream:sensorstream'] ||= []
|
173
|
+
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),nil) rescue nil
|
174
|
+
CPEE::Logging::val_merge(event['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
138
178
|
end
|
139
179
|
if receiving && !receiving.empty?
|
140
180
|
fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
|
@@ -142,35 +182,24 @@ module CPEE
|
|
142
182
|
|
143
183
|
if File.exists?(fname)
|
144
184
|
te = event.dup
|
145
|
-
te['stream:sensorstream'] = []
|
146
185
|
|
147
186
|
rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
|
148
187
|
XML::Smart::open_unprotected(fname) do |doc|
|
149
188
|
doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
|
150
|
-
doc.find('//d:probe').
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),
|
155
|
-
|
156
|
-
val.each do |e|
|
157
|
-
if e.is_a? StreamPoint
|
158
|
-
e.source ||= tso
|
159
|
-
te['stream:sensorstream'] << e.to_h(tid)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
else
|
163
|
-
tp = StreamPoint.new
|
164
|
-
tp.source = tso
|
165
|
-
tp.value = val
|
166
|
-
te['stream:sensorstream'] << tp.to_h(tid)
|
167
|
-
end
|
189
|
+
if doc.find('//d:probe/d:extractor_type[.="extrinsic"]').any?
|
190
|
+
rc = CPEE::Logging::extract_result(receiving)
|
191
|
+
doc.find('//d:probe[d:extractor_type="extrinsic"]').each do |p|
|
192
|
+
te['stream:sensorstream'] ||= []
|
193
|
+
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),rc) rescue nil
|
194
|
+
CPEE::Logging::val_merge(te['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
|
168
195
|
end
|
169
196
|
end
|
170
197
|
end
|
171
|
-
te[
|
172
|
-
|
173
|
-
|
198
|
+
if te['stream:sensorstream']
|
199
|
+
te["cpee:lifecycle:transition"] = "sensor/stream"
|
200
|
+
File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
|
201
|
+
f << {'event' => te}.to_yaml
|
202
|
+
end
|
174
203
|
end
|
175
204
|
end
|
176
205
|
|