コード例 #1
0
        private DebugChannelData Debug_CreateChannelData()
        {
            // Create from settings.
            if (HasSensor && m_GridSensor.AutoDetectionEnabled)
            {
                // TODO Assuming IEncoder writes grid positions to DebugChannelData.
                // Might want to parameterize this at some point.
                return(DebugChannelData.FromSettings(m_GridSensor.Encoder.Settings));
            }


            // Create from labels provided via ChannelLabels property.
            if (m_ChannelLabels != null && m_ChannelLabels.Count > 0)
            {
                return(DebugChannelData.FromLabels(m_ChannelLabels));
            }


            // Create fallback labels.
            int n      = m_GridShape.NumChannels;
            var labels = new List <ChannelLabel>(n);

            for (int i = 0; i < n; i++)
            {
                labels.Add(new ChannelLabel(
                               "Observation " + i,
                               Color.HSVToRGB(i / (float)n, 1, 1)));
            }

            return(DebugChannelData.FromLabels(labels, false));
        }
コード例 #2
0
        private void Debug_SetDrawGridBufferEnabled(bool enabled, bool standby = false)
        {
            if (enabled)
            {
                m_Debug_ChannelData?.Dispose();
                m_Debug_ChannelData       = Debug_CreateChannelData();
                m_GridSensor.UpdateEvent += m_Debug_GridBufferDrawer.OnSensorUpdate;
                ((IDebugable)m_GridSensor.Encoder)?.SetDebugEnabled(true, m_Debug_ChannelData);
                m_Debug_GridBufferDrawer.Enable(this, m_Debug_ChannelData, m_GridBuffer);
            }
            else
            {
                m_Debug_ChannelData?.Dispose();

                if (Debug_HasRuntimeSensor())
                {
                    m_GridSensor.UpdateEvent -= m_Debug_GridBufferDrawer.OnSensorUpdate;
                    ((IDebugable)m_GridSensor.Encoder)?.SetDebugEnabled(false);
                }

                if (standby)
                {
                    m_Debug_GridBufferDrawer.Standby();
                }
                else
                {
                    m_Debug_GridBufferDrawer.Disable();
                }
            }

            m_Debug_IsEnabled             = enabled;
            m_Debug_DrawGridBufferEnabled = enabled;
        }
コード例 #3
0
        /// <inheritdoc/>
        public void SetDebugEnabled(bool enabled, DebugChannelData target = null)
        {
            m_Debug_IsEnabled = enabled;

            if (enabled)
            {
                m_Debug_ChannelData = target;
            }
        }
コード例 #4
0
        /// <summary>
        /// Enables drawer.
        /// </summary>
        /// <param name="channelData"><see cref="DebugChannelData"/> instance</param>
        /// <param name="buffer"><see cref="GridBuffer"/> instance</param>
        public void Enable(MonoBehaviour context, DebugChannelData channelData, GridBuffer buffer)
        {
            ChannelData   = channelData;
            Buffer        = buffer;
            GridSizeRatio = buffer.Height / (float)buffer.Width;

            Context = context;
            m_RepaintOnFirstUpdate = true;
            m_StopRepaintCoroutine ??= StopRepaintCoroutine();

            IsEnabled = true;
            IsStandby = false;
        }