class

Quartz::DTSS::AtomicModel

Inherits Quartz::Verifiable / Quartz::Observable / Quartz::Coupleable / Quartz::Transferable / Quartz::Stateful / Quartz::Model / Reference / Object

This class represent a PDTSS atomic model.

Constants

STATE_CHECKS = {state_complete: false}

Constructors

new(name, state)
Source
new(name)
Source

Class methods

check(*attributes : Symbol, **kwargs)
Source
check_with(klass : Verifiers::RuntimeValidator.class, **kwargs)

Passes the model off to the class or classes specified and allows them to add errors based on more complex conditions.

class MyModel
  include Quartz::Verifiable
  check_with MyVerifier
end

class MyVerifier < Quartz::Verifiers::RuntimeChecker
  def validate(model)
    if some_test
      model.errors.add(:phase, "This model state is invalid")
    end
  end

  # ...
end
Source
check_with(klass : Verifiers::EachChecker.class, *attributes : Symbol, **kwargs)

Passes the model off to the class or classes specified and allows them to add errors based on more complex conditions.

class MyModel
  include Quartz::Verifiable
  check_with MyVerifier
end

class MyVerifier < Quartz::Verifiers::EachChecker
  def check_each(model, attribute, value)
    if some_test
      model.errors.add(attribute, "This model attribute is invalid")
    end
  end

  # ...
end
Source
clear_verifiers
Source
precision_scale
Source
time_delta
Source
time_delta=(time_delta : Duration)
Source
verifiers
Source

Instance methods

inspect(io)
Source
model_precision

Returns the precision associated with the class.

Source
output

The output function (λ)

Override this method to implement the appropriate behavior of your model. See #post to send values to output ports.

Example:

def output
  post(42, :output)
end
Source
time_delta
Source
transition(messages : Hash(InputPort, Array(Any)))
Source

Macros

def_serialization
Source
input(*names)

Defines default input ports for each of the given arguments. Those default input ports will be available in all instances, including instances of subclasses (meaning that ports are inherited).

Writing:

class MyModel < AtomicModel
  input port_name
end

Is the same as writing:

class MyModel < AtomicModel
  def initialize(name)
    super(name)
    add_input_port :port_name
  end
end

The arguments can be string literals, symbol literals or plain names. However, they will be converted to symbol literals when the model is instantiated.

class MyModel < AtomicModel
  input :in1, "in2", in3
end
Source
output(*names)

Defines default output ports for each of the given arguments. Those default output ports will be available in all instances, including instances of subclasses (meaning that ports are inherited).

Writing:

class MyModel < AtomicModel
  output port_name
end

Is the same as writing:

class MyModel < AtomicModel
  def initialize(name)
    super(name)
    add_output_port :port_name
  end
end

The arguments can be string literals, symbol literals or plain names. However, they will be converted to symbols literals when the model is instantiated.

class MyModel < AtomicModel
  output :out1, "out2", out3
end
Source