cpee-logging-xes-yaml 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a089999eb754b1261a11e99783f151d3efb591fbe2a9ce0bca20681a80973da
|
4
|
+
data.tar.gz: 12813da31c00bd2b78c279ff8d69c48d280219452b672f0c7c3b4871097e964b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 288fbd3c749913373ee0535e5b029a0bb9df11c076c88ae3f37db6b9f5493d4b0b1fd336d2bbbf6eb35f38bb14c961fdd45249ddb4bc81bb1269cb67bad98801
|
7
|
+
data.tar.gz: 5ff48fd29f8051c298f1b13bbd831a2fbcbb022ff3c56f25dc64a5e65f2d13fd01204e9c8572b17917692b02d8ee4579e6e2fc818bd432c1f2150d282653ada0
|
@@ -2,12 +2,20 @@
|
|
2
2
|
<interface name="events">
|
3
3
|
<xi:include href="http://www.riddl.org/ns/common-patterns/notifications-consumer/2.0/consumer.xml"/>
|
4
4
|
</interface>
|
5
|
+
<interface name="notifications">
|
6
|
+
<xi:include href="http://www.riddl.org/ns/common-patterns/notifications-producer/2.0/producer.xml"/>
|
7
|
+
</interface>
|
8
|
+
|
5
9
|
|
6
10
|
<facade>
|
7
11
|
<tile>
|
8
12
|
<layer name="events">
|
9
13
|
<apply-to>/</apply-to>
|
10
14
|
</layer>
|
15
|
+
<layer name="notifications">
|
16
|
+
<apply-to>/</apply-to>
|
17
|
+
<block method="sse">/notifications/subscriptions/{}/sse</block>
|
18
|
+
</layer>
|
11
19
|
</tile>
|
12
20
|
</facade>
|
13
21
|
</declaration>
|
@@ -2,21 +2,57 @@ require 'weel'
|
|
2
2
|
|
3
3
|
class StreamPoint
|
4
4
|
attr_accessor :value, :timestamp, :source, :meta
|
5
|
+
attr_reader :id
|
5
6
|
|
6
|
-
def initialize
|
7
|
+
def initialize(id)
|
8
|
+
@id = id
|
7
9
|
@value = nil
|
8
10
|
@timestamp = Time.now
|
9
11
|
@source = nil
|
10
12
|
@meta = nil
|
11
13
|
end
|
12
14
|
|
13
|
-
def to_h
|
14
|
-
tp = {
|
15
|
-
tp['stream:
|
16
|
-
tp['stream:
|
17
|
-
tp['stream:
|
18
|
-
tp['stream:
|
19
|
-
tp['stream:
|
15
|
+
def to_h
|
16
|
+
tp = { }
|
17
|
+
tp['stream:id'] = @id
|
18
|
+
tp['stream:value'] = @value
|
19
|
+
tp['stream:timestamp'] = @timestamp
|
20
|
+
tp['stream:source'] = @source unless @source.nil?
|
21
|
+
tp['stream:meta'] = @meta unless @meta.nil?
|
22
|
+
tp
|
23
|
+
end
|
24
|
+
end
|
25
|
+
class Stream
|
26
|
+
attr_accessor :id, :source, :meta
|
27
|
+
attr_reader :name
|
28
|
+
|
29
|
+
def initialize(name)
|
30
|
+
@name = name
|
31
|
+
@id = nil
|
32
|
+
@source = nil
|
33
|
+
@meta = nil
|
34
|
+
@values = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def <<(val)
|
38
|
+
@values << val
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_list
|
42
|
+
tp = []
|
43
|
+
tp << {'stream:name' => @name}
|
44
|
+
tp << {'stream:id' => @id} unless @id.nil?
|
45
|
+
tp << {'stream:source' => @source} unless @source.nil?
|
46
|
+
tp << {'stream:meta' => @meta} unless @meta.nil?
|
47
|
+
@values.each do |e|
|
48
|
+
if e.is_a? Stream
|
49
|
+
e.source = @source if e.source.nil? && !@source.nil?
|
50
|
+
tp << { 'stream:sensorstream' => e.to_list }
|
51
|
+
elsif e.is_a? StreamPoint
|
52
|
+
e.source = @source if e.source.nil? && !@source.nil?
|
53
|
+
tp << { 'stream:point' => e.to_h }
|
54
|
+
end
|
55
|
+
end
|
20
56
|
tp
|
21
57
|
end
|
22
58
|
end
|
@@ -25,24 +61,20 @@ module CPEE
|
|
25
61
|
module Logging
|
26
62
|
|
27
63
|
def self::val_merge(target,val,tid,tso)
|
28
|
-
if val.is_a?
|
29
|
-
val.
|
30
|
-
|
31
|
-
e.source ||= tso
|
32
|
-
target << e.to_h(tid)
|
33
|
-
end
|
34
|
-
end
|
64
|
+
if val.is_a? Stream
|
65
|
+
val.source = tso if val.source.nil?
|
66
|
+
target.push *val.to_list
|
35
67
|
else
|
36
68
|
tp = nil
|
37
69
|
if val.is_a? StreamPoint
|
38
70
|
tp = val
|
39
71
|
tp.source = tso if tp.source.nil?
|
40
72
|
else
|
41
|
-
tp = StreamPoint.new
|
73
|
+
tp = StreamPoint.new(tid)
|
42
74
|
tp.source = tso
|
43
75
|
tp.value = val
|
44
76
|
end
|
45
|
-
target << tp.to_h
|
77
|
+
target << { 'stream:point' => tp.to_h }
|
46
78
|
end
|
47
79
|
end
|
48
80
|
|
@@ -66,9 +98,9 @@ module CPEE
|
|
66
98
|
JSON::parse(res['data'])
|
67
99
|
elsif res['mimetype'] == 'application/xml' || res['mimetype'] == 'text/xml'
|
68
100
|
XML::Smart::string(res['data']) rescue nil
|
69
|
-
elsif res
|
101
|
+
elsif res['mimetype'] == 'text/yaml'
|
70
102
|
YAML::load(res['data']) rescue nil
|
71
|
-
elsif
|
103
|
+
elsif res['mimetype'] == 'text/plain'
|
72
104
|
t = res['data']
|
73
105
|
if t.start_with?("<?xml version=")
|
74
106
|
t = XML::Smart::string(t)
|
@@ -77,7 +109,7 @@ module CPEE
|
|
77
109
|
t = t.to_i if t == t.to_i.to_s
|
78
110
|
end
|
79
111
|
t
|
80
|
-
elsif res
|
112
|
+
elsif res['mimetype'] == 'text/html'
|
81
113
|
t = res['data']
|
82
114
|
t = t.to_f if t == t.to_f.to_s
|
83
115
|
t = t.to_i if t == t.to_i.to_s
|
@@ -89,8 +121,10 @@ module CPEE
|
|
89
121
|
ret.length == 1 ? ret[0] : ret
|
90
122
|
end
|
91
123
|
|
92
|
-
def self::extract_sensor(rs,code,result)
|
93
|
-
rs.instance_eval(code)
|
124
|
+
def self::extract_sensor(rs,code,pid,result)
|
125
|
+
rs.instance_eval(code,'probe',1)
|
126
|
+
rescue => e
|
127
|
+
e.backtrace[0].gsub(/(\w+):(\d+):in.*/,'Probe ' + pid + ' Line \2: ') + e.message
|
94
128
|
end
|
95
129
|
|
96
130
|
def self::persist_values(where,values)
|
@@ -169,9 +203,10 @@ module CPEE
|
|
169
203
|
XML::Smart::open_unprotected(fname) do |doc|
|
170
204
|
doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
|
171
205
|
doc.find('//d:probe[d:extractor_type="intrinsic"]').each do |p|
|
206
|
+
pid = p.find('string(d:id)')
|
172
207
|
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,
|
208
|
+
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),pid,nil) rescue nil
|
209
|
+
CPEE::Logging::val_merge(event['stream:sensorstream'],val,pid,p.find('string(d:source)'))
|
175
210
|
end
|
176
211
|
end
|
177
212
|
end
|
@@ -189,9 +224,10 @@ module CPEE
|
|
189
224
|
if doc.find('//d:probe/d:extractor_type[.="extrinsic"]').any?
|
190
225
|
rc = CPEE::Logging::extract_result(receiving)
|
191
226
|
doc.find('//d:probe[d:extractor_type="extrinsic"]').each do |p|
|
227
|
+
pid = p.find('string(d:id)')
|
192
228
|
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,
|
229
|
+
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),pid,rc) rescue nil
|
230
|
+
CPEE::Logging::val_merge(te['stream:sensorstream'],val,pid,p.find('string(d:source)'))
|
195
231
|
end
|
196
232
|
end
|
197
233
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-logging-xes-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: tools
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-10
|
12
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riddl
|