Exemple #1
0
 private List<AlarmSensor> LoadAlarmSensors()
 {
     List<AlarmSensor> res = new List<AlarmSensor>();
     try
     {
         XDocument sensorConfig = XDocument.Load(Path.Combine(HttpRuntime.AppDomainAppPath, _configSource.Configs["BacNet"].Get("ErrorFileUrl")));
         if (sensorConfig.Root != null)
             foreach (XElement error in sensorConfig.Root.Elements())
             {
                 AlarmSensor sensor = new AlarmSensor();
                 if (error.Attribute("Address") != null)
                 {
                     sensor.Address = (string) error.Attribute("Address");
                     if (error.Attribute("Value") != null)
                         sensor.Value = (string) error.Attribute("Value");
                     if (error.Attribute("Description") != null)
                         sensor.Description = (string) error.Attribute("Description");
                     if (error.Attribute("ErrorValue") != null)
                         sensor.ErrorValue = (string) error.Attribute("ErrorValue");
                     if (error.Attribute("MaxValue") != null)
                         sensor.MaxValue = (double)error.Attribute("MaxValue");
                     else
                         sensor.MaxValue = double.MaxValue;
                     if (error.Attribute("MinValue") != null)
                         sensor.MinValue = (double) error.Attribute("MinValue");
                     else
                         sensor.MinValue = double.MinValue;
                     if (error.Attribute("ErrorCode") != null)
                         sensor.ErrorCode = (int) error.Attribute("ErrorCode");
                     if (error.Attribute("Priority") != null)
                         sensor.Priority = (int)error.Attribute("Priority");
                 }
                 if (error.Attribute("ErrorValue") != null || error.Attribute("MaxValue") != null || error.Attribute("MinValue") != null)
                 {
                     res.Add(sensor);
                     BacNetServer.SubscribeToBacnetCOV(sensor.Address);
                 }
             }
     }
     catch (Exception)
     {
         //_logger.ErrorException("Не удалось загрузить cписок датчиков аварийных ситуаций. Сообщение:", ex);
     }
     return res;
 }
Exemple #2
0
        private List <AlarmSensor> LoadAlarmSensors()
        {
            List <AlarmSensor> res = new List <AlarmSensor>();

            try
            {
                XDocument sensorConfig = XDocument.Load(Path.Combine(HttpRuntime.AppDomainAppPath, _configSource.Configs["BacNet"].Get("ErrorFileUrl")));
                if (sensorConfig.Root != null)
                {
                    foreach (XElement error in sensorConfig.Root.Elements())
                    {
                        AlarmSensor sensor = new AlarmSensor();
                        if (error.Attribute("Address") != null)
                        {
                            sensor.Address = (string)error.Attribute("Address");
                            if (error.Attribute("Value") != null)
                            {
                                sensor.Value = (string)error.Attribute("Value");
                            }
                            if (error.Attribute("Description") != null)
                            {
                                sensor.Description = (string)error.Attribute("Description");
                            }
                            if (error.Attribute("ErrorValue") != null)
                            {
                                sensor.ErrorValue = (string)error.Attribute("ErrorValue");
                            }
                            if (error.Attribute("MaxValue") != null)
                            {
                                sensor.MaxValue = (double)error.Attribute("MaxValue");
                            }
                            else
                            {
                                sensor.MaxValue = double.MaxValue;
                            }
                            if (error.Attribute("MinValue") != null)
                            {
                                sensor.MinValue = (double)error.Attribute("MinValue");
                            }
                            else
                            {
                                sensor.MinValue = double.MinValue;
                            }
                            if (error.Attribute("ErrorCode") != null)
                            {
                                sensor.ErrorCode = (int)error.Attribute("ErrorCode");
                            }
                            if (error.Attribute("Priority") != null)
                            {
                                sensor.Priority = (int)error.Attribute("Priority");
                            }
                        }
                        if (error.Attribute("ErrorValue") != null || error.Attribute("MaxValue") != null || error.Attribute("MinValue") != null)
                        {
                            res.Add(sensor);
                            BacNetServer.SubscribeToBacnetCOV(sensor.Address);
                        }
                    }
                }
            }
            catch (Exception)
            {
                //_logger.ErrorException("Не удалось загрузить cписок датчиков аварийных ситуаций. Сообщение:", ex);
            }
            return(res);
        }