class WEEL

Public Class Methods

connectionwrapper(aClassname, *args) click to toggle source
# File lib/weel.rb, line 459
def self::connectionwrapper(aClassname, *args)# {{{
  define_method :initialize_connectionwrapper do
    self.connectionwrapper = aClassname
    self.connectionwrapper_args = args unless args.empty?
  end
end
control(flow, &block) click to toggle source
# File lib/weel.rb, line 465
def self::control(flow, &block)# {{{
  define_method :initialize_control do
    self.description = block
  end
end
data(data_elements) click to toggle source
# File lib/weel.rb, line 450
def self::data(data_elements)# {{{
  @@__weel_new_data_elements ||= {}
  @@__weel_new_data_elements.merge! data_elements
  define_method :initialize_data do
    @@__weel_new_data_elements.each do |name,value|
      @dslr.__weel_data[name.to_s.to_sym] = value
    end
  end
end
endpoint(new_endpoints) click to toggle source
# File lib/weel.rb, line 440
def self::endpoint(new_endpoints)# {{{
  @@__weel_new_endpoints ||= {}
  @@__weel_new_endpoints.merge! new_endpoints
  remove_method :initialize_endpoints if method_defined? :initialize_endpoints
  define_method :initialize_endpoints do
    @@__weel_new_endpoints.each do |name,value|
      @dslr.__weel_endpoints[name.to_s.to_sym] = value
    end
  end
end
flow(flow_data=nil) click to toggle source
# File lib/weel.rb, line 470
def self::flow(flow_data=nil) # {{{
  define_method :initialize_flow_data do
    self.flow_data = flow_data
  end if flow_data
end
new(*args) click to toggle source
# File lib/weel.rb, line 21
def initialize(*args)# {{{
  @dslr = DSLRealization.new
  @dslr.__weel_connectionwrapper_args = args

  initialize_search if methods.include?(:initialize_search)
  initialize_data if methods.include?(:initialize_data)
  initialize_endpoints if methods.include?(:initialize_endpoints)
  initialize_connectionwrapper if methods.include?(:initialize_connectionwrapper)
  initialize_control if methods.include?(:initialize_control)
  initialize_flow_data if methods.include?(:initialize_flow_data)
end

Public Instance Methods

abandon() click to toggle source
# File lib/weel.rb, line 1115
def abandon # {{{
  @dslr.__weel_state = :abandoned
end
connectionwrapper() click to toggle source

set the connectionwrapper

# File lib/weel.rb, line 1083
def connectionwrapper # {{{
  @dslr.__weel_connectionwrapper
end
connectionwrapper=(new_weel_connectionwrapper) click to toggle source
# File lib/weel.rb, line 1086
def connectionwrapper=(new_weel_connectionwrapper) # {{{
  superclass = new_weel_connectionwrapper
  while superclass
    check_ok = true if superclass == WEEL::ConnectionWrapperBase
    superclass = superclass.superclass
  end
  raise "ConnectionWrapper is not inherited from ConnectionWrapperBase" unless check_ok
  @dslr.__weel_connectionwrapper = new_weel_connectionwrapper
end
connectionwrapper_args() click to toggle source

Get/Set the connectionwrapper arguments

# File lib/weel.rb, line 1097
def connectionwrapper_args # {{{
  @dslr.__weel_connectionwrapper_args
end
connectionwrapper_args=(args) click to toggle source
# File lib/weel.rb, line 1100
def connectionwrapper_args=(args) # {{{
  if args.class == Array
    @dslr.__weel_connectionwrapper_args = args
  end
  nil
end
data(new_data=nil) click to toggle source
# File lib/weel.rb, line 1179
def data(new_data=nil) # {{{
  unless new_data.nil? || !new_data.is_a?(Hash)
    new_data.each{ |k,v| @dslr.__weel_data[k] = v }
  end
  @dslr.__weel_data
end
description(&blk) click to toggle source

get/set workflow description

# File lib/weel.rb, line 1120
def description(&blk)
  self.description=(blk)
end
description=(code) click to toggle source
# File lib/weel.rb, line 1123
def description=(code) # {{{
  (class << self; self; end).class_eval do
    remove_method :__weel_control_flow if method_defined? :__weel_control_flow
    define_method :__weel_control_flow do |state,final_state=:finished|
      @dslr.__weel_positions.clear
      @dslr.__weel_state = state
      begin
        if code.is_a? Proc
          @dslr.instance_eval(&code)
        else
          @dslr.instance_eval(code)
        end
      rescue SyntaxError => se
        @dslr.__weel_state = :stopping
        @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,se,code)
      rescue NameError => err # don't look into it, or it will explode
        @dslr.__weel_state = :stopping
        @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new("main: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),code)
      rescue => err
        @dslr.__weel_state = :stopping
        @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,err,code)
      end
      if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
        ipc = { :unmark => [] }
        @dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp }
        @dslr.__weel_positions.clear
        @dslr.__weel_connectionwrapper::inform_position_change(@dslr.__weel_connectionwrapper_args,ipc)
        @dslr.__weel_state = :finished
      end
      if @dslr.__weel_state == :simulating
        @dslr.__weel_state = final_state
      end
      if @dslr.__weel_state == :stopping
        @dslr.__weel_finalize
      end
    end
  end
end
endpoint(new_endpoints) click to toggle source
# File lib/weel.rb, line 1191
def endpoint(new_endpoints) # {{{
  unless new_endpoints.nil? || !new_endpoints.is_a?(Hash) || !new_endpoints.length == 1
    new_endpoints.each{ |k,v| @dslr.__weel_endpoints[k] = v }
  end
  nil
end
endpoints(new_endpoints=nil) click to toggle source
# File lib/weel.rb, line 1185
def endpoints(new_endpoints=nil) # {{{
  unless new_endpoints.nil? || !new_endpoints.is_a?(Hash)
    new_endpoints.each{ |k,v| @dslr.__weel_endpoints[k] = v }
  end
  @dslr.__weel_endpoints
end
positions() click to toggle source
# File lib/weel.rb, line 1078
def positions # {{{
  @dslr.__weel_positions
end
sim() click to toggle source
# File lib/weel.rb, line 1227
def sim # {{{
  stat = @dslr.__weel_state
  return nil unless stat == :ready || stat == :stopped
  @dslr.__weel_main = Thread.new do
    __weel_control_flow :simulating, stat
  end
end
start() click to toggle source

Start the workflow execution

# File lib/weel.rb, line 1213
def start # {{{
  return nil if @dslr.__weel_state != :ready && @dslr.__weel_state != :stopped
  @dslr.__weel_main = Thread.new do
    Thread.current[:branch_search] = true if @dslr.__weel_search_positions.any?
    begin
      __weel_control_flow(:running)
    rescue => e
      puts e.message
      puts e.backtrace
      connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e
    end
  end
end
state() click to toggle source

Get the state of execution (ready|running|stopping|stopped|finished|simulating|abandoned)

# File lib/weel.rb, line 1108
def state # {{{
  @dslr.__weel_state
end
state_signal() click to toggle source
# File lib/weel.rb, line 1111
def state_signal # {{{
  connectionwrapper::inform_state_change connectionwrapper_args, state
  state
end
status() click to toggle source
# File lib/weel.rb, line 1197
def status # {{{
  @dslr.__weel_status
end
stop() click to toggle source

Stop the workflow execution

# File lib/weel.rb, line 1202
def stop # {{{
  Thread.new do
    if  @dslr.__weel_state == :running
      @dslr.__weel_state = :stopping
      @dslr.__weel_main.join if @dslr.__weel_main
    elsif @dslr.__weel_state == :ready || @dslr.__weel_state == :stopped
      @dslr.__weel_state = :stopped
    end
  end
end