cpee-handlerwrapper-opcua 0.5 → 0.10

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: f37682803c030cfe276827a2c1eb378f50dfc6ab7e755dc12a456e6ce88fa523
4
- data.tar.gz: b7c508574b45a91100579a649204894fbd0a32b4c3350794b33410ca2749ebcd
3
+ metadata.gz: 84caa4fb564364733a9eb92978ceb92d2d5447bd6f576205c044bbf7d35c6ecc
4
+ data.tar.gz: e7f03ae7ad6fd02f66fcf0c8a63121ba3bfd26fca4fc4d943a8460091025986b
5
5
  SHA512:
6
- metadata.gz: bf62016abb1077af6a8dbc22a0e600b5a6969454b680fd302c5bc1fe2c3292cb201b574a944580f930138b277f74e0a8a0290a288636abe89e9bfd3deb23d352
7
- data.tar.gz: 5e65951566c8c4e4f742f11ab7b524bc6063c6bdc2e2986affc68a3b95aae2c6e6540f44eefd885d051fb2dc30b695e444385f64e563845564465c1486293d4a
6
+ metadata.gz: 288e56f841c4305fb70f3f2b9b4632c7fc517188a8f6a7a752488f96cb96427c6f4dfef3c67e1c0e2e32e617c47c721cf726909bfd569cd3fdf60337906c21d1
7
+ data.tar.gz: b01dd477994a60bd07ba996d54cd237da4c403232baf7ef9c6d826dc54b63304e3f4473935696e0a6ec54658affef76b692cbbd2755d9285884268ef52ee333c
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-handlerwrapper-opcua"
3
- s.version = "0.5"
3
+ s.version = "0.10"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "OPCUA for CPEE HandlerWrapper. Use opc.tcp-read|write|exececute:// links."
@@ -45,6 +45,7 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
45
45
  @handler_passthrough = nil
46
46
  @handler_returnValue = nil
47
47
  @handler_returnOptions = nil
48
+ @handler_activity_uuid = Digest::MD5.hexdigest(Kernel::rand().to_s)
48
49
  @label = ''
49
50
  end # }}}
50
51
 
@@ -73,14 +74,14 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
73
74
  if s.respond_to?(:mimetype)
74
75
  params << Riddl::Parameter::Complex.new(s.name.to_s,v.mimetype,v.value)
75
76
  else
76
- if s.name.to_s =~ /^__Q_/
77
- params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^__Q_/,''),CPEE::ValueHelper::generate(s.value),:query)
78
- elsif s.name.to_s =~ /^__B_/
79
- params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^__B_/,''),CPEE::ValueHelper::generate(s.value),:body)
80
- elsif s.name.to_s =~ /^__H_/
81
- params << Riddl::Header.new(s.name.to_s.sub(/^__H_/,''),CPEE::ValueHelper::generate(s.value))
82
- elsif s.name.to_s =~ /^__C_/
83
- params << Riddl::Parameter::Complex.new(s.name.to_s.sub(/^__C_/,''),*CPEE::ValueHelper::generate(s.value).split(';',2))
77
+ if s.name.to_s =~ /^_Q_/
78
+ params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^_Q_/,''),CPEE::ValueHelper::generate(s.value),:query)
79
+ elsif s.name.to_s =~ /^_B_/
80
+ params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^_B_/,''),CPEE::ValueHelper::generate(s.value),:body)
81
+ elsif s.name.to_s =~ /^_H_/
82
+ params << Riddl::Header.new(s.name.to_s.sub(/^_H_/,''),CPEE::ValueHelper::generate(s.value))
83
+ elsif s.name.to_s =~ /^_C_/
84
+ params << Riddl::Parameter::Complex.new(s.name.to_s.sub(/^_C_/,''),*CPEE::ValueHelper::generate(s.value).split(';',2))
84
85
  else
85
86
  params << Riddl::Parameter::Simple.new(s.name.to_s,CPEE::ValueHelper::generate(s.value))
86
87
  end
@@ -116,7 +117,7 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
116
117
  callback([ Riddl::Parameter::Complex.new('error','application/json',StringIO.new(JSON::generate({ 'status' => status, 'error' => c }))) ], headers)
117
118
  else
118
119
  if headers['CPEE_INSTANTIATION']
119
- @controller.notify("task/instantiation", :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(headers['CPEE_INSTANTIATION']), :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
120
+ @controller.notify("task/instantiation", :activity_uuid => @handler_activity_uuid, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(headers['CPEE_INSTANTIATION']), :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
120
121
  end
121
122
  if headers['CPEE_CALLBACK'] && headers['CPEE_CALLBACK'] == 'true' && result.any?
122
123
  headers['CPEE_UPDATE'] = true
@@ -129,7 +130,7 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
129
130
  end
130
131
  end #}}}
131
132
 
132
- def proto_opcua
133
+ def proto_opcua(parameters)
133
134
  if @handler_endpoint =~ /^opc\.tcp-read:\/\/([^\/]+)\/(\d+)\/(.+)/
134
135
  nid = $3 == $3.to_i.to_s ? $3.to_i : $3
135
136
  ns = $2
@@ -195,10 +196,10 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
195
196
  def activity_handle(passthrough, parameters) # {{{
196
197
  raise "Wrong endpoint" if @handler_endpoint.nil? || @handler_endpoint.empty?
197
198
  @label = parameters[:label]
198
- @sensors = parameters[:sensors]
199
- @aggregators = parameters[:aggregators]
200
- @costs = parameters[:costs]
201
- @controller.notify("activity/calling", :instance => @controller.instance, :instance_uuid => @controller.uuid, :label => @label, :instance_name => @controller.info, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
199
+ @sensors = parameters.dig(:stream,:sensors)
200
+ @aggregators = parameters.dig(:stream,:aggregators)
201
+ @costs = parameters.dig(:stream,:costs)
202
+ @controller.notify("activity/calling", :activity_uuid => @handler_activity_uuid, :instance => @controller.instance, :instance_uuid => @controller.uuid, :label => @label, :instance_name => @controller.info, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
202
203
  if passthrough.to_s.empty?
203
204
  if @handler_endpoint.start_with?('opc.tcp')
204
205
  proto_opcua parameters
@@ -235,15 +236,15 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
235
236
  end # }}}
236
237
 
237
238
  def inform_activity_done # {{{
238
- @controller.notify("activity/done", :endpoint => @handler_endpoint, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
239
+ @controller.notify("activity/done", :activity_uuid => @handler_activity_uuid, :endpoint => @handler_endpoint, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
239
240
  end # }}}
240
241
  def inform_activity_manipulate # {{{
241
- @controller.notify("activity/manipulating", :endpoint => @handler_endpoint, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
242
+ @controller.notify("activity/manipulating", :activity_uuid => @handler_activity_uuid, :endpoint => @handler_endpoint, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
242
243
  end # }}}
243
244
  def inform_activity_failed(err) # {{{
244
245
  puts err.message
245
246
  puts err.backtrace
246
- @controller.notify("activity/failed", :endpoint => @handler_endpoint, :label => @label, :instance_name => @controller.info, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1], :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
247
+ @controller.notify("activity/failed", :activity_uuid => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :instance_name => @controller.info, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1], :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
247
248
  end # }}}
248
249
  def inform_manipulate_change(status,changed_dataelements,changed_endpoints,dataelements,endpoints) # {{{
249
250
  unless status.nil?
@@ -261,10 +262,10 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
261
262
  end # }}}
262
263
 
263
264
  def vote_sync_after # {{{
264
- @controller.call_vote("activity/syncing_after", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"))
265
+ @controller.call_vote("activity/syncing_after", :activity_uuid => @handler_activity_uuid, :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"))
265
266
  end # }}}
266
267
  def vote_sync_before(parameters=nil) # {{{
267
- @controller.call_vote("activity/syncing_before", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :parameters => parameters, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"))
268
+ @controller.call_vote("activity/syncing_before", :activity_uuid => @handler_activity_uuid, :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :parameters => parameters, :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"))
268
269
  end # }}}
269
270
 
270
271
  def simplify_result(result)
@@ -323,13 +324,13 @@ class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
323
324
  end
324
325
 
325
326
  def callback(result=nil,options={})
326
- @controller.notify("activity/receiving", :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result), :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated, :sensors => @sensors, :aggregators => @aggregators, :costs => @costs)
327
+ @controller.notify("activity/receiving", :activity_uuid => @handler_activity_uuid, :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result), :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated, :sensors => @sensors, :aggregators => @aggregators, :costs => @costs)
327
328
  result = simplify_result(result)
328
329
  @handler_returnValue = result
329
330
  @handler_returnOptions = options
330
331
  if options['CPEE_UPDATE']
331
332
  if options['CPEE_UPDATE_STATUS']
332
- @controller.notify("activity/status", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS'], :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
333
+ @controller.notify("activity/status", :activity_uuid => @handler_activity_uuid, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS'], :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
333
334
  end
334
335
  @handler_continue.continue WEEL::Signal::Again
335
336
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-handlerwrapper-opcua
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  autorequire:
9
9
  bindir: tools
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cpee