Beispiel #1
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     AlarmTag = new AlarmTag {
         DigTag = new DigTag {
             Id       = RandomGenerator.GetRandomInt32(),
             IoDevice = new IoDevice {
                 Id = RandomGenerator.GetRandomInt32()
             }
         },
         Id = RandomGenerator.GetRandomInt32(),
         Acknowledgeable = Acknowledgeable
     };
     AlarmCatetory = new AlarmCategory {
         Name          = "AlarmCategory",
         TimeToStoreDb = TimeToStore
     };
     AlarmCatetory.AlarmTags.Add(AlarmTag);
     Reporter    = new Mock <INotificationReporter>();
     Repository  = new Mock <IAlarmsRepository>();
     Project     = new Mock <IProject>();
     TimeService = new Mock <ITimeService>();
     TimeService.Setup(t => t.UtcTime).Returns(DateTime.UtcNow);
     ConnectionFactory = new Mock <INpgsqlConnectionFactory>();
     Connection        = new NpgsqlConnection();
     ConnectionFactory.Setup(f => f.Create()).Returns(Connection);
     AlarmsRunTarget = new AlarmsRunTarget(
         AlarmCatetory,
         Reporter.Object,
         Repository.Object,
         Project.Object,
         TimeService.Object,
         ConnectionFactory.Object);
 }
Beispiel #2
0
 private static void AcknowledgeAlarms(RemapAlarmsParameter parameter, IAlarmsRunTarget runTarget)
 {
     foreach (var p in parameter.AcknowledgeParameters)
     {
         runTarget.Acknowledge(p.Item1, p.Item2);
     }
 }
Beispiel #3
0
        private static void ReadAlarmStatus(RemapAlarmsParameter parameter, RemapAlarmResult result,
                                            IAlarmsRunTarget runTarget)
        {
            if (!parameter.GetStatus)
            {
                return;
            }
            var status = runTarget.GetHasActiveAndUnacknowledged();

            result.HasActive         = status.Item1;
            result.HasUnacknowledged = status.Item2;
        }
Beispiel #4
0
 private void StartAlarms()
 {
     foreach (AlarmCategory category in _context.Get <AlarmCategory>().ToArray())
     {
         IAlarmsRunTarget alarmRunTarget = _alarmsRunTargetFactory.Create(
             _dataDbConnectionString, this, category, _timeService);
         AlarmsRunTargets.Add(category.Id, alarmRunTarget);
         ICyclicRunner runner = _cyclicRunnerFactory.Create(alarmRunTarget);
         _alarmsRunners.Add(new Tuple <IRunner, string>(runner, category.Name));
         runner.Start();
         _reporter.Report(string.Format(Res.AlarmsStartedMessage, category.Name));
     }
 }
Beispiel #5
0
        private static void ReadHistoryAlarms(RemapAlarmsParameter parameter, RemapAlarmResult result,
                                              IAlarmsRunTarget runTarget)
        {
            var currentAlarms = new Alarm[parameter.HistoryParameters.Length][];

            for (var i = 0; i < parameter.HistoryParameters.Length; i++)
            {
                var curPar = parameter.HistoryParameters[i];
                currentAlarms[i] = runTarget.GetHistoryAlarms(curPar.Item1, curPar.Item2, curPar.Item3);
            }

            result.History = currentAlarms;
        }
Beispiel #6
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     AlarmTag = new alarm_tags
     {
         dig_tags = new dig_tags
         {
             id         = RandomGenerator.GetRandomInt32(),
             io_devices = new io_devices
             {
                 id = RandomGenerator.GetRandomInt32()
             }
         },
         id = RandomGenerator.GetRandomInt32(),
         acknowledgeable = Acknowledgeable
     };
     AlarmCatetory = new alarm_categories
     {
         name          = "AlarmCategory",
         time_to_store = TimeToStore
     };
     AlarmCatetory.alarm_tags.Add(AlarmTag);
     Reporter    = new Mock <INotificationReporter>();
     Repository  = new Mock <IAlarmsRepository>();
     Project     = new Mock <IProject>();
     TimeService = new Mock <ITimeService>();
     TimeService.Setup(t => t.UtcTime).Returns(DateTime.UtcNow);
     ConnectionFactory = new Mock <INpgsqlConnectionFactory>();
     Connection        = new NpgsqlConnection();
     ConnectionFactory.Setup(f => f.Create()).Returns(Connection);
     AlarmsRunTarget = new AlarmsRunTarget(
         AlarmCatetory,
         Reporter.Object,
         Repository.Object,
         Project.Object,
         TimeService.Object,
         ConnectionFactory.Object);
 }
Beispiel #7
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     AlarmTag = new alarm_tags
                    {
                        dig_tags = new dig_tags
                                       {
                                           id = RandomGenerator.GetRandomInt32(),
                                           io_devices = new io_devices
                                                            {
                                                                id = RandomGenerator.GetRandomInt32()
                                                            }
                                       },
                        id = RandomGenerator.GetRandomInt32(),
                        acknowledgeable = Acknowledgeable
                    };
     AlarmCatetory = new alarm_categories
                         {
                             name = "AlarmCategory",
                             time_to_store = TimeToStore
                         };
     AlarmCatetory.alarm_tags.Add(AlarmTag);
     Reporter = new Mock<INotificationReporter>();
     Repository = new Mock<IAlarmsRepository>();
     Project = new Mock<IProject>();
     TimeService = new Mock<ITimeService>();
     TimeService.Setup(t => t.UtcTime).Returns(DateTime.UtcNow);
     ConnectionFactory = new Mock<INpgsqlConnectionFactory>();
     Connection = new NpgsqlConnection();
     ConnectionFactory.Setup(f => f.Create()).Returns(Connection);
     AlarmsRunTarget = new AlarmsRunTarget(
         AlarmCatetory,
         Reporter.Object,
         Repository.Object,
         Project.Object,
         TimeService.Object,
         ConnectionFactory.Object);
 }
Beispiel #8
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     AlarmTag = new AlarmTag
                    {
                        DigTag = new DigTag
                                       {
                                           Id = RandomGenerator.GetRandomInt32(),
                                           IoDevice = new PHmiModel.Entities.IoDevice
                                                            {
                                                                Id = RandomGenerator.GetRandomInt32()
                                                            }
                                       },
                        Id = RandomGenerator.GetRandomInt32(),
                        Acknowledgeable = Acknowledgeable
                    };
     AlarmCatetory = new AlarmCategory
                         {
                             Name = "AlarmCategory",
                             TimeToStoreDb = TimeToStore
                         };
     AlarmCatetory.AlarmTags.Add(AlarmTag);
     Reporter = new Mock<INotificationReporter>();
     Repository = new Mock<IAlarmsRepository>();
     Project = new Mock<IProject>();
     TimeService = new Mock<ITimeService>();
     TimeService.Setup(t => t.UtcTime).Returns(DateTime.UtcNow);
     ConnectionFactory = new Mock<INpgsqlConnectionFactory>();
     Connection = new NpgsqlConnection();
     ConnectionFactory.Setup(f => f.Create()).Returns(Connection);
     AlarmsRunTarget = new AlarmsRunTarget(
         AlarmCatetory,
         Reporter.Object,
         Repository.Object,
         Project.Object,
         TimeService.Object,
         ConnectionFactory.Object);
 }
Beispiel #9
0
 private static void ReadHistoryAlarms(RemapAlarmsParameter parameter, RemapAlarmResult result, IAlarmsRunTarget runTarget)
 {
     var currentAlarms = new Alarm[parameter.HistoryParameters.Length][];
     for (var i = 0; i < parameter.HistoryParameters.Length; i++)
     {
         var curPar = parameter.HistoryParameters[i];
         currentAlarms[i] = runTarget.GetHistoryAlarms(curPar.Item1, curPar.Item2, curPar.Item3);
     }
     result.History = currentAlarms;
 }
Beispiel #10
0
 private static void ReadAlarmStatus(RemapAlarmsParameter parameter, RemapAlarmResult result, IAlarmsRunTarget runTarget)
 {
     if (!parameter.GetStatus)
         return;
     var status = runTarget.GetHasActiveAndUnacknowledged();
     result.HasActive = status.Item1;
     result.HasUnacknowledged = status.Item2;
 }
Beispiel #11
0
 private static void AcknowledgeAlarms(RemapAlarmsParameter parameter, IAlarmsRunTarget runTarget)
 {
     foreach (var p in parameter.AcknowledgeParameters)
     {
         runTarget.Acknowledge(p.Item1, p.Item2);
     }
 }