abstract class Quartz::DTSS::AtomicModel
- Quartz::DTSS::AtomicModel
- Quartz::Model
- Reference
- Object
Overview
This class represent a PDTSS atomic model.
Included Modules
Defined in:
quartz/dtss/atomic.crquartz/json.cr
Constant Summary
-
STATE_CHECKS =
{state_complete: false}
Constructors
Class Method Summary
- .check(*attributes : Symbol, **kwargs)
-
.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.
-
.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.
- .clear_verifiers
- .precision_scale : Scale
- .time_delta : Duration
- .time_delta=(time_delta : Duration)
- .verifiers
Instance Method Summary
- #inspect(io)
-
#model_precision : Scale
Returns the precision associated with the class.
-
#output
The output function (λ)
- #time_delta : Duration
- #transition(messages : Hash(InputPort, Array(Any)))
Macro Summary
- def_serialization
-
input(*names)
Defines default input ports for each of the given arguments.
-
output(*names)
Defines default output ports for each of the given arguments.
Instance methods inherited from module Quartz::Verifiable
clear_errors
clear_errors,
errors
errors,
invalid?(context : Symbol | Nil = nil) : Bool
invalid?,
valid?(context : Symbol | Nil = nil) : Bool
valid?
Instance methods inherited from module Quartz::Observable
add_observer(observer : Observer)
add_observer,
count_observers
count_observers,
delete_observer(observer : Observer) : Bool
delete_observer,
notify_observers(info = nil)
notify_observers
Instance methods inherited from module Quartz::Coupleable
add_input_port(name)
add_input_port,
add_output_port(name)
add_output_port,
add_port(port : InputPort)add_port(port : OutputPort) add_port, each_input_port(&) each_input_port, each_output_port(&) each_output_port, input_port(name : Name) : InputPort input_port, input_port?(name : Name) : InputPort | Nil input_port?, input_port_list : Array(InputPort) input_port_list, input_port_names input_port_names, output_port(name : Name) : OutputPort output_port, output_port?(name : Name) : OutputPort | Nil output_port?, output_port_list : Array(OutputPort) output_port_list, output_port_names output_port_names, remove_input_port(name) remove_input_port, remove_output_port(name) remove_output_port, remove_port(port : InputPort)
remove_port(port : OutputPort) remove_port
Instance methods inherited from module Quartz::Stateful
initial_state
initial_state,
initial_state=(state : Quartz::State)
initial_state=,
state
state,
state=(state : Quartz::State)
state=
Instance methods inherited from class Quartz::Model
accept(visitor : Visitor)
accept,
accept_children(visitor)
accept_children,
after_initialize
after_initialize,
inspect(io)
inspect,
name : Name
name,
name=(name : Name)
name=,
processor : Processor | Nil
processor,
processor=(processor : Processor | Nil)
processor=,
processor? : Processor | Nil | Nil
processor?,
to_s(io)
to_s
Constructor methods inherited from class Quartz::Model
new(name : Name)
new
Instance methods inherited from class Reference
==(other : Quartz::Any)
==
Instance methods inherited from class Object
===(other : Quartz::Any)
===
Constructor Detail
Class Method Detail
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
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
Instance Method Detail
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
Macro Detail
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
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