<commit_before>package org.yamcs.xtceproc;

import java.util.Collection;

import org.yamcs.AlarmReporter;
import org.yamcs.ParameterValue;
import org.yamcs.protobuf.Pvalue.MonitoringResult;
import org.yamcs.xtce.AlarmLevels;
import org.yamcs.xtce.AlarmRanges;
import org.yamcs.xtce.AlarmType;
import org.yamcs.xtce.EnumeratedParameterType;
import org.yamcs.xtce.EnumerationAlarm;
import org.yamcs.xtce.EnumerationAlarm.EnumerationAlarmItem;
import org.yamcs.xtce.EnumerationContextAlarm;
import org.yamcs.xtce.FloatParameterType;
import org.yamcs.xtce.FloatRange;
import org.yamcs.xtce.IntegerParameterType;
import org.yamcs.xtce.NumericAlarm;
import org.yamcs.xtce.NumericContextAlarm;
import org.yamcs.xtce.ParameterType;

/**
 * Part of the TM processing chain. Is called upon by the
 * ParameterRequestManager whenever a new parameter value may need alarms
 * published together with it.
 */
public class AlarmChecker {
    
    private AlarmReporter alarmReporter;
    
    /**
     * Updates the supplied ParameterValues with monitoring (out of limits)
     * information. Any pvals that are required for performing comparison
     * matches are taken from the same set of pvals.
     */
    public void performAlarmChecking(Collection<ParameterValue> pvals) {
        ComparisonProcessor comparisonProcessor=new ComparisonProcessor(pvals);
        for(ParameterValue pval:pvals) {
            if(pval.getParameter().getParameterType().hasAlarm()) {
                performAlarmChecking(pval, comparisonProcessor);
            }
        }
    }
    
    public void enableReporting(AlarmReporter alarmReporter) {
        this.alarmReporter=alarmReporter;
    }
    
    /**
     * Updates the ParameterValue with monitoring (out of limits) information
     */
    private void performAlarmChecking(ParameterValue pv, ComparisonProcessor comparisonProcessor) {
        ParameterType ptype=pv.getParameter().getParameterType();<commit_msg>Fix potential NPE with PPs and alarms<commit_after>package org.yamcs.xtceproc;

import java.util.Collection;

import org.yamcs.AlarmReporter;
import org.yamcs.ParameterValue;
import org.yamcs.protobuf.Pvalue.MonitoringResult;
import org.yamcs.xtce.AlarmLevels;
import org.yamcs.xtce.AlarmRanges;
import org.yamcs.xtce.AlarmType;
import org.yamcs.xtce.EnumeratedParameterType;
import org.yamcs.xtce.EnumerationAlarm;
import org.yamcs.xtce.EnumerationAlarm.EnumerationAlarmItem;
import org.yamcs.xtce.EnumerationContextAlarm;
import org.yamcs.xtce.FloatParameterType;
import org.yamcs.xtce.FloatRange;
import org.yamcs.xtce.IntegerParameterType;
import org.yamcs.xtce.NumericAlarm;
import org.yamcs.xtce.NumericContextAlarm;
import org.yamcs.xtce.ParameterType;

/**
 * Part of the TM processing chain. Is called upon by the
 * ParameterRequestManager whenever a new parameter value may need alarms
 * published together with it.
 */
public class AlarmChecker {
    
    private AlarmReporter alarmReporter;
    
    /**
     * Updates the supplied ParameterValues with monitoring (out of limits)
     * information. Any pvals that are required for performing comparison
     * matches are taken from the same set of pvals.
     */
    public void performAlarmChecking(Collection<ParameterValue> pvals) {
        ComparisonProcessor comparisonProcessor=new ComparisonProcessor(pvals);
        for(ParameterValue pval:pvals) {
            if(pval.getParameter().getParameterType()!=null && pval.getParameter().getParameterType().hasAlarm()) {
                performAlarmChecking(pval, comparisonProcessor);
            }
        }
    }
    
    public void enableReporting(AlarmReporter alarmReporter) {
        this.alarmReporter=alarmReporter;
    }
    
    /**
     * Updates the ParameterValue with monitoring (out of limits) information
     */
    private void performAlarmChecking(ParameterValue pv, ComparisonProcessor comparisonProcessor) {
        ParameterType ptype=pv.getParameter().getParameterType();
{'fraction_non_alphanumeric': 0.08135421930267812, 'fraction_numerical': 0.0, 'mean_word_length': 4.056194125159642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5394767', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1175, 'n_words': 260}