private void SetHeadingProperties() { if (SelectedShortPLCconnection != null) { int manufacturer = SelectedShortPLCconnection.CPUmanufacturer; if (manufacturer == 1) { S7PlcConnectionDefinition definition = _originalListOfS7connections.Single(x => x.PLCconnectionID == SelectedShortPLCconnection.PLCconnectionID); CurrentConnectionIP = $"{definition.FirstOctet}.{definition.SecondOctet}.{definition.ThirdOctet}.{definition.FourthOctet}"; ConnectionActivated = definition.ConnectionActivated; S7CpuTypeConverter converter = new S7CpuTypeConverter(); CpuType = converter.GetS7TypeEnum(definition.CPUtype).ToString(); GetAlarmsForS7Connection(definition.PLCconnectionID); } MultipleAlarmsDeletionButtonEnabled = _canModifyAlarm; AddingNewAlarmsEnabled = _canModifyAlarm; EnableFiltering = true; } else { CurrentConnectionIP = "_._._._"; ConnectionActivated = false; CpuType = "-----"; AddingNewAlarmsEnabled = false; MultipleAlarmsDeletionButtonEnabled = false; EnableFiltering = false; AlarmsForSelectedS7Connection.Clear(); } }
//method for reseting filters public void ResetFilters() { //reset filters AssignAlarmListStartupFilters(); // clear current list AlarmsForSelectedS7Connection.Clear(); //add all alarms to the list view control foreach (var item in _originalS7AlarmWithTexts) { AlarmsForSelectedS7Connection.Add(item); } }
private void GetAlarmsForS7Connection(int connnectionID) { _logger.Info($"Algorithm of rreading all alarms for St connection with PLC connection ID: {connnectionID}, started."); //read values with texts AlarmS7Reader reader = new AlarmS7Reader(_realmProvider); _originalS7AlarmWithTexts = reader.GetAllAlarmsOffS7plcConnectionWithTexts(connnectionID); //assign names of alarm urgency profiles and sms recipients groups AssignSMSgroupAndAlarmProfile(ref _originalS7AlarmWithTexts); //clear current list AlarmsForSelectedS7Connection.Clear(); //add all alarms to the list view control ApplyFIlters(); //modify amount of alarms AlarmsAmount = _originalS7AlarmWithTexts.Count(); }
//apply filters when creating list of alarms public void ApplyFIlters() { //clear current list AlarmsForSelectedS7Connection.Clear(); //add all alarms to the list view control foreach (var item in _originalS7AlarmWithTexts) { try { if (item.AlarmTagName.Contains(_almTagNameFilter) && item.AckTagName.Contains(_ackTagNameFilter) && item.AlarmProfileName.Contains(_alarmProfileFIlter) && item.SMSrecipientsGroupName.Contains(_smsGroupFilter) && item.AlarmTagString.Contains(_almAddressFilter)) { AlarmsForSelectedS7Connection.Add(item); } } catch (Exception ex) { _logger.Error($"Error while filtering alarms. Exception: {ex.Message}. Item: {item.ToString()}."); } } }