Class: WEEL
- Inherits:
-
Object
- Object
- WEEL
- Defined in:
- lib/weel.rb
Defined Under Namespace
Modules: Signal Classes: ConnectionWrapperBase, Continue, DSLRealization, ManipulateHash, ManipulateStructure, Position, ProcString, ReadHash, ReadOnlyHash, ReadStructure, Status
Class Method Summary collapse
-
.connectionwrapper(aClassname, *args) ⇒ Object
}}}.
-
.control(flow, &block) ⇒ Object
}}}.
-
.data(data_elements) ⇒ Object
}}}.
-
.endpoint(new_endpoints) ⇒ Object
}}}.
-
.flow(flow_data = nil) ⇒ Object
}}}.
-
.search(*weel_search) ⇒ Object
}}}.
Instance Method Summary collapse
-
#abandon ⇒ Object
}}}.
-
#connectionwrapper ⇒ Object
set the connectionwrapper.
-
#connectionwrapper=(new_weel_connectionwrapper) ⇒ Object
}}}.
-
#connectionwrapper_args ⇒ Object
Get/Set the connectionwrapper arguments.
-
#connectionwrapper_args=(args) ⇒ Object
}}}.
-
#data(new_data = nil) ⇒ Object
}}}.
-
#description(&blk) ⇒ Object
get/set workflow description.
-
#description=(code) ⇒ Object
{{{.
-
#endpoint(new_endpoints) ⇒ Object
}}}.
-
#endpoints(new_endpoints = nil) ⇒ Object
}}}.
-
#initialize(*args) ⇒ WEEL
constructor
{{{.
-
#positions ⇒ Object
{{{.
-
#search(new_weel_search = false) ⇒ Object
Set search positions set new_weel_search to a boolean (or anything else) to start the process from beginning (reset serach positions).
-
#sim ⇒ Object
}}}.
-
#start ⇒ Object
Start the workflow execution.
-
#state ⇒ Object
Get the state of execution (ready|running|stopping|stopped|finished|simulating|abandoned).
-
#state_signal ⇒ Object
}}}.
-
#status ⇒ Object
}}}.
-
#stop ⇒ Object
Stop the workflow execution.
Constructor Details
#initialize(*args) ⇒ WEEL
{{{
21 22 23 24 25 26 27 28 29 30 31 |
# 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 |
Class Method Details
.connectionwrapper(aClassname, *args) ⇒ Object
}}}
468 469 470 471 472 473 |
# File 'lib/weel.rb', line 468 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) ⇒ Object
}}}
474 475 476 477 478 |
# File 'lib/weel.rb', line 474 def self::control(flow, &block)# {{{ define_method :initialize_control do self.description = block end end |
.data(data_elements) ⇒ Object
}}}
459 460 461 462 463 464 465 466 467 |
# File 'lib/weel.rb', line 459 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) ⇒ Object
}}}
449 450 451 452 453 454 455 456 457 458 |
# File 'lib/weel.rb', line 449 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) ⇒ Object
}}}
479 480 481 482 483 |
# File 'lib/weel.rb', line 479 def self::flow(flow_data=nil) # {{{ define_method :initialize_flow_data do self.flow_data = flow_data end if flow_data end |
.search(*weel_search) ⇒ Object
}}}
444 445 446 447 448 |
# File 'lib/weel.rb', line 444 def self::search(*weel_search)# {{{ define_method :initialize_search do self.search weel_search end end |
Instance Method Details
#abandon ⇒ Object
}}}
1180 1181 1182 |
# File 'lib/weel.rb', line 1180 def abandon # {{{ @dslr.__weel_state = :abandoned end |
#connectionwrapper ⇒ Object
set the connectionwrapper
1148 1149 1150 |
# File 'lib/weel.rb', line 1148 def connectionwrapper # {{{ @dslr.__weel_connectionwrapper end |
#connectionwrapper=(new_weel_connectionwrapper) ⇒ Object
}}}
1151 1152 1153 1154 1155 1156 1157 1158 1159 |
# File 'lib/weel.rb', line 1151 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 ⇒ Object
Get/Set the connectionwrapper arguments
1162 1163 1164 |
# File 'lib/weel.rb', line 1162 def connectionwrapper_args # {{{ @dslr.__weel_connectionwrapper_args end |
#connectionwrapper_args=(args) ⇒ Object
}}}
1165 1166 1167 1168 1169 1170 |
# File 'lib/weel.rb', line 1165 def connectionwrapper_args=(args) # {{{ if args.class == Array @dslr.__weel_connectionwrapper_args = args end nil end |
#data(new_data = nil) ⇒ Object
}}}
1244 1245 1246 1247 1248 1249 |
# File 'lib/weel.rb', line 1244 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) ⇒ Object
get/set workflow description
1185 1186 1187 |
# File 'lib/weel.rb', line 1185 def description(&blk) self.description=(blk) end |
#description=(code) ⇒ Object
{{{
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/weel.rb', line 1188 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) ⇒ Object
}}}
1256 1257 1258 1259 1260 1261 |
# File 'lib/weel.rb', line 1256 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) ⇒ Object
}}}
1250 1251 1252 1253 1254 1255 |
# File 'lib/weel.rb', line 1250 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 ⇒ Object
{{{
1143 1144 1145 |
# File 'lib/weel.rb', line 1143 def positions # {{{ @dslr.__weel_positions end |
#search(new_weel_search = false) ⇒ Object
Set search positions set new_weel_search to a boolean (or anything else) to start the process from beginning (reset serach positions)
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 |
# File 'lib/weel.rb', line 1229 def search(new_weel_search=false) # {{{ @dslr.__weel_search_positions.clear new_weel_search = [new_weel_search] if new_weel_search.is_a?(Position) if !new_weel_search.is_a?(Array) || new_weel_search.empty? false else new_weel_search.each do |search_position| @dslr.__weel_search_positions[search_position.position] = search_position end true end end |
#sim ⇒ Object
}}}
1292 1293 1294 1295 1296 1297 1298 |
# File 'lib/weel.rb', line 1292 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 ⇒ Object
Start the workflow execution
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 |
# File 'lib/weel.rb', line 1278 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. puts e.backtrace connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e end end end |
#state ⇒ Object
Get the state of execution (ready|running|stopping|stopped|finished|simulating|abandoned)
1173 1174 1175 |
# File 'lib/weel.rb', line 1173 def state # {{{ @dslr.__weel_state end |
#state_signal ⇒ Object
}}}
1176 1177 1178 1179 |
# File 'lib/weel.rb', line 1176 def state_signal # {{{ connectionwrapper::inform_state_change connectionwrapper_args, state state end |
#status ⇒ Object
}}}
1262 1263 1264 |
# File 'lib/weel.rb', line 1262 def status # {{{ @dslr.__weel_status end |
#stop ⇒ Object
Stop the workflow execution
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 |
# File 'lib/weel.rb', line 1267 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 |