Exemple #1
0
 public RemapAlarmResult[] RemapAlarms(RemapAlarmsParameter[] parameters)
 {
     if (NotValid())
         return null;
     var results = new RemapAlarmResult[parameters.Length];
     for (var i = 0; i < parameters.Length; i++)
     {
         var result = new RemapAlarmResult();
         var parameter = parameters[i];
         results[i] = result;
         IAlarmsRunTarget runTarget;
         if (!_project.AlarmsRunTargets.TryGetValue(parameter.CategoryId, out runTarget))
             continue;
         AcknowledgeAlarms(parameter, runTarget);
         ReadAlarmStatus(parameter, result, runTarget);
         ReadCurrentAlarms(parameter, result, runTarget);
         ReadHistoryAlarms(parameter, result, runTarget);
         result.Notifications = GetNotifications(runTarget.Reporter.Notifications);
     }
     return results;
 }
Exemple #2
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;
 }
Exemple #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;
 }
Exemple #4
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Parameter = new RemapAlarmsParameter
         {
             AcknowledgeParameters = new Tuple<AlarmSampleId[], Identity>[0],
             GetStatus = true,
             CategoryId = Id,
             CurrentParameters = new []
                 {
                     new Tuple<CriteriaType, AlarmSampleId, int>(
                         CriteriaType.DownFromInfinity, new AlarmSampleId(
                             DateTime.Now, RandomGenerator.GetRandomInt32()), RandomGenerator.GetRandomInt32())
                 },
             HistoryParameters = new[]
                 {
                     new Tuple<CriteriaType, AlarmSampleId, int>(
                         CriteriaType.DownFromInfinity, new AlarmSampleId(
                             DateTime.Now, RandomGenerator.GetRandomInt32()), RandomGenerator.GetRandomInt32())
                 },
         };
     AlarmsRunTarget.Setup(t => t.GetHasActiveAndUnacknowledged()).Returns(new Tuple<bool, bool>(true, false)).Verifiable();
     var curPar = Parameter.CurrentParameters.Single();
     Current = new Alarm[0];
     AlarmsRunTarget.Setup(t => t.GetCurrentAlarms(curPar.Item1, curPar.Item2, curPar.Item3)).Returns(Current).Verifiable();
     var histPar = Parameter.HistoryParameters.Single();
     History = new Alarm[0];
     AlarmsRunTarget.Setup(t => t.GetHistoryAlarms(histPar.Item1, histPar.Item2, histPar.Item3)).Returns(History).Verifiable();
     Notification = new Notification(DateTime.Now, "Message", "Short", "Long");
     AlarmsRunTarget.Setup(t => t.Reporter.Notifications).Returns(
         new ReadOnlyObservableCollection<Notification>(new ObservableCollection<Notification>
             {
                 Notification
             })).Verifiable();
     Result = Service.RemapAlarms(new [] {Parameter}).Single();
 }
Exemple #5
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Parameter = new RemapAlarmsParameter
     {
         AcknowledgeParameters = new Tuple<AlarmSampleId[], Identity>[0],
         GetStatus = false,
         CategoryId = Id,
         CurrentParameters = new Tuple<CriteriaType, AlarmSampleId, int>[0],
         HistoryParameters = new Tuple<CriteriaType, AlarmSampleId, int>[0]
     };
     Notification = new Notification(DateTime.Now, "Message", "Short", "Long");
     AlarmsRunTarget.Setup(t => t.Reporter.Notifications).Returns(
         new ReadOnlyObservableCollection<Notification>(new ObservableCollection<Notification>
             {
                 Notification
             })).Verifiable();
     Result = Service.RemapAlarms(new[] { Parameter }).Single();
 }
Exemple #6
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Service = new Mock<IService>();
     Notification = new WcfNotification
     {
         StartTime = DateTime.UtcNow,
         Message = "Message",
         ShortDescription = "ShortDescription",
         LongDescription = "LongDescription"
     };
     Result = new RemapAlarmResult
     {
         HasActive = true,
         HasUnacknowledged = false,
         Current = new Alarm[0][],
         History = new Alarm[0][],
         Notifications = new[] { Notification }
     };
     Service.Setup(s => s.RemapAlarms(It.Is<RemapAlarmsParameter[]>(p =>
         p.Length == 1 && p[0].CategoryId == Category.Object.Id && p[0].GetStatus)))
         .Returns(new[] { Result }).Verifiable();
 }