zepben.ewb 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zepben/ewb/__init__.py +601 -0
- zepben/ewb/auth/__init__.py +10 -0
- zepben/ewb/auth/client/__init__.py +5 -0
- zepben/ewb/auth/client/zepben_token_fetcher.py +273 -0
- zepben/ewb/auth/common/__init__.py +5 -0
- zepben/ewb/auth/common/auth_exception.py +16 -0
- zepben/ewb/auth/common/auth_method.py +28 -0
- zepben/ewb/auth/common/auth_provider_config.py +96 -0
- zepben/ewb/database/__init__.py +4 -0
- zepben/ewb/database/paths/__init__.py +4 -0
- zepben/ewb/database/paths/database_type.py +34 -0
- zepben/ewb/database/paths/ewb_data_file_paths.py +237 -0
- zepben/ewb/database/sql/__init__.py +4 -0
- zepben/ewb/database/sql/column.py +37 -0
- zepben/ewb/database/sql/sql_table.py +142 -0
- zepben/ewb/database/sqlite/__init__.py +4 -0
- zepben/ewb/database/sqlite/common/__init__.py +4 -0
- zepben/ewb/database/sqlite/common/base_cim_reader.py +212 -0
- zepben/ewb/database/sqlite/common/base_cim_writer.py +159 -0
- zepben/ewb/database/sqlite/common/base_collection_reader.py +96 -0
- zepben/ewb/database/sqlite/common/base_collection_writer.py +73 -0
- zepben/ewb/database/sqlite/common/base_database_reader.py +127 -0
- zepben/ewb/database/sqlite/common/base_database_tables.py +137 -0
- zepben/ewb/database/sqlite/common/base_database_writer.py +195 -0
- zepben/ewb/database/sqlite/common/base_entry_writer.py +34 -0
- zepben/ewb/database/sqlite/common/base_service_reader.py +50 -0
- zepben/ewb/database/sqlite/common/base_service_writer.py +104 -0
- zepben/ewb/database/sqlite/common/metadata_collection_reader.py +39 -0
- zepben/ewb/database/sqlite/common/metadata_collection_writer.py +38 -0
- zepben/ewb/database/sqlite/common/metadata_entry_reader.py +45 -0
- zepben/ewb/database/sqlite/common/metadata_entry_writer.py +41 -0
- zepben/ewb/database/sqlite/common/reader_exceptions.py +30 -0
- zepben/ewb/database/sqlite/customer/__init__.py +4 -0
- zepben/ewb/database/sqlite/customer/customer_cim_reader.py +169 -0
- zepben/ewb/database/sqlite/customer/customer_cim_writer.py +137 -0
- zepben/ewb/database/sqlite/customer/customer_database_reader.py +44 -0
- zepben/ewb/database/sqlite/customer/customer_database_tables.py +37 -0
- zepben/ewb/database/sqlite/customer/customer_database_writer.py +45 -0
- zepben/ewb/database/sqlite/customer/customer_service_reader.py +57 -0
- zepben/ewb/database/sqlite/customer/customer_service_writer.py +47 -0
- zepben/ewb/database/sqlite/diagram/__init__.py +4 -0
- zepben/ewb/database/sqlite/diagram/diagram_cim_reader.py +105 -0
- zepben/ewb/database/sqlite/diagram/diagram_cim_writer.py +81 -0
- zepben/ewb/database/sqlite/diagram/diagram_database_reader.py +45 -0
- zepben/ewb/database/sqlite/diagram/diagram_database_tables.py +29 -0
- zepben/ewb/database/sqlite/diagram/diagram_database_writer.py +44 -0
- zepben/ewb/database/sqlite/diagram/diagram_service_reader.py +49 -0
- zepben/ewb/database/sqlite/diagram/diagram_service_writer.py +41 -0
- zepben/ewb/database/sqlite/extensions/__init__.py +4 -0
- zepben/ewb/database/sqlite/extensions/prepared_statement.py +112 -0
- zepben/ewb/database/sqlite/extensions/result_set.py +153 -0
- zepben/ewb/database/sqlite/network/__init__.py +4 -0
- zepben/ewb/database/sqlite/network/network_cim_reader.py +3167 -0
- zepben/ewb/database/sqlite/network/network_cim_writer.py +2561 -0
- zepben/ewb/database/sqlite/network/network_database_reader.py +175 -0
- zepben/ewb/database/sqlite/network/network_database_tables.py +242 -0
- zepben/ewb/database/sqlite/network/network_database_writer.py +43 -0
- zepben/ewb/database/sqlite/network/network_service_reader.py +265 -0
- zepben/ewb/database/sqlite/network/network_service_writer.py +209 -0
- zepben/ewb/database/sqlite/tables/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/associations/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/associations/loop_substation_relationship.py +17 -0
- zepben/ewb/database/sqlite/tables/associations/table_asset_organisation_roles_assets.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_assets_power_system_resources.py +41 -0
- zepben/ewb/database/sqlite/tables/associations/table_battery_units_battery_controls.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_circuits_substations.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_circuits_terminals.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_customer_agreements_pricing_structures.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_end_devices_end_device_functions.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_equipment_equipment_containers.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_equipment_operational_restrictions.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_equipment_usage_points.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_loops_substations.py +43 -0
- zepben/ewb/database/sqlite/tables/associations/table_pricing_structures_tariffs.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_protection_relay_functions_protected_switches.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_protection_relay_functions_sensors.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_protection_relay_schemes_protection_relay_functions.py +40 -0
- zepben/ewb/database/sqlite/tables/associations/table_synchronous_machines_reactive_capability_curves.py +39 -0
- zepben/ewb/database/sqlite/tables/associations/table_usage_points_end_devices.py +40 -0
- zepben/ewb/database/sqlite/tables/exceptions.py +10 -0
- zepben/ewb/database/sqlite/tables/extensions/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/table_reclose_delays.py +38 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/table_relay_info.py +21 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/metering/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61968/metering/table_pan_demand_response_functions.py +21 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/core/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/core/table_sites.py +15 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/table_loops.py +15 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/table_lv_feeders.py +20 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/production/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/production/table_ev_charging_units.py +15 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_distance_relays.py +28 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_function_thresholds.py +36 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_function_time_limits.py +34 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_functions.py +24 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_schemes.py +20 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_systems.py +20 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_voltage_relays.py +15 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/table_battery_controls.py +23 -0
- zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/table_power_transformer_end_ratings.py +34 -0
- zepben/ewb/database/sqlite/tables/iec61968/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_cable_info.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_no_load_tests.py +24 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_open_circuit_tests.py +24 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_overhead_wire_info.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_power_transformer_info.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_short_circuit_tests.py +29 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_shunt_compensator_info.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_switch_info.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_end_info.py +46 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_tank_info.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_test.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_wire_info.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_containers.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_functions.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_info.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_organisation_roles.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_owners.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_assets.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_streetlights.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61968/assets/table_structures.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_agreements.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_documents.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_location_street_address_field.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_location_street_addresses.py +33 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_locations.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_organisation_roles.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_organisations.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_position_points.py +30 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_street_addresses.py +26 -0
- zepben/ewb/database/sqlite/tables/iec61968/common/table_town_details.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61968/customers/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/customers/table_customer_agreements.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61968/customers/table_customers.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61968/customers/table_pricing_structures.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/customers/table_tariffs.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/table_current_transformer_info.py +33 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/table_potential_transformer_info.py +26 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassets/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassets/table_poles.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61968/metering/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/metering/table_end_device_functions.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61968/metering/table_end_devices.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61968/metering/table_meters.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61968/metering/table_usage_points.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61968/operations/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61968/operations/table_operational_restrictions.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_auxiliary_equipment.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_current_transformers.py +21 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_fault_indicators.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_potential_transformers.py +21 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_sensors.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_ac_dc_terminals.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_base_voltages.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_conducting_equipment.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_connectivity_node_containers.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_connectivity_nodes.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_curve_data.py +46 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_curves.py +17 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_equipment.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_equipment_containers.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_feeders.py +28 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_geographical_regions.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_identified_objects.py +29 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_name_types.py +28 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_names.py +36 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_power_system_resources.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_sub_geographical_regions.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_substations.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/core/table_terminals.py +35 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagram_object_points.py +35 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagram_objects.py +31 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagrams.py +21 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/table_equivalent_branches.py +35 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/table_equivalent_equipment.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_battery_units.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_photo_voltaic_units.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_power_electronics_units.py +26 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_power_electronics_wind_units.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_accumulators.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_analogs.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_controls.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_discretes.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_io_points.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_measurements.py +30 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/protection/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/protection/table_current_relays.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/scada/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_controls.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_points.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_sources.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ac_line_segments.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_breakers.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_busbar_sections.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_clamps.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_conductors.py +21 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_connectors.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_cuts.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_disconnectors.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_earth_fault_compensators.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_connections.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_consumer_phases.py +37 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_consumers.py +26 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_source_phases.py +33 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_sources.py +44 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_fuses.py +20 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ground_disconnectors.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_grounding_impedances.py +24 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_grounds.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_jumpers.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_junctions.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_linear_shunt_compensators.py +23 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_lines.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_load_break_switches.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_impedances.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_line_parameters.py +14 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_phase_impedances.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_sequence_impedances.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_petersen_coils.py +27 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_phase_impedance_data.py +52 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_electronics_connection_phases.py +30 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_electronics_connections.py +50 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_transformer_ends.py +43 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_transformers.py +24 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_protected_switches.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ratio_tap_changers.py +28 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_reactive_capability_curves.py +18 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_reclosers.py +15 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_regulating_cond_eq.py +19 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_regulating_controls.py +29 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_rotating_machines.py +36 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_series_compensators.py +25 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_shunt_compensators.py +22 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_static_var_compensator.py +24 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_switches.py +21 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_synchronous_machines.py +95 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_tap_changer_controls.py +28 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_tap_changers.py +25 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_transformer_ends.py +30 -0
- zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_transformer_star_impedances.py +32 -0
- zepben/ewb/database/sqlite/tables/iec61970/infiec61970/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/infiec61970/feeder/__init__.py +4 -0
- zepben/ewb/database/sqlite/tables/iec61970/infiec61970/feeder/table_circuits.py +27 -0
- zepben/ewb/database/sqlite/tables/sqlite_table.py +45 -0
- zepben/ewb/database/sqlite/tables/table_metadata_data_sources.py +21 -0
- zepben/ewb/database/sqlite/tables/table_version.py +39 -0
- zepben/ewb/dataclassy/__init__.py +15 -0
- zepben/ewb/dataclassy/dataclass.py +192 -0
- zepben/ewb/dataclassy/decorator.py +35 -0
- zepben/ewb/dataclassy/functions.py +80 -0
- zepben/ewb/examples/__init__.py +6 -0
- zepben/ewb/examples/simple_test_network.py +158 -0
- zepben/ewb/exceptions.py +52 -0
- zepben/ewb/model/__init__.py +4 -0
- zepben/ewb/model/busbranch/__init__.py +4 -0
- zepben/ewb/model/busbranch/bus_branch.py +1051 -0
- zepben/ewb/model/cim/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61968/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61968/assetinfo/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61968/assetinfo/relay_info.py +128 -0
- zepben/ewb/model/cim/extensions/iec61968/metering/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61968/metering/pan_demand_reponse_function.py +112 -0
- zepben/ewb/model/cim/extensions/iec61970/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/core/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/core/site.py +37 -0
- zepben/ewb/model/cim/extensions/iec61970/base/feeder/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/feeder/loop.py +207 -0
- zepben/ewb/model/cim/extensions/iec61970/base/feeder/lv_feeder.py +258 -0
- zepben/ewb/model/cim/extensions/iec61970/base/generation/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/generation/production/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/generation/production/ev_charging_unit.py +18 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/distance_relay.py +69 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py +36 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_kind.py +112 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_function.py +448 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_scheme.py +97 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_system.py +97 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/relay_setting.py +35 -0
- zepben/ewb/model/cim/extensions/iec61970/base/protection/voltage_relay.py +20 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/__init__.py +4 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control.py +36 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py +83 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py +57 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_end_rated_s.py +26 -0
- zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py +293 -0
- zepben/ewb/model/cim/extensions/zbex.py +17 -0
- zepben/ewb/model/cim/iec61968/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/assetinfo/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/assetinfo/cable_info.py +15 -0
- zepben/ewb/model/cim/iec61968/assetinfo/no_load_test.py +42 -0
- zepben/ewb/model/cim/iec61968/assetinfo/open_circuit_test.py +42 -0
- zepben/ewb/model/cim/iec61968/assetinfo/overhead_wire_info.py +15 -0
- zepben/ewb/model/cim/iec61968/assetinfo/power_transformer_info.py +103 -0
- zepben/ewb/model/cim/iec61968/assetinfo/short_circuit_test.py +67 -0
- zepben/ewb/model/cim/iec61968/assetinfo/shunt_compensator_info.py +26 -0
- zepben/ewb/model/cim/iec61968/assetinfo/switch_info.py +17 -0
- zepben/ewb/model/cim/iec61968/assetinfo/transformer_end_info.py +137 -0
- zepben/ewb/model/cim/iec61968/assetinfo/transformer_tank_info.py +108 -0
- zepben/ewb/model/cim/iec61968/assetinfo/transformer_test.py +26 -0
- zepben/ewb/model/cim/iec61968/assetinfo/wire_info.py +24 -0
- zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py +57 -0
- zepben/ewb/model/cim/iec61968/assets/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/assets/asset.py +154 -0
- zepben/ewb/model/cim/iec61968/assets/asset_container.py +16 -0
- zepben/ewb/model/cim/iec61968/assets/asset_function.py +15 -0
- zepben/ewb/model/cim/iec61968/assets/asset_info.py +19 -0
- zepben/ewb/model/cim/iec61968/assets/asset_organisation_role.py +13 -0
- zepben/ewb/model/cim/iec61968/assets/asset_owner.py +13 -0
- zepben/ewb/model/cim/iec61968/assets/streetlight.py +29 -0
- zepben/ewb/model/cim/iec61968/assets/structure.py +16 -0
- zepben/ewb/model/cim/iec61968/common/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/common/agreement.py +16 -0
- zepben/ewb/model/cim/iec61968/common/document.py +36 -0
- zepben/ewb/model/cim/iec61968/common/location.py +129 -0
- zepben/ewb/model/cim/iec61968/common/organisation.py +15 -0
- zepben/ewb/model/cim/iec61968/common/organisation_role.py +22 -0
- zepben/ewb/model/cim/iec61968/common/position_point.py +44 -0
- zepben/ewb/model/cim/iec61968/common/street_address.py +28 -0
- zepben/ewb/model/cim/iec61968/common/street_detail.py +46 -0
- zepben/ewb/model/cim/iec61968/common/town_detail.py +25 -0
- zepben/ewb/model/cim/iec61968/customers/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/customers/customer.py +93 -0
- zepben/ewb/model/cim/iec61968/customers/customer_agreement.py +107 -0
- zepben/ewb/model/cim/iec61968/customers/customer_kind.py +69 -0
- zepben/ewb/model/cim/iec61968/customers/pricing_structure.py +88 -0
- zepben/ewb/model/cim/iec61968/customers/tariff.py +18 -0
- zepben/ewb/model/cim/iec61968/infiec61968/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/current_transformer_info.py +51 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/potential_transformer_info.py +33 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py +69 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py +45 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassets/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassets/pole.py +87 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py +27 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infcommon/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/infiec61968/infcommon/ratio.py +34 -0
- zepben/ewb/model/cim/iec61968/metering/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py +152 -0
- zepben/ewb/model/cim/iec61968/metering/end_device.py +165 -0
- zepben/ewb/model/cim/iec61968/metering/end_device_function.py +17 -0
- zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py +48 -0
- zepben/ewb/model/cim/iec61968/metering/meter.py +28 -0
- zepben/ewb/model/cim/iec61968/metering/usage_point.py +186 -0
- zepben/ewb/model/cim/iec61968/operations/__init__.py +4 -0
- zepben/ewb/model/cim/iec61968/operations/operational_restriction.py +92 -0
- zepben/ewb/model/cim/iec61970/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/auxiliary_equipment.py +24 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/current_transformer.py +37 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/fault_indicator.py +18 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer.py +38 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py +30 -0
- zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/sensor.py +92 -0
- zepben/ewb/model/cim/iec61970/base/core/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/core/ac_dc_terminal.py +16 -0
- zepben/ewb/model/cim/iec61970/base/core/base_voltage.py +17 -0
- zepben/ewb/model/cim/iec61970/base/core/conducting_equipment.py +198 -0
- zepben/ewb/model/cim/iec61970/base/core/connectivity_node.py +105 -0
- zepben/ewb/model/cim/iec61970/base/core/connectivity_node_container.py +15 -0
- zepben/ewb/model/cim/iec61970/base/core/curve.py +125 -0
- zepben/ewb/model/cim/iec61970/base/core/curve_data.py +29 -0
- zepben/ewb/model/cim/iec61970/base/core/equipment.py +366 -0
- zepben/ewb/model/cim/iec61970/base/core/equipment_container.py +199 -0
- zepben/ewb/model/cim/iec61970/base/core/feeder.py +260 -0
- zepben/ewb/model/cim/iec61970/base/core/geographical_region.py +82 -0
- zepben/ewb/model/cim/iec61970/base/core/identified_object.py +239 -0
- zepben/ewb/model/cim/iec61970/base/core/name.py +36 -0
- zepben/ewb/model/cim/iec61970/base/core/name_type.py +203 -0
- zepben/ewb/model/cim/iec61970/base/core/phase_code.py +202 -0
- zepben/ewb/model/cim/iec61970/base/core/power_system_resource.py +106 -0
- zepben/ewb/model/cim/iec61970/base/core/sub_geographical_region.py +93 -0
- zepben/ewb/model/cim/iec61970/base/core/substation.py +277 -0
- zepben/ewb/model/cim/iec61970/base/core/terminal.py +171 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram.py +109 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_object.py +160 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_object_point.py +25 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py +28 -0
- zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py +29 -0
- zepben/ewb/model/cim/iec61970/base/domain/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py +494 -0
- zepben/ewb/model/cim/iec61970/base/equivalents/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/equivalents/equivalent_branch.py +113 -0
- zepben/ewb/model/cim/iec61970/base/equivalents/equivalent_equipment.py +15 -0
- zepben/ewb/model/cim/iec61970/base/generation/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py +39 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/battery_unit.py +108 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/photo_voltaic_unit.py +13 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/power_electronics_unit.py +28 -0
- zepben/ewb/model/cim/iec61970/base/generation/production/power_electronics_wind_unit.py +13 -0
- zepben/ewb/model/cim/iec61970/base/meas/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/meas/accumulator.py +13 -0
- zepben/ewb/model/cim/iec61970/base/meas/accumulator_value.py +20 -0
- zepben/ewb/model/cim/iec61970/base/meas/analog.py +18 -0
- zepben/ewb/model/cim/iec61970/base/meas/analog_value.py +20 -0
- zepben/ewb/model/cim/iec61970/base/meas/control.py +26 -0
- zepben/ewb/model/cim/iec61970/base/meas/discrete.py +13 -0
- zepben/ewb/model/cim/iec61970/base/meas/discrete_value.py +20 -0
- zepben/ewb/model/cim/iec61970/base/meas/iopoint.py +16 -0
- zepben/ewb/model/cim/iec61970/base/meas/measurement.py +60 -0
- zepben/ewb/model/cim/iec61970/base/meas/measurement_value.py +21 -0
- zepben/ewb/model/cim/iec61970/base/protection/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/protection/current_relay.py +23 -0
- zepben/ewb/model/cim/iec61970/base/scada/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/scada/remote_control.py +22 -0
- zepben/ewb/model/cim/iec61970/base/scada/remote_point.py +16 -0
- zepben/ewb/model/cim/iec61970/base/scada/remote_source.py +22 -0
- zepben/ewb/model/cim/iec61970/base/wires/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/base/wires/ac_line_segment.py +214 -0
- zepben/ewb/model/cim/iec61970/base/wires/breaker.py +32 -0
- zepben/ewb/model/cim/iec61970/base/wires/busbar_section.py +19 -0
- zepben/ewb/model/cim/iec61970/base/wires/clamp.py +32 -0
- zepben/ewb/model/cim/iec61970/base/wires/conductor.py +49 -0
- zepben/ewb/model/cim/iec61970/base/wires/connector.py +16 -0
- zepben/ewb/model/cim/iec61970/base/wires/cut.py +36 -0
- zepben/ewb/model/cim/iec61970/base/wires/disconnector.py +17 -0
- zepben/ewb/model/cim/iec61970/base/wires/earth_fault_compensator.py +21 -0
- zepben/ewb/model/cim/iec61970/base/wires/energy_connection.py +15 -0
- zepben/ewb/model/cim/iec61970/base/wires/energy_consumer.py +107 -0
- zepben/ewb/model/cim/iec61970/base/wires/energy_consumer_phase.py +56 -0
- zepben/ewb/model/cim/iec61970/base/wires/energy_source.py +172 -0
- zepben/ewb/model/cim/iec61970/base/wires/energy_source_phase.py +45 -0
- zepben/ewb/model/cim/iec61970/base/wires/fuse.py +23 -0
- zepben/ewb/model/cim/iec61970/base/wires/ground.py +15 -0
- zepben/ewb/model/cim/iec61970/base/wires/ground_disconnector.py +15 -0
- zepben/ewb/model/cim/iec61970/base/wires/grounding_impedance.py +19 -0
- zepben/ewb/model/cim/iec61970/base/wires/jumper.py +16 -0
- zepben/ewb/model/cim/iec61970/base/wires/junction.py +15 -0
- zepben/ewb/model/cim/iec61970/base/wires/line.py +13 -0
- zepben/ewb/model/cim/iec61970/base/wires/linear_shunt_compensator.py +26 -0
- zepben/ewb/model/cim/iec61970/base/wires/load_break_switch.py +14 -0
- zepben/ewb/model/cim/iec61970/base/wires/per_length_impedance.py +13 -0
- zepben/ewb/model/cim/iec61970/base/wires/per_length_line_parameter.py +13 -0
- zepben/ewb/model/cim/iec61970/base/wires/per_length_phase_impedance.py +99 -0
- zepben/ewb/model/cim/iec61970/base/wires/per_length_sequence_impedance.py +43 -0
- zepben/ewb/model/cim/iec61970/base/wires/petersen_coil.py +22 -0
- zepben/ewb/model/cim/iec61970/base/wires/phase_impedance_data.py +37 -0
- zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py +40 -0
- zepben/ewb/model/cim/iec61970/base/wires/power_electronics_connection.py +524 -0
- zepben/ewb/model/cim/iec61970/base/wires/power_electronics_connection_phase.py +34 -0
- zepben/ewb/model/cim/iec61970/base/wires/power_transformer.py +217 -0
- zepben/ewb/model/cim/iec61970/base/wires/power_transformer_end.py +208 -0
- zepben/ewb/model/cim/iec61970/base/wires/protected_switch.py +96 -0
- zepben/ewb/model/cim/iec61970/base/wires/ratio_tap_changer.py +30 -0
- zepben/ewb/model/cim/iec61970/base/wires/reactive_capability_curve.py +16 -0
- zepben/ewb/model/cim/iec61970/base/wires/recloser.py +15 -0
- zepben/ewb/model/cim/iec61970/base/wires/regulating_cond_eq.py +45 -0
- zepben/ewb/model/cim/iec61970/base/wires/regulating_control.py +173 -0
- zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py +48 -0
- zepben/ewb/model/cim/iec61970/base/wires/rotating_machine.py +36 -0
- zepben/ewb/model/cim/iec61970/base/wires/series_compensator.py +42 -0
- zepben/ewb/model/cim/iec61970/base/wires/shunt_compensator.py +59 -0
- zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py +107 -0
- zepben/ewb/model/cim/iec61970/base/wires/static_var_compensator.py +40 -0
- zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py +30 -0
- zepben/ewb/model/cim/iec61970/base/wires/switch.py +119 -0
- zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine.py +168 -0
- zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py +46 -0
- zepben/ewb/model/cim/iec61970/base/wires/tap_changer.py +150 -0
- zepben/ewb/model/cim/iec61970/base/wires/tap_changer_control.py +49 -0
- zepben/ewb/model/cim/iec61970/base/wires/transformer_end.py +73 -0
- zepben/ewb/model/cim/iec61970/base/wires/transformer_star_impedance.py +48 -0
- zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py +45 -0
- zepben/ewb/model/cim/iec61970/infiec61970/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/infiec61970/feeder/__init__.py +4 -0
- zepben/ewb/model/cim/iec61970/infiec61970/feeder/circuit.py +144 -0
- zepben/ewb/model/phases.py +168 -0
- zepben/ewb/model/resistance_reactance.py +40 -0
- zepben/ewb/services/__init__.py +4 -0
- zepben/ewb/services/common/__init__.py +16 -0
- zepben/ewb/services/common/base_service.py +383 -0
- zepben/ewb/services/common/base_service_comparator.py +394 -0
- zepben/ewb/services/common/difference.py +47 -0
- zepben/ewb/services/common/enum_mapper.py +55 -0
- zepben/ewb/services/common/meta/__init__.py +4 -0
- zepben/ewb/services/common/meta/data_source.py +16 -0
- zepben/ewb/services/common/meta/metadata_collection.py +28 -0
- zepben/ewb/services/common/meta/metadata_translations.py +47 -0
- zepben/ewb/services/common/meta/service_info.py +22 -0
- zepben/ewb/services/common/reference_resolvers.py +374 -0
- zepben/ewb/services/common/resolver.py +597 -0
- zepben/ewb/services/common/translator/__init__.py +4 -0
- zepben/ewb/services/common/translator/base_cim2proto.py +115 -0
- zepben/ewb/services/common/translator/base_proto2cim.py +146 -0
- zepben/ewb/services/common/translator/service_differences.py +81 -0
- zepben/ewb/services/common/translator/util.py +75 -0
- zepben/ewb/services/customer/__init__.py +4 -0
- zepben/ewb/services/customer/customer_service_comparator.py +52 -0
- zepben/ewb/services/customer/customers.py +23 -0
- zepben/ewb/services/customer/translator/__init__.py +21 -0
- zepben/ewb/services/customer/translator/customer_cim2proto.py +71 -0
- zepben/ewb/services/customer/translator/customer_enum_mappers.py +18 -0
- zepben/ewb/services/customer/translator/customer_proto2cim.py +87 -0
- zepben/ewb/services/diagram/__init__.py +4 -0
- zepben/ewb/services/diagram/diagram_service_comparator.py +39 -0
- zepben/ewb/services/diagram/diagrams.py +107 -0
- zepben/ewb/services/diagram/translator/__init__.py +11 -0
- zepben/ewb/services/diagram/translator/diagram_cim2proto.py +51 -0
- zepben/ewb/services/diagram/translator/diagram_enum_mappers.py +21 -0
- zepben/ewb/services/diagram/translator/diagram_proto2cim.py +61 -0
- zepben/ewb/services/measurement/__init__.py +4 -0
- zepben/ewb/services/measurement/measurements.py +35 -0
- zepben/ewb/services/measurement/translator/__init__.py +6 -0
- zepben/ewb/services/measurement/translator/measurement_cim2proto.py +42 -0
- zepben/ewb/services/measurement/translator/measurement_proto2cim.py +52 -0
- zepben/ewb/services/network/__init__.py +4 -0
- zepben/ewb/services/network/network_extensions.py +119 -0
- zepben/ewb/services/network/network_service.py +302 -0
- zepben/ewb/services/network/network_service_comparator.py +1322 -0
- zepben/ewb/services/network/network_state.py +36 -0
- zepben/ewb/services/network/tracing/__init__.py +4 -0
- zepben/ewb/services/network/tracing/busbranch_trace.py +36 -0
- zepben/ewb/services/network/tracing/connectivity/__init__.py +4 -0
- zepben/ewb/services/network/tracing/connectivity/connectivity_result.py +105 -0
- zepben/ewb/services/network/tracing/connectivity/nominal_phase_path.py +23 -0
- zepben/ewb/services/network/tracing/connectivity/phase_paths.py +70 -0
- zepben/ewb/services/network/tracing/connectivity/terminal_connectivity_connected.py +226 -0
- zepben/ewb/services/network/tracing/connectivity/terminal_connectivity_internal.py +64 -0
- zepben/ewb/services/network/tracing/connectivity/transformer_phase_paths.py +202 -0
- zepben/ewb/services/network/tracing/connectivity/xy_candidate_phase_paths.py +235 -0
- zepben/ewb/services/network/tracing/connectivity/xy_phase_step.py +24 -0
- zepben/ewb/services/network/tracing/feeder/__init__.py +4 -0
- zepben/ewb/services/network/tracing/feeder/assign_to_feeders.py +202 -0
- zepben/ewb/services/network/tracing/feeder/assign_to_lv_feeders.py +202 -0
- zepben/ewb/services/network/tracing/feeder/clear_direction.py +80 -0
- zepben/ewb/services/network/tracing/feeder/direction_status.py +133 -0
- zepben/ewb/services/network/tracing/feeder/feeder_direction.py +107 -0
- zepben/ewb/services/network/tracing/feeder/set_direction.py +143 -0
- zepben/ewb/services/network/tracing/find_swer_equipment.py +175 -0
- zepben/ewb/services/network/tracing/networktrace/__init__.py +4 -0
- zepben/ewb/services/network/tracing/networktrace/actions/__init__.py +4 -0
- zepben/ewb/services/network/tracing/networktrace/actions/equipment_tree_builder.py +104 -0
- zepben/ewb/services/network/tracing/networktrace/actions/tree_node.py +35 -0
- zepben/ewb/services/network/tracing/networktrace/compute_data.py +60 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/__init__.py +4 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/conditions.py +73 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/direction_condition.py +63 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/equipment_step_limit_condition.py +26 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/equipment_type_step_limit_condition.py +44 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/network_trace_queue_condition.py +67 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/network_trace_stop_condition.py +65 -0
- zepben/ewb/services/network/tracing/networktrace/conditions/open_condition.py +39 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace.py +433 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace_action_type.py +42 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace_queue_next.py +84 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace_step.py +128 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace_step_path_provider.py +351 -0
- zepben/ewb/services/network/tracing/networktrace/network_trace_tracker.py +39 -0
- zepben/ewb/services/network/tracing/networktrace/operators/__init__.py +14 -0
- zepben/ewb/services/network/tracing/networktrace/operators/equipment_container_state_operators.py +264 -0
- zepben/ewb/services/network/tracing/networktrace/operators/feeder_direction_state_operations.py +181 -0
- zepben/ewb/services/network/tracing/networktrace/operators/in_service_state_operators.py +76 -0
- zepben/ewb/services/network/tracing/networktrace/operators/network_state_operators.py +120 -0
- zepben/ewb/services/network/tracing/networktrace/operators/open_state_operators.py +104 -0
- zepben/ewb/services/network/tracing/networktrace/operators/phase_state_operators.py +56 -0
- zepben/ewb/services/network/tracing/networktrace/tracing.py +132 -0
- zepben/ewb/services/network/tracing/phases/__init__.py +4 -0
- zepben/ewb/services/network/tracing/phases/phase_inferrer.py +205 -0
- zepben/ewb/services/network/tracing/phases/phase_status.py +101 -0
- zepben/ewb/services/network/tracing/phases/remove_phases.py +143 -0
- zepben/ewb/services/network/tracing/phases/set_phases.py +490 -0
- zepben/ewb/services/network/tracing/traversal/__init__.py +4 -0
- zepben/ewb/services/network/tracing/traversal/context_value_computer.py +63 -0
- zepben/ewb/services/network/tracing/traversal/debug_logging.py +124 -0
- zepben/ewb/services/network/tracing/traversal/queue.py +112 -0
- zepben/ewb/services/network/tracing/traversal/queue_condition.py +75 -0
- zepben/ewb/services/network/tracing/traversal/step_action.py +83 -0
- zepben/ewb/services/network/tracing/traversal/step_context.py +59 -0
- zepben/ewb/services/network/tracing/traversal/stop_condition.py +57 -0
- zepben/ewb/services/network/tracing/traversal/traversal.py +634 -0
- zepben/ewb/services/network/tracing/traversal/traversal_condition.py +22 -0
- zepben/ewb/services/network/tracing/traversal/weighted_priority_queue.py +85 -0
- zepben/ewb/services/network/tracing/util.py +93 -0
- zepben/ewb/services/network/translator/__init__.py +392 -0
- zepben/ewb/services/network/translator/network_cim2proto.py +1867 -0
- zepben/ewb/services/network/translator/network_enum_mappers.py +78 -0
- zepben/ewb/services/network/translator/network_proto2cim.py +2201 -0
- zepben/ewb/services/services.py +48 -0
- zepben/ewb/streaming/__init__.py +4 -0
- zepben/ewb/streaming/data/__init__.py +4 -0
- zepben/ewb/streaming/data/current_state_event.py +314 -0
- zepben/ewb/streaming/data/current_state_event_batch.py +25 -0
- zepben/ewb/streaming/data/set_current_states_status.py +286 -0
- zepben/ewb/streaming/exceptions.py +14 -0
- zepben/ewb/streaming/get/__init__.py +4 -0
- zepben/ewb/streaming/get/consumer.py +209 -0
- zepben/ewb/streaming/get/customer_consumer.py +111 -0
- zepben/ewb/streaming/get/diagram_consumer.py +107 -0
- zepben/ewb/streaming/get/hierarchy/__init__.py +4 -0
- zepben/ewb/streaming/get/hierarchy/data.py +27 -0
- zepben/ewb/streaming/get/included_energized_containers.py +36 -0
- zepben/ewb/streaming/get/included_energizing_containers.py +36 -0
- zepben/ewb/streaming/get/network_consumer.py +870 -0
- zepben/ewb/streaming/get/query_network_state_client.py +64 -0
- zepben/ewb/streaming/get/query_network_state_service.py +94 -0
- zepben/ewb/streaming/grpc/__init__.py +4 -0
- zepben/ewb/streaming/grpc/auth_token_plugin.py +24 -0
- zepben/ewb/streaming/grpc/connect.py +209 -0
- zepben/ewb/streaming/grpc/grpc.py +107 -0
- zepben/ewb/streaming/grpc/grpc_channel_builder.py +190 -0
- zepben/ewb/streaming/mutations/__init__.py +4 -0
- zepben/ewb/streaming/mutations/update_network_state_client.py +80 -0
- zepben/ewb/streaming/mutations/update_network_state_service.py +61 -0
- zepben/ewb/testing/__init__.py +4 -0
- zepben/ewb/testing/test_network_builder.py +816 -0
- zepben/ewb/types.py +17 -0
- zepben/ewb/util.py +200 -0
- zepben_ewb-1.0.0.dist-info/METADATA +90 -0
- zepben_ewb-1.0.0.dist-info/RECORD +641 -0
- zepben_ewb-1.0.0.dist-info/WHEEL +5 -0
- zepben_ewb-1.0.0.dist-info/licenses/LICENSE +374 -0
- zepben_ewb-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Copyright 2025 Zeppelin Bend Pty Ltd
|
|
2
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
|
|
6
|
+
__all__ = ['NetworkTraceStopCondition']
|
|
7
|
+
|
|
8
|
+
from typing import TypeVar, Generic
|
|
9
|
+
|
|
10
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_step import NetworkTraceStep
|
|
11
|
+
from zepben.ewb.services.network.tracing.traversal.step_context import StepContext
|
|
12
|
+
from zepben.ewb.services.network.tracing.traversal.stop_condition import StopCondition, ShouldStop
|
|
13
|
+
|
|
14
|
+
T = TypeVar('T')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NetworkTraceStopCondition(StopCondition[T], Generic[T]):
|
|
18
|
+
"""
|
|
19
|
+
A special stop condition implementation that allows only checking `should_stop` when a [NetworkTraceStep] matches a given
|
|
20
|
+
[NetworkTraceStep.Type]. When [step_type] is:
|
|
21
|
+
*[NetworkTraceStep.Type.ALL]: [should_stop] will be checked for every step.
|
|
22
|
+
*[NetworkTraceStep.Type.INTERNAL]: [should_stop] will be checked only when [NetworkTraceStep.type] is [NetworkTraceStep.Type.INTERNAL].
|
|
23
|
+
*[NetworkTraceStep.Type.EXTERNAL]: [should_stop] will be checked only when [NetworkTraceStep.type] is [NetworkTraceStep.Type.EXTERNAL].
|
|
24
|
+
|
|
25
|
+
If the step does not match the given step type, `false` will always be returned.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, step_type: NetworkTraceStep.Type, condition: ShouldStop):
|
|
29
|
+
"""
|
|
30
|
+
:param step_type: The step type to match to check `should_stop`.
|
|
31
|
+
:param condition: function with the signature of `ShouldStop` to be called when step_type matches the current items step
|
|
32
|
+
"""
|
|
33
|
+
super().__init__(self.should_stop)
|
|
34
|
+
if condition is not None:
|
|
35
|
+
self.should_stop_matched_step = condition
|
|
36
|
+
self.should_stop = self._should_stop_func(step_type)
|
|
37
|
+
|
|
38
|
+
def should_stop(self, item: NetworkTraceStep[T], context: StepContext) -> bool:
|
|
39
|
+
raise NotImplementedError()
|
|
40
|
+
|
|
41
|
+
def should_stop_matched_step(self, item: NetworkTraceStep[T], context: StepContext) -> bool:
|
|
42
|
+
"""
|
|
43
|
+
The logic you would normally put in `should_stop`. However, this will only be called when a step matches the `step_type`
|
|
44
|
+
"""
|
|
45
|
+
raise NotImplementedError()
|
|
46
|
+
|
|
47
|
+
def should_stop_internal_step(self, item: NetworkTraceStep[T], context: StepContext) -> bool:
|
|
48
|
+
if item.type() == NetworkTraceStep.Type.INTERNAL:
|
|
49
|
+
return self.should_stop_matched_step(item, context)
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
def should_stop_external_step(self, item: NetworkTraceStep[T], context: StepContext) -> bool:
|
|
53
|
+
# We also need to check start items as they are always marked as internal, but we still want to be able to stop on them.
|
|
54
|
+
if (item.type() == NetworkTraceStep.Type.EXTERNAL) or context.is_start_item:
|
|
55
|
+
return self.should_stop_matched_step(item, context)
|
|
56
|
+
return False
|
|
57
|
+
|
|
58
|
+
def _should_stop_func(self, step_type: NetworkTraceStep.Type) -> ShouldStop:
|
|
59
|
+
if step_type == NetworkTraceStep.Type.ALL:
|
|
60
|
+
return self.should_stop_matched_step
|
|
61
|
+
elif step_type == NetworkTraceStep.Type.INTERNAL:
|
|
62
|
+
return self.should_stop_internal_step
|
|
63
|
+
elif step_type == NetworkTraceStep.Type.EXTERNAL:
|
|
64
|
+
return self.should_stop_external_step
|
|
65
|
+
raise ValueError(f"INTERNAL ERROR: step type [{step_type}] didn't match expected")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright 2025 Zeppelin Bend Pty Ltd
|
|
2
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
__all__ = ['OpenCondition']
|
|
9
|
+
|
|
10
|
+
from collections.abc import Callable
|
|
11
|
+
from typing import Generic, TYPE_CHECKING
|
|
12
|
+
|
|
13
|
+
from typing_extensions import TypeVar
|
|
14
|
+
|
|
15
|
+
from zepben.ewb.services.network.tracing.networktrace.conditions.network_trace_queue_condition import NetworkTraceQueueCondition
|
|
16
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_step import NetworkTraceStep
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from zepben.ewb.model.cim.iec61970.base.wires.switch import Switch
|
|
20
|
+
from zepben.ewb.model.cim.iec61970.base.wires.single_phase_kind import SinglePhaseKind
|
|
21
|
+
from zepben.ewb.services.network.tracing.traversal.step_context import StepContext
|
|
22
|
+
|
|
23
|
+
T = TypeVar('T')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class OpenCondition(NetworkTraceQueueCondition[T], Generic[T]):
|
|
27
|
+
def __init__(self, is_open: Callable[[Switch, SinglePhaseKind], bool], phase: SinglePhaseKind = None):
|
|
28
|
+
super().__init__(NetworkTraceStep.Type.INTERNAL)
|
|
29
|
+
self._is_open = is_open
|
|
30
|
+
self._phase = phase
|
|
31
|
+
|
|
32
|
+
def should_queue_matched_step(self, next_item: NetworkTraceStep[T], next_context: StepContext, current_item: NetworkTraceStep[T],
|
|
33
|
+
current_context: StepContext) -> bool:
|
|
34
|
+
from zepben.ewb.model.cim.iec61970.base.wires.switch import Switch
|
|
35
|
+
equip = next_item.path.to_equipment
|
|
36
|
+
if isinstance(equip, Switch):
|
|
37
|
+
return not self._is_open(equip, self._phase)
|
|
38
|
+
else:
|
|
39
|
+
return True
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
# Copyright 2025 Zeppelin Bend Pty Ltd
|
|
2
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
|
|
6
|
+
__all__ = ['NetworkTrace']
|
|
7
|
+
|
|
8
|
+
import inspect
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
from functools import singledispatchmethod
|
|
11
|
+
from logging import Logger
|
|
12
|
+
from typing import TypeVar, Union, Generic, Set, Type, Generator, FrozenSet
|
|
13
|
+
|
|
14
|
+
from zepben.ewb.model.cim.iec61970.base.core.conducting_equipment import ConductingEquipment
|
|
15
|
+
from zepben.ewb.model.cim.iec61970.base.core.phase_code import PhaseCode
|
|
16
|
+
from zepben.ewb.model.cim.iec61970.base.core.terminal import Terminal
|
|
17
|
+
from zepben.ewb.model.cim.iec61970.base.wires.ac_line_segment import AcLineSegment
|
|
18
|
+
from zepben.ewb.model.cim.iec61970.base.wires.clamp import Clamp
|
|
19
|
+
from zepben.ewb.model.cim.iec61970.base.wires.single_phase_kind import SinglePhaseKind
|
|
20
|
+
from zepben.ewb.services.network.tracing.connectivity.nominal_phase_path import NominalPhasePath
|
|
21
|
+
from zepben.ewb.services.network.tracing.networktrace.compute_data import ComputeData, ComputeDataWithPaths
|
|
22
|
+
from zepben.ewb.services.network.tracing.networktrace.conditions.network_trace_queue_condition import NetworkTraceQueueCondition
|
|
23
|
+
from zepben.ewb.services.network.tracing.networktrace.conditions.network_trace_stop_condition import NetworkTraceStopCondition
|
|
24
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_action_type import NetworkTraceActionType, CanActionItem
|
|
25
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_queue_next import NetworkTraceQueueNext
|
|
26
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_step import NetworkTraceStep
|
|
27
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_tracker import NetworkTraceTracker
|
|
28
|
+
from zepben.ewb.services.network.tracing.networktrace.operators.network_state_operators import NetworkStateOperators
|
|
29
|
+
from zepben.ewb.services.network.tracing.traversal.queue import TraversalQueue
|
|
30
|
+
from zepben.ewb.services.network.tracing.traversal.queue_condition import QueueCondition
|
|
31
|
+
from zepben.ewb.services.network.tracing.traversal.step_context import StepContext
|
|
32
|
+
from zepben.ewb.services.network.tracing.traversal.stop_condition import ShouldStop
|
|
33
|
+
from zepben.ewb.services.network.tracing.traversal.traversal import Traversal, StopConditionTypes
|
|
34
|
+
|
|
35
|
+
T = TypeVar('T')
|
|
36
|
+
D = TypeVar('D')
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class NetworkTrace(Traversal[NetworkTraceStep[T], 'NetworkTrace[T]'], Generic[T]):
|
|
40
|
+
"""
|
|
41
|
+
A :class:`Traversal` implementation specifically designed to trace connected :class:`Terminal`s of :class:`ConductingEquipment` in a network.
|
|
42
|
+
|
|
43
|
+
This trace manages the complexity of network connectivity, especially in cases where connectivity is not straightforward,
|
|
44
|
+
such as with :class:`BusbarSection`s and :class:`Clamp`s. It checks the in service flag of equipment and only steps to equipment that is marked as in service.
|
|
45
|
+
It also provides the optional ability to trace only specific phases.
|
|
46
|
+
|
|
47
|
+
Steps are represented by a :class:`NetworkTraceStep`, which contains a :class:`NetworkTraceStep.Path` and allows associating arbitrary data with each step.
|
|
48
|
+
The arbitrary data for each step is computed via a :class:`ComputeData` or :class:`ComputeDataWithPaths` function provided at construction.
|
|
49
|
+
The trace invokes these functions when queueing each item and stores the result with the next step.
|
|
50
|
+
|
|
51
|
+
When traversing, this trace will step on every connected terminal, as long as they match all the traversal conditions.
|
|
52
|
+
Each step is classified as either an external step or an internal step:
|
|
53
|
+
|
|
54
|
+
- **External Step**: Moves from one terminal to another with different ``Terminal.conducting_equipment``.
|
|
55
|
+
- **Internal Step**: Moves between terminals within the same ``Terminal.conducting_equipment``.
|
|
56
|
+
|
|
57
|
+
Often, you may want to act upon a :class:`ConductingEquipment` only once, rather than multiple times for each internal and external terminal step.
|
|
58
|
+
To achieve this, set ``action_type`` to ``NetworkTraceActionType.FIRST_STEP_ON_EQUIPMENT``. With this type, the trace will only call step actions and
|
|
59
|
+
conditions once for each :class:`ConductingEquipment`, regardless of how many terminals it has. However, queue conditions can be configured to be called
|
|
60
|
+
differently for each condition as continuing the trace can rely on different conditions based on an external or internal step. For example, not
|
|
61
|
+
queuing past open switches should happen on an internal step, thus if the trace is configured with ``FIRST_STEP_ON_EQUIPMENT``, it will by default only
|
|
62
|
+
action the first external step to each equipment, and thus the provided `Conditions.stopAtOpen` condition overrides the default behaviour such that
|
|
63
|
+
it is called on all internal steps.
|
|
64
|
+
|
|
65
|
+
The network trace is state-aware by requiring an instance of :class:`NetworkStateOperators`.
|
|
66
|
+
This allows traversal conditions and step actions to query and act upon state-based properties and functions of equipment in the network when required.
|
|
67
|
+
|
|
68
|
+
'Branching' traversals are also supported allowing tracing both ways around loops in the network. When using a branching instance, a new 'branch'
|
|
69
|
+
is created for each terminal when a step has two or more terminals it can step to. That is on an internal step, if the equipment has more than 2 terminals
|
|
70
|
+
and more than 2 terminals will be queued, a branch will be created for each terminal. On an external step, if 2 or more terminals are to be queued,
|
|
71
|
+
a branch will be created for each terminal.
|
|
72
|
+
If you do not need to trace loops both ways or have no loops, do not use a branching instance as it is less efficient than the non-branching one.
|
|
73
|
+
|
|
74
|
+
To create instances of this class, use the factory methods provided in the :class:`Tracing` object.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
network_state_operators: Type[NetworkStateOperators],
|
|
80
|
+
queue_type: Union[Traversal.BasicQueueType, Traversal.BranchingQueueType],
|
|
81
|
+
parent: 'NetworkTrace[T]' = None,
|
|
82
|
+
action_type: CanActionItem = None,
|
|
83
|
+
debug_logger: Logger = None,
|
|
84
|
+
name: str = None,
|
|
85
|
+
):
|
|
86
|
+
|
|
87
|
+
if name is None:
|
|
88
|
+
raise ValueError('name can not be None')
|
|
89
|
+
self.name = name
|
|
90
|
+
if action_type is None:
|
|
91
|
+
raise ValueError('action_type can not be None')
|
|
92
|
+
|
|
93
|
+
self._queue_type = queue_type
|
|
94
|
+
self.network_state_operators = network_state_operators
|
|
95
|
+
self._action_type = action_type
|
|
96
|
+
|
|
97
|
+
self._tracker = NetworkTraceTracker()
|
|
98
|
+
|
|
99
|
+
super().__init__(self._queue_type, parent=parent, debug_logger=debug_logger)
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def non_branching(
|
|
103
|
+
cls,
|
|
104
|
+
network_state_operators: Type[NetworkStateOperators],
|
|
105
|
+
queue: TraversalQueue[NetworkTraceStep[T]],
|
|
106
|
+
action_type: CanActionItem,
|
|
107
|
+
name: str,
|
|
108
|
+
compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]],
|
|
109
|
+
debug_logger=None,
|
|
110
|
+
) -> 'NetworkTrace[T]':
|
|
111
|
+
|
|
112
|
+
return cls(
|
|
113
|
+
network_state_operators,
|
|
114
|
+
Traversal.BasicQueueType(NetworkTraceQueueNext.Basic(network_state_operators, compute_data_with_action_type(compute_data, action_type)), queue),
|
|
115
|
+
None,
|
|
116
|
+
action_type,
|
|
117
|
+
debug_logger,
|
|
118
|
+
name,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def branching(
|
|
123
|
+
cls,
|
|
124
|
+
network_state_operators: Type[NetworkStateOperators],
|
|
125
|
+
queue_factory: Callable[[], TraversalQueue[T]],
|
|
126
|
+
branch_queue_factory: Callable[[], TraversalQueue['NetworkTrace[T]']],
|
|
127
|
+
action_type: CanActionItem,
|
|
128
|
+
name: str,
|
|
129
|
+
parent: 'NetworkTrace[T]' = None,
|
|
130
|
+
compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]] = None,
|
|
131
|
+
debug_logger: Logger = None,
|
|
132
|
+
) -> 'NetworkTrace[T]':
|
|
133
|
+
|
|
134
|
+
return cls(
|
|
135
|
+
network_state_operators,
|
|
136
|
+
Traversal.BranchingQueueType(
|
|
137
|
+
NetworkTraceQueueNext.Branching(network_state_operators, compute_data_with_action_type(compute_data, action_type)),
|
|
138
|
+
queue_factory,
|
|
139
|
+
branch_queue_factory,
|
|
140
|
+
),
|
|
141
|
+
parent,
|
|
142
|
+
action_type,
|
|
143
|
+
debug_logger,
|
|
144
|
+
name,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
@singledispatchmethod
|
|
148
|
+
def add_start_item(self, start: Union[Terminal, ConductingEquipment, NetworkTraceStep.Path], data: T = None, phases: PhaseCode = None) -> "NetworkTrace[T]":
|
|
149
|
+
"""
|
|
150
|
+
Depending on the type of `start` adds one of the following as starting points in the trace, along
|
|
151
|
+
with the associated data:
|
|
152
|
+
|
|
153
|
+
- A starting `Terminal`
|
|
154
|
+
- All terminals of the given :class:`ConductingEquipment`.
|
|
155
|
+
- All terminals of the given :class:`AcLineSegment`.
|
|
156
|
+
- The :class:`NetworkTraceStep.Path` passed in.
|
|
157
|
+
|
|
158
|
+
Tracing will be only external from this terminal and not trace internally back through its conducting equipment.
|
|
159
|
+
|
|
160
|
+
:param start: The starting item for the trace.
|
|
161
|
+
:param data: The data associated with the start step.
|
|
162
|
+
:param phases: Phases to trace; `None` to ignore phases.
|
|
163
|
+
|
|
164
|
+
:returns: This `NetworkTrace` instance
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
raise Exception('INTERNAL ERROR:: unexpected add_start_item params')
|
|
168
|
+
|
|
169
|
+
@add_start_item.register
|
|
170
|
+
def _(self, start: ConductingEquipment, data=None, phases=None):
|
|
171
|
+
"""
|
|
172
|
+
Adds all terminals of the given :class:`ConductingEquipment` as starting points in the trace, with the associated data.
|
|
173
|
+
Tracing will be only external from each terminal and not trace internally back through the conducting equipment.
|
|
174
|
+
|
|
175
|
+
:param start: The starting equipment whose terminals will be added to the trace
|
|
176
|
+
:param data: The data associated with the start step.
|
|
177
|
+
:param phases: Phases to trace; `None` to ignore phases.
|
|
178
|
+
|
|
179
|
+
:returns: This :class:`NetworkTrace` instance
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
# We don't have a special case for Clamp here because we say if you start from the whole Clamp rather than its terminal specifically,
|
|
183
|
+
# we want to trace externally from it and traverse its segment.
|
|
184
|
+
for it in start.terminals:
|
|
185
|
+
self._add_start_item(it, data=data, phases=phases)
|
|
186
|
+
return self
|
|
187
|
+
|
|
188
|
+
@add_start_item.register
|
|
189
|
+
def _(self, start: Terminal, data=None, phases=None):
|
|
190
|
+
"""
|
|
191
|
+
Adds a starting :class:`Terminal` to the trace with the associated step data. Tracing will be only external from this
|
|
192
|
+
terminal and not trace internally back through its conducting equipment.
|
|
193
|
+
|
|
194
|
+
:param start: The starting `Terminal` for the trace.
|
|
195
|
+
:param data: The data associated with the start step.
|
|
196
|
+
:param phases: Phases to trace; `None` to ignore phases.
|
|
197
|
+
|
|
198
|
+
:returns: This :class:`NetworkTrace` instance
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
# We have a special case when starting specifically on a clamp terminal that we mark it as having traversed the segment such that it
|
|
202
|
+
# will only trace externally from the clamp terminal. This behaves differently to when the whole Clamp is added as a start item.
|
|
203
|
+
traversed_ac_line_segment = None
|
|
204
|
+
if isinstance(start.conducting_equipment, Clamp):
|
|
205
|
+
traversed_ac_line_segment = start.conducting_equipment.ac_line_segment
|
|
206
|
+
self._add_start_item(start, data=data, phases=phases, traversed_ac_line_segment=traversed_ac_line_segment)
|
|
207
|
+
return self
|
|
208
|
+
|
|
209
|
+
@add_start_item.register
|
|
210
|
+
def _(self, start: AcLineSegment, data=None, phases=None):
|
|
211
|
+
"""
|
|
212
|
+
Adds all terminals of the given :class:`AcLineSegment` as starting points in the trace, with the associated data.
|
|
213
|
+
Tracing will be only external from each terminal and not trace internally back through the `AcLineSegment`.
|
|
214
|
+
|
|
215
|
+
:param start: The starting `AcLineSegment` whose terminals will be added to the trace
|
|
216
|
+
:param data: The data associated with the start step.
|
|
217
|
+
:param phases: Phases to trace; `None` to ignore phases.
|
|
218
|
+
|
|
219
|
+
:returns: This :class:`NetworkTrace` instance
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
# If we start on an AcLineSegment, we queue the segments terminals, and all its Cut and Clamp terminals as if we have traversed the segment,
|
|
223
|
+
# so the next steps will be external from all the terminals "belonging" to the segment.
|
|
224
|
+
def start_terminals() -> Generator[Terminal, None, None]:
|
|
225
|
+
for _terminal in start.terminals:
|
|
226
|
+
yield _terminal
|
|
227
|
+
for clamp in start.clamps:
|
|
228
|
+
for _terminal in clamp.terminals:
|
|
229
|
+
yield _terminal
|
|
230
|
+
break
|
|
231
|
+
for cut in start.cuts:
|
|
232
|
+
for _terminal in cut.terminals:
|
|
233
|
+
yield _terminal
|
|
234
|
+
|
|
235
|
+
for terminal in start_terminals():
|
|
236
|
+
self._add_start_item(terminal, data=data, phases=phases, traversed_ac_line_segment=start)
|
|
237
|
+
return self
|
|
238
|
+
|
|
239
|
+
@add_start_item.register
|
|
240
|
+
def _(self, start: NetworkTraceStep.Path, data: T, phases=None):
|
|
241
|
+
if phases:
|
|
242
|
+
raise ValueError('starting from a NetworkTraceStep.Path does not support specifying phases')
|
|
243
|
+
self._add_start_item(start, data=data)
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
def _add_start_item(
|
|
247
|
+
self, start: Union[Terminal, NetworkTraceStep.Path], data: T = None, phases: PhaseCode = None, traversed_ac_line_segment: AcLineSegment = None
|
|
248
|
+
):
|
|
249
|
+
"""
|
|
250
|
+
To be called by self.add_start_item(), this method builds the start :class:`NetworkTraceStep.Path`s for the start item
|
|
251
|
+
and adds it to the :class:`Traversal`
|
|
252
|
+
|
|
253
|
+
If `start` is a `NetworkTraceStep.Path`, [`phases`, `traversed_ac_line_segment`] will all be ignored.
|
|
254
|
+
|
|
255
|
+
:param start: The starting :class:`Terminal` or `NetworkTraceStep.Path` to be added to the trace
|
|
256
|
+
:param data: The data associated with the start `Terminal`.
|
|
257
|
+
:param phases: Phases to trace; `None` to ignore phases.
|
|
258
|
+
:param traversed_ac_line_segment: The :class:`AcLineSegment` that was just traversed
|
|
259
|
+
|
|
260
|
+
:returns: This `NetworkTrace` instance
|
|
261
|
+
"""
|
|
262
|
+
|
|
263
|
+
if isinstance(start, NetworkTraceStep.Path):
|
|
264
|
+
if any([phases, traversed_ac_line_segment]):
|
|
265
|
+
raise ValueError('phases and traversed_ac_line_segment are all ignored when start is a NetworkTraceStep.Path')
|
|
266
|
+
start_path = start
|
|
267
|
+
else:
|
|
268
|
+
start_path = NetworkTraceStep.Path(start, start, traversed_ac_line_segment, self.start_nominal_phase_path(phases))
|
|
269
|
+
|
|
270
|
+
super().add_start_item(NetworkTraceStep(start_path, 0, 0, data))
|
|
271
|
+
|
|
272
|
+
async def run(
|
|
273
|
+
self,
|
|
274
|
+
start: Union[ConductingEquipment, Terminal, NetworkTraceStep.Path] = None,
|
|
275
|
+
data: T = None,
|
|
276
|
+
phases: PhaseCode = None,
|
|
277
|
+
can_stop_on_start_item: bool = True,
|
|
278
|
+
) -> "NetworkTrace[T]":
|
|
279
|
+
"""
|
|
280
|
+
Runs the network trace starting from ``start``
|
|
281
|
+
|
|
282
|
+
Depending on the type of ``start``, this will either start from::
|
|
283
|
+
|
|
284
|
+
- A starting Terminal to the trace with the associated step data.
|
|
285
|
+
- All terminals of the given ConductingEquipment as starting points in the trace, with the associated data.
|
|
286
|
+
|
|
287
|
+
:param start: The starting :class:`Terminal` or :class:`ConductingEquipment` for the trace.
|
|
288
|
+
:param data: The data associated with the start step.
|
|
289
|
+
:param phases: Phases to trace; ``None`` to ignore phases.
|
|
290
|
+
:param can_stop_on_start_item: indicates whether the trace should check stop conditions on start items.
|
|
291
|
+
"""
|
|
292
|
+
|
|
293
|
+
if start is not None:
|
|
294
|
+
self.add_start_item(start, data, phases)
|
|
295
|
+
|
|
296
|
+
await super().run(can_stop_on_start_item=can_stop_on_start_item)
|
|
297
|
+
return self
|
|
298
|
+
|
|
299
|
+
@singledispatchmethod
|
|
300
|
+
def add_condition(self, condition: QueueCondition[T], **kwargs) -> "NetworkTrace[T]":
|
|
301
|
+
"""
|
|
302
|
+
Adds a traversal condition to the trace.
|
|
303
|
+
|
|
304
|
+
Valid types for ``condition`` are::
|
|
305
|
+
|
|
306
|
+
- A predefined traversal condition (eg: Conditions.stop_at_open())
|
|
307
|
+
- A function implementing ShouldQueue or ShouldStop signature.
|
|
308
|
+
- A class subclassing StopCondition or QueueCondition
|
|
309
|
+
|
|
310
|
+
:param condition: The condition to be added
|
|
311
|
+
:keyword allow_re_wrapping: Allow rewrapping of :class:`StopCondition`s with debug logging
|
|
312
|
+
:returns: This :class:`NetworkTrace` instance
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
return super().add_condition(condition, **kwargs)
|
|
316
|
+
|
|
317
|
+
@add_condition.register
|
|
318
|
+
def _(self, condition: Callable, **kwargs):
|
|
319
|
+
"""
|
|
320
|
+
Adds a traversal condition to the trace using the trace's :class:`NetworkStateOperators` as the receiver.
|
|
321
|
+
|
|
322
|
+
This overload primarily exists to enable a DSL-like syntax for adding predefined traversal conditions to the trace.
|
|
323
|
+
For example, to configure the trace to stop at open points using the :meth:`Conditions.stop_at_open` factory, you can use:
|
|
324
|
+
|
|
325
|
+
.. code-block::
|
|
326
|
+
|
|
327
|
+
from zepben.ewb import stop_at_open
|
|
328
|
+
NetworkTrace().add_condition(stop_at_open())
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
if len(inspect.getfullargspec(condition).args) == 1: # Catches DSL Style lambda conditions from zepben.ewb.Conditions
|
|
332
|
+
return self.add_condition(condition(self.network_state_operators), **kwargs)
|
|
333
|
+
return super().add_condition(condition, **kwargs)
|
|
334
|
+
|
|
335
|
+
@singledispatchmethod
|
|
336
|
+
def add_queue_condition(
|
|
337
|
+
self, condition: NetworkTraceQueueCondition[NetworkTraceStep[T]], step_type: NetworkTraceStep.Type = None, **kwargs
|
|
338
|
+
) -> "NetworkTrace[T]":
|
|
339
|
+
"""
|
|
340
|
+
Adds a :class:`QueueCondition` to the traversal. However, before registering it with the traversal, it will make sure that the queue condition
|
|
341
|
+
is only checked on step types relevant to the `NetworkTraceActionType` assigned to this instance. That is when:
|
|
342
|
+
|
|
343
|
+
- ``step_type`` is ``NetworkTraceActionType.ALL_STEPS`` the condition will be checked on all steps.
|
|
344
|
+
- ``step_type`` is ``NetworkTraceActionType.FIRST_STEP_ON_EQUIPMENT`` the condition will be checked on external steps.
|
|
345
|
+
|
|
346
|
+
However, if the `condition` is an instance of :class:`NetworkTraceQueueCondition` the ``NetworkTraceQueueCondition.step_type`` will be honoured.
|
|
347
|
+
|
|
348
|
+
:param condition: The queue condition to add.
|
|
349
|
+
:param step_type: `NetworkTraceStepType` value.
|
|
350
|
+
:keyword allow_re_wrapping: Allow rewrapping of :class:`QueueCondition`s with debug logging
|
|
351
|
+
:returns: This :class:`NetworkTrace` instance
|
|
352
|
+
"""
|
|
353
|
+
|
|
354
|
+
return super().add_queue_condition(condition, **kwargs)
|
|
355
|
+
|
|
356
|
+
@add_queue_condition.register
|
|
357
|
+
def _(self, condition: Callable, step_type: NetworkTraceStep.Type = None, **kwargs):
|
|
358
|
+
return self.add_queue_condition(NetworkTraceQueueCondition(default_condition_step_type(self._action_type) or step_type, condition), **kwargs)
|
|
359
|
+
|
|
360
|
+
@singledispatchmethod
|
|
361
|
+
def add_stop_condition(self, condition: StopConditionTypes, step_type: NetworkTraceStep.Type = None, **kwargs) -> "NetworkTrace[T]":
|
|
362
|
+
"""
|
|
363
|
+
Adds a :class:`StopCondition` to the traversal. However, before registering it with the traversal, it will make sure that the queue condition
|
|
364
|
+
is only checked on step types relevant to the `NetworkTraceActionType` assigned to this instance. That is when:
|
|
365
|
+
|
|
366
|
+
- ``step_type`` is ``NetworkTraceActionType.ALL_STEPS`` the condition will be checked on all steps.
|
|
367
|
+
- ``step_type`` is ``NetworkTraceActionType.FIRST_STEP_ON_EQUIPMENT`` the condition will be checked on external steps.
|
|
368
|
+
|
|
369
|
+
However, if the `condition` is an instance of :class:`NetworkTraceStopCondition` the ``NetworkTraceStopCondition.step_type`` will be honoured.
|
|
370
|
+
|
|
371
|
+
:param condition: The stop condition to add.
|
|
372
|
+
:param step_type: `NetworkTraceStepType` value.
|
|
373
|
+
:keyword allow_re_wrapping: Allow rewrapping of :class:`StopCondition`s with debug logging
|
|
374
|
+
:returns: This :class:`NetworkTrace` instance
|
|
375
|
+
"""
|
|
376
|
+
|
|
377
|
+
return super().add_stop_condition(condition, **kwargs)
|
|
378
|
+
|
|
379
|
+
@add_stop_condition.register(Callable)
|
|
380
|
+
def _(self, condition: ShouldStop, step_type=None, **kwargs):
|
|
381
|
+
return self.add_stop_condition(NetworkTraceStopCondition(default_condition_step_type(self._action_type) or step_type, condition), **kwargs)
|
|
382
|
+
|
|
383
|
+
def can_action_item(self, item: T, context: StepContext) -> bool:
|
|
384
|
+
return self._action_type(item, context, self.has_visited)
|
|
385
|
+
|
|
386
|
+
def on_reset(self):
|
|
387
|
+
self._tracker.clear()
|
|
388
|
+
|
|
389
|
+
def can_visit_item(self, item: T, context: StepContext) -> bool:
|
|
390
|
+
return self.visit(item.path.to_terminal, item.path.to_phases_set())
|
|
391
|
+
|
|
392
|
+
def get_derived_this(self) -> 'NetworkTrace[T]':
|
|
393
|
+
return self
|
|
394
|
+
|
|
395
|
+
def create_new_this(self) -> 'NetworkTrace[T]':
|
|
396
|
+
return NetworkTrace(self.network_state_operators, self._queue_type, self, self._action_type, debug_logger=None, name=self.name)
|
|
397
|
+
|
|
398
|
+
@staticmethod
|
|
399
|
+
def start_nominal_phase_path(phases: PhaseCode) -> Set[NominalPhasePath]:
|
|
400
|
+
return {NominalPhasePath(it, it) for it in phases.single_phases} if phases and phases.single_phases else set()
|
|
401
|
+
|
|
402
|
+
def has_visited(self, terminal: Terminal, phases: FrozenSet[SinglePhaseKind]) -> bool:
|
|
403
|
+
parent = self.parent
|
|
404
|
+
while parent is not None:
|
|
405
|
+
if parent._tracker.has_visited(terminal, phases):
|
|
406
|
+
return True
|
|
407
|
+
parent = parent.parent
|
|
408
|
+
return self._tracker.has_visited(terminal, phases)
|
|
409
|
+
|
|
410
|
+
def visit(self, terminal: Terminal, phases: FrozenSet[SinglePhaseKind]) -> bool:
|
|
411
|
+
if self.parent and self.parent.has_visited(terminal, phases):
|
|
412
|
+
return False
|
|
413
|
+
return self._tracker.visit(terminal, phases)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def default_condition_step_type(step_type: CanActionItem) -> NetworkTraceStep.Type:
|
|
417
|
+
if step_type == NetworkTraceActionType.ALL_STEPS:
|
|
418
|
+
return NetworkTraceStep.Type.ALL
|
|
419
|
+
elif step_type == NetworkTraceActionType.FIRST_STEP_ON_EQUIPMENT:
|
|
420
|
+
return NetworkTraceStep.Type.EXTERNAL
|
|
421
|
+
raise Exception('step doesnt match expected types')
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def compute_data_with_action_type(compute_data: ComputeData[T], action_type: CanActionItem) -> ComputeData[T]:
|
|
425
|
+
if action_type == NetworkTraceActionType.ALL_STEPS:
|
|
426
|
+
return compute_data
|
|
427
|
+
elif action_type == NetworkTraceActionType.FIRST_STEP_ON_EQUIPMENT:
|
|
428
|
+
return ComputeData(
|
|
429
|
+
lambda current_step, current_context, next_path: (
|
|
430
|
+
current_step.data if next_path.traced_internally else compute_data.compute_next(current_step, current_context, next_path)
|
|
431
|
+
)
|
|
432
|
+
)
|
|
433
|
+
raise Exception(f'{action_type.__name__}: step doesnt match expected types')
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Copyright 2025 Zeppelin Bend Pty Ltd
|
|
2
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
from typing import Callable, FrozenSet, Any
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
from zepben.ewb import Terminal, SinglePhaseKind
|
|
9
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_step import NetworkTraceStep
|
|
10
|
+
from zepben.ewb.services.network.tracing.traversal.step_context import StepContext
|
|
11
|
+
|
|
12
|
+
HasTracked = Callable[[Terminal, FrozenSet[SinglePhaseKind]], bool]
|
|
13
|
+
CanActionItem = Callable[[NetworkTraceStep[Any], StepContext, HasTracked], bool]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _all_steps(item: NetworkTraceStep, context: StepContext, has_tracked: HasTracked) -> bool:
|
|
17
|
+
return True
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _first_step_on_equipment(item: NetworkTraceStep[Any], context: StepContext, has_tracked: HasTracked) -> bool:
|
|
21
|
+
phases = item.path.to_phases_set()
|
|
22
|
+
return not any(has_tracked(it, phases) for it in item.path.to_terminal.other_terminals())
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NetworkTraceActionType(Enum):
|
|
26
|
+
"""
|
|
27
|
+
Options to configure when a [NetworkTrace] actions a [NetworkTraceStep].
|
|
28
|
+
"""
|
|
29
|
+
def __call__(self, *args, **kwargs) -> bool:
|
|
30
|
+
return self.value(*args, **kwargs)
|
|
31
|
+
|
|
32
|
+
ALL_STEPS: CanActionItem = _all_steps
|
|
33
|
+
"""
|
|
34
|
+
All steps visited during a [NetworkTrace] will be actioned.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
FIRST_STEP_ON_EQUIPMENT: CanActionItem = _first_step_on_equipment
|
|
38
|
+
"""
|
|
39
|
+
Only actions steps where the `toEquipment` on the [NetworkTraceStep.path] has not been visited before on the phases within the [NetworkTraceStep.path].
|
|
40
|
+
This means that all [NetworkTraceStep.type] of [NetworkTraceStep.Type.INTERNAL] will never be actioned as a first visit will always occur on an
|
|
41
|
+
external step, except if the step is a start item in the trace.
|
|
42
|
+
"""
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright 2025 Zeppelin Bend Pty Ltd
|
|
2
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
|
|
6
|
+
from abc import ABC
|
|
7
|
+
from typing import TypeVar, Callable, Generator, Generic, List, Union, Type
|
|
8
|
+
|
|
9
|
+
from zepben.ewb.services.network.tracing.networktrace.operators.network_state_operators import NetworkStateOperators
|
|
10
|
+
from zepben.ewb.services.network.tracing.networktrace.network_trace_step import NetworkTraceStep
|
|
11
|
+
from zepben.ewb.services.network.tracing.traversal.traversal import Traversal
|
|
12
|
+
from zepben.ewb.services.network.tracing.networktrace.compute_data import ComputeData, ComputeDataWithPaths
|
|
13
|
+
from zepben.ewb.services.network.tracing.traversal.step_context import StepContext
|
|
14
|
+
|
|
15
|
+
T = TypeVar('T')
|
|
16
|
+
|
|
17
|
+
QueueItem = Callable[[NetworkTraceStep[T]], bool]
|
|
18
|
+
QueueBranch = Callable[[NetworkTraceStep[T]], bool]
|
|
19
|
+
GetNextSteps = Callable[[NetworkTraceStep[T], StepContext], Generator[NetworkTraceStep[T], None, None]]
|
|
20
|
+
GetNextStepsBranching = Callable[[NetworkTraceStep[T], StepContext], List[NetworkTraceStep[T]]]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class NetworkTraceQueueNext(ABC):
|
|
24
|
+
state_operators = NetworkStateOperators
|
|
25
|
+
|
|
26
|
+
def __init__(self, state_operators: Type[NetworkStateOperators]):
|
|
27
|
+
self.state_operators = state_operators
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def next_trace_steps(self,
|
|
31
|
+
current_step: NetworkTraceStep[T],
|
|
32
|
+
current_context: StepContext,
|
|
33
|
+
compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]]
|
|
34
|
+
) -> Generator[NetworkTraceStep[T], None, None]:
|
|
35
|
+
""" Builds a list of next `NetworkTraceStep` to add to the `NetworkTrace` queue """
|
|
36
|
+
next_paths = list(self.state_operators.next_paths(current_step.path))
|
|
37
|
+
if isinstance(compute_data, ComputeData):
|
|
38
|
+
compute_next = lambda _it: compute_data.compute_next(current_step, current_context, _it)
|
|
39
|
+
elif isinstance(compute_data, ComputeDataWithPaths):
|
|
40
|
+
compute_next = lambda _it: compute_data.compute_next(current_step, current_context, _it, next_paths)
|
|
41
|
+
else:
|
|
42
|
+
raise TypeError(f'ComputeData was not of a recognised class: {compute_data.__class__} not in [ComputeData, ComputeDataWithPaths]')
|
|
43
|
+
|
|
44
|
+
next_num_terminal_steps = current_step.next_num_terminal_steps()
|
|
45
|
+
for it in next_paths:
|
|
46
|
+
data = compute_next(it)
|
|
47
|
+
yield NetworkTraceStep(it, next_num_terminal_steps, it.next_num_equipment_steps(current_step.num_equipment_steps), data)
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def Basic(state_operators: Type[NetworkStateOperators], compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]]):
|
|
51
|
+
return Basic(state_operators, compute_data)
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def Branching(state_operators: Type[NetworkStateOperators], compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]]):
|
|
55
|
+
return Branching(state_operators, compute_data)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Basic(NetworkTraceQueueNext, Traversal.QueueNext[NetworkTraceStep[T]], Generic[T]):
|
|
59
|
+
def __init__(self, state_operators: Type[NetworkStateOperators], compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]]):
|
|
60
|
+
super().__init__(state_operators)
|
|
61
|
+
|
|
62
|
+
self._get_next_steps: GetNextSteps = lambda item, context: self.next_trace_steps(item, context, compute_data)
|
|
63
|
+
|
|
64
|
+
def __iinit__(self, get_next_steps: GetNextSteps):
|
|
65
|
+
self._get_next_steps: GetNextSteps = get_next_steps
|
|
66
|
+
|
|
67
|
+
def accept(self, item: NetworkTraceStep[T], context: StepContext, queue_item: QueueItem):
|
|
68
|
+
for it in self._get_next_steps(item, context):
|
|
69
|
+
queue_item(it)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class Branching(NetworkTraceQueueNext, Traversal.BranchingQueueNext[NetworkTraceStep[T]], Generic[T]):
|
|
73
|
+
def __init__(self, state_operators: Type[NetworkStateOperators], compute_data: Union[ComputeData[T], ComputeDataWithPaths[T]]):
|
|
74
|
+
super().__init__(state_operators)
|
|
75
|
+
|
|
76
|
+
self._get_next_steps: GetNextStepsBranching = lambda item, context: list(self.next_trace_steps(item, context, compute_data))
|
|
77
|
+
|
|
78
|
+
def accept(self, item: NetworkTraceStep[T], context: StepContext, queue_item: QueueItem, queue_branch: QueueBranch):
|
|
79
|
+
next_steps = self._get_next_steps(item, context)
|
|
80
|
+
if len(next_steps) == 1:
|
|
81
|
+
queue_item(next_steps[0])
|
|
82
|
+
else:
|
|
83
|
+
for step in next_steps:
|
|
84
|
+
queue_branch(step)
|