public FrmAddAlarm(ClassAlarm AlarmCurrent = null) { objChannelManager = ChannelService.GetChannelManager(); objDeviceManager = DeviceService.GetDeviceManager(); objDataBlockManager = DataBlockService.GetDataBlockManager(); objTagManager = TagService.GetTagManager(); InitializeComponent(); Alarm = AlarmCurrent; }
private void btnOK_Click(object sender, System.EventArgs e) { try { if (Alarm == null) { ClassAlarm newAlarm = new ClassAlarm { TriggerTeg = txtTagName.Text, Channel = txtChannel.Text, Name = ColName.Text, DataBlock = txtDataBlock.Text, Device = txtDevice.Text, AlarmCalss = ColAlarmCalss.Text, AlarmText = ColAlarmText.Text, Value = ColValue.Text }; eventAlarmChanged?.Invoke(newAlarm, true); } else { Alarm.TriggerTeg = txtTagName.Text; Alarm.Channel = txtChannel.Text; Alarm.Name = ColName.Text; Alarm.DataBlock = txtDataBlock.Text; Alarm.Device = txtDevice.Text; Alarm.AlarmCalss = ColAlarmCalss.Text; Alarm.AlarmText = ColAlarmText.Text; Alarm.Value = ColValue.Text; eventAlarmChanged?.Invoke(Alarm, false); } } catch (Exception ex) { EventscadaException?.Invoke(GetType().Name, ex.Message); } }
private void EditorAlarm_Click(object sender, EventArgs e) { if (DGAlarmAnalog.SelectedRows.Count == 1) { string tgName = (string)DGAlarmAnalog.SelectedRows[0].Cells[0].Value; ClassAlarm tgCurrent = objAlarmManager.GetByAlarmName(tgName); FrmAddAlarm tgFrm = new FrmAddAlarm(tgCurrent); tgFrm.eventAlarmChanged += (Ar, isNew) => { objAlarmManager.UpdateAlarm(Ar); DGAlarmAnalog.Rows.Clear(); foreach (ClassAlarm tg in objAlarmManager.Alarms) { string[] row = { tg.Name, string.Format("{0}", tg.AlarmText), string.Format("{0}", tg.AlarmCalss), tg.Value, tg.TriggerTeg, tg.DataBlock, tg.Device, tg.Channel }; DGAlarmAnalog.Rows.Add(row); } IsDataChanged = true; }; tgFrm.StartPosition = FormStartPosition.CenterScreen; tgFrm.ShowDialog(); } }