Module: CPEE::Frames

Defined in:
lib/cpee-frames/implementation.rb

Defined Under Namespace

Classes: Delete, DeleteFrame, Get, GetAllConfigs, GetCpeeInstance, GetDataElements, GetFrames, GetInfo, GetLangs, GetStyle, GetTutorial, Handler, InitFrame, NewFrameSet, NewFrameWait, OutputTest, SSE, SSE2, SetDataElements, SetLang, Signaling

Constant Summary collapse

SERVER =
File.expand_path(File.join(__dir__,'frames.xml'))

Class Method Summary collapse

Class Method Details

.implementation(opts) ⇒ Object

}}}



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/cpee-frames/implementation.rb', line 460

def self::implementation(opts)
  opts[:signals] = {}
  opts[:signals2] = {}
  opts[:data_dir] ||= File.expand_path(File.join(__dir__,'data'))

  Proc.new do
    parallel do
      loop do
        opts[:signals].each do |k,v|
          v.send('keepalive')
        end
        opts[:signals2].each do |k,v|
          v.send('keepalive')
        end
        sleep 5
      end
    end

    on resource do
      run GetTutorial if get

      on resource 'getConfigs' do
        run GetAllConfigs, opts[:data_dir] if get
      end

      on resource do |r|
        idx = r[:r][0]
        opts[:signals][idx] ||= Signaling.new
        opts[:signals2]["handler"] ||= Signaling.new

        run Get if get
        run InitFrame, opts[:signals][idx], opts[:data_dir] if post 'input'

        run NewFrameSet, opts[:signals][idx], opts[:data_dir] if put 'sframe'
        run NewFrameWait, opts[:signals][idx], opts[:data_dir] if put 'wframe'

        run DeleteFrame, opts[:signals][idx], opts[:data_dir] if post 'deleteframe'

        on resource 'handler' do
          run Handler, opts[:signals2]["handler"], opts[:data_dir] if post
          on resource 'sse' do
            run SSE2, opts[:signals2]["handler"] if sse
          end
        end

        run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opa'
        run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opb'
        run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opc'
        on resource 'sse' do
          run SSE, opts[:signals][idx] if sse
        end
        on resource 'languages' do
          run GetLangs, opts[:data_dir] if get
          run SetLang, opts[:signals][idx], opts[:data_dir] if post 'lang'
        end
        on resource 'style.url' do
          run GetStyle, opts[:data_dir] if get
        end
        on resource 'cpeeinstance.url' do
          run GetCpeeInstance, opts[:data_dir] if get
        end
        on resource 'info.json' do
          run GetInfo, opts[:data_dir] if get
        end
        on resource 'frames.json' do
          run GetFrames, opts[:data_dir] if get
        end
        on resource 'test' do
          run OutputTest if put
        end

        on resource 'dataelements.json' do
          run SetDataElements, opts[:data_dir] if post
          run GetDataElements, opts[:data_dir] if get
        end
      end
    end
  end
end

.overlap?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/cpee-frames/implementation.rb', line 32

def self::overlap?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
  if l1x > r2x || l2x > r1x
      return false
  end
  if l1y > r2y || l2y > r1y
      return false
  end
  return true
end