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_301_statevariables_ap_con_complex_shacl(dataset: &CimDataset) -> Vec<Violation> {
    let mut v = Vec::new();
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_cs_converter_gamma_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_cs_converter_alpha_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_udc_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_uc_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_pole_loss_p_min_etc(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_sv_shunt_compensator_sections_sv_shunt_compe_etc(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_sv_voltage_sv_voltage_v_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_vs_converter_uv_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_vs_converter_delta_min_incl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_udc_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_uc_min_excl(dataset));
    v.extend(check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_pole_loss_p_min_etc(dataset));
    v
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_cs_converter_gamma_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("CsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::CsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.gamma.is_none() { continue; }
        if obj.gamma.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:CsConverter.gamma-valueRange".to_string(),
                class:       "CsConverter".to_string(),
                property:    "CsConverter.gamma".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:CsConverter.gamma:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_cs_converter_alpha_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("CsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::CsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.alpha.is_none() { continue; }
        if obj.alpha.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:CsConverter.alpha-valueRange".to_string(),
                class:       "CsConverter".to_string(),
                property:    "CsConverter.alpha".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:CsConverter.alpha:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_udc_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("CsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::CsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.udc.is_none() { continue; }
        if obj.base.udc.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.udc-valueRange".to_string(),
                class:       "CsConverter".to_string(),
                property:    "ACDCConverter.udc".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.udc:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_uc_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("CsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::CsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.uc.is_none() { continue; }
        if obj.base.uc.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.uc-valueRange".to_string(),
                class:       "CsConverter".to_string(),
                property:    "ACDCConverter.uc".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.uc:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_cs_converter_acdc_converter_pole_loss_p_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("CsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::CsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.pole_loss_p.is_none() { continue; }
        if obj.base.pole_loss_p.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.poleLossP-valueRange".to_string(),
                class:       "CsConverter".to_string(),
                property:    "ACDCConverter.poleLossP".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.poleLossP:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_sv_shunt_compensator_sections_sv_shunt_compe_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("SvShuntCompensatorSections").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::SvShuntCompensatorSections>() {
            Some(o) => o, None => continue,
        };
        if obj.sections.is_none() { continue; }
        if obj.sections.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:SvShuntCompensatorSections.sections-valueRange".to_string(),
                class:       "SvShuntCompensatorSections".to_string(),
                property:    "SvShuntCompensatorSections.sections".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:SvShuntCompensatorSections.sections:valueRange".to_string(),
                description: "The attribute shall be a positive value or zero.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_sv_voltage_sv_voltage_v_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("SvVoltage").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::SvVoltage>() {
            Some(o) => o, None => continue,
        };
        if obj.v.is_none() { continue; }
        if obj.v.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:SvVoltage.v-valueRange".to_string(),
                class:       "SvVoltage".to_string(),
                property:    "SvVoltage.v".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:SvVoltage.v:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_vs_converter_uv_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("VsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::VsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.uv.is_none() { continue; }
        if obj.uv.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:VsConverter.uv-valueRange".to_string(),
                class:       "VsConverter".to_string(),
                property:    "VsConverter.uv".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:VsConverter.uv:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_vs_converter_delta_min_incl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("VsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::VsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.delta.is_none() { continue; }
        if obj.delta.unwrap() < 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:VsConverter.delta-valueRange".to_string(),
                class:       "VsConverter".to_string(),
                property:    "VsConverter.delta".to_string(),
                message:     "The value is negative.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:VsConverter.delta:valueRange".to_string(),
                description: "The attribute shall be a positive value or zero.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_udc_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("VsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::VsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.udc.is_none() { continue; }
        if obj.base.udc.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.udc-valueRange".to_string(),
                class:       "VsConverter".to_string(),
                property:    "ACDCConverter.udc".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.udc:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_uc_min_excl(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("VsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::VsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.uc.is_none() { continue; }
        if obj.base.uc.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.uc-valueRange".to_string(),
                class:       "VsConverter".to_string(),
                property:    "ACDCConverter.uc".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.uc:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}

pub fn check_p61970_301_statevariables_ap_con_complex_shacl_vs_converter_acdc_converter_pole_loss_p_min_etc(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    for mrid in dataset.by_type.get("VsConverter").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::VsConverter>() {
            Some(o) => o, None => continue,
        };
        if obj.base.pole_loss_p.is_none() { continue; }
        if obj.base.pole_loss_p.unwrap() <= 0_f64 {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "svu:ACDCConverter.poleLossP-valueRange".to_string(),
                class:       "VsConverter".to_string(),
                property:    "ACDCConverter.poleLossP".to_string(),
                message:     "The value is negative or zero.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:301:SV:ACDCConverter.poleLossP:valueRange".to_string(),
                description: "The attribute shall be a positive value.".to_string(),
            });
        }
    }
    violations
}