use of cl.utfsm.acs.acg.core.ReductionRule in project ACS by ACS-Community.
the class ReductionsView method fillNRParentChAlarmList.
public void fillNRParentChAlarmList(String ff, String fm, int fc) {
_NRParentErrorMessageLabel.setText("");
_NRParentChAlarmList.removeAll();
ReductionRule nrr = _reductionManager.getNRParentByTriplet(ff, fm, fc);
Alarm parent;
// This should never happen anyways...
if (nrr == null) {
parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
_NRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
} else
parent = nrr.getParent();
if (parent == null) {
_NRParentErrorMessageLabel.setText("Couldn't find the selected Alarm.");
return;
}
List<Alarm> alarms = _alarmManager.getAlarms();
List<String> tmp = new ArrayList<String>();
List<Alarm> sortedAlarms = new ArrayList<Alarm>();
for (Alarm al : alarms) tmp.add(al.getIdentifier());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sal : tmp) sortedAlarms.add(_alarmManager.getAlarm(sal));
alarms = sortedAlarms;
try {
for (Iterator<Alarm> iterator = alarms.iterator(); iterator.hasNext(); ) {
Alarm alarm = iterator.next();
if (alarm.getAlarmId().compareTo(parent.getAlarmId()) == 0)
continue;
if (_NRParentChFFCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultFamily().compareTo(_NRParentChFFCombo.getText()) != 0)
continue;
if (_NRParentChFMCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultMember().compareTo(_NRParentChFMCombo.getText()) != 0)
continue;
if (_NRParentChFCCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultCode() != Integer.parseInt(_NRParentChFCCombo.getText()))
continue;
if (_NRParentChFilterText.getText().compareTo("") != 0)
if (!alarm.getAlarmId().matches(_NRParentChFilterText.getText()))
continue;
if (_NRParentChSelectedRadio.getSelection() && (nrr == null || nrr.getChild(alarm.getAlarmId()) == null))
continue;
if (_NRParentChUnselectedRadio.getSelection() && (nrr != null && nrr.getChild(alarm.getAlarmId()) != null))
continue;
TableItem t = new TableItem(_NRParentChAlarmList, SWT.None);
t.setText(alarm.getAlarmId());
if (nrr != null) {
List<Alarm> children = nrr.getChildren();
for (Iterator<Alarm> iterator2 = children.iterator(); iterator2.hasNext(); ) {
Alarm alarm2 = iterator2.next();
if (alarm.getAlarmId().compareTo(alarm2.getAlarmId()) == 0) {
t.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
break;
}
}
}
}
} catch (Exception e) {
_NRParentErrorMessageLabel.setText(e.getMessage());
}
}
use of cl.utfsm.acs.acg.core.ReductionRule in project ACS by ACS-Community.
the class ReductionsView method sortNodeReductionRuleList.
public void sortNodeReductionRuleList(TreeItem iTree) {
List<ReductionRule> rrList = _reductionManager.getNodeReductionRules();
List<ReductionRule> sortedRRList = new ArrayList<ReductionRule>();
List<String> tmp = new ArrayList<String>();
for (ReductionRule rr : rrList) {
Triplet t = rr.getParent().getTriplet();
String name = "<" + t.getFaultFamily() + "," + t.getFaultMember() + "," + t.getFaultCode() + ">";
tmp.add(name);
}
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String srr : tmp) for (ReductionRule rr : rrList) {
Triplet t = rr.getParent().getTriplet();
String name = "<" + t.getFaultFamily() + "," + t.getFaultMember() + "," + t.getFaultCode() + ">";
if (name.compareTo(srr) == 0)
sortedRRList.add(rr);
}
rrList = sortedRRList;
for (ReductionRule rule : rrList) {
TreeItem kTree = new TreeItem(iTree, SWT.NONE);
Triplet t = rule.getParent().getTriplet();
kTree.setText("<" + t.getFaultFamily() + "," + t.getFaultMember() + "," + t.getFaultCode() + ">");
kTree.setData(NodeType.NODE_REDUCTION_PARENT_DATA);
}
}
use of cl.utfsm.acs.acg.core.ReductionRule in project ACS by ACS-Community.
the class ReductionsView method fillNRParentWidgets.
private void fillNRParentWidgets(String ff, String fm, int fc) {
//_updateNRParentFF.setEnabled(false);
ReductionRule nrr = _reductionManager.getNRParentByTriplet(ff, fm, fc);
Alarm parent = null;
// This should happen only when creating a new rule...
if (nrr == null) {
parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
_NRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
} else
parent = nrr.getParent();
_NRParentFFCombo.removeAll();
_NRParentChFFCombo.removeAll();
_NRParentChFFCombo.add("Any");
_NRParentChFFCombo.select(0);
List<FaultFamily> ffList = _alarmManager.getAllAlarms();
List<String> tmp = new ArrayList<String>();
List<FaultFamily> sortedFFList = new ArrayList<FaultFamily>();
for (FaultFamily tff : ffList) tmp.add(tff.getName());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sff : tmp) sortedFFList.add(_alarmManager.getFaultFamily(sff));
ffList = sortedFFList;
FaultFamily ffs = null;
int i = -1;
for (Iterator<FaultFamily> iterator = ffList.iterator(); iterator.hasNext(); ) {
FaultFamily fft = iterator.next();
if (fft.getFaultCodeCount() > 0 && fft.getFaultMemberCount() > 0)
_NRParentFFCombo.add(fft.getName());
_NRParentChFFCombo.add(fft.getName());
if (parent != null && fft.getName().compareTo(parent.getTriplet().getFaultFamily()) == 0) {
i = _NRParentFFCombo.getItemCount() - 1;
ffs = fft;
}
}
_NRParentFFCombo.select(i);
_NRParentFMCombo.removeAll();
if (ffs != null) {
i = -1;
FaultMember[] fml = ffs.getFaultMember();
List<FaultMember> fmList = Arrays.asList(fml);
tmp = new ArrayList<String>();
List<FaultMember> sortedFMList = new ArrayList<FaultMember>();
for (FaultMember tfm : fmList) tmp.add(tfm.getName());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sfm : tmp) for (FaultMember tfm : fmList) if (sfm.compareTo(tfm.getName()) == 0)
sortedFMList.add(tfm);
fmList = sortedFMList;
for (FaultMember fmt : fmList) {
_NRParentFMCombo.add(fmt.getName());
if (fmt.getName().compareTo(parent.getTriplet().getFaultMember()) == 0)
i = _NRParentFMCombo.getItemCount() - 1;
}
_NRParentFMCombo.select(i);
}
_NRParentFCCombo.removeAll();
if (ffs != null) {
i = -1;
FaultCode[] fcl = ffs.getFaultCode();
List<FaultCode> fcList = Arrays.asList(fcl);
tmp = new ArrayList<String>();
List<FaultCode> sortedFCList = new ArrayList<FaultCode>();
for (FaultCode tfc : fcList) tmp.add(Integer.toString(tfc.getValue()));
Collections.sort(tmp);
for (String sfc : tmp) for (FaultCode tfc : fcList) if (sfc.compareTo(Integer.toString(tfc.getValue())) == 0)
sortedFCList.add(tfc);
fcList = sortedFCList;
for (FaultCode fct : fcList) {
_NRParentFCCombo.add(Integer.toString(fct.getValue()));
if (fct.getValue() == parent.getTriplet().getFaultCode())
i = _NRParentFCCombo.getItemCount() - 1;
}
_NRParentFCCombo.select(i);
}
_NRParentChFMCombo.removeAll();
_NRParentChFMCombo.add("Any");
_NRParentChFMCombo.select(0);
_NRParentChFCCombo.removeAll();
_NRParentChFCCombo.add("Any");
_NRParentChFCCombo.select(0);
if (ff.isEmpty() && fm.isEmpty() && fc == 0) {
if (!_NRParentFFCombo.getText().isEmpty() && !_NRParentFMCombo.getText().isEmpty() && !_NRParentFCCombo.getText().isEmpty())
fillNRParentChAlarmList(_NRParentFFCombo.getText(), _NRParentFMCombo.getText(), Integer.parseInt(_NRParentFCCombo.getText()));
} else
fillNRParentChAlarmList(ff, fm, fc);
//_updateNRParentFF.setEnabled(true);
}
use of cl.utfsm.acs.acg.core.ReductionRule in project ACS by ACS-Community.
the class ReductionsView method fillMRParentChAlarmList.
public void fillMRParentChAlarmList(String ff, String fm, int fc) {
_MRParentErrorMessageLabel.setText("");
_MRParentChAlarmList.removeAll();
ReductionRule mrr = _reductionManager.getMRParentByTriplet(ff, fm, fc);
Alarm parent;
// This should only happen when creating a new rule...
if (mrr == null) {
parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
_MRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
} else
parent = mrr.getParent();
if (parent == null) {
_MRParentErrorMessageLabel.setText("Couldn't find the selected Alarm.");
return;
}
if (_MRParentThresholdText.getText().isEmpty()) {
_MRParentErrorMessageLabel.setText("Please set a Threshold value.");
return;
}
try {
Integer.parseInt(_MRParentThresholdText.getText());
} catch (NumberFormatException e) {
_MRParentErrorMessageLabel.setText("Incorrect Threshold. A number is required.");
return;
}
List<Alarm> alarms = _alarmManager.getAlarms();
List<String> tmp = new ArrayList<String>();
List<Alarm> sortedAlarms = new ArrayList<Alarm>();
for (Alarm al : alarms) tmp.add(al.getIdentifier());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sal : tmp) sortedAlarms.add(_alarmManager.getAlarm(sal));
alarms = sortedAlarms;
try {
for (Iterator<Alarm> iterator = alarms.iterator(); iterator.hasNext(); ) {
Alarm alarm = iterator.next();
if (alarm.getAlarmId().compareTo(parent.getAlarmId()) == 0)
continue;
if (_MRParentChFFCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultFamily().compareTo(_MRParentChFFCombo.getText()) != 0)
continue;
if (_MRParentChFMCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultMember().compareTo(_MRParentChFMCombo.getText()) != 0)
continue;
if (_MRParentChFCCombo.getText().compareTo("Any") != 0)
if (alarm.getTriplet().getFaultCode() != Integer.parseInt(_MRParentChFCCombo.getText()))
continue;
if (_MRParentChFilterText.getText().compareTo("") != 0)
if (!alarm.getAlarmId().matches(_MRParentChFilterText.getText()))
continue;
if (_MRParentChSelectedRadio.getSelection() && (mrr == null || mrr.getChild(alarm.getAlarmId()) == null))
continue;
if (_MRParentChUnselectedRadio.getSelection() && (mrr != null && mrr.getChild(alarm.getAlarmId()) != null))
continue;
TableItem t = new TableItem(_MRParentChAlarmList, SWT.None);
t.setText(alarm.getAlarmId());
if (mrr != null) {
List<Alarm> children = mrr.getChildren();
for (Iterator<Alarm> iterator2 = children.iterator(); iterator2.hasNext(); ) {
Alarm alarm2 = iterator2.next();
if (alarm.getAlarmId().compareTo(alarm2.getAlarmId()) == 0) {
t.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
break;
}
}
}
}
if (mrr != null && mrr.getChildrenCount() < mrr.getThreshold())
_MRParentErrorMessageLabel.setText("You need to have at least threshold (" + mrr.getThreshold() + ") childs for this triplet.");
} catch (PatternSyntaxException e) {
_MRParentErrorMessageLabel.setText(e.getMessage());
}
}
Aggregations