Пример #1
0
        private void UpdateTimer_Tick(object sender, EventArgs e)
        {
            lock (chartLock)
            {
                if (motionLevel > motionTriggerThreshold)
                {
                    if (!playOnce && enableBeepOnTrigger)
                    {
                        playOnce = true;
                        PlayBeep();
                    }
                    if (!captureImageOnce && cbEnableSaveImg.IsChecked == true)
                    {
                        captureImageOnce = true;
                        CaptureAsImage();
                    }
                }

                // update data into collection
                DateTime currentTime = DateTime.Now;
                double   elapsedTime = (currentTime - startTime).TotalSeconds;
                motionLevelData = new MotionLevelData(elapsedTime, motionLevel, motionTriggerThreshold, startTime, currentTime, detectedObjectsCount);
                GraphDataCollection.Add(motionLevelData);
                if (GraphDataCollection.Count > 10000)
                {
                    GraphDataCollection.RemoveAt(0);
                }

                // update sensitivity bar
                UpdateSensivityBarUI();

                // update graph
                OxyGraph.InvalidatePlot(true);

                // autoscroll graph x-axis
                if ((elapsedTime + 0.001) >= xAxis.Maximum)
                {
                    double panStep = (xAxis.ActualMaximum - xAxis.DataMaximum) * xAxis.Scale;
                    xAxis.Pan(panStep);
                }

                // write to log file
                if (!customIntervalEnabled)
                {
                    LogData(motionLevelData);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Called when sensor impact is received.
        /// </summary>
        /// <param name="sensorImpactData">The sensor impact data.</param>
        private void OnSensorHit(ReceiverEvents.SensorHit e)
        {
            if (e.SensorId == this.Id)
            {
                this.ImpactLevel = e.ImpactLevel;
                this.HitPanelNum = (int)e.Panel;

                if (e.ImpactLevel > this.HighestImpactLevel)
                {
                    this.HighestImpactLevel = e.ImpactLevel;
                }

                // Update history
                while (_graphDataItems.Count >= 10)
                {
                    _graphDataItems.RemoveAt(0);
                }
                _graphDataItems.Add(e.ImpactLevel);
            }
        }