Esempio n. 1
0
        private void AddAlarmToStatistics(int avgX, int yPic, float length, DetectResultStatistic detectResultStatistic)
        {
            int         xPos        = avgX;
            int         yPos        = serialComm.LoopCount % AlarmRecord.TotalLoopCount;
            AlarmRecord alarmRecord = new AlarmRecord {
                XPos = xPos, YPos = yPos, YPic = yPic, LatestOccurTime = DateTime.Now, CreatedTime = DateTime.Now, Length = length
            };

            App.Current?.Dispatcher.Invoke(() =>
            {
                if (Alarms.Contains(alarmRecord))
                {
                    int index = Alarms.IndexOf(alarmRecord);
                    var alarm = Alarms[index];
                    //alarm.XPos = alarmRecord.XPos;
                    if (AlarmHeadFlag)
                    {
                        if (firstAlarmRecord == null)
                        {
                            firstAlarmRecord = alarmRecord;
                        }
                        if (firstAlarmRecord == alarmRecord)
                        {
                            LoopOffset = alarmRecord.YPos - alarm.YPos;
                        }
                        alarm.YPos    = alarmRecord.YPos;
                        AlarmHeadFlag = false;
                    }
                    alarm.Length          = alarmRecord.Length;
                    alarm.LatestOccurTime = alarmRecord.LatestOccurTime;
                }
                else
                {
                    Alarms.Add(alarmRecord);
                    Alarm(alarmRecord);
                }
                SelectedAlarmIndex = Alarms.IndexOf(alarmRecord);
                AsyncSaveObject("Alarms", Alarms);
            });
        }