Module: RedShift

Includes:
Math
Defined in:
lib/redshift/meta.rb,
lib/redshift/port.rb,
lib/redshift/queue.rb,
lib/redshift/world.rb,
lib/redshift/syntax.rb,
lib/redshift/redshift.rb,
lib/redshift/component.rb,
lib/redshift/target/c/library.rb,
lib/redshift/target/c/flow-gen.rb,
lib/redshift/target/c/flow-gen.rb,
lib/redshift/target/c/flow/rk4.rb,
lib/redshift/target/c/flow/expr.rb,
lib/redshift/target/c/flow/expr.rb,
lib/redshift/target/c/flow/expr.rb,
lib/redshift/target/c/world-gen.rb,
lib/redshift/target/c/flow/delay.rb,
lib/redshift/target/c/flow/euler.rb,
lib/redshift/target/c/component-gen.rb,
lib/redshift/target/c/flow/algebraic.rb,
lib/redshift/target/c/flow/derivative.rb,
ext/redshift/dvector/dvector.rb,
ext/redshift/dvector-float/dvector-float.rb

Defined Under Namespace

Modules: AugmentedException, FlowSyntax, Shell, TransitionSyntax Classes: AlgebraicAssignmentError, AlgebraicFlow, AlreadyStarted, CexprGuard, CircularDefinitionError, Component, ConstnessError, DVector, DVectorFloat, DelayFlow, DerivativeFlow, EulerDifferentialFlow, Expr, Flow, Library, LinkTypeError, NilLinkError, NoValueError, Queue, RK4DifferentialFlow, RedShiftError, ResetExpr, SimultaneousQueueEntries, State, StrictnessError, SyntaxError, Transition, TransitionError, UnconnectedInputError, VarTypeError, World, XArray, ZenoError

Constant Summary collapse

ZENO_UNLIMITED =

Set zeno_level to this to turn off zeno checking.

-1
VERSION =
'1.3.29'
Infinity =
Math::Infinity
Always =
Transition.new :name => :Always, :guard => nil
Enter =

The asymmetry between these two states is that components in Enter are active in the continuous and discrete updates. Components in Exit do not evolve.

Component::Enter
Exit =
Component::Exit

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.do_library_callsObject



123
124
125
126
127
# File 'lib/redshift/redshift.rb', line 123

def RedShift.do_library_calls
  @library_calls.each do |block|
    block[library]
  end
end

.libraryObject



6
7
8
# File 'lib/redshift/target/c/library.rb', line 6

def RedShift.library
  @clib ||= Library.new($REDSHIFT_CLIB_NAME)
end

.require_targetObject



129
130
131
# File 'lib/redshift/redshift.rb', line 129

def RedShift.require_target
  require $REDSHIFT_TARGET
end

.with_library(&block) ⇒ Object

Defer a block until just after the library ruby code is loaded, but before commit. Necessary for defining inline C functions or shadow_attrs. Note that a whole require statement could be placed inside the with_library block.



119
120
121
# File 'lib/redshift/redshift.rb', line 119

def RedShift.with_library(&block) # :yields: library
  @library_calls << block
end

.worlds(world_class = World) ⇒ Object

Returns a list of all worlds (instances of RedShift::World and subclasses), or just those descending from world_class. Not very efficient, since it uses ObjectSpace.each_object, but useful in irb.



95
96
97
98
99
# File 'lib/redshift/redshift.rb', line 95

def self.worlds(world_class = World)
  worlds = []
  ObjectSpace.each_object(world_class) {|w| worlds << w}
  worlds
end

Instance Method Details

#debug(setting = true, &block) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/redshift/redshift.rb', line 77

def debug setting = true, &block
  if block
    begin
      save_setting = $REDSHIFT_DEBUG
      $REDSHIFT_DEBUG = setting
      block.call
    ensure
      $REDSHIFT_DEBUG = save_setting
    end
  else
    $REDSHIFT_DEBUG = setting
  end
end