cpee 2.1.70 → 2.1.71
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/cockpit/js/instance.js +13 -1
- data/cockpit/templates/{Coopis 2010 Ext.xml → Coopis 2010 Eval.xml } +2 -3
- data/cockpit/themes/reduced/rngs/alternative.rng +25 -0
- data/cockpit/themes/reduced/rngs/call.rng +228 -0
- data/cockpit/themes/reduced/rngs/callmanipulate.rng +257 -0
- data/cockpit/themes/reduced/rngs/choose.rng +14 -0
- data/cockpit/themes/reduced/rngs/closed_loop.rng +62 -0
- data/cockpit/themes/reduced/rngs/closed_loop_cancel.rng +5 -0
- data/cockpit/themes/reduced/rngs/closed_loop_control.rng +31 -0
- data/cockpit/themes/reduced/rngs/closed_loop_measuring.rng +12 -0
- data/cockpit/themes/reduced/rngs/critical.rng +5 -0
- data/cockpit/themes/reduced/rngs/escape.rng +1 -0
- data/cockpit/themes/reduced/rngs/group.rng +3 -0
- data/cockpit/themes/reduced/rngs/loop.rng +22 -0
- data/cockpit/themes/reduced/rngs/manipulate.rng +9 -0
- data/cockpit/themes/reduced/rngs/otherwise.rng +22 -0
- data/cockpit/themes/reduced/rngs/parallel.rng +27 -0
- data/cockpit/themes/reduced/rngs/parallel_branch.rng +2 -0
- data/cockpit/themes/reduced/rngs/scripts.rng +23 -0
- data/cockpit/themes/reduced/rngs/start.rng +131 -0
- data/cockpit/themes/reduced/rngs/stop.rng +5 -0
- data/cockpit/themes/reduced/rngs/terminate.rng +1 -0
- data/cockpit/themes/reduced/symbols/alternative.svg +5 -0
- data/cockpit/themes/reduced/symbols/arrow.svg +3 -0
- data/cockpit/themes/reduced/symbols/call.svg +6 -0
- data/cockpit/themes/reduced/symbols/call_sensor.svg +9 -0
- data/cockpit/themes/reduced/symbols/callmanipulate.svg +8 -0
- data/cockpit/themes/reduced/symbols/callmanipulate_sensor.svg +11 -0
- data/cockpit/themes/reduced/symbols/choose.svg +5 -0
- data/cockpit/themes/reduced/symbols/choose_exclusive.svg +5 -0
- data/cockpit/themes/reduced/symbols/choose_inclusive.svg +4 -0
- data/cockpit/themes/reduced/symbols/closed_loop.svg +5 -0
- data/cockpit/themes/reduced/symbols/closed_loop_cancel.svg +5 -0
- data/cockpit/themes/reduced/symbols/closed_loop_control.svg +5 -0
- data/cockpit/themes/reduced/symbols/closed_loop_measuring.svg +6 -0
- data/cockpit/themes/reduced/symbols/complex.svg +8 -0
- data/cockpit/themes/reduced/symbols/critical.svg +4 -0
- data/cockpit/themes/reduced/symbols/delete.svg +4 -0
- data/cockpit/themes/reduced/symbols/end.svg +3 -0
- data/cockpit/themes/reduced/symbols/escape.svg +5 -0
- data/cockpit/themes/reduced/symbols/event_end.svg +3 -0
- data/cockpit/themes/reduced/symbols/loop.svg +5 -0
- data/cockpit/themes/reduced/symbols/manipulate.svg +4 -0
- data/cockpit/themes/reduced/symbols/otherwise.svg +5 -0
- data/cockpit/themes/reduced/symbols/parallel.svg +5 -0
- data/cockpit/themes/reduced/symbols/parallel_branch.svg +5 -0
- data/cockpit/themes/reduced/symbols/parallel_branch_compact.svg +4 -0
- data/cockpit/themes/reduced/symbols/parallel_branch_event.svg +14 -0
- data/cockpit/themes/reduced/symbols/parallel_branch_normal.svg +5 -0
- data/cockpit/themes/reduced/symbols/parallel_eventbased_exclusive.svg +9 -0
- data/cockpit/themes/reduced/symbols/parallel_eventbased_parallel.svg +8 -0
- data/cockpit/themes/reduced/symbols/scripts.svg +4 -0
- data/cockpit/themes/reduced/symbols/start.svg +3 -0
- data/cockpit/themes/reduced/symbols/start_event.svg +5 -0
- data/cockpit/themes/reduced/symbols/stop.svg +5 -0
- data/cockpit/themes/reduced/symbols/terminate.svg +4 -0
- data/cockpit/themes/reduced/theme.js +11 -0
- data/cpee.gemspec +1 -1
- data/server/executionhandlers/{rubyext → eval}/backend/opts.yaml +1 -3
- data/server/executionhandlers/{rubyext → eval}/connection.rb +37 -106
- data/server/executionhandlers/{rubyext → eval}/controller.rb +0 -6
- data/server/executionhandlers/{rubyext → eval}/execution.rb +20 -22
- data/server/executionhandlers/ruby/backend/opts.yaml +2 -0
- data/server/executionhandlers/ruby/connection.rb +154 -57
- data/server/executionhandlers/ruby/controller.rb +16 -0
- data/server/executionhandlers/ruby/dsl_to_dslx.xsl +29 -29
- data/server/executionhandlers/ruby/execution.rb +15 -13
- data/server/routing/end.pid +1 -1
- data/server/routing/forward-events-00.pid +1 -1
- data/server/routing/forward-votes.pid +1 -1
- data/server/routing/persist.pid +1 -1
- metadata +67 -12
- /data/server/executionhandlers/{rubyext → eval}/backend/README.md +0 -0
- /data/server/executionhandlers/{rubyext → eval}/backend/instance.template +0 -0
- /data/server/executionhandlers/{rubyext → eval}/backend/run +0 -0
- /data/server/executionhandlers/{rubyext → eval}/dsl_to_dslx.xsl +0 -0
|
@@ -36,18 +36,20 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
36
36
|
def self::inform_syntax_error(arguments,err,code)# {{{
|
|
37
37
|
# TODO extract spot (code) where error happened for better error handling (ruby 3.1 only)
|
|
38
38
|
# https://github.com/rails/rails/pull/45818/commits/3beb2aff3be712e44c34a588fbf35b79c0246ca5
|
|
39
|
-
puts err.message
|
|
40
|
-
puts err.backtrace
|
|
41
39
|
controller = arguments[0]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
begin
|
|
41
|
+
controller.notify("description/error", :message => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):\s(.*)/)[4] + err.message, :line => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):/)[3], :where => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):/)[1])
|
|
42
|
+
rescue => e
|
|
43
|
+
controller.notify("description/error", :message => err.message)
|
|
44
|
+
end
|
|
45
45
|
end# }}}
|
|
46
46
|
def self::inform_connectionwrapper_error(arguments,err) # {{{
|
|
47
47
|
controller = arguments[0]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
begin
|
|
49
|
+
controller.notify("executionhandler/error", :message => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):\s(.*)/)[4] + err.message, :line => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):/)[3], :where => err.backtrace[0].match(/(.*?)(, Line |:)(\d+):/)[1])
|
|
50
|
+
rescue => e
|
|
51
|
+
controller.notify("executionhandler/error", :message => err.message)
|
|
52
|
+
end
|
|
51
53
|
end # }}}
|
|
52
54
|
def self::inform_position_change(arguments,ipc={}) # {{{
|
|
53
55
|
controller = arguments[0]
|
|
@@ -74,6 +76,7 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
74
76
|
'base' => @controller.base_url,
|
|
75
77
|
'instance' => @controller.instance_id,
|
|
76
78
|
'instance_url' => @controller.instance_url,
|
|
79
|
+
'instance_url_encoded' => Riddl::Protocols::Utils::escape(@controller.instance_url),
|
|
77
80
|
'instance_uuid' => @controller.uuid
|
|
78
81
|
},
|
|
79
82
|
:task => {
|
|
@@ -112,7 +115,7 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
112
115
|
params << Riddl::Header.new("CPEE-CALLBACK-ID",callback)
|
|
113
116
|
params << Riddl::Header.new("CPEE-ACTIVITY",@handler_position)
|
|
114
117
|
params << Riddl::Header.new("CPEE-LABEL",@label||'')
|
|
115
|
-
params << Riddl::Header.new("CPEE-
|
|
118
|
+
params << Riddl::Header.new("CPEE-SIM-TARGET",@controller.attributes['sim_target']) if @controller.attributes['sim_target']
|
|
116
119
|
@controller.attributes.each do |key,value|
|
|
117
120
|
params << Riddl::Header.new("CPEE-ATTR-#{key.to_s.gsub(/_/,'-')}",value)
|
|
118
121
|
end
|
|
@@ -131,11 +134,11 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
131
134
|
@guard_files += result
|
|
132
135
|
|
|
133
136
|
if status == 561
|
|
134
|
-
if @controller.attributes['
|
|
135
|
-
gettrans = Riddl::Client.new(@controller.attributes['
|
|
137
|
+
if @controller.attributes['sim_translate']
|
|
138
|
+
gettrans = Riddl::Client.new(@controller.attributes['sim_translate'])
|
|
136
139
|
gtstatus, gtresult, gtheaders = gettrans.get
|
|
137
140
|
if gtstatus >= 200 && gtstatus < 300
|
|
138
|
-
transwhat = case headers['CPEE-
|
|
141
|
+
transwhat = case headers['CPEE-SIM-TASKTYPE']
|
|
139
142
|
when 'i'; 'instantiation'
|
|
140
143
|
when 'ir'; 'ipc-receive'
|
|
141
144
|
when 'is'; 'ipc-send'
|
|
@@ -188,10 +191,10 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
188
191
|
callback result, headers
|
|
189
192
|
elsif headers['CPEE_CALLBACK'] && headers['CPEE_CALLBACK'] == 'true' && result.empty?
|
|
190
193
|
if headers['CPEE_INSTANTIATION']
|
|
191
|
-
@controller.notify("task/instantiation", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(headers['CPEE_INSTANTIATION']))
|
|
194
|
+
@controller.notify("task/instantiation", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(headers['CPEE_INSTANTIATION']))
|
|
192
195
|
end
|
|
193
196
|
if headers['CPEE_EVENT']
|
|
194
|
-
@controller.notify("task/#{headers['CPEE_EVENT'].gsub(/[^\w_-]/,'')}", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint)
|
|
197
|
+
@controller.notify("task/#{headers['CPEE_EVENT'].gsub(/[^\w_-]/,'')}", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint)
|
|
195
198
|
end
|
|
196
199
|
# do nothing, later on things will happend
|
|
197
200
|
else
|
|
@@ -205,7 +208,7 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
205
208
|
@label = parameters[:label]
|
|
206
209
|
@anno = parameters.delete(:annotations) rescue nil
|
|
207
210
|
@controller.notify("status/resource_utilization", :mib => GetProcessMem.new.mb, **Process.times.to_h)
|
|
208
|
-
@controller.notify("activity/calling", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :annotations => @anno)
|
|
211
|
+
@controller.notify("activity/calling", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :annotations => @anno)
|
|
209
212
|
if passthrough.to_s.empty?
|
|
210
213
|
proto_curl parameters
|
|
211
214
|
else
|
|
@@ -242,20 +245,18 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
242
245
|
end #}}}
|
|
243
246
|
|
|
244
247
|
def inform_activity_done # {{{
|
|
245
|
-
@controller.notify("activity/done", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
|
|
248
|
+
@controller.notify("activity/done", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
|
|
246
249
|
@controller.notify("status/resource_utilization", :mib => GetProcessMem.new.mb, **Process.times.to_h)
|
|
247
250
|
end # }}}
|
|
248
251
|
def inform_activity_manipulate # {{{
|
|
249
|
-
@controller.notify("activity/manipulating", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
|
|
252
|
+
@controller.notify("activity/manipulating", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
|
|
250
253
|
end # }}}
|
|
251
254
|
def inform_activity_failed(err) # {{{
|
|
252
|
-
|
|
253
|
-
puts err.backtrace
|
|
254
|
-
@controller.notify("activity/failed", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1])
|
|
255
|
+
@controller.notify("activity/failed", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position, :message => err.backtrace[0].match(/(.*?):(\d+):\s(.*)/)[3], :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1])
|
|
255
256
|
end # }}}
|
|
256
257
|
def inform_manipulate_change(status,changed_dataelements,changed_endpoints,dataelements,endpoints) # {{{
|
|
257
258
|
unless status.nil?
|
|
258
|
-
@controller.notify("status/change", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position, :id => status.id, :message => status.message)
|
|
259
|
+
@controller.notify("status/change", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position, :id => status.id, :message => status.message)
|
|
259
260
|
end
|
|
260
261
|
unless changed_dataelements.nil? || changed_dataelements.empty?
|
|
261
262
|
de = dataelements.slice(*changed_dataelements).transform_values { |v| enc = CPEE::EvalRuby::Translation::detect_encoding(v); (enc == 'OTHER' ? v : (v.encode('UTF-8',enc) rescue CPEE::EvalRuby::Translation::convert_to_base64(v))) }
|
|
@@ -274,22 +275,29 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
274
275
|
end # }}}
|
|
275
276
|
|
|
276
277
|
def callback(result=nil,options={}) #{{{
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
status, ret, headers = Riddl::Client.new(@controller.url_result_transformation).request 'put' => result
|
|
279
|
+
recv = if status >= 200 && status < 300
|
|
280
|
+
JSON::parse(ret[0].value.read)
|
|
281
|
+
else
|
|
282
|
+
nil
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
@controller.notify("activity/receiving", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv, :annotations => @anno)
|
|
279
286
|
|
|
280
287
|
@guard_files += result
|
|
288
|
+
@guard_files += ret
|
|
281
289
|
|
|
282
290
|
if options['CPEE_INSTANTIATION']
|
|
283
|
-
@controller.notify("task/instantiation", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(options['CPEE_INSTANTIATION']))
|
|
291
|
+
@controller.notify("task/instantiation", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(options['CPEE_INSTANTIATION']))
|
|
284
292
|
end
|
|
285
293
|
if options['CPEE_EVENT']
|
|
286
|
-
@controller.notify("task/#{options['CPEE_EVENT'].gsub(/[^\w_-]/,'')}", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv)
|
|
294
|
+
@controller.notify("task/#{options['CPEE_EVENT'].gsub(/[^\w_-]/,'')}", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv)
|
|
287
295
|
else
|
|
288
296
|
@handler_returnValue = recv
|
|
289
297
|
@handler_returnOptions = options
|
|
290
298
|
end
|
|
291
299
|
if options['CPEE_STATUS']
|
|
292
|
-
@controller.notify("activity/status", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_STATUS'])
|
|
300
|
+
@controller.notify("activity/status", :ecid => Thread.current.__id__, :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_STATUS'])
|
|
293
301
|
end
|
|
294
302
|
if options['CPEE_UPDATE']
|
|
295
303
|
@handler_continue.continue WEEL::Signal::UpdateAgain
|
|
@@ -318,48 +326,137 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
|
318
326
|
GC.start
|
|
319
327
|
end #}}}
|
|
320
328
|
|
|
321
|
-
def
|
|
322
|
-
|
|
323
|
-
|
|
329
|
+
def code_error_handling(ret,where,what=RuntimeError) #{{{
|
|
330
|
+
sig = ret.find{|e| e.name == "signal" }.value
|
|
331
|
+
sigt = ret.find{|e| e.name == "signal_text" }.value
|
|
332
|
+
case sig
|
|
333
|
+
when 'Signal::Again'; throw WEEL::Signal::Again
|
|
334
|
+
when 'Signal::Error'; raise what, '', [where + ' ' + sigt]
|
|
335
|
+
when 'Signal::Stop'; raise WEEL::Signal::Stop
|
|
336
|
+
when 'Signal::SyntaxError'; raise SyntaxError, '', [where + ' ' + sigt]
|
|
337
|
+
else
|
|
338
|
+
raise 'something bad happened, but we dont know what.'
|
|
339
|
+
end
|
|
340
|
+
end #}}}
|
|
341
|
+
|
|
342
|
+
def argument_transform_value(obj, struct)
|
|
343
|
+
return nil unless obj.is_a?(Array) || obj.is_a?(Hash) || obj.is_a?(WEEL::ProcString)
|
|
344
|
+
case obj
|
|
345
|
+
when Hash
|
|
346
|
+
obj.each { |k, v| ret = argument_transform_value(v, struct); obj[k] = ret unless ret.nil? }
|
|
347
|
+
nil
|
|
348
|
+
when Array
|
|
349
|
+
obj.each_with_index { |v,i| ret = argument_transform_value(v, struct); obj[i] = ret unless ret.nil? }
|
|
350
|
+
nil
|
|
351
|
+
when WEEL::ProcString
|
|
352
|
+
argument_eval obj.code, struct
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def argument_eval(code,struct)
|
|
357
|
+
send = []
|
|
358
|
+
send.push Riddl::Parameter::Simple::new('code',code)
|
|
359
|
+
send.push Riddl::Parameter::Complex::new('dataelements','application/json', JSON::generate(struct.data))
|
|
360
|
+
send.push Riddl::Parameter::Complex::new('local','application/json', JSON::generate(struct.local)) if struct.local
|
|
361
|
+
send.push Riddl::Parameter::Complex::new('endpoints','application/json', JSON::generate(struct.endpoints))
|
|
362
|
+
send.push Riddl::Parameter::Complex::new('additional','application/json', JSON::generate(struct.additional))
|
|
363
|
+
|
|
364
|
+
status, ret, headers = Riddl::Client.new(@controller.url_code).request 'put' => send
|
|
365
|
+
recv = if status >= 200 && status < 300
|
|
366
|
+
ret.empty? ? nil : JSON::parse(ret[0].value.read)
|
|
324
367
|
else
|
|
325
|
-
|
|
368
|
+
code_error_handling ret, 'Parameter ' + code
|
|
326
369
|
end
|
|
327
|
-
|
|
328
|
-
|
|
370
|
+
recv
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def prepare(lock,dataelements,endpoints,status,local,additional,code,exec_endpoints,exec_parameters) #{{{
|
|
374
|
+
struct = if code
|
|
375
|
+
manipulate(true,lock,dataelements,endpoints,status,local,additional,code,'prepare')
|
|
376
|
+
else
|
|
377
|
+
WEEL::ReadStructure.new(dataelements,endpoints,local,additional)
|
|
378
|
+
end
|
|
379
|
+
@handler_endpoint = exec_endpoints.is_a?(Array) ? exec_endpoints.map{ |ep| struct.endpoints[ep] }.compact : struct.endpoints[exec_endpoints]
|
|
380
|
+
if @controller.attributes['sim_engine']
|
|
329
381
|
@handler_endpoint_orig = @handler_endpoint
|
|
330
|
-
@handler_endpoint = @controller.attributes['
|
|
382
|
+
@handler_endpoint = @controller.attributes['sim_engine'].to_s + '?original_endpoint=' + Riddl::Protocols::Utils::escape(@handler_endpoint)
|
|
331
383
|
end
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if
|
|
337
|
-
|
|
384
|
+
params = exec_parameters.dup
|
|
385
|
+
params[:arguments] = params[:arguments].dup if params[:arguments]
|
|
386
|
+
params[:arguments]&.map! do |ele|
|
|
387
|
+
t = ele.dup
|
|
388
|
+
if t.value.is_a?(WEEL::ProcString)
|
|
389
|
+
t.value = argument_eval t.value.code, struct
|
|
390
|
+
elsif t.value.is_a?(Array) || t.value.is_a?(Hash)
|
|
391
|
+
argument_transform_value t.value, struct
|
|
338
392
|
end
|
|
339
|
-
|
|
393
|
+
t
|
|
340
394
|
end
|
|
341
|
-
|
|
342
|
-
end #}}}
|
|
343
|
-
def test_condition(__dataelements,__endpoints,__local,__additional,__code,__args={}) #{{{
|
|
344
|
-
__struct = WEEL::ReadStructure.new(__dataelements,__endpoints,__local,__additional).instance_eval(__code,'Condition',1)
|
|
345
|
-
@controller.notify("gateway/decide", :instance_uuid => @controller.uuid, :code => __code, :condition => (__struct ? "true" : "false"))
|
|
346
|
-
__struct
|
|
395
|
+
params
|
|
347
396
|
end #}}}
|
|
348
|
-
def
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
397
|
+
def test_condition(dataelements,endpoints,local,additional,code,args={}) #{{{
|
|
398
|
+
send = []
|
|
399
|
+
send.push Riddl::Parameter::Simple::new('code',code)
|
|
400
|
+
send.push Riddl::Parameter::Complex::new('dataelements','application/json', JSON::generate(dataelements))
|
|
401
|
+
send.push Riddl::Parameter::Complex::new('local','application/json', JSON::generate(local)) if local
|
|
402
|
+
send.push Riddl::Parameter::Complex::new('endpoints','application/json', JSON::generate(endpoints))
|
|
403
|
+
send.push Riddl::Parameter::Complex::new('additional','application/json', JSON::generate(additional))
|
|
404
|
+
|
|
405
|
+
status, ret, headers = Riddl::Client.new(@controller.url_code).request 'put' => send
|
|
406
|
+
recv = if status >= 200 && status < 300
|
|
407
|
+
ret.empty? ? nil : JSON::parse(ret[0].value.read)
|
|
352
408
|
else
|
|
353
|
-
WEEL::
|
|
409
|
+
code_error_handling ret, 'Condition ' + code, WEEL::Signal::Error
|
|
410
|
+
end
|
|
411
|
+
recv = 'false' unless recv
|
|
412
|
+
recv = (recv == 'false' || recv == 'null' || recv == 'nil' || recv == false ? false : true)
|
|
413
|
+
@controller.notify("gateway/decide", :ecid => Thread.current.__id__, :instance_uuid => @controller.uuid, :code => code, :condition => recv)
|
|
414
|
+
recv
|
|
415
|
+
end #}}}
|
|
416
|
+
def manipulate(readonly,lock,dataelements,endpoints,status,local,additional,code,where,result=nil,options=nil) #{{{
|
|
417
|
+
lock.synchronize do
|
|
418
|
+
send = []
|
|
419
|
+
send.push Riddl::Parameter::Simple::new('code',code)
|
|
420
|
+
send.push Riddl::Parameter::Complex::new('dataelements','application/json', JSON::generate(dataelements))
|
|
421
|
+
send.push Riddl::Parameter::Complex::new('local','application/json', JSON::generate(local)) if local
|
|
422
|
+
send.push Riddl::Parameter::Complex::new('endpoints','application/json', JSON::generate(endpoints))
|
|
423
|
+
send.push Riddl::Parameter::Complex::new('additional','application/json', JSON::generate(additional))
|
|
424
|
+
send.push Riddl::Parameter::Complex::new('status','application/json', JSON::generate(status)) if status
|
|
425
|
+
send.push Riddl::Parameter::Complex::new('call_result','application/json', JSON::generate(result))
|
|
426
|
+
send.push Riddl::Parameter::Complex::new('call_headers','application/json', JSON::generate(options))
|
|
427
|
+
|
|
428
|
+
stat, ret, headers = Riddl::Client.new(@controller.url_code).request 'put' => send
|
|
429
|
+
if stat >= 200 && stat < 300
|
|
430
|
+
ret.shift # drop result
|
|
431
|
+
signal = changed_status = nil
|
|
432
|
+
changed_dataelements = changed_local = changed_endpoints = []
|
|
433
|
+
signal = ret.shift.value if ret.any? && ret[0].name == 'signal'
|
|
434
|
+
changed_dataelements = JSON::parse(ret.shift.value.read) if ret.any? && ret[0].name == 'changed_dataelements'
|
|
435
|
+
changed_endpoints = JSON::parse(ret.shift.value.read) if ret.any? && ret[0].name == 'changed_endpoints'
|
|
436
|
+
changed_status = JSON::parse(ret.shift.value.read) if ret.any? && ret[0].name == 'changed_status'
|
|
437
|
+
|
|
438
|
+
struct = if readonly
|
|
439
|
+
WEEL::ReadStructure.new(dataelements,endpoints,local,additional)
|
|
440
|
+
else
|
|
441
|
+
WEEL::ManipulateStructure.new(dataelements, endpoints, status, local, additional)
|
|
442
|
+
end
|
|
443
|
+
struct.update(changed_dataelements,changed_endpoints,changed_status)
|
|
444
|
+
|
|
445
|
+
struct
|
|
446
|
+
else
|
|
447
|
+
code_error_handling ret, where
|
|
448
|
+
end
|
|
354
449
|
end
|
|
355
|
-
__struct.instance_eval(__code,__where,1)
|
|
356
|
-
__struct
|
|
357
450
|
end #}}}
|
|
358
451
|
|
|
359
|
-
def split_branches(branches) # factual, so for inclusive or [[a],[b],[c,d,e]]{{{
|
|
360
|
-
|
|
452
|
+
def split_branches(id, branches = []) # factual, so for inclusive or [[a],[b],[c,d,e]] {{{
|
|
453
|
+
payload = { :instance_uuid => @controller.uuid, :ecid => id.to_s }
|
|
454
|
+
payload[:branches] = branches.length if branches.length > 0
|
|
455
|
+
@controller.notify("gateway/split", payload )
|
|
361
456
|
end #}}}
|
|
362
|
-
def join_branches(branches) # factual, so for inclusive or [[a],[b],[c,d,e]]{{{
|
|
363
|
-
|
|
457
|
+
def join_branches(id, branches = []) # factual, so for inclusive or [[a],[b],[c,d,e]] {{{
|
|
458
|
+
payload = { :instance_uuid => @controller.uuid, :ecid => id.to_s }
|
|
459
|
+
payload[:branches] = branches.length if branches.length > 0
|
|
460
|
+
@controller.notify("gateway/join", payload )
|
|
364
461
|
end #}}}
|
|
365
462
|
end
|
|
@@ -125,6 +125,12 @@ class Controller
|
|
|
125
125
|
def dataelements
|
|
126
126
|
@instance.data
|
|
127
127
|
end
|
|
128
|
+
def url_result_transformation
|
|
129
|
+
@opts[:url_result_transformation]
|
|
130
|
+
end
|
|
131
|
+
def url_code
|
|
132
|
+
@opts[:url_code]
|
|
133
|
+
end
|
|
128
134
|
|
|
129
135
|
def start
|
|
130
136
|
if vote("state/change", :state => 'running')
|
|
@@ -136,6 +142,16 @@ class Controller
|
|
|
136
142
|
end
|
|
137
143
|
end
|
|
138
144
|
|
|
145
|
+
def sim
|
|
146
|
+
if vote("state/change", :state => 'simulating')
|
|
147
|
+
@thread = @instance.sim
|
|
148
|
+
@thread.join
|
|
149
|
+
else
|
|
150
|
+
@thread = @instance.stop
|
|
151
|
+
@thread.join
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
139
155
|
def stop
|
|
140
156
|
### tell the instance to stop
|
|
141
157
|
@instance.stop
|
|
@@ -631,14 +631,14 @@
|
|
|
631
631
|
<!-- FUUUU, there is probably much more TODO. Updated Matthias und Juergen, we tested for ing-opcua/execute -->
|
|
632
632
|
<xsl:choose>
|
|
633
633
|
<xsl:when test="child::* and name(child::*)=concat(name(.),'_item') and count(child::*[not(name()=name(../child::*[1]))])=0">
|
|
634
|
-
<xsl:text>
|
|
634
|
+
<xsl:text>[ </xsl:text>
|
|
635
635
|
<xsl:apply-templates select="*" mode="JSONArrayItem"/>
|
|
636
|
-
<xsl:text>]
|
|
636
|
+
<xsl:text>]</xsl:text>
|
|
637
637
|
</xsl:when>
|
|
638
638
|
<xsl:otherwise>
|
|
639
|
-
<xsl:text>
|
|
639
|
+
<xsl:text>{ </xsl:text>
|
|
640
640
|
<xsl:apply-templates select="*" mode="JSONSUB"/>
|
|
641
|
-
<xsl:text>}
|
|
641
|
+
<xsl:text>}</xsl:text>
|
|
642
642
|
</xsl:otherwise>
|
|
643
643
|
</xsl:choose>
|
|
644
644
|
</xsl:when>
|
|
@@ -759,9 +759,9 @@
|
|
|
759
759
|
</xsl:template>
|
|
760
760
|
|
|
761
761
|
<xsl:template match="*" mode="JSONSUB">
|
|
762
|
-
<xsl:text
|
|
762
|
+
<xsl:text>"</xsl:text>
|
|
763
763
|
<xsl:value-of select="name()"/>
|
|
764
|
-
<xsl:text
|
|
764
|
+
<xsl:text>": </xsl:text>
|
|
765
765
|
<xsl:call-template name="JSONProperties">
|
|
766
766
|
<xsl:with-param name="parent" select="'Yes'"></xsl:with-param>
|
|
767
767
|
</xsl:call-template>
|
|
@@ -804,49 +804,49 @@
|
|
|
804
804
|
<xsl:otherwise>
|
|
805
805
|
<xsl:choose>
|
|
806
806
|
<xsl:when test="substring(.,1,1) = '!'">
|
|
807
|
-
<xsl:text
|
|
808
|
-
<xsl:value-of select="substring(.,2)"/>
|
|
809
|
-
<xsl:text>)
|
|
807
|
+
<xsl:text>🠊("</xsl:text>
|
|
808
|
+
<xsl:value-of select="str:replace(str:replace(substring(.,2),'\','\\'),'"','\"')"/>
|
|
809
|
+
<xsl:text>")</xsl:text>
|
|
810
810
|
</xsl:when>
|
|
811
811
|
<xsl:otherwise>
|
|
812
|
-
<xsl:text
|
|
812
|
+
<xsl:text>"</xsl:text>
|
|
813
813
|
<xsl:value-of select="str:replace(str:replace(.,'\','\\'),'"','\\\"')"/>
|
|
814
|
-
<xsl:text
|
|
814
|
+
<xsl:text>"</xsl:text>
|
|
815
815
|
</xsl:otherwise>
|
|
816
816
|
</xsl:choose>
|
|
817
817
|
</xsl:otherwise>
|
|
818
818
|
</xsl:choose>
|
|
819
819
|
</xsl:when>
|
|
820
820
|
<xsl:otherwise>
|
|
821
|
-
<xsl:text
|
|
821
|
+
<xsl:text>"</xsl:text>
|
|
822
822
|
<xsl:value-of select="name()"/>
|
|
823
|
-
<xsl:text
|
|
823
|
+
<xsl:text>": </xsl:text>
|
|
824
824
|
<xsl:choose>
|
|
825
825
|
<xsl:when test="string(number(.)) = .">
|
|
826
826
|
<xsl:value-of select="."/>
|
|
827
827
|
</xsl:when>
|
|
828
828
|
<xsl:otherwise>
|
|
829
|
-
<xsl:text
|
|
829
|
+
<xsl:text>"</xsl:text>
|
|
830
830
|
<xsl:choose>
|
|
831
831
|
<xsl:when test="substring(.,1,1) = '!'">
|
|
832
|
-
<xsl:text
|
|
832
|
+
<xsl:text>>🠊("</xsl:text>
|
|
833
833
|
<xsl:value-of select="str:replace(str:replace(substring(.,2),'\','\\'),'"','\\\"')"/>
|
|
834
|
-
<xsl:text>
|
|
834
|
+
<xsl:text>")</xsl:text>
|
|
835
835
|
</xsl:when>
|
|
836
836
|
<xsl:otherwise>
|
|
837
837
|
<xsl:value-of select="str:replace(str:replace(.,'\','\\'),'"','\\\"')"/>
|
|
838
838
|
</xsl:otherwise>
|
|
839
839
|
</xsl:choose>
|
|
840
|
-
<xsl:text
|
|
840
|
+
<xsl:text>"</xsl:text>
|
|
841
841
|
</xsl:otherwise>
|
|
842
842
|
</xsl:choose>
|
|
843
843
|
</xsl:otherwise>
|
|
844
844
|
</xsl:choose>
|
|
845
845
|
</xsl:when>
|
|
846
846
|
<xsl:when test="count(*[name()=$childName]) > 1">
|
|
847
|
-
<xsl:text>{
|
|
847
|
+
<xsl:text>{ "</xsl:text>
|
|
848
848
|
<xsl:value-of select="$childName"/>
|
|
849
|
-
<xsl:text
|
|
849
|
+
<xsl:text>": [ </xsl:text>
|
|
850
850
|
<xsl:apply-templates select="*" mode="JSONArrayElement"/>
|
|
851
851
|
<xsl:text>] }</xsl:text>
|
|
852
852
|
</xsl:when>
|
|
@@ -860,18 +860,18 @@
|
|
|
860
860
|
<xsl:text>}</xsl:text>
|
|
861
861
|
<xsl:if test="text()[normalize-space(.)]">
|
|
862
862
|
<xsl:text>, </xsl:text>
|
|
863
|
-
<xsl:text
|
|
863
|
+
<xsl:text>"</xsl:text>
|
|
864
864
|
<xsl:choose>
|
|
865
865
|
<xsl:when test="substring(.,1,1) = '!'">
|
|
866
|
-
<xsl:text
|
|
866
|
+
<xsl:text>>🠊("</xsl:text>
|
|
867
867
|
<xsl:value-of select="str:replace(str:replace(substring(.,2),'\','\\'),'"','\\\"')"/>
|
|
868
|
-
<xsl:text>
|
|
868
|
+
<xsl:text>")</xsl:text>
|
|
869
869
|
</xsl:when>
|
|
870
870
|
<xsl:otherwise>
|
|
871
871
|
<xsl:value-of select="str:replace(str:replace(.,'\','\\'),'"','\\\"')"/>
|
|
872
872
|
</xsl:otherwise>
|
|
873
873
|
</xsl:choose>
|
|
874
|
-
<xsl:text
|
|
874
|
+
<xsl:text>"</xsl:text>
|
|
875
875
|
<xsl:text>]</xsl:text>
|
|
876
876
|
</xsl:if>
|
|
877
877
|
</xsl:otherwise>
|
|
@@ -880,26 +880,26 @@
|
|
|
880
880
|
|
|
881
881
|
<!-- JSON Attribute Property -->
|
|
882
882
|
<xsl:template match="@*" mode="JSONSUB">
|
|
883
|
-
<xsl:text
|
|
883
|
+
<xsl:text>"@</xsl:text>
|
|
884
884
|
<xsl:value-of select="name()"/>
|
|
885
|
-
<xsl:text
|
|
885
|
+
<xsl:text>": </xsl:text>
|
|
886
886
|
<xsl:choose>
|
|
887
887
|
<xsl:when test="number(.) = .">
|
|
888
888
|
<xsl:value-of select="."/>
|
|
889
889
|
</xsl:when>
|
|
890
890
|
<xsl:otherwise>
|
|
891
|
-
<xsl:text
|
|
891
|
+
<xsl:text>"</xsl:text>
|
|
892
892
|
<xsl:choose>
|
|
893
893
|
<xsl:when test="substring(.,1,1) = '!'">
|
|
894
|
-
<xsl:text
|
|
894
|
+
<xsl:text>>🠊("</xsl:text>
|
|
895
895
|
<xsl:value-of select="str:replace(str:replace(substring(.,2),'\','\\'),'"','\\\"')"/>
|
|
896
|
-
<xsl:text>
|
|
896
|
+
<xsl:text>")</xsl:text>
|
|
897
897
|
</xsl:when>
|
|
898
898
|
<xsl:otherwise>
|
|
899
899
|
<xsl:value-of select="str:replace(str:replace(.,'\','\\'),'"','\\\"')"/>
|
|
900
900
|
</xsl:otherwise>
|
|
901
901
|
</xsl:choose>
|
|
902
|
-
<xsl:text
|
|
902
|
+
<xsl:text>"</xsl:text>
|
|
903
903
|
</xsl:otherwise>
|
|
904
904
|
</xsl:choose>
|
|
905
905
|
<xsl:choose>
|
|
@@ -18,9 +18,9 @@ module CPEE
|
|
|
18
18
|
|
|
19
19
|
module Ruby
|
|
20
20
|
BACKEND_INSTANCE = 'instance.rb'
|
|
21
|
-
BACKEND_OPTS = 'opts.yaml'
|
|
22
21
|
DSL_TO_DSLX_XSL = File.expand_path(File.join(__dir__,'dsl_to_dslx.xsl'))
|
|
23
22
|
BACKEND_RUN = File.expand_path(File.join(__dir__,'backend','run'))
|
|
23
|
+
BACKEND_OPTS = File.expand_path(File.join(__dir__,'backend','opts.yaml'))
|
|
24
24
|
BACKEND_TEMPLATE = File.expand_path(File.join(__dir__,'backend','instance.template'))
|
|
25
25
|
|
|
26
26
|
def self::dslx_to_dsl(dslx) # transpile
|
|
@@ -39,18 +39,20 @@ module CPEE
|
|
|
39
39
|
positions.map! do |k, v|
|
|
40
40
|
[ k, v, CPEE::Persistence::extract_item(id,opts,File.join('positions',k,'@passthrough')) ]
|
|
41
41
|
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
iopts = YAML::load_file(ExecutionHandler::Ruby::BACKEND_OPTS)
|
|
43
|
+
pp iopts
|
|
44
|
+
iopts[:host] = opts[:host]
|
|
45
|
+
iopts[:url] = opts[:url]
|
|
46
|
+
iopts[:redis_url] = opts[:redis_url]
|
|
47
|
+
iopts[:redis_path] = File.join(opts[:basepath],opts[:redis_path])
|
|
48
|
+
iopts[:redis_db] = opts[:redis_db]
|
|
49
|
+
iopts[:workers] = opts[:workers]
|
|
50
|
+
iopts[:global_executionhandlers] = opts[:global_executionhandlers]
|
|
51
|
+
iopts[:executionhandlers] = opts[:executionhandlers]
|
|
52
|
+
iopts[:executionhandler] = hw
|
|
53
|
+
|
|
54
|
+
File.open(File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_OPTS)),'w') do |f|
|
|
55
|
+
YAML::dump(iopts,f)
|
|
54
56
|
end
|
|
55
57
|
template = ERB.new(File.read(ExecutionHandler::Ruby::BACKEND_TEMPLATE), trim_mode: '-')
|
|
56
58
|
res = template.result_with_hash(dsl: dsl, dataelements: dataelements, endpoints: endpoints, positions: positions)
|
data/server/routing/end.pid
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
570906
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
570924
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
570918
|
data/server/routing/persist.pid
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
570912
|