コード例 #1
0
        private void DataRetrievedEventHandler(object sender, EventArgs e)
        {
            List <string> alarmNames         = new List <string>();
            List <string> warningNames       = new List <string>();
            List <bool>   activeAlarmsFlags  = new List <bool>();
            List <bool>   activeWarningFlags = new List <bool>();

            // Let's make a local copy (thread safety)
            IList <MeasurePoint> _mbAlarms = DriverContainer.Driver.MbAlarm;

            if (_mbAlarms != null)
            {
                // Distinct Values
                List <string> uniqueRegNames = _mbAlarms.Select(x => x.Reg_Name).ToList().Distinct().ToList();
                foreach (string sg in uniqueRegNames)
                {
                    if (N3PR_Data.ALARM_NAMES.Contains(sg))
                    {
                        alarmNames.Add(sg);
                    }
                    else
                    {
                        warningNames.Add(sg);
                    }
                }
                activeAlarmsFlags  = Plotter.AreThereActiveAlarms(alarmNames, _mbAlarms);
                activeWarningFlags = Plotter.AreThereActiveAlarms(warningNames, _mbAlarms);
            }

            AlarmsActive = "Green";
            if (activeAlarmsFlags != null)
            {
                if (activeAlarmsFlags.Contains(true))
                {
                    AlarmsActive = "Red";
                }
            }

            WarningsActive = "Green";
            if (activeWarningFlags != null)
            {
                if (activeWarningFlags.Contains(true))
                {
                    WarningsActive = "Orange";
                }
            }
        }