Monitors and returns the status of the application.
| 82 | |
| 83 | |
| 84 | class Status(views.ColumnTextModel): |
| 85 | """Monitors and returns the status of the application.""" |
| 86 | |
| 87 | def __init__(self, time_multiplier, pause, frame_timer): |
| 88 | """Instance initializer. |
| 89 | |
| 90 | Args: |
| 91 | time_multiplier: Instance of util.TimeMultiplier. |
| 92 | pause: An observable pause subject, instance of util.ObservableFlag. |
| 93 | frame_timer: A Timer instance counting duration of frames. |
| 94 | """ |
| 95 | self._runtime = None |
| 96 | self._time_multiplier = time_multiplier |
| 97 | self._camera = None |
| 98 | self._pause = pause |
| 99 | self._frame_timer = frame_timer |
| 100 | self._fps_counter = util.Integrator() |
| 101 | self._cpu_counter = util.Integrator() |
| 102 | |
| 103 | self._value = collections.OrderedDict([ |
| 104 | (_STATUS_LABEL, _MISSING_STATUS_ENTRY), |
| 105 | (_TIME_LABEL, _MISSING_STATUS_ENTRY), |
| 106 | (_CPU_LABEL, _MISSING_STATUS_ENTRY), |
| 107 | (_FPS_LABEL, _MISSING_STATUS_ENTRY), |
| 108 | (_CAMERA_LABEL, _MISSING_STATUS_ENTRY), |
| 109 | (_PAUSED_LABEL, _MISSING_STATUS_ENTRY), |
| 110 | (_ERROR_LABEL, _MISSING_STATUS_ENTRY), |
| 111 | ]) |
| 112 | |
| 113 | def set_camera(self, camera): |
| 114 | """Updates the active camera instance. |
| 115 | |
| 116 | Args: |
| 117 | camera: Instance of renderer.SceneCamera. |
| 118 | """ |
| 119 | self._camera = camera |
| 120 | |
| 121 | def set_runtime(self, instance): |
| 122 | """Updates the active runtime instance. |
| 123 | |
| 124 | Args: |
| 125 | instance: Instance of runtime.Base. |
| 126 | """ |
| 127 | if self._runtime: |
| 128 | self._runtime.on_error -= self._on_error |
| 129 | self._runtime.on_episode_begin -= self._clear_error |
| 130 | self._runtime = instance |
| 131 | if self._runtime: |
| 132 | self._runtime.on_error += self._on_error |
| 133 | self._runtime.on_episode_begin += self._clear_error |
| 134 | |
| 135 | def get_columns(self): |
| 136 | """Returns the text to display in two columns.""" |
| 137 | if self._frame_timer.measured_time > 0: |
| 138 | self._fps_counter.value = 1. / self._frame_timer.measured_time |
| 139 | self._value[_FPS_LABEL] = '{0:.1f}'.format(self._fps_counter.value) |
| 140 | |
| 141 | if self._runtime: |
no outgoing calls
no test coverage detected
searching dependent graphs…