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.
1994 1995 1996 1997 1998 |
# File 'lib/mdk_runtime.rb', line 1994 def initialize() self.__init_fields__ nil end |
Instance Attribute Details
#_counter ⇒ Object
Returns the value of attribute _counter.
1985 1986 1987 |
# File 'lib/mdk_runtime.rb', line 1985 def _counter @_counter end |
#_now ⇒ Object
Returns the value of attribute _now.
1985 1986 1987 |
# File 'lib/mdk_runtime.rb', line 1985 def _now @_now end |
#_scheduled ⇒ Object
Returns the value of attribute _scheduled.
1985 1986 1987 |
# File 'lib/mdk_runtime.rb', line 1985 def _scheduled @_scheduled end |
#dispatcher ⇒ Object
Returns the value of attribute dispatcher.
1985 1986 1987 |
# File 'lib/mdk_runtime.rb', line 1985 def dispatcher @dispatcher end |
Instance Method Details
#__init_fields__ ⇒ Object
2119 2120 2121 2122 2123 2124 2125 2126 2127 |
# File 'lib/mdk_runtime.rb', line 2119 def __init_fields__() self._now = 1000.0 self._scheduled = {} self.dispatcher = nil self._counter = 0 nil end |
#_getClass ⇒ Object
2065 2066 2067 2068 2069 2070 |
# File 'lib/mdk_runtime.rb', line 2065 def _getClass() return "mdk_runtime.FakeTime" nil end |
#_getField(name) ⇒ Object
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 |
# File 'lib/mdk_runtime.rb', line 2072 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
2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 |
# File 'lib/mdk_runtime.rb', line 2091 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.
2048 2049 2050 2051 2052 2053 |
# File 'lib/mdk_runtime.rb', line 2048 def advance(seconds) (self)._now = ((self)._now) + (seconds) nil end |
#onMessage(origin, msg) ⇒ Object
2010 2011 2012 2013 2014 2015 2016 2017 |
# File 'lib/mdk_runtime.rb', line 2010 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
2003 2004 2005 2006 2007 2008 |
# File 'lib/mdk_runtime.rb', line 2003 def onStart(dispatcher) (self).dispatcher = dispatcher nil end |
#onStop ⇒ Object
The Actor should begin shutting down.
2112 2113 2114 2115 2116 2117 |
# File 'lib/mdk_runtime.rb', line 2112 def onStop() nil nil end |
#pump ⇒ Object
Run scheduled events whose time has come.
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 |
# File 'lib/mdk_runtime.rb', line 2029 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.
2058 2059 2060 2061 2062 2063 |
# File 'lib/mdk_runtime.rb', line 2058 def scheduled() return (::DatawireQuarkCore::List.new(((self)._scheduled).keys)).size nil end |
#time ⇒ Object
2019 2020 2021 2022 2023 2024 |
# File 'lib/mdk_runtime.rb', line 2019 def time() return (self)._now nil end |