cpee-logging-xes-yaml 1.1.4 → 1.2.0

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: 8a28cb07da1a9501ae42be2daed564edbe2e9c8f19d9b935beae41eb92d9e858
4
- data.tar.gz: c0608403c7d0ed382f31bc268c5d6091ab3de1ac27b3be45dab7b7b3474cfbf1
3
+ metadata.gz: 421ab3070bdb8f28214e0b712f4ecbe8cdc7738427df56692f2be5e010378642
4
+ data.tar.gz: 3dd19409583da0cd2ba0f022c40505fc16071001017fd01364a9bedd7b993e08
5
5
  SHA512:
6
- metadata.gz: d8c0ec086213534780c96fd7ca2da9cc9f4621985876db32c47e061566ded16e3c530e6c28156f1ff49f0955136816ca09b24c0c125218c256c1179db42a8a9b
7
- data.tar.gz: a14a71277ee317c3214bda9310cded04c9367d5363a75b8669a1ee67417ec539846e5908e570637c493a01e78b5a53c503c83b20a231e111b23cab665c5e5898
6
+ metadata.gz: 3afaebb9674da2559218a7461a7a639ecbb3055b772768cea5b5e1380f63bb159f57b979dc961e1c751e900f9229dfc0f1fca2f3bb367663fb8780bf0a923c5f
7
+ data.tar.gz: d06c3392fdb38ebf71dd0730c157741d91630b4c6028e1c9be9c936067e97761e2669f337e0830bbbebbf6f010c0229a0a572408b94aefb52306ccff888b4762
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.1.4"
3
+ s.version = "1.2.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Logging for the cloud process execution engine (cpee.org)"
@@ -23,6 +23,8 @@ require 'time'
23
23
 
24
24
  require_relative 'tools'
25
25
 
26
+ matze = 'localhostr:9318'
27
+
26
28
  module CPEE
27
29
  module Logging
28
30
 
@@ -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(id)
14
- tp = { 'stream:point' => { } }
15
- tp['stream:point']['stream:id'] = id
16
- tp['stream:point']['stream:value'] = @value
17
- tp['stream:point']['stream:timestamp'] = @timestamp
18
- tp['stream:point']['stream:source'] = @source unless @source.nil?
19
- tp['stream:point']['stream:meta'] = @meta unless @meta.nil?
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? 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
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(tid)
77
+ target << { 'stream:point' => e.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.mimetype == 'text/yaml'
101
+ elsif res['mimetype'] == 'text/yaml'
70
102
  YAML::load(res['data']) rescue nil
71
- elsif result[0].mimetype == 'text/plain'
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.mimetype == 'text/html'
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,p.find('string(d:id)'),p.find('string(d:source)'))
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,p.find('string(d:id)'),p.find('string(d:source)'))
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
4
+ version: 1.2.0
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-18 00:00:00.000000000 Z
12
+ date: 2022-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riddl