public void Reconhecer() { AbstractAlarm drv = _bs.Current as AbstractAlarm; IAlarm alarm = AlarmManager.Instance.Alarms.Find(delegate(IAlarm alm) { return(alm.Name == drv.Name && alm.TimeStamp == drv.TimeStamp); }); alarm.TimeStampAck = DateTime.Now.ToString(); }
public void Execute(IAlarm alarm) { if (alarm.CurrentStatus != AlarmStatus.Activated) return; alarm.Trigger(); alarm.EventDispatcher.Dispatch(new AlarmTriggerdEvent(_detector)); }
public AlarmMetadata AskAlarmMetadata(IAlarm alarm = null) { using (var alarmForm = new AlarmForm()) { if (alarm != null) { alarmForm.timeAlarmTime.Value = alarm.Time; alarmForm.timeAlarmTitle.Text = alarm.Title; } else { alarmForm.timeAlarmTitle.Clear(); alarmForm.timeAlarmTime.Value = DateTime.Now; } if (alarmForm.ShowDialog() == DialogResult.OK) { return(new AlarmMetadata { Title = alarmForm.timeAlarmTitle.Text, Time = alarmForm.timeAlarmTime.Value }); } return(null); } }
public void TriggerAlarmStatusChange(IAlarm alarm) { if (!this.alarms.Contains(alarm)) this.alarms.Add(alarm); this.OnAlarmStatusChange.Invoke(e: new AlarmEventArgs(alarm)); }
//public UC2M2_UC3M3_Measure(IDAQ actualDaq, DataTreatment _dataTreatment, UC5S1_Alarm alarmController) public UC2M2_UC3M3_Measure(IDAQ actualDaq, DataTreatment _dataTreatment, IAlarm alarmController, IFilter filter) { Daq = actualDaq; dataTreatment = _dataTreatment; AlarmController = alarmController; FilterController = filter; }
public OrderHub(IOrdersService ordersService, IAlarm alarm, ILogger <OrderHub> logger, IHubContext <UserOrdersHub> hubUser) { this.ordersService = ordersService; this.alarm = alarm; this.logger = logger; this.hubUser = hubUser; }
public DoorControlClass(IAlarm alarm, IDoor door, IEntryNotification entryNotification, IUserValidation userValidation) { _alarm = alarm; _door = door; _entryNotification = entryNotification; _userValidation = userValidation; }
public NSubstituteDoorControlFactory() { UserValidation = Substitute.For <IUserValidation>(); Door = Substitute.For <IDoor>(); EntryNotification = Substitute.For <IEntryNotification>(); Alarm = Substitute.For <IAlarm>(); }
public DoorControl(IUserValidation userValidation, IAlarm alarm, IDoor door, IEntryNotification entryNotification) { UserValidation = userValidation; Alarm = alarm; Door = door; EntryNotification = entryNotification; }
/// <summary> /// Registers the given alarm to the given host. /// </summary> /// <param name="host">Host.</param> /// <param name="alarm">Alarm.</param> /// <returns>True if the alarm was registered to the host.</returns> public bool RegisterAlarmToHost(object host, IAlarm alarm) { if (HostHasAlarmOfType(alarm.GetType(), host)) { Log.E(this, "Object " + host + " already has an alarm of type " + alarm.GetType().Name); return(false); } HashSet <IAlarm> alarms = null; if (__alarmMapping.ContainsKey(host)) { alarms = __alarmMapping[host]; } else { __alarmMapping[host] = alarms = new HashSet <IAlarm>(); } alarm.id = ++alarmIdCounter; __idAlarmMapping.Add(alarm.id, alarm); alarms.Add(alarm); alarm.onAlarmEvent += OnAlarmEvent; return(true); }
public DoorControl(IDoor door, IAlarm alarm, IValidator validator, INotifier notifier) { _Door = door; _Alarm = alarm; _Validator = validator; _Notifier = notifier; }
public DoorControl(IUserValidation uv, IEntryNotification en, IDoor door, IAlarm alarm) { _uv = uv; _en = en; _door = door; _alarm = alarm; }
public DoorControl(IDoor door, IUserValidation userValidation, IEntryNotification entryNotification, IAlarm alarm) { _door = door; _userValidation = userValidation; _entryNotification = entryNotification; _alarm = alarm; }
public Car(IMyIoCContainer myIoCContainer, IAlarm alarmSystem, IAirBag airBagSystem, IPowerSteering powerSteeringSystem) { _myIoCContainer = myIoCContainer; AddAccessory(alarmSystem); AddAccessory(airBagSystem); AddAccessory(powerSteeringSystem); }
private static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); var carType = configuration.GetSection("carType").Value; Console.WriteLine("The car type is :" + carType); Console.WriteLine("Please press the option"); Console.WriteLine("i/I for increase car speed"); Console.WriteLine("d/D for decrease car speed"); Console.WriteLine("u/U for unlock car"); Console.WriteLine("l/L for lock car"); Console.WriteLine("e/E for exit the application"); var simulator = new CarSpeedSimulator(); var speedometer = new Speedometer(simulator); IAlarm alarm = carType == "normal1" ? (IAlarm) new Alarm() : new FreecolAlarm(); var speedAlarm = new SpeedAlarm(alarm, speedometer); var seatBelt = new SeatBelt(alarm, speedometer); while (true) { var key = Console.ReadKey(); Console.WriteLine(); var keyChar = key.KeyChar; var optionString = keyChar.ToString().ToLower(); if (optionString == "i") { simulator.Increase(); } else if (optionString == "d") { simulator.Decrease(); } else if (optionString == "l") { seatBelt.Lock(); } else if (optionString == "u") { seatBelt.UnLock(); } else if (optionString == "e") { break; } else { Console.WriteLine("unknown option"); } } }
private void Update() { _refreshTmr.Stop(); // Remove os alarmes reconhecidos foreach (DataGridViewRow dgvr in dgvAlarms.Rows) { if (dgvr.Cells["ColumnTimeStamp"].Value != null && Convert.ToDateTime(dgvr.Cells["ColumnTimeStamp"].Value) <= DateTime.Now.Subtract(new TimeSpan(24, 0, 0))) { _bs.RemoveAt(dgvr.Index); } } // Reserva a lista de alarmes recentes List <IAlarm> list = AlarmManager.Instance.Alarms.FindAll(delegate(IAlarm alarm) { return(alarm.TimeStampAck == null && Convert.ToDateTime(alarm.TimeStamp) > DateTime.Now.Subtract(new TimeSpan(24, 0, 0))); }); // Decide qual lista vai utilizar // A preferência é para a maior lista if (list.Count >= _almList.Count) { foreach (IAlarm alm in list) { IAlarm currAlm = _almList.Find(delegate(IAlarm alarm){ return(alarm.Name == alm.Name && alarm.TimeStamp == alm.TimeStamp); }); if (currAlm != null) { currAlm.TimeStampAck = alm.TimeStampAck; } else { _almList.Insert(0, alm); } } } else { for (int i = 0; i < _almList.Count; i++) { IAlarm currAlm = list.Find(delegate(IAlarm alarm){ return(alarm.Name == _almList[i].Name && alarm.TimeStamp == _almList[i].TimeStamp); }); if (currAlm != null) { _almList[i].TimeStampAck = currAlm.TimeStampAck; } } } foreach (DataGridViewRow dgvr in dgvAlarms.Rows) { if (dgvr.Cells["ColumnTimeStampAck"].Value == null) { dgvr.DefaultCellStyle.BackColor = Color.Red; } else { dgvr.DefaultCellStyle.BackColor = Color.LightGray; } } _refreshTmr.Start(); }
public DoorControl(IDoorControlFactory factory) { _userValidation = factory.CreateUserValidation(); _door = factory.CreateDoor(); _entryNotification = factory.CreateEntryNotification(); _alarm = factory.CreateAlarm(); _doorState = State.DoorClosed; }
public DoorControl(IDoor door, IAlarm alarm, IEntryNotification entryNotification, IUserValidation userValidation) { _door = door; _alarm = alarm; _entryNotification = entryNotification; _userValidation = userValidation; _doorState = DState.Closed; }
private static void UpdateAlarmItem(IAlarm alarm, ListViewItem alarmItem) { alarmItem.Text = alarm.Title; alarmItem.SubItems[1].Text = alarm.Time.ToShortTimeString(); alarmItem.SubItems[2].Text = AlarmStatusText(alarm); alarmItem.Tag = alarm; alarmItem.BackColor = GetColor(alarm); }
public void SetUp() { _door = Substitute.For <IDoor>(); _alarm = Substitute.For <IAlarm>(); _entryNotification = Substitute.For <IEntryNotification>(); _userValidation = Substitute.For <IUserValidation>(); _uut = new DoorControlClass(_alarm, _door, _entryNotification, _userValidation); }
public DoorControl(IDoor door, IUserValidation UV, IEntryNotification EN, IAlarm alarm) { _door = door; _userValidation = UV; _entry = EN; _alarm = alarm; _state = DoorControlState.Closed; }
public bool Match(IAlarm alarm) { if (alarm == null) throw new ArgumentNullException("alarm"); var isFinished = alarm.Status == AlarmStatus.Canceled || alarm.Status == AlarmStatus.Completed; return !isFinished || alarm.Time >= GetTime().AddMinutes(-this.freshnessInMinutes); }
public void SetUp() { _doorFake = Substitute.For <IDoor>(); _alarmFake = Substitute.For <IAlarm>(); _entryNotificationFake = Substitute.For <IEntryNotification>(); _userValidationFake = Substitute.For <IUserValidation>(); _uut = new DoorControl(_doorFake, _alarmFake, _entryNotificationFake, _userValidationFake); }
public void Setup() { _alarm = Substitute.For <IAlarm>(); _door = Substitute.For <IDoor>(); _entryNotification = Substitute.For <IEntryNotification>(); _userValidation = Substitute.For <IUserValidation>(); _uut = new DoorControl(_door, _userValidation, _entryNotification, _alarm); }
public void Setup() { alarm = Substitute.For <IAlarm>(); door = Substitute.For <IDoor>(); entryNotification = Substitute.For <IEntryNotification>(); userValidation = Substitute.For <IUserValidation>(); _uut = new Door_control.DoorControl(door, userValidation, entryNotification, alarm); }
public void Setup() { alarm = new FakeAlarm(); door = new FakeDoor(); entryNotification = new FakeEntryNotfication(); userValidation = new FakeUserValidation(); _uut = new Door_control.DoorControl(door, userValidation, entryNotification, alarm); }
public MainPageViewModel(INavigationService navigationService, IAlarm alarm) : base(navigationService) { Title = "Main Page"; _alarm = alarm; CommandNameCmd = new DelegateCommand <object>(OnCommandName); }
private void Alarm_StatusChanged(object sender, AlarmStatusChangedEventArgs e) { IAlarm alarm = sender as IAlarm; string s = string.Format("Alarm '{0}' {1}", alarm.Name, e.Value ? "on" : "off"); log.Debug(s); CreateEvent(EventTypes.IO, s); }
public DoorControl(IDoor door, IUserValidation user, IEntryNotification noti, IAlarm alarm) { _door = door; _user = user; _noti = noti; _alarm = alarm; _state = DoorState.DoorClosed; }
public SecurityDoor(IDoor door, IAlarm alarm, int alarmTimeout) { _door = door; _alarm = alarm; _timer = new Timer(); _timer.Interval = alarmTimeout; _timer.Elapsed += (o, e) => _alarm.Alert("Alarm!"); }
public DoorController(IAlarm alarm, IDoor door, IEntryNotification entryNotification, IUserValidation userValidation) { _alarm = alarm; _door = door; _entryNotification = entryNotification; _userValidation = userValidation; door.DoorChangedEvent += HandleDoorChanged; }
public void AddAlarm(IAlarm alarm) { if (alarm == null) return; if (AlarmExist(alarm.AlarmNo)) return; Items.Add(alarm.AlarmNo, alarm); }
public DoorControl(IAlarm alarm, IDoor door, IEntryNotification notification, IUserValidation validation) { _door = door; _door.Control = this; _entryNotification = notification; _alarm = alarm; _validation = validation; _state = States.DoorClosed; }
static void Main(string[] args) { AlarmClock ac = new AlarmClock(); IAlarm ar = (IAlarm)ac; IClock cl = (IClock)ac; FuncAlarm(ar); FuncClock(cl); }
public void Execute(IAlarm alarm) { switch (alarm.CurrentStatus) { case AlarmStatus.Activated: case AlarmStatus.Triggerd: alarm.Receive(new TurnOffCommand(_initiator)); break; case AlarmStatus.Deactivated: alarm.Receive(new TurnOnCommand(_initiator)); break; } }
public void Add(IAlarm alarm) { if (alarm == null) throw new ArgumentNullException("alarm"); lock (this.cache) { this.cache.Add(alarm.Id, alarm); this.UpdateRepository(); if (this.OnAlarmAdd != null) this.OnAlarmAdd.Invoke(this, new AlarmEventArgs(alarm)); this.CheckAlarmStatus(alarm); } }
public NotificationAlarm(Unit unit, IAlarm alarm, bool ack) { this.Unit = unit; this.Date = DateTime.Now; this.State = alarm.State; this.Prefix = "UN"; this.Code = alarm.Code; this.Description = alarm.Description; this.Ack = ack; string[] codeComp = alarm.Code.Split(new Char[] { '-' }); if (codeComp.Length > 1) { this.Prefix = codeComp[0].Substring(0, 2).ToUpper(); } }
public void Log(IUnit unit, IAlarm alarm) { int code = 10000; string[] codeComp = alarm.Code.Split(new Char[] { '-' }); if (codeComp.Length == 2) { code += Convert.ToInt32(codeComp[1]); } try { switch (alarm.State) { case ParamState.Idle: case ParamState.A: EventLog.WriteEntry(Journal.EventLogSource, String.Format("{0} [{1}, {2}]: {3}", unit.FullName, alarm.Code, ParamStateConverter.ToString(alarm.State), alarm.Description), EventLogEntryType.Information, code, Convert.ToInt16(unit.SymbolicName)); break; case ParamState.B: EventLog.WriteEntry(Journal.EventLogSource, String.Format("{0} [{1}, {2}]: {3}", unit.FullName, alarm.Code, ParamStateConverter.ToString(alarm.State), alarm.Description), EventLogEntryType.Warning, code, Convert.ToInt16(unit.SymbolicName)); break; case ParamState.C: EventLog.WriteEntry(Journal.EventLogSource, String.Format("{0} [{1}, {2}]: {3}", unit.FullName, alarm.Code, ParamStateConverter.ToString(alarm.State), alarm.Description), EventLogEntryType.Error, code, Convert.ToInt16(unit.SymbolicName)); break; case ParamState.Unknown: default: EventLog.WriteEntry(Journal.EventLogSource, String.Format("{0} [{1}, {2}]: {3}", unit.FullName, alarm.Code, ParamStateConverter.ToString(alarm.State), alarm.Description), EventLogEntryType.Information, code, Convert.ToInt16(unit.SymbolicName)); break; } } catch (SystemException e) { } }
public void Remove(IAlarm alarm) { if (alarm == null) throw new ArgumentNullException("alarm"); lock (this.cache) { this.cache.Remove(alarm.Id); this.UpdateRepository(); if (this.OnAlarmRemoval != null) this.OnAlarmRemoval.Invoke(this, new AlarmEventArgs(alarm)); } }
public void Add(IAlarm alarm) { this.alarms.Add(alarm); this.OnAlarmAdd.Invoke(e: new AlarmEventArgs(alarm)); }
public void UpdateAlarm(Unit unit, IAlarm alarm) { lock (Alarms) { List<NotificationAlarm> alarms = new List<NotificationAlarm>(Alarms); foreach (var notificationAlarm in alarms) { if (notificationAlarm.Unit.Uri.Equals(unit.Uri) && notificationAlarm.Code.Equals(alarm.Code)) { if (notificationAlarm.State != alarm.State) { if (alarm.State == ParamState.Idle) { Alarms.Remove(notificationAlarm); if (GeneralAlarmsStateChangedEvent != null) { GeneralAlarmsStateChangedEvent(this); } CanPlayShortNotification = true; return; } notificationAlarm.State = alarm.State; notificationAlarm.Ack = false; if (GeneralAlarmsStateChangedEvent != null) { GeneralAlarmsStateChangedEvent(this); } CanPlayShortNotification = true; if (notificationAlarm.State == ParamState.C) { LongNotificationTimer.Stop(); LongNotificationTimer.Interval = 3000; LongNotificationTimer.Start(); } } return; } } if (alarm.State > ParamState.Idle) { NotificationAlarm notificationAlarm = new NotificationAlarm(unit, alarm, false); Alarms.Add(notificationAlarm); if (GeneralAlarmsStateChangedEvent != null) { GeneralAlarmsStateChangedEvent(this); } CanPlayShortNotification = true; if (notificationAlarm.State == ParamState.C) { LongNotificationTimer.Stop(); LongNotificationTimer.Interval = 3000; LongNotificationTimer.Start(); } } } }
public AlarmEventArgs(IAlarm alarm) { Alarm = alarm; }
public void ModifyAlarm(IAlarm alarm) { if (alarm == null) return; if (AlarmExist(alarm.AlarmNo) == false) return; if (Items[alarm.AlarmNo] == null) return; IAlarm obj = Items[alarm.AlarmNo]; obj.AlarmName = alarm.AlarmName; obj.Solution = alarm.Solution; obj.ImagePath = alarm.ImagePath; obj.AlarmStatus = alarm.AlarmStatus; obj.AlarmType = alarm.AlarmType; }
public abstract string AskCancelReason(IAlarm alarm);
public abstract void RemoveAlarm(IAlarm alarm);
public AlarmCancelEventArgs(IAlarm alarm, string reason) { this.Reason = reason; this.Alarm = alarm; }
public void Remove(IAlarm alarm) { this.alarms.Remove(alarm); this.OnAlarmRemoval.Invoke(e: new AlarmEventArgs(alarm)); }
public void Import(IAlarm alarm) { if (alarm == null) throw new ArgumentNullException("alarm"); this.Status = alarm.Status; this.Time = alarm.Time; this.Title = alarm.Title; this.IsHushed = alarm.IsHushed; }
public void Update(IAlarm alarm) { this.OnAlarmUpdate.Invoke(e: new AlarmEventArgs(alarm)); }
public void Execute(IAlarm alarm) { alarm.Deactivate(); alarm.EventDispatcher.Dispatch(new DeactivatedEvent(_initiator)); }
public void Execute(IAlarm alarm) { alarm.EventDispatcher.Dispatch(new InvalidLoginEvent()); }
public void Add(IAlarm alarm) { this.Alarms.Add(alarm.Id, alarm); }
public void Update(IAlarm alarm) { this.Alarms[alarm.Id] = alarm; }
public void Remove(IAlarm alarm) { this.Alarms.Remove(alarm.Id); }
public void Import(IAlarm alarm) { }
public abstract void UpdateAlarm(IAlarm alarm);
public abstract void AddAlarm(IAlarm alarm);
public abstract AlarmMetadata AskAlarmMetadata(IAlarm alarm = null);
private void CheckAlarmStatus(IAlarm cachedAlarm) { if (cachedAlarm.CheckStatusChange()) { if (this.OnAlarmStatusChange != null) this.OnAlarmStatusChange.Invoke(this, new AlarmEventArgs(cachedAlarm)); } }
public void AddStorage(IAlarm alarm) { this.alarms.Add(alarm); }