cimoxide-validation 0.3.2

SHACL validation of CGMES datasets against the ENTSO-E profile constraints
Documentation
// Generated by cimgen — do not edit by hand.
#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;

pub fn validate_p61970_456_steadystatehypothesis_ap_con_complex_shacl(dataset: &CimDataset) -> Vec<Violation> {
    let mut v = Vec::new();
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_conform_load_energy_consumer_q_min_incl(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_conform_load_energy_consumer_p_min_incl(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_consumer_energy_consumer_q_min_etc(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_consumer_energy_consumer_p_min_etc(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_source_and(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_non_conform_load_energy_consumer_q_mi_etc(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_non_conform_load_energy_consumer_p_mi_etc(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_station_supply_energy_consumer_q_min_etc(dataset));
    v.extend(check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_station_supply_energy_consumer_p_min_etc(dataset));
    v
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_conform_load_energy_consumer_q_min_incl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("ConformLoad").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::ConformLoad>() {
            Some(o) => o, None => continue,
        };
        if obj.base.q.is_none() { continue; }
        if obj.base.q.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.q-valueRange".to_string(),
                class:       "ConformLoad".to_string(),
                property:    "EnergyConsumer.q".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.q:ValueRange".to_string(),
                description: "Negative reactive power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_conform_load_energy_consumer_p_min_incl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("ConformLoad").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::ConformLoad>() {
            Some(o) => o, None => continue,
        };
        if obj.base.p.is_none() { continue; }
        if obj.base.p.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.p-valueRange".to_string(),
                class:       "ConformLoad".to_string(),
                property:    "EnergyConsumer.p".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.p:ValueRange".to_string(),
                description: "Negative active power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_consumer_energy_consumer_q_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("EnergyConsumer").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::EnergyConsumer>() {
            Some(o) => o, None => continue,
        };
        if obj.q.is_none() { continue; }
        if obj.q.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.q-valueRange".to_string(),
                class:       "EnergyConsumer".to_string(),
                property:    "EnergyConsumer.q".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.q:ValueRange".to_string(),
                description: "Negative reactive power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_consumer_energy_consumer_p_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("EnergyConsumer").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::EnergyConsumer>() {
            Some(o) => o, None => continue,
        };
        if obj.p.is_none() { continue; }
        if obj.p.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.p-valueRange".to_string(),
                class:       "EnergyConsumer".to_string(),
                property:    "EnergyConsumer.p".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.p:ValueRange".to_string(),
                description: "Negative active power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_energy_source_and(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("EnergySource").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::EnergySource>() {
            Some(o) => o, None => continue,
        };
        if obj.voltage_magnitude.is_some() || obj.voltage_angle.is_some() {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergySource-EnergySourcePQ".to_string(),
                class:       "EnergySource".to_string(),
                property:    "C:456:SSH:EnergySource:EnergySourcePQ".to_string(),
                message:     "EnergySource modelled as voltage source (attributes voltageAngle and voltageMagnitude are used). Please assess depending on the use case.".to_string(),
                severity:    "sh:Warning".to_string(),
                name:        "C:456:SSH:EnergySource:EnergySourcePQ".to_string(),
                description: "The attributes voltageAngle and voltageMagnitude shall not be used when the EnergySource is representing a constant active and reactive power injection (PQ injection), i.e. they shall only be used when the EnergySource is modelling a voltage source.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_non_conform_load_energy_consumer_q_mi_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("NonConformLoad").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::NonConformLoad>() {
            Some(o) => o, None => continue,
        };
        if obj.base.q.is_none() { continue; }
        if obj.base.q.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.q-valueRange".to_string(),
                class:       "NonConformLoad".to_string(),
                property:    "EnergyConsumer.q".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.q:ValueRange".to_string(),
                description: "Negative reactive power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_non_conform_load_energy_consumer_p_mi_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("NonConformLoad").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::NonConformLoad>() {
            Some(o) => o, None => continue,
        };
        if obj.base.p.is_none() { continue; }
        if obj.base.p.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.p-valueRange".to_string(),
                class:       "NonConformLoad".to_string(),
                property:    "EnergyConsumer.p".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.p:ValueRange".to_string(),
                description: "Negative active power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_station_supply_energy_consumer_q_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("StationSupply").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::StationSupply>() {
            Some(o) => o, None => continue,
        };
        if obj.base.q.is_none() { continue; }
        if obj.base.q.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.q-valueRange".to_string(),
                class:       "StationSupply".to_string(),
                property:    "EnergyConsumer.q".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.q:ValueRange".to_string(),
                description: "Negative reactive power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_456_steadystatehypothesis_ap_con_complex_shacl_station_supply_energy_consumer_p_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("StationSupply").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::StationSupply>() {
            Some(o) => o, None => continue,
        };
        if obj.base.p.is_none() { continue; }
        if obj.base.p.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "ssh456:EnergyConsumer.p-valueRange".to_string(),
                class:       "StationSupply".to_string(),
                property:    "EnergyConsumer.p".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:456:SSH:EnergyConsumer.p:ValueRange".to_string(),
                description: "Negative active power loads shall not be exchanged. In cases where this is needed EquivalentInjection is used instead.".to_string(),
            });
        }
    }
    violations
}