Class: Quark::MdkRuntime::FakeTime
- Inherits:
-
DatawireQuarkCore::QuarkObject
- Object
- DatawireQuarkCore::QuarkObject
- Quark::MdkRuntime::FakeTime
- Extended by:
- DatawireQuarkCore::Static
- Defined in:
- lib/mdk_runtime.rb
Overview
Testing fake.
Constant Summary
Constants included from DatawireQuarkCore::Static
DatawireQuarkCore::Static::Unassigned
Instance Attribute Summary collapse
-
#_counter ⇒ Object
Returns the value of attribute _counter.
-
#_now ⇒ Object
Returns the value of attribute _now.
-
#_scheduled ⇒ Object
Returns the value of attribute _scheduled.
-
#dispatcher ⇒ Object
Returns the value of attribute dispatcher.
Instance Method Summary collapse
- #__init_fields__ ⇒ Object
- #_getClass ⇒ Object
- #_getField(name) ⇒ Object
- #_setField(name, value) ⇒ Object
-
#advance(seconds) ⇒ Object
Move time forward.
-
#initialize ⇒ FakeTime
constructor
A new instance of FakeTime.
- #onMessage(origin, msg) ⇒ Object
- #onStart(dispatcher) ⇒ Object
-
#onStop ⇒ Object
The Actor should begin shutting down.
-
#pump ⇒ Object
Run scheduled events whose time has come.
-
#scheduled ⇒ Object
Number of scheduled events.
- #time ⇒ Object
Methods included from DatawireQuarkCore::Static
_lazy_statics, static, unlazy_statics
Methods inherited from DatawireQuarkCore::QuarkObject
Constructor Details
#initialize ⇒ FakeTime
Returns a new instance of FakeTime.
1997 1998 1999 2000 2001 |
# File 'lib/mdk_runtime.rb', line 1997 def initialize() self.__init_fields__ nil end |
Instance Attribute Details
#_counter ⇒ Object
Returns the value of attribute _counter.
1988 1989 1990 |
# File 'lib/mdk_runtime.rb', line 1988 def _counter @_counter end |
#_now ⇒ Object
Returns the value of attribute _now.
1988 1989 1990 |
# File 'lib/mdk_runtime.rb', line 1988 def _now @_now end |
#_scheduled ⇒ Object
Returns the value of attribute _scheduled.
1988 1989 1990 |
# File 'lib/mdk_runtime.rb', line 1988 def _scheduled @_scheduled end |
#dispatcher ⇒ Object
Returns the value of attribute dispatcher.
1988 1989 1990 |
# File 'lib/mdk_runtime.rb', line 1988 def dispatcher @dispatcher end |
Instance Method Details
#__init_fields__ ⇒ Object
2122 2123 2124 2125 2126 2127 2128 2129 2130 |
# File 'lib/mdk_runtime.rb', line 2122 def __init_fields__() self._now = 1000.0 self._scheduled = {} self.dispatcher = nil self._counter = 0 nil end |
#_getClass ⇒ Object
2068 2069 2070 2071 2072 2073 |
# File 'lib/mdk_runtime.rb', line 2068 def _getClass() return "mdk_runtime.FakeTime" nil end |
#_getField(name) ⇒ Object
2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 |
# File 'lib/mdk_runtime.rb', line 2075 def _getField(name) if ((name) == ("_now")) return (self)._now end if ((name) == ("_scheduled")) return (self)._scheduled end if ((name) == ("dispatcher")) return (self).dispatcher end if ((name) == ("_counter")) return (self)._counter end return nil nil end |
#_setField(name, value) ⇒ Object
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 |
# File 'lib/mdk_runtime.rb', line 2094 def _setField(name, value) if ((name) == ("_now")) (self)._now = ::DatawireQuarkCore.cast(value) { ::Float } end if ((name) == ("_scheduled")) (self)._scheduled = ::DatawireQuarkCore.cast(value) { ::Hash } end if ((name) == ("dispatcher")) (self).dispatcher = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.actors.MessageDispatcher } end if ((name) == ("_counter")) (self)._counter = ::DatawireQuarkCore.cast(value) { ::Integer } end nil end |
#advance(seconds) ⇒ Object
Move time forward.
2051 2052 2053 2054 2055 2056 |
# File 'lib/mdk_runtime.rb', line 2051 def advance(seconds) (self)._now = ((self)._now) + (seconds) nil end |
#onMessage(origin, msg) ⇒ Object
2013 2014 2015 2016 2017 2018 2019 2020 |
# File 'lib/mdk_runtime.rb', line 2013 def onMessage(origin, msg) sched = ::DatawireQuarkCore.cast(msg) { ::Quark.mdk_runtime.Schedule } (self)._counter = ((self)._counter) + (1) (@_scheduled)[(@_counter)] = (::Quark.mdk_runtime._FakeTimeRequest.new(origin, (sched).event, ((self)._now) + ((sched).seconds))) nil end |
#onStart(dispatcher) ⇒ Object
2006 2007 2008 2009 2010 2011 |
# File 'lib/mdk_runtime.rb', line 2006 def onStart(dispatcher) (self).dispatcher = dispatcher nil end |
#onStop ⇒ Object
The Actor should begin shutting down.
2115 2116 2117 2118 2119 2120 |
# File 'lib/mdk_runtime.rb', line 2115 def onStop() nil nil end |
#pump ⇒ Object
Run scheduled events whose time has come.
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 |
# File 'lib/mdk_runtime.rb', line 2032 def pump() idx = 0 keys = ::DatawireQuarkCore::List.new(((self)._scheduled).keys) while ((idx) < ((keys).size)) do request = (@_scheduled)[(keys)[idx]] if (((request).happensAt) <= ((self)._now)) ((self)._scheduled).delete((keys)[idx]) (self).dispatcher.tell(self, ::Quark.mdk_runtime.Happening.new((request).event, self.time()), (request).requester) end idx = (idx) + (1) end nil end |
#scheduled ⇒ Object
Number of scheduled events.
2061 2062 2063 2064 2065 2066 |
# File 'lib/mdk_runtime.rb', line 2061 def scheduled() return (::DatawireQuarkCore::List.new(((self)._scheduled).keys)).size nil end |
#time ⇒ Object
2022 2023 2024 2025 2026 2027 |
# File 'lib/mdk_runtime.rb', line 2022 def time() return (self)._now nil end |