Ejemplo n.º 1
0
 /// <summary>
 /// Notifies the onAnalyzerEvent handler that a new event should be thrown.
 /// </summary>
 /// <param name="analyzerEvent">Analyzer event.</param>
 private void NotifyOfAnalyzerEvent(AnalyzerEvent analyzerEvent)
 {
     if (onAnalyzerEvent != null)
     {
         onAnalyzerEvent(analyzerEvent);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to place the given sensor in tho the given index slot. If a sensor is already present at the given
        /// index, it will be removed and replaced with the given sensor if force is true.
        /// </summary>
        /// <returns><c>true</c>, if sensor was put, <c>false</c> otherwise.</returns>
        /// <param name="index">Index.</param>
        /// <param name="sensor">Sensor.</param>
        public bool PutSensor(int index, Sensor sensor, bool force = false)
        {
            if (HasSensor(sensor) && !force)
            {
                return(false);
            }

            RemoveSensor(index);

            sensors[index] = sensor;

            var ae = new AnalyzerEvent(AnalyzerEvent.EType.Added, sensor, index);

            NotifyOfAnalyzerEvent(ae);
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the sensor at the given index.
        /// </summary>
        /// <returns><c>true</c>, if sensor was removed, <c>false</c> otherwise.</returns>
        /// <param name="index">Index.</param>
        public bool RemoveSensor(int index)
        {
            if (index < 0 || index >= sensors.Length || sensors[index] == null)
            {
                return(false);
            }

            var sensor = sensors[index];

            sensors[index] = null;

            if (lowSideSensor != null)
            {
                if (lowSideSensor.Equals(sensor))
                {
                    RemoveManifold(ESide.Low);
                }
                else
                {
                    lowSideSensor.SetLinkedSensor(null);
                }
            }

            if (highSideSensor != null)
            {
                if (highSideSensor.Equals(sensor))
                {
                    RemoveManifold(ESide.High);
                }
                else
                {
                    highSideSensor.SetLinkedSensor(null);
                }
            }

            var ae = new AnalyzerEvent(AnalyzerEvent.EType.Removed, sensor, index);

            NotifyOfAnalyzerEvent(ae);

            return(true);
        }