Esempio n. 1
0
        /// <summary>
        /// Refreshes the alarm drawing with the latest information.
        /// </summary>
        public void UpdateAlarms()
        {
            // Copy the alarms since CurrentAlarms are modified in VesselPresenter asynchronously
            var alarms = new Cker.Simulator.OnAlarmEventArgs[vesselPresenter.CurrentAlarms.Count];

            vesselPresenter.CurrentAlarms.CopyTo(alarms);

            foreach (var alarm in alarms)
            {
                DrawAlarm(alarm.type, alarm.first);
                DrawAlarm(alarm.type, alarm.second);

                // Draw line connecting the two vessels, only if at least one of the vessel is displayed.
                if (vesselPresenter.DisplayedVessels.Contains(alarm.first) || vesselPresenter.DisplayedVessels.Contains(alarm.second))
                {
                    Line alarmLine = new Line();
                    alarmLine.X1              = ToPixelX(alarm.first.X);
                    alarmLine.Y1              = ToPixelY(alarm.first.Y);
                    alarmLine.X2              = ToPixelX(alarm.second.X);
                    alarmLine.Y2              = ToPixelY(alarm.second.Y);
                    alarmLine.Opacity         = 0.75;
                    alarmLine.StrokeThickness = 1.0;
                    alarmLine.Stroke          = new SolidColorBrush(alarm.type == Cker.Simulator.AlarmType.Low ? Colors.Yellow : Colors.Red);
                    canvas.Children.Add(alarmLine);
                }
            }
        }
Esempio n. 2
0
        private void OnSimulationAlarmEvent(Cker.Simulator.OnAlarmEventArgs alarm)
        {
            CurrentAlarms.Add(alarm);

            // Keep only the high risk alarm if there is both a low and a high risk alarm for a vessel.
            if (alarm.type == Simulator.AlarmType.High)
            {
                CurrentAlarms.RemoveAll(a1 => a1.type == Simulator.AlarmType.Low && IsAlarmVesselShared(a1, alarm));
            }
        }
Esempio n. 3
0
 // helper to check whether two alarms share the same vessel.
 private bool IsAlarmVesselShared(Cker.Simulator.OnAlarmEventArgs a1, Cker.Simulator.OnAlarmEventArgs a2)
 {
     return(a1.first == a2.first || a1.first == a2.second || a1.second == a2.first || a1.second == a2.second);
 }