zepben.ewb 1.0.0b1__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.
Files changed (639) hide show
  1. zepben/ewb/__init__.py +601 -0
  2. zepben/ewb/auth/__init__.py +10 -0
  3. zepben/ewb/auth/client/__init__.py +5 -0
  4. zepben/ewb/auth/client/zepben_token_fetcher.py +273 -0
  5. zepben/ewb/auth/common/__init__.py +5 -0
  6. zepben/ewb/auth/common/auth_exception.py +16 -0
  7. zepben/ewb/auth/common/auth_method.py +28 -0
  8. zepben/ewb/auth/common/auth_provider_config.py +96 -0
  9. zepben/ewb/database/__init__.py +4 -0
  10. zepben/ewb/database/paths/__init__.py +4 -0
  11. zepben/ewb/database/paths/database_type.py +34 -0
  12. zepben/ewb/database/paths/ewb_data_file_paths.py +237 -0
  13. zepben/ewb/database/sqlite/__init__.py +4 -0
  14. zepben/ewb/database/sqlite/common/__init__.py +4 -0
  15. zepben/ewb/database/sqlite/common/base_cim_reader.py +212 -0
  16. zepben/ewb/database/sqlite/common/base_cim_writer.py +159 -0
  17. zepben/ewb/database/sqlite/common/base_collection_reader.py +96 -0
  18. zepben/ewb/database/sqlite/common/base_collection_writer.py +73 -0
  19. zepben/ewb/database/sqlite/common/base_database_reader.py +127 -0
  20. zepben/ewb/database/sqlite/common/base_database_tables.py +137 -0
  21. zepben/ewb/database/sqlite/common/base_database_writer.py +195 -0
  22. zepben/ewb/database/sqlite/common/base_entry_writer.py +34 -0
  23. zepben/ewb/database/sqlite/common/base_service_reader.py +50 -0
  24. zepben/ewb/database/sqlite/common/base_service_writer.py +104 -0
  25. zepben/ewb/database/sqlite/common/metadata_collection_reader.py +39 -0
  26. zepben/ewb/database/sqlite/common/metadata_collection_writer.py +38 -0
  27. zepben/ewb/database/sqlite/common/metadata_entry_reader.py +45 -0
  28. zepben/ewb/database/sqlite/common/metadata_entry_writer.py +41 -0
  29. zepben/ewb/database/sqlite/common/reader_exceptions.py +30 -0
  30. zepben/ewb/database/sqlite/customer/__init__.py +4 -0
  31. zepben/ewb/database/sqlite/customer/customer_cim_reader.py +169 -0
  32. zepben/ewb/database/sqlite/customer/customer_cim_writer.py +137 -0
  33. zepben/ewb/database/sqlite/customer/customer_database_reader.py +44 -0
  34. zepben/ewb/database/sqlite/customer/customer_database_tables.py +37 -0
  35. zepben/ewb/database/sqlite/customer/customer_database_writer.py +45 -0
  36. zepben/ewb/database/sqlite/customer/customer_service_reader.py +57 -0
  37. zepben/ewb/database/sqlite/customer/customer_service_writer.py +47 -0
  38. zepben/ewb/database/sqlite/diagram/__init__.py +4 -0
  39. zepben/ewb/database/sqlite/diagram/diagram_cim_reader.py +105 -0
  40. zepben/ewb/database/sqlite/diagram/diagram_cim_writer.py +81 -0
  41. zepben/ewb/database/sqlite/diagram/diagram_database_reader.py +45 -0
  42. zepben/ewb/database/sqlite/diagram/diagram_database_tables.py +29 -0
  43. zepben/ewb/database/sqlite/diagram/diagram_database_writer.py +44 -0
  44. zepben/ewb/database/sqlite/diagram/diagram_service_reader.py +49 -0
  45. zepben/ewb/database/sqlite/diagram/diagram_service_writer.py +41 -0
  46. zepben/ewb/database/sqlite/extensions/__init__.py +4 -0
  47. zepben/ewb/database/sqlite/extensions/prepared_statement.py +112 -0
  48. zepben/ewb/database/sqlite/extensions/result_set.py +153 -0
  49. zepben/ewb/database/sqlite/network/__init__.py +4 -0
  50. zepben/ewb/database/sqlite/network/network_cim_reader.py +3167 -0
  51. zepben/ewb/database/sqlite/network/network_cim_writer.py +2561 -0
  52. zepben/ewb/database/sqlite/network/network_database_reader.py +173 -0
  53. zepben/ewb/database/sqlite/network/network_database_tables.py +242 -0
  54. zepben/ewb/database/sqlite/network/network_database_writer.py +43 -0
  55. zepben/ewb/database/sqlite/network/network_service_reader.py +265 -0
  56. zepben/ewb/database/sqlite/network/network_service_writer.py +209 -0
  57. zepben/ewb/database/sqlite/tables/__init__.py +4 -0
  58. zepben/ewb/database/sqlite/tables/associations/__init__.py +4 -0
  59. zepben/ewb/database/sqlite/tables/associations/loop_substation_relationship.py +17 -0
  60. zepben/ewb/database/sqlite/tables/associations/table_asset_organisation_roles_assets.py +40 -0
  61. zepben/ewb/database/sqlite/tables/associations/table_assets_power_system_resources.py +41 -0
  62. zepben/ewb/database/sqlite/tables/associations/table_battery_units_battery_controls.py +40 -0
  63. zepben/ewb/database/sqlite/tables/associations/table_circuits_substations.py +40 -0
  64. zepben/ewb/database/sqlite/tables/associations/table_circuits_terminals.py +40 -0
  65. zepben/ewb/database/sqlite/tables/associations/table_customer_agreements_pricing_structures.py +40 -0
  66. zepben/ewb/database/sqlite/tables/associations/table_end_devices_end_device_functions.py +40 -0
  67. zepben/ewb/database/sqlite/tables/associations/table_equipment_equipment_containers.py +40 -0
  68. zepben/ewb/database/sqlite/tables/associations/table_equipment_operational_restrictions.py +40 -0
  69. zepben/ewb/database/sqlite/tables/associations/table_equipment_usage_points.py +40 -0
  70. zepben/ewb/database/sqlite/tables/associations/table_loops_substations.py +43 -0
  71. zepben/ewb/database/sqlite/tables/associations/table_pricing_structures_tariffs.py +40 -0
  72. zepben/ewb/database/sqlite/tables/associations/table_protection_relay_functions_protected_switches.py +40 -0
  73. zepben/ewb/database/sqlite/tables/associations/table_protection_relay_functions_sensors.py +40 -0
  74. zepben/ewb/database/sqlite/tables/associations/table_protection_relay_schemes_protection_relay_functions.py +40 -0
  75. zepben/ewb/database/sqlite/tables/associations/table_synchronous_machines_reactive_capability_curves.py +39 -0
  76. zepben/ewb/database/sqlite/tables/associations/table_usage_points_end_devices.py +40 -0
  77. zepben/ewb/database/sqlite/tables/column.py +37 -0
  78. zepben/ewb/database/sqlite/tables/exceptions.py +10 -0
  79. zepben/ewb/database/sqlite/tables/extensions/__init__.py +4 -0
  80. zepben/ewb/database/sqlite/tables/extensions/iec61968/__init__.py +4 -0
  81. zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/__init__.py +4 -0
  82. zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/table_reclose_delays.py +38 -0
  83. zepben/ewb/database/sqlite/tables/extensions/iec61968/assetinfo/table_relay_info.py +21 -0
  84. zepben/ewb/database/sqlite/tables/extensions/iec61968/metering/__init__.py +4 -0
  85. zepben/ewb/database/sqlite/tables/extensions/iec61968/metering/table_pan_demand_response_functions.py +21 -0
  86. zepben/ewb/database/sqlite/tables/extensions/iec61970/__init__.py +4 -0
  87. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/__init__.py +4 -0
  88. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/core/__init__.py +4 -0
  89. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/core/table_sites.py +15 -0
  90. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/__init__.py +4 -0
  91. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/table_loops.py +15 -0
  92. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/feeder/table_lv_feeders.py +20 -0
  93. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/__init__.py +4 -0
  94. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/production/__init__.py +4 -0
  95. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/generation/production/table_ev_charging_units.py +15 -0
  96. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/__init__.py +4 -0
  97. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_distance_relays.py +28 -0
  98. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_function_thresholds.py +36 -0
  99. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_function_time_limits.py +34 -0
  100. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_functions.py +24 -0
  101. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_schemes.py +20 -0
  102. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_protection_relay_systems.py +20 -0
  103. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/protection/table_voltage_relays.py +15 -0
  104. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/__init__.py +4 -0
  105. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/table_battery_controls.py +23 -0
  106. zepben/ewb/database/sqlite/tables/extensions/iec61970/base/wires/table_power_transformer_end_ratings.py +34 -0
  107. zepben/ewb/database/sqlite/tables/iec61968/__init__.py +4 -0
  108. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/__init__.py +4 -0
  109. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_cable_info.py +15 -0
  110. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_no_load_tests.py +24 -0
  111. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_open_circuit_tests.py +24 -0
  112. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_overhead_wire_info.py +15 -0
  113. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_power_transformer_info.py +15 -0
  114. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_short_circuit_tests.py +29 -0
  115. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_shunt_compensator_info.py +23 -0
  116. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_switch_info.py +20 -0
  117. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_end_info.py +46 -0
  118. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_tank_info.py +27 -0
  119. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_transformer_test.py +19 -0
  120. zepben/ewb/database/sqlite/tables/iec61968/assetinfo/table_wire_info.py +19 -0
  121. zepben/ewb/database/sqlite/tables/iec61968/assets/__init__.py +4 -0
  122. zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_containers.py +14 -0
  123. zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_functions.py +14 -0
  124. zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_info.py +14 -0
  125. zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_organisation_roles.py +14 -0
  126. zepben/ewb/database/sqlite/tables/iec61968/assets/table_asset_owners.py +15 -0
  127. zepben/ewb/database/sqlite/tables/iec61968/assets/table_assets.py +18 -0
  128. zepben/ewb/database/sqlite/tables/iec61968/assets/table_streetlights.py +22 -0
  129. zepben/ewb/database/sqlite/tables/iec61968/assets/table_structures.py +14 -0
  130. zepben/ewb/database/sqlite/tables/iec61968/common/__init__.py +4 -0
  131. zepben/ewb/database/sqlite/tables/iec61968/common/table_agreements.py +14 -0
  132. zepben/ewb/database/sqlite/tables/iec61968/common/table_documents.py +23 -0
  133. zepben/ewb/database/sqlite/tables/iec61968/common/table_location_street_address_field.py +18 -0
  134. zepben/ewb/database/sqlite/tables/iec61968/common/table_location_street_addresses.py +33 -0
  135. zepben/ewb/database/sqlite/tables/iec61968/common/table_locations.py +15 -0
  136. zepben/ewb/database/sqlite/tables/iec61968/common/table_organisation_roles.py +18 -0
  137. zepben/ewb/database/sqlite/tables/iec61968/common/table_organisations.py +15 -0
  138. zepben/ewb/database/sqlite/tables/iec61968/common/table_position_points.py +30 -0
  139. zepben/ewb/database/sqlite/tables/iec61968/common/table_street_addresses.py +26 -0
  140. zepben/ewb/database/sqlite/tables/iec61968/common/table_town_details.py +19 -0
  141. zepben/ewb/database/sqlite/tables/iec61968/customers/__init__.py +4 -0
  142. zepben/ewb/database/sqlite/tables/iec61968/customers/table_customer_agreements.py +27 -0
  143. zepben/ewb/database/sqlite/tables/iec61968/customers/table_customers.py +22 -0
  144. zepben/ewb/database/sqlite/tables/iec61968/customers/table_pricing_structures.py +15 -0
  145. zepben/ewb/database/sqlite/tables/iec61968/customers/table_tariffs.py +15 -0
  146. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/__init__.py +4 -0
  147. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/__init__.py +4 -0
  148. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/table_current_transformer_info.py +33 -0
  149. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassetinfo/table_potential_transformer_info.py +26 -0
  150. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassets/__init__.py +4 -0
  151. zepben/ewb/database/sqlite/tables/iec61968/infiec61968/infassets/table_poles.py +20 -0
  152. zepben/ewb/database/sqlite/tables/iec61968/metering/__init__.py +4 -0
  153. zepben/ewb/database/sqlite/tables/iec61968/metering/table_end_device_functions.py +18 -0
  154. zepben/ewb/database/sqlite/tables/iec61968/metering/table_end_devices.py +19 -0
  155. zepben/ewb/database/sqlite/tables/iec61968/metering/table_meters.py +15 -0
  156. zepben/ewb/database/sqlite/tables/iec61968/metering/table_usage_points.py +23 -0
  157. zepben/ewb/database/sqlite/tables/iec61968/operations/__init__.py +4 -0
  158. zepben/ewb/database/sqlite/tables/iec61968/operations/table_operational_restrictions.py +15 -0
  159. zepben/ewb/database/sqlite/tables/iec61970/__init__.py +4 -0
  160. zepben/ewb/database/sqlite/tables/iec61970/base/__init__.py +4 -0
  161. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/__init__.py +4 -0
  162. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_auxiliary_equipment.py +18 -0
  163. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_current_transformers.py +21 -0
  164. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_fault_indicators.py +15 -0
  165. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_potential_transformers.py +21 -0
  166. zepben/ewb/database/sqlite/tables/iec61970/base/auxiliaryequipment/table_sensors.py +14 -0
  167. zepben/ewb/database/sqlite/tables/iec61970/base/core/__init__.py +4 -0
  168. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_ac_dc_terminals.py +14 -0
  169. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_base_voltages.py +20 -0
  170. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_conducting_equipment.py +18 -0
  171. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_connectivity_node_containers.py +14 -0
  172. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_connectivity_nodes.py +15 -0
  173. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_curve_data.py +46 -0
  174. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_curves.py +17 -0
  175. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_equipment.py +20 -0
  176. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_equipment_containers.py +14 -0
  177. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_feeders.py +28 -0
  178. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_geographical_regions.py +15 -0
  179. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_identified_objects.py +29 -0
  180. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_name_types.py +28 -0
  181. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_names.py +36 -0
  182. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_power_system_resources.py +19 -0
  183. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_sub_geographical_regions.py +27 -0
  184. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_substations.py +27 -0
  185. zepben/ewb/database/sqlite/tables/iec61970/base/core/table_terminals.py +35 -0
  186. zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/__init__.py +4 -0
  187. zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagram_object_points.py +35 -0
  188. zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagram_objects.py +31 -0
  189. zepben/ewb/database/sqlite/tables/iec61970/base/diagramlayout/table_diagrams.py +21 -0
  190. zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/__init__.py +4 -0
  191. zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/table_equivalent_branches.py +35 -0
  192. zepben/ewb/database/sqlite/tables/iec61970/base/equivalents/table_equivalent_equipment.py +14 -0
  193. zepben/ewb/database/sqlite/tables/iec61970/base/generation/__init__.py +4 -0
  194. zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/__init__.py +4 -0
  195. zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_battery_units.py +22 -0
  196. zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_photo_voltaic_units.py +15 -0
  197. zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_power_electronics_units.py +26 -0
  198. zepben/ewb/database/sqlite/tables/iec61970/base/generation/production/table_power_electronics_wind_units.py +15 -0
  199. zepben/ewb/database/sqlite/tables/iec61970/base/meas/__init__.py +4 -0
  200. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_accumulators.py +15 -0
  201. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_analogs.py +20 -0
  202. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_controls.py +20 -0
  203. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_discretes.py +15 -0
  204. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_io_points.py +14 -0
  205. zepben/ewb/database/sqlite/tables/iec61970/base/meas/table_measurements.py +30 -0
  206. zepben/ewb/database/sqlite/tables/iec61970/base/protection/__init__.py +4 -0
  207. zepben/ewb/database/sqlite/tables/iec61970/base/protection/table_current_relays.py +22 -0
  208. zepben/ewb/database/sqlite/tables/iec61970/base/scada/__init__.py +4 -0
  209. zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_controls.py +20 -0
  210. zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_points.py +14 -0
  211. zepben/ewb/database/sqlite/tables/iec61970/base/scada/table_remote_sources.py +20 -0
  212. zepben/ewb/database/sqlite/tables/iec61970/base/wires/__init__.py +4 -0
  213. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ac_line_segments.py +20 -0
  214. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_breakers.py +20 -0
  215. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_busbar_sections.py +15 -0
  216. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_clamps.py +23 -0
  217. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_conductors.py +21 -0
  218. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_connectors.py +14 -0
  219. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_cuts.py +23 -0
  220. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_disconnectors.py +15 -0
  221. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_earth_fault_compensators.py +22 -0
  222. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_connections.py +14 -0
  223. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_consumer_phases.py +37 -0
  224. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_consumers.py +26 -0
  225. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_source_phases.py +33 -0
  226. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_energy_sources.py +44 -0
  227. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_fuses.py +20 -0
  228. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ground_disconnectors.py +15 -0
  229. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_grounding_impedances.py +24 -0
  230. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_grounds.py +15 -0
  231. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_jumpers.py +15 -0
  232. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_junctions.py +15 -0
  233. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_linear_shunt_compensators.py +23 -0
  234. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_lines.py +14 -0
  235. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_load_break_switches.py +15 -0
  236. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_impedances.py +14 -0
  237. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_line_parameters.py +14 -0
  238. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_phase_impedances.py +18 -0
  239. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_per_length_sequence_impedances.py +27 -0
  240. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_petersen_coils.py +27 -0
  241. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_phase_impedance_data.py +52 -0
  242. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_electronics_connection_phases.py +30 -0
  243. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_electronics_connections.py +50 -0
  244. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_transformer_ends.py +43 -0
  245. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_power_transformers.py +24 -0
  246. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_protected_switches.py +18 -0
  247. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_ratio_tap_changers.py +28 -0
  248. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_reactive_capability_curves.py +18 -0
  249. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_reclosers.py +15 -0
  250. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_regulating_cond_eq.py +19 -0
  251. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_regulating_controls.py +29 -0
  252. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_rotating_machines.py +36 -0
  253. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_series_compensators.py +25 -0
  254. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_shunt_compensators.py +22 -0
  255. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_static_var_compensator.py +24 -0
  256. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_switches.py +21 -0
  257. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_synchronous_machines.py +95 -0
  258. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_tap_changer_controls.py +28 -0
  259. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_tap_changers.py +25 -0
  260. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_transformer_ends.py +30 -0
  261. zepben/ewb/database/sqlite/tables/iec61970/base/wires/table_transformer_star_impedances.py +32 -0
  262. zepben/ewb/database/sqlite/tables/iec61970/infiec61970/__init__.py +4 -0
  263. zepben/ewb/database/sqlite/tables/iec61970/infiec61970/feeder/__init__.py +4 -0
  264. zepben/ewb/database/sqlite/tables/iec61970/infiec61970/feeder/table_circuits.py +27 -0
  265. zepben/ewb/database/sqlite/tables/sqlite_table.py +142 -0
  266. zepben/ewb/database/sqlite/tables/table_metadata_data_sources.py +21 -0
  267. zepben/ewb/database/sqlite/tables/table_version.py +38 -0
  268. zepben/ewb/dataclassy/__init__.py +15 -0
  269. zepben/ewb/dataclassy/dataclass.py +192 -0
  270. zepben/ewb/dataclassy/decorator.py +35 -0
  271. zepben/ewb/dataclassy/functions.py +80 -0
  272. zepben/ewb/examples/__init__.py +6 -0
  273. zepben/ewb/examples/simple_test_network.py +158 -0
  274. zepben/ewb/exceptions.py +52 -0
  275. zepben/ewb/model/__init__.py +4 -0
  276. zepben/ewb/model/busbranch/__init__.py +4 -0
  277. zepben/ewb/model/busbranch/bus_branch.py +1051 -0
  278. zepben/ewb/model/cim/__init__.py +4 -0
  279. zepben/ewb/model/cim/extensions/__init__.py +4 -0
  280. zepben/ewb/model/cim/extensions/iec61968/__init__.py +4 -0
  281. zepben/ewb/model/cim/extensions/iec61968/assetinfo/__init__.py +4 -0
  282. zepben/ewb/model/cim/extensions/iec61968/assetinfo/relay_info.py +128 -0
  283. zepben/ewb/model/cim/extensions/iec61968/metering/__init__.py +4 -0
  284. zepben/ewb/model/cim/extensions/iec61968/metering/pan_demand_reponse_function.py +112 -0
  285. zepben/ewb/model/cim/extensions/iec61970/__init__.py +4 -0
  286. zepben/ewb/model/cim/extensions/iec61970/base/__init__.py +4 -0
  287. zepben/ewb/model/cim/extensions/iec61970/base/core/__init__.py +4 -0
  288. zepben/ewb/model/cim/extensions/iec61970/base/core/site.py +37 -0
  289. zepben/ewb/model/cim/extensions/iec61970/base/feeder/__init__.py +4 -0
  290. zepben/ewb/model/cim/extensions/iec61970/base/feeder/loop.py +207 -0
  291. zepben/ewb/model/cim/extensions/iec61970/base/feeder/lv_feeder.py +258 -0
  292. zepben/ewb/model/cim/extensions/iec61970/base/generation/__init__.py +4 -0
  293. zepben/ewb/model/cim/extensions/iec61970/base/generation/production/__init__.py +4 -0
  294. zepben/ewb/model/cim/extensions/iec61970/base/generation/production/ev_charging_unit.py +18 -0
  295. zepben/ewb/model/cim/extensions/iec61970/base/protection/__init__.py +4 -0
  296. zepben/ewb/model/cim/extensions/iec61970/base/protection/distance_relay.py +69 -0
  297. zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py +35 -0
  298. zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_kind.py +113 -0
  299. zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_function.py +448 -0
  300. zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_scheme.py +97 -0
  301. zepben/ewb/model/cim/extensions/iec61970/base/protection/protection_relay_system.py +97 -0
  302. zepben/ewb/model/cim/extensions/iec61970/base/protection/relay_setting.py +35 -0
  303. zepben/ewb/model/cim/extensions/iec61970/base/protection/voltage_relay.py +20 -0
  304. zepben/ewb/model/cim/extensions/iec61970/base/wires/__init__.py +4 -0
  305. zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control.py +36 -0
  306. zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py +82 -0
  307. zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py +56 -0
  308. zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_end_rated_s.py +26 -0
  309. zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py +292 -0
  310. zepben/ewb/model/cim/extensions/zbex.py +17 -0
  311. zepben/ewb/model/cim/iec61968/__init__.py +4 -0
  312. zepben/ewb/model/cim/iec61968/assetinfo/__init__.py +4 -0
  313. zepben/ewb/model/cim/iec61968/assetinfo/cable_info.py +15 -0
  314. zepben/ewb/model/cim/iec61968/assetinfo/no_load_test.py +42 -0
  315. zepben/ewb/model/cim/iec61968/assetinfo/open_circuit_test.py +42 -0
  316. zepben/ewb/model/cim/iec61968/assetinfo/overhead_wire_info.py +15 -0
  317. zepben/ewb/model/cim/iec61968/assetinfo/power_transformer_info.py +103 -0
  318. zepben/ewb/model/cim/iec61968/assetinfo/short_circuit_test.py +67 -0
  319. zepben/ewb/model/cim/iec61968/assetinfo/shunt_compensator_info.py +26 -0
  320. zepben/ewb/model/cim/iec61968/assetinfo/switch_info.py +17 -0
  321. zepben/ewb/model/cim/iec61968/assetinfo/transformer_end_info.py +137 -0
  322. zepben/ewb/model/cim/iec61968/assetinfo/transformer_tank_info.py +108 -0
  323. zepben/ewb/model/cim/iec61968/assetinfo/transformer_test.py +26 -0
  324. zepben/ewb/model/cim/iec61968/assetinfo/wire_info.py +24 -0
  325. zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py +55 -0
  326. zepben/ewb/model/cim/iec61968/assets/__init__.py +4 -0
  327. zepben/ewb/model/cim/iec61968/assets/asset.py +154 -0
  328. zepben/ewb/model/cim/iec61968/assets/asset_container.py +16 -0
  329. zepben/ewb/model/cim/iec61968/assets/asset_function.py +15 -0
  330. zepben/ewb/model/cim/iec61968/assets/asset_info.py +19 -0
  331. zepben/ewb/model/cim/iec61968/assets/asset_organisation_role.py +13 -0
  332. zepben/ewb/model/cim/iec61968/assets/asset_owner.py +13 -0
  333. zepben/ewb/model/cim/iec61968/assets/streetlight.py +29 -0
  334. zepben/ewb/model/cim/iec61968/assets/structure.py +16 -0
  335. zepben/ewb/model/cim/iec61968/common/__init__.py +4 -0
  336. zepben/ewb/model/cim/iec61968/common/agreement.py +16 -0
  337. zepben/ewb/model/cim/iec61968/common/document.py +36 -0
  338. zepben/ewb/model/cim/iec61968/common/location.py +129 -0
  339. zepben/ewb/model/cim/iec61968/common/organisation.py +15 -0
  340. zepben/ewb/model/cim/iec61968/common/organisation_role.py +22 -0
  341. zepben/ewb/model/cim/iec61968/common/position_point.py +44 -0
  342. zepben/ewb/model/cim/iec61968/common/street_address.py +28 -0
  343. zepben/ewb/model/cim/iec61968/common/street_detail.py +45 -0
  344. zepben/ewb/model/cim/iec61968/common/town_detail.py +25 -0
  345. zepben/ewb/model/cim/iec61968/customers/__init__.py +4 -0
  346. zepben/ewb/model/cim/iec61968/customers/customer.py +93 -0
  347. zepben/ewb/model/cim/iec61968/customers/customer_agreement.py +107 -0
  348. zepben/ewb/model/cim/iec61968/customers/customer_kind.py +67 -0
  349. zepben/ewb/model/cim/iec61968/customers/pricing_structure.py +88 -0
  350. zepben/ewb/model/cim/iec61968/customers/tariff.py +18 -0
  351. zepben/ewb/model/cim/iec61968/infiec61968/__init__.py +4 -0
  352. zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/__init__.py +4 -0
  353. zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/current_transformer_info.py +51 -0
  354. zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/potential_transformer_info.py +33 -0
  355. zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py +67 -0
  356. zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py +43 -0
  357. zepben/ewb/model/cim/iec61968/infiec61968/infassets/__init__.py +4 -0
  358. zepben/ewb/model/cim/iec61968/infiec61968/infassets/pole.py +87 -0
  359. zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py +25 -0
  360. zepben/ewb/model/cim/iec61968/infiec61968/infcommon/__init__.py +4 -0
  361. zepben/ewb/model/cim/iec61968/infiec61968/infcommon/ratio.py +34 -0
  362. zepben/ewb/model/cim/iec61968/metering/__init__.py +4 -0
  363. zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py +150 -0
  364. zepben/ewb/model/cim/iec61968/metering/end_device.py +165 -0
  365. zepben/ewb/model/cim/iec61968/metering/end_device_function.py +17 -0
  366. zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py +46 -0
  367. zepben/ewb/model/cim/iec61968/metering/meter.py +26 -0
  368. zepben/ewb/model/cim/iec61968/metering/usage_point.py +186 -0
  369. zepben/ewb/model/cim/iec61968/operations/__init__.py +4 -0
  370. zepben/ewb/model/cim/iec61968/operations/operational_restriction.py +92 -0
  371. zepben/ewb/model/cim/iec61970/__init__.py +4 -0
  372. zepben/ewb/model/cim/iec61970/base/__init__.py +4 -0
  373. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/__init__.py +4 -0
  374. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/auxiliary_equipment.py +24 -0
  375. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/current_transformer.py +37 -0
  376. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/fault_indicator.py +18 -0
  377. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer.py +38 -0
  378. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py +28 -0
  379. zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/sensor.py +92 -0
  380. zepben/ewb/model/cim/iec61970/base/core/__init__.py +4 -0
  381. zepben/ewb/model/cim/iec61970/base/core/ac_dc_terminal.py +16 -0
  382. zepben/ewb/model/cim/iec61970/base/core/base_voltage.py +17 -0
  383. zepben/ewb/model/cim/iec61970/base/core/conducting_equipment.py +198 -0
  384. zepben/ewb/model/cim/iec61970/base/core/connectivity_node.py +105 -0
  385. zepben/ewb/model/cim/iec61970/base/core/connectivity_node_container.py +15 -0
  386. zepben/ewb/model/cim/iec61970/base/core/curve.py +124 -0
  387. zepben/ewb/model/cim/iec61970/base/core/curve_data.py +29 -0
  388. zepben/ewb/model/cim/iec61970/base/core/equipment.py +366 -0
  389. zepben/ewb/model/cim/iec61970/base/core/equipment_container.py +199 -0
  390. zepben/ewb/model/cim/iec61970/base/core/feeder.py +260 -0
  391. zepben/ewb/model/cim/iec61970/base/core/geographical_region.py +82 -0
  392. zepben/ewb/model/cim/iec61970/base/core/identified_object.py +234 -0
  393. zepben/ewb/model/cim/iec61970/base/core/name.py +36 -0
  394. zepben/ewb/model/cim/iec61970/base/core/name_type.py +203 -0
  395. zepben/ewb/model/cim/iec61970/base/core/phase_code.py +201 -0
  396. zepben/ewb/model/cim/iec61970/base/core/power_system_resource.py +106 -0
  397. zepben/ewb/model/cim/iec61970/base/core/sub_geographical_region.py +93 -0
  398. zepben/ewb/model/cim/iec61970/base/core/substation.py +277 -0
  399. zepben/ewb/model/cim/iec61970/base/core/terminal.py +171 -0
  400. zepben/ewb/model/cim/iec61970/base/diagramlayout/__init__.py +4 -0
  401. zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram.py +109 -0
  402. zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_object.py +160 -0
  403. zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_object_point.py +25 -0
  404. zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py +26 -0
  405. zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py +27 -0
  406. zepben/ewb/model/cim/iec61970/base/domain/__init__.py +4 -0
  407. zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py +492 -0
  408. zepben/ewb/model/cim/iec61970/base/equivalents/__init__.py +4 -0
  409. zepben/ewb/model/cim/iec61970/base/equivalents/equivalent_branch.py +113 -0
  410. zepben/ewb/model/cim/iec61970/base/equivalents/equivalent_equipment.py +15 -0
  411. zepben/ewb/model/cim/iec61970/base/generation/__init__.py +4 -0
  412. zepben/ewb/model/cim/iec61970/base/generation/production/__init__.py +4 -0
  413. zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py +37 -0
  414. zepben/ewb/model/cim/iec61970/base/generation/production/battery_unit.py +108 -0
  415. zepben/ewb/model/cim/iec61970/base/generation/production/photo_voltaic_unit.py +13 -0
  416. zepben/ewb/model/cim/iec61970/base/generation/production/power_electronics_unit.py +28 -0
  417. zepben/ewb/model/cim/iec61970/base/generation/production/power_electronics_wind_unit.py +13 -0
  418. zepben/ewb/model/cim/iec61970/base/meas/__init__.py +4 -0
  419. zepben/ewb/model/cim/iec61970/base/meas/accumulator.py +13 -0
  420. zepben/ewb/model/cim/iec61970/base/meas/accumulator_value.py +20 -0
  421. zepben/ewb/model/cim/iec61970/base/meas/analog.py +16 -0
  422. zepben/ewb/model/cim/iec61970/base/meas/analog_value.py +20 -0
  423. zepben/ewb/model/cim/iec61970/base/meas/control.py +26 -0
  424. zepben/ewb/model/cim/iec61970/base/meas/discrete.py +13 -0
  425. zepben/ewb/model/cim/iec61970/base/meas/discrete_value.py +20 -0
  426. zepben/ewb/model/cim/iec61970/base/meas/iopoint.py +16 -0
  427. zepben/ewb/model/cim/iec61970/base/meas/measurement.py +60 -0
  428. zepben/ewb/model/cim/iec61970/base/meas/measurement_value.py +21 -0
  429. zepben/ewb/model/cim/iec61970/base/protection/__init__.py +4 -0
  430. zepben/ewb/model/cim/iec61970/base/protection/current_relay.py +23 -0
  431. zepben/ewb/model/cim/iec61970/base/scada/__init__.py +4 -0
  432. zepben/ewb/model/cim/iec61970/base/scada/remote_control.py +22 -0
  433. zepben/ewb/model/cim/iec61970/base/scada/remote_point.py +16 -0
  434. zepben/ewb/model/cim/iec61970/base/scada/remote_source.py +22 -0
  435. zepben/ewb/model/cim/iec61970/base/wires/__init__.py +4 -0
  436. zepben/ewb/model/cim/iec61970/base/wires/ac_line_segment.py +214 -0
  437. zepben/ewb/model/cim/iec61970/base/wires/breaker.py +32 -0
  438. zepben/ewb/model/cim/iec61970/base/wires/busbar_section.py +19 -0
  439. zepben/ewb/model/cim/iec61970/base/wires/clamp.py +32 -0
  440. zepben/ewb/model/cim/iec61970/base/wires/conductor.py +49 -0
  441. zepben/ewb/model/cim/iec61970/base/wires/connector.py +16 -0
  442. zepben/ewb/model/cim/iec61970/base/wires/cut.py +36 -0
  443. zepben/ewb/model/cim/iec61970/base/wires/disconnector.py +17 -0
  444. zepben/ewb/model/cim/iec61970/base/wires/earth_fault_compensator.py +21 -0
  445. zepben/ewb/model/cim/iec61970/base/wires/energy_connection.py +15 -0
  446. zepben/ewb/model/cim/iec61970/base/wires/energy_consumer.py +107 -0
  447. zepben/ewb/model/cim/iec61970/base/wires/energy_consumer_phase.py +56 -0
  448. zepben/ewb/model/cim/iec61970/base/wires/energy_source.py +172 -0
  449. zepben/ewb/model/cim/iec61970/base/wires/energy_source_phase.py +45 -0
  450. zepben/ewb/model/cim/iec61970/base/wires/fuse.py +23 -0
  451. zepben/ewb/model/cim/iec61970/base/wires/ground.py +15 -0
  452. zepben/ewb/model/cim/iec61970/base/wires/ground_disconnector.py +15 -0
  453. zepben/ewb/model/cim/iec61970/base/wires/grounding_impedance.py +19 -0
  454. zepben/ewb/model/cim/iec61970/base/wires/jumper.py +16 -0
  455. zepben/ewb/model/cim/iec61970/base/wires/junction.py +15 -0
  456. zepben/ewb/model/cim/iec61970/base/wires/line.py +13 -0
  457. zepben/ewb/model/cim/iec61970/base/wires/linear_shunt_compensator.py +26 -0
  458. zepben/ewb/model/cim/iec61970/base/wires/load_break_switch.py +14 -0
  459. zepben/ewb/model/cim/iec61970/base/wires/per_length_impedance.py +13 -0
  460. zepben/ewb/model/cim/iec61970/base/wires/per_length_line_parameter.py +13 -0
  461. zepben/ewb/model/cim/iec61970/base/wires/per_length_phase_impedance.py +99 -0
  462. zepben/ewb/model/cim/iec61970/base/wires/per_length_sequence_impedance.py +43 -0
  463. zepben/ewb/model/cim/iec61970/base/wires/petersen_coil.py +22 -0
  464. zepben/ewb/model/cim/iec61970/base/wires/phase_impedance_data.py +37 -0
  465. zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py +38 -0
  466. zepben/ewb/model/cim/iec61970/base/wires/power_electronics_connection.py +524 -0
  467. zepben/ewb/model/cim/iec61970/base/wires/power_electronics_connection_phase.py +34 -0
  468. zepben/ewb/model/cim/iec61970/base/wires/power_transformer.py +217 -0
  469. zepben/ewb/model/cim/iec61970/base/wires/power_transformer_end.py +208 -0
  470. zepben/ewb/model/cim/iec61970/base/wires/protected_switch.py +96 -0
  471. zepben/ewb/model/cim/iec61970/base/wires/ratio_tap_changer.py +30 -0
  472. zepben/ewb/model/cim/iec61970/base/wires/reactive_capability_curve.py +16 -0
  473. zepben/ewb/model/cim/iec61970/base/wires/recloser.py +15 -0
  474. zepben/ewb/model/cim/iec61970/base/wires/regulating_cond_eq.py +45 -0
  475. zepben/ewb/model/cim/iec61970/base/wires/regulating_control.py +173 -0
  476. zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py +46 -0
  477. zepben/ewb/model/cim/iec61970/base/wires/rotating_machine.py +36 -0
  478. zepben/ewb/model/cim/iec61970/base/wires/series_compensator.py +42 -0
  479. zepben/ewb/model/cim/iec61970/base/wires/shunt_compensator.py +59 -0
  480. zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py +105 -0
  481. zepben/ewb/model/cim/iec61970/base/wires/static_var_compensator.py +40 -0
  482. zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py +28 -0
  483. zepben/ewb/model/cim/iec61970/base/wires/switch.py +119 -0
  484. zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine.py +168 -0
  485. zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py +44 -0
  486. zepben/ewb/model/cim/iec61970/base/wires/tap_changer.py +150 -0
  487. zepben/ewb/model/cim/iec61970/base/wires/tap_changer_control.py +49 -0
  488. zepben/ewb/model/cim/iec61970/base/wires/transformer_end.py +73 -0
  489. zepben/ewb/model/cim/iec61970/base/wires/transformer_star_impedance.py +48 -0
  490. zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py +43 -0
  491. zepben/ewb/model/cim/iec61970/infiec61970/__init__.py +4 -0
  492. zepben/ewb/model/cim/iec61970/infiec61970/feeder/__init__.py +4 -0
  493. zepben/ewb/model/cim/iec61970/infiec61970/feeder/circuit.py +144 -0
  494. zepben/ewb/model/phases.py +168 -0
  495. zepben/ewb/model/resistance_reactance.py +40 -0
  496. zepben/ewb/services/__init__.py +4 -0
  497. zepben/ewb/services/common/__init__.py +16 -0
  498. zepben/ewb/services/common/base_service.py +383 -0
  499. zepben/ewb/services/common/base_service_comparator.py +394 -0
  500. zepben/ewb/services/common/difference.py +47 -0
  501. zepben/ewb/services/common/enum_mapper.py +55 -0
  502. zepben/ewb/services/common/meta/__init__.py +4 -0
  503. zepben/ewb/services/common/meta/data_source.py +16 -0
  504. zepben/ewb/services/common/meta/metadata_collection.py +28 -0
  505. zepben/ewb/services/common/meta/metadata_translations.py +47 -0
  506. zepben/ewb/services/common/meta/service_info.py +22 -0
  507. zepben/ewb/services/common/reference_resolvers.py +374 -0
  508. zepben/ewb/services/common/resolver.py +597 -0
  509. zepben/ewb/services/common/translator/__init__.py +4 -0
  510. zepben/ewb/services/common/translator/base_cim2proto.py +92 -0
  511. zepben/ewb/services/common/translator/base_proto2cim.py +112 -0
  512. zepben/ewb/services/common/translator/service_differences.py +81 -0
  513. zepben/ewb/services/common/translator/util.py +78 -0
  514. zepben/ewb/services/customer/__init__.py +4 -0
  515. zepben/ewb/services/customer/customer_service_comparator.py +52 -0
  516. zepben/ewb/services/customer/customers.py +23 -0
  517. zepben/ewb/services/customer/translator/__init__.py +21 -0
  518. zepben/ewb/services/customer/translator/customer_cim2proto.py +71 -0
  519. zepben/ewb/services/customer/translator/customer_enum_mappers.py +18 -0
  520. zepben/ewb/services/customer/translator/customer_proto2cim.py +87 -0
  521. zepben/ewb/services/diagram/__init__.py +4 -0
  522. zepben/ewb/services/diagram/diagram_service_comparator.py +39 -0
  523. zepben/ewb/services/diagram/diagrams.py +107 -0
  524. zepben/ewb/services/diagram/translator/__init__.py +11 -0
  525. zepben/ewb/services/diagram/translator/diagram_cim2proto.py +51 -0
  526. zepben/ewb/services/diagram/translator/diagram_enum_mappers.py +21 -0
  527. zepben/ewb/services/diagram/translator/diagram_proto2cim.py +61 -0
  528. zepben/ewb/services/measurement/__init__.py +4 -0
  529. zepben/ewb/services/measurement/measurements.py +35 -0
  530. zepben/ewb/services/measurement/translator/__init__.py +6 -0
  531. zepben/ewb/services/measurement/translator/measurement_cim2proto.py +42 -0
  532. zepben/ewb/services/measurement/translator/measurement_proto2cim.py +52 -0
  533. zepben/ewb/services/network/__init__.py +4 -0
  534. zepben/ewb/services/network/network_extensions.py +119 -0
  535. zepben/ewb/services/network/network_service.py +302 -0
  536. zepben/ewb/services/network/network_service_comparator.py +1322 -0
  537. zepben/ewb/services/network/network_state.py +34 -0
  538. zepben/ewb/services/network/tracing/__init__.py +4 -0
  539. zepben/ewb/services/network/tracing/busbranch_trace.py +36 -0
  540. zepben/ewb/services/network/tracing/connectivity/__init__.py +4 -0
  541. zepben/ewb/services/network/tracing/connectivity/connectivity_result.py +105 -0
  542. zepben/ewb/services/network/tracing/connectivity/nominal_phase_path.py +23 -0
  543. zepben/ewb/services/network/tracing/connectivity/phase_paths.py +70 -0
  544. zepben/ewb/services/network/tracing/connectivity/terminal_connectivity_connected.py +226 -0
  545. zepben/ewb/services/network/tracing/connectivity/terminal_connectivity_internal.py +64 -0
  546. zepben/ewb/services/network/tracing/connectivity/transformer_phase_paths.py +202 -0
  547. zepben/ewb/services/network/tracing/connectivity/xy_candidate_phase_paths.py +235 -0
  548. zepben/ewb/services/network/tracing/connectivity/xy_phase_step.py +24 -0
  549. zepben/ewb/services/network/tracing/feeder/__init__.py +4 -0
  550. zepben/ewb/services/network/tracing/feeder/assign_to_feeders.py +202 -0
  551. zepben/ewb/services/network/tracing/feeder/assign_to_lv_feeders.py +202 -0
  552. zepben/ewb/services/network/tracing/feeder/clear_direction.py +80 -0
  553. zepben/ewb/services/network/tracing/feeder/direction_status.py +133 -0
  554. zepben/ewb/services/network/tracing/feeder/feeder_direction.py +107 -0
  555. zepben/ewb/services/network/tracing/feeder/set_direction.py +143 -0
  556. zepben/ewb/services/network/tracing/find_swer_equipment.py +175 -0
  557. zepben/ewb/services/network/tracing/networktrace/__init__.py +4 -0
  558. zepben/ewb/services/network/tracing/networktrace/actions/__init__.py +4 -0
  559. zepben/ewb/services/network/tracing/networktrace/actions/equipment_tree_builder.py +71 -0
  560. zepben/ewb/services/network/tracing/networktrace/actions/tree_node.py +37 -0
  561. zepben/ewb/services/network/tracing/networktrace/compute_data.py +60 -0
  562. zepben/ewb/services/network/tracing/networktrace/conditions/__init__.py +4 -0
  563. zepben/ewb/services/network/tracing/networktrace/conditions/conditions.py +73 -0
  564. zepben/ewb/services/network/tracing/networktrace/conditions/direction_condition.py +63 -0
  565. zepben/ewb/services/network/tracing/networktrace/conditions/equipment_step_limit_condition.py +26 -0
  566. zepben/ewb/services/network/tracing/networktrace/conditions/equipment_type_step_limit_condition.py +44 -0
  567. zepben/ewb/services/network/tracing/networktrace/conditions/network_trace_queue_condition.py +67 -0
  568. zepben/ewb/services/network/tracing/networktrace/conditions/network_trace_stop_condition.py +65 -0
  569. zepben/ewb/services/network/tracing/networktrace/conditions/open_condition.py +39 -0
  570. zepben/ewb/services/network/tracing/networktrace/network_trace.py +450 -0
  571. zepben/ewb/services/network/tracing/networktrace/network_trace_action_type.py +42 -0
  572. zepben/ewb/services/network/tracing/networktrace/network_trace_queue_next.py +84 -0
  573. zepben/ewb/services/network/tracing/networktrace/network_trace_step.py +125 -0
  574. zepben/ewb/services/network/tracing/networktrace/network_trace_step_path_provider.py +351 -0
  575. zepben/ewb/services/network/tracing/networktrace/network_trace_tracker.py +39 -0
  576. zepben/ewb/services/network/tracing/networktrace/operators/__init__.py +14 -0
  577. zepben/ewb/services/network/tracing/networktrace/operators/equipment_container_state_operators.py +264 -0
  578. zepben/ewb/services/network/tracing/networktrace/operators/feeder_direction_state_operations.py +181 -0
  579. zepben/ewb/services/network/tracing/networktrace/operators/in_service_state_operators.py +76 -0
  580. zepben/ewb/services/network/tracing/networktrace/operators/network_state_operators.py +120 -0
  581. zepben/ewb/services/network/tracing/networktrace/operators/open_state_operators.py +104 -0
  582. zepben/ewb/services/network/tracing/networktrace/operators/phase_state_operators.py +56 -0
  583. zepben/ewb/services/network/tracing/networktrace/tracing.py +132 -0
  584. zepben/ewb/services/network/tracing/phases/__init__.py +4 -0
  585. zepben/ewb/services/network/tracing/phases/phase_inferrer.py +205 -0
  586. zepben/ewb/services/network/tracing/phases/phase_status.py +101 -0
  587. zepben/ewb/services/network/tracing/phases/remove_phases.py +143 -0
  588. zepben/ewb/services/network/tracing/phases/set_phases.py +490 -0
  589. zepben/ewb/services/network/tracing/traversal/__init__.py +4 -0
  590. zepben/ewb/services/network/tracing/traversal/context_value_computer.py +63 -0
  591. zepben/ewb/services/network/tracing/traversal/debug_logging.py +124 -0
  592. zepben/ewb/services/network/tracing/traversal/queue.py +112 -0
  593. zepben/ewb/services/network/tracing/traversal/queue_condition.py +75 -0
  594. zepben/ewb/services/network/tracing/traversal/step_action.py +83 -0
  595. zepben/ewb/services/network/tracing/traversal/step_context.py +59 -0
  596. zepben/ewb/services/network/tracing/traversal/stop_condition.py +57 -0
  597. zepben/ewb/services/network/tracing/traversal/traversal.py +634 -0
  598. zepben/ewb/services/network/tracing/traversal/traversal_condition.py +22 -0
  599. zepben/ewb/services/network/tracing/traversal/weighted_priority_queue.py +85 -0
  600. zepben/ewb/services/network/tracing/util.py +93 -0
  601. zepben/ewb/services/network/translator/__init__.py +392 -0
  602. zepben/ewb/services/network/translator/network_cim2proto.py +1782 -0
  603. zepben/ewb/services/network/translator/network_enum_mappers.py +78 -0
  604. zepben/ewb/services/network/translator/network_proto2cim.py +2147 -0
  605. zepben/ewb/services/services.py +48 -0
  606. zepben/ewb/streaming/__init__.py +4 -0
  607. zepben/ewb/streaming/data/__init__.py +4 -0
  608. zepben/ewb/streaming/data/current_state_event.py +314 -0
  609. zepben/ewb/streaming/data/current_state_event_batch.py +25 -0
  610. zepben/ewb/streaming/data/set_current_states_status.py +286 -0
  611. zepben/ewb/streaming/exceptions.py +14 -0
  612. zepben/ewb/streaming/get/__init__.py +4 -0
  613. zepben/ewb/streaming/get/consumer.py +209 -0
  614. zepben/ewb/streaming/get/customer_consumer.py +111 -0
  615. zepben/ewb/streaming/get/diagram_consumer.py +107 -0
  616. zepben/ewb/streaming/get/hierarchy/__init__.py +4 -0
  617. zepben/ewb/streaming/get/hierarchy/data.py +27 -0
  618. zepben/ewb/streaming/get/included_energized_containers.py +34 -0
  619. zepben/ewb/streaming/get/included_energizing_containers.py +34 -0
  620. zepben/ewb/streaming/get/network_consumer.py +870 -0
  621. zepben/ewb/streaming/get/query_network_state_client.py +64 -0
  622. zepben/ewb/streaming/get/query_network_state_service.py +94 -0
  623. zepben/ewb/streaming/grpc/__init__.py +4 -0
  624. zepben/ewb/streaming/grpc/auth_token_plugin.py +24 -0
  625. zepben/ewb/streaming/grpc/connect.py +209 -0
  626. zepben/ewb/streaming/grpc/grpc.py +107 -0
  627. zepben/ewb/streaming/grpc/grpc_channel_builder.py +185 -0
  628. zepben/ewb/streaming/mutations/__init__.py +4 -0
  629. zepben/ewb/streaming/mutations/update_network_state_client.py +80 -0
  630. zepben/ewb/streaming/mutations/update_network_state_service.py +61 -0
  631. zepben/ewb/testing/__init__.py +4 -0
  632. zepben/ewb/testing/test_network_builder.py +816 -0
  633. zepben/ewb/types.py +17 -0
  634. zepben/ewb/util.py +189 -0
  635. zepben_ewb-1.0.0b1.dist-info/METADATA +102 -0
  636. zepben_ewb-1.0.0b1.dist-info/RECORD +639 -0
  637. zepben_ewb-1.0.0b1.dist-info/WHEEL +5 -0
  638. zepben_ewb-1.0.0b1.dist-info/licenses/LICENSE +374 -0
  639. zepben_ewb-1.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3167 @@
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__ = ["NetworkCimReader"]
7
+
8
+ import sys
9
+ from typing import Callable, Optional
10
+
11
+ from zepben.ewb.database.sqlite.tables.associations.table_battery_units_battery_controls import TableBatteryUnitsBatteryControls
12
+ from zepben.ewb.database.sqlite.tables.associations.table_end_devices_end_device_functions import TableEndDevicesEndDeviceFunctions
13
+ from zepben.ewb.database.sqlite.tables.associations.table_synchronous_machines_reactive_capability_curves import \
14
+ TableSynchronousMachinesReactiveCapabilityCurves
15
+ from zepben.ewb.database.sqlite.tables.extensions.iec61968.metering.table_pan_demand_response_functions import TablePanDemandResponseFunctions
16
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.wires.table_battery_controls import TableBatteryControls
17
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_asset_functions import TableAssetFunctions
18
+ from zepben.ewb.database.sqlite.tables.iec61968.metering.table_end_device_functions import TableEndDeviceFunctions
19
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_curve_data import TableCurveData
20
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_curves import TableCurves
21
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_earth_fault_compensators import TableEarthFaultCompensators
22
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_grounding_impedances import TableGroundingImpedances
23
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_per_length_phase_impedances import TablePerLengthPhaseImpedances
24
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_petersen_coils import TablePetersenCoils
25
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_phase_impedance_data import TablePhaseImpedanceData
26
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_reactive_capability_curves import TableReactiveCapabilityCurves
27
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_rotating_machines import TableRotatingMachines
28
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_static_var_compensator import TableStaticVarCompensators
29
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_synchronous_machines import TableSynchronousMachines
30
+ from zepben.ewb.model.cim.extensions.iec61968.metering.pan_demand_reponse_function import PanDemandResponseFunction
31
+ from zepben.ewb.model.cim.extensions.iec61970.base.wires.battery_control import BatteryControl
32
+ from zepben.ewb.model.cim.extensions.iec61970.base.wires.battery_control_mode import BatteryControlMode
33
+ from zepben.ewb.model.cim.iec61968.assets.asset_function import AssetFunction
34
+ from zepben.ewb.model.cim.iec61968.metering.end_device_function_kind import EndDeviceFunctionKind
35
+ from zepben.ewb.model.cim.iec61970.base.core.curve import Curve
36
+ from zepben.ewb.model.cim.iec61970.base.wires.earth_fault_compensator import EarthFaultCompensator
37
+ from zepben.ewb.model.cim.iec61970.base.wires.grounding_impedance import GroundingImpedance
38
+ from zepben.ewb.model.cim.iec61970.base.wires.per_length_phase_impedance import PerLengthPhaseImpedance
39
+ from zepben.ewb.model.cim.iec61970.base.wires.petersen_coil import PetersenCoil
40
+ from zepben.ewb.model.cim.iec61970.base.wires.phase_impedance_data import PhaseImpedanceData
41
+ from zepben.ewb.model.cim.iec61970.base.wires.reactive_capability_curve import ReactiveCapabilityCurve
42
+ from zepben.ewb.model.cim.iec61970.base.wires.rotating_machine import RotatingMachine
43
+ from zepben.ewb.model.cim.iec61970.base.wires.static_var_compensator import StaticVarCompensator
44
+ from zepben.ewb.model.cim.iec61970.base.wires.svc_control_mode import SVCControlMode
45
+ from zepben.ewb.model.cim.iec61970.base.wires.synchronous_machine import SynchronousMachine
46
+ from zepben.ewb.model.cim.iec61970.base.wires.synchronous_machine_kind import SynchronousMachineKind
47
+
48
+ # `assert_never` changed packages with the release of 3.11, so import it from the old spot while we still support 3.9 and 3.10.
49
+ v = sys.version_info
50
+ if v.major == 3 and v.minor < 11:
51
+ from typing_extensions import assert_never
52
+ else:
53
+ from typing import assert_never
54
+
55
+ from zepben.ewb.database.sqlite.common.base_cim_reader import BaseCimReader
56
+ from zepben.ewb.database.sqlite.extensions.result_set import ResultSet
57
+ from zepben.ewb.database.sqlite.tables.associations.loop_substation_relationship import LoopSubstationRelationship
58
+ from zepben.ewb.database.sqlite.tables.associations.table_asset_organisation_roles_assets import TableAssetOrganisationRolesAssets
59
+ from zepben.ewb.database.sqlite.tables.associations.table_assets_power_system_resources import TableAssetsPowerSystemResources
60
+ from zepben.ewb.database.sqlite.tables.associations.table_circuits_substations import TableCircuitsSubstations
61
+ from zepben.ewb.database.sqlite.tables.associations.table_circuits_terminals import TableCircuitsTerminals
62
+ from zepben.ewb.database.sqlite.tables.associations.table_equipment_equipment_containers import TableEquipmentEquipmentContainers
63
+ from zepben.ewb.database.sqlite.tables.associations.table_equipment_operational_restrictions import TableEquipmentOperationalRestrictions
64
+ from zepben.ewb.database.sqlite.tables.associations.table_equipment_usage_points import TableEquipmentUsagePoints
65
+ from zepben.ewb.database.sqlite.tables.associations.table_loops_substations import TableLoopsSubstations
66
+ from zepben.ewb.database.sqlite.tables.associations.table_protection_relay_functions_protected_switches import TableProtectionRelayFunctionsProtectedSwitches
67
+ from zepben.ewb.database.sqlite.tables.associations.table_protection_relay_functions_sensors import TableProtectionRelayFunctionsSensors
68
+ from zepben.ewb.database.sqlite.tables.associations.table_protection_relay_schemes_protection_relay_functions import \
69
+ TableProtectionRelaySchemesProtectionRelayFunctions
70
+ from zepben.ewb.database.sqlite.tables.associations.table_usage_points_end_devices import TableUsagePointsEndDevices
71
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_cable_info import TableCableInfo
72
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_no_load_tests import TableNoLoadTests
73
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_open_circuit_tests import TableOpenCircuitTests
74
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_overhead_wire_info import TableOverheadWireInfo
75
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_power_transformer_info import TablePowerTransformerInfo
76
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_short_circuit_tests import TableShortCircuitTests
77
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_shunt_compensator_info import TableShuntCompensatorInfo
78
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_switch_info import TableSwitchInfo
79
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_transformer_end_info import TableTransformerEndInfo
80
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_transformer_tank_info import TableTransformerTankInfo
81
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_transformer_test import TableTransformerTest
82
+ from zepben.ewb.database.sqlite.tables.iec61968.assetinfo.table_wire_info import TableWireInfo
83
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_asset_containers import TableAssetContainers
84
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_asset_info import TableAssetInfo
85
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_asset_organisation_roles import TableAssetOrganisationRoles
86
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_asset_owners import TableAssetOwners
87
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_assets import TableAssets
88
+ from zepben.ewb.database.sqlite.tables.iec61968.infiec61968.infassets.table_poles import TablePoles
89
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_streetlights import TableStreetlights
90
+ from zepben.ewb.database.sqlite.tables.iec61968.assets.table_structures import TableStructures
91
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_location_street_address_field import TableLocationStreetAddressField
92
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_location_street_addresses import TableLocationStreetAddresses
93
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_locations import TableLocations
94
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_position_points import TablePositionPoints
95
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_street_addresses import TableStreetAddresses
96
+ from zepben.ewb.database.sqlite.tables.iec61968.common.table_town_details import TableTownDetails
97
+ from zepben.ewb.database.sqlite.tables.iec61968.infiec61968.infassetinfo.table_current_transformer_info import TableCurrentTransformerInfo
98
+ from zepben.ewb.database.sqlite.tables.iec61968.infiec61968.infassetinfo.table_potential_transformer_info import TablePotentialTransformerInfo
99
+ from zepben.ewb.database.sqlite.tables.extensions.iec61968.assetinfo.table_reclose_delays import TableRecloseDelays
100
+ from zepben.ewb.database.sqlite.tables.extensions.iec61968.assetinfo.table_relay_info import TableRelayInfo
101
+ from zepben.ewb.database.sqlite.tables.iec61968.metering.table_end_devices import TableEndDevices
102
+ from zepben.ewb.database.sqlite.tables.iec61968.metering.table_meters import TableMeters
103
+ from zepben.ewb.database.sqlite.tables.iec61968.metering.table_usage_points import TableUsagePoints
104
+ from zepben.ewb.database.sqlite.tables.iec61968.operations.table_operational_restrictions import TableOperationalRestrictions
105
+ from zepben.ewb.database.sqlite.tables.iec61970.base.auxiliaryequipment.table_auxiliary_equipment import TableAuxiliaryEquipment
106
+ from zepben.ewb.database.sqlite.tables.iec61970.base.auxiliaryequipment.table_current_transformers import TableCurrentTransformers
107
+ from zepben.ewb.database.sqlite.tables.iec61970.base.auxiliaryequipment.table_fault_indicators import TableFaultIndicators
108
+ from zepben.ewb.database.sqlite.tables.iec61970.base.auxiliaryequipment.table_potential_transformers import TablePotentialTransformers
109
+ from zepben.ewb.database.sqlite.tables.iec61970.base.auxiliaryequipment.table_sensors import TableSensors
110
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_ac_dc_terminals import TableAcDcTerminals
111
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_base_voltages import TableBaseVoltages
112
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_conducting_equipment import TableConductingEquipment
113
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_connectivity_node_containers import TableConnectivityNodeContainers
114
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_connectivity_nodes import TableConnectivityNodes
115
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_equipment import TableEquipment
116
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_equipment_containers import TableEquipmentContainers
117
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_feeders import TableFeeders
118
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_geographical_regions import TableGeographicalRegions
119
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_power_system_resources import TablePowerSystemResources
120
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.core.table_sites import TableSites
121
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_sub_geographical_regions import TableSubGeographicalRegions
122
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_substations import TableSubstations
123
+ from zepben.ewb.database.sqlite.tables.iec61970.base.core.table_terminals import TableTerminals
124
+ from zepben.ewb.database.sqlite.tables.iec61970.base.equivalents.table_equivalent_branches import TableEquivalentBranches
125
+ from zepben.ewb.database.sqlite.tables.iec61970.base.equivalents.table_equivalent_equipment import TableEquivalentEquipment
126
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_accumulators import TableAccumulators
127
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_analogs import TableAnalogs
128
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_controls import TableControls
129
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_discretes import TableDiscretes
130
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_io_points import TableIoPoints
131
+ from zepben.ewb.database.sqlite.tables.iec61970.base.meas.table_measurements import TableMeasurements
132
+ from zepben.ewb.database.sqlite.tables.iec61970.base.protection.table_current_relays import TableCurrentRelays
133
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_distance_relays import TableDistanceRelays
134
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_protection_relay_function_thresholds import \
135
+ TableProtectionRelayFunctionThresholds
136
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_protection_relay_function_time_limits import \
137
+ TableProtectionRelayFunctionTimeLimits
138
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_protection_relay_functions import TableProtectionRelayFunctions
139
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_protection_relay_schemes import TableProtectionRelaySchemes
140
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_protection_relay_systems import TableProtectionRelaySystems
141
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.protection.table_voltage_relays import TableVoltageRelays
142
+ from zepben.ewb.database.sqlite.tables.iec61970.base.scada.table_remote_controls import TableRemoteControls
143
+ from zepben.ewb.database.sqlite.tables.iec61970.base.scada.table_remote_points import TableRemotePoints
144
+ from zepben.ewb.database.sqlite.tables.iec61970.base.scada.table_remote_sources import TableRemoteSources
145
+ from zepben.ewb.database.sqlite.tables.iec61970.base.generation.production.table_battery_units import TableBatteryUnits
146
+ from zepben.ewb.database.sqlite.tables.iec61970.base.generation.production.table_photo_voltaic_units import TablePhotoVoltaicUnits
147
+ from zepben.ewb.database.sqlite.tables.iec61970.base.generation.production.table_power_electronics_units import TablePowerElectronicsUnits
148
+ from zepben.ewb.database.sqlite.tables.iec61970.base.generation.production.table_power_electronics_wind_units import TablePowerElectronicsWindUnits
149
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_ac_line_segments import TableAcLineSegments
150
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_breakers import TableBreakers
151
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_busbar_sections import TableBusbarSections
152
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_clamps import TableClamps
153
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_conductors import TableConductors
154
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_connectors import TableConnectors
155
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_cuts import TableCuts
156
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_disconnectors import TableDisconnectors
157
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_energy_connections import TableEnergyConnections
158
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_energy_consumer_phases import TableEnergyConsumerPhases
159
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_energy_consumers import TableEnergyConsumers
160
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_energy_source_phases import TableEnergySourcePhases
161
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_energy_sources import TableEnergySources
162
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_fuses import TableFuses
163
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_ground_disconnectors import TableGroundDisconnectors
164
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_grounds import TableGrounds
165
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_jumpers import TableJumpers
166
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_junctions import TableJunctions
167
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_linear_shunt_compensators import TableLinearShuntCompensators
168
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_lines import TableLines
169
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_load_break_switches import TableLoadBreakSwitches
170
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_per_length_impedances import TablePerLengthImpedances
171
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_per_length_line_parameters import TablePerLengthLineParameters
172
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_per_length_sequence_impedances import TablePerLengthSequenceImpedances
173
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_power_electronics_connection_phases import TablePowerElectronicsConnectionPhases
174
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_power_electronics_connections import TablePowerElectronicsConnections
175
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.wires.table_power_transformer_end_ratings import TablePowerTransformerEndRatings
176
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_power_transformer_ends import TablePowerTransformerEnds
177
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_power_transformers import TablePowerTransformers
178
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_protected_switches import TableProtectedSwitches
179
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_ratio_tap_changers import TableRatioTapChangers
180
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_reclosers import TableReclosers
181
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_regulating_cond_eq import TableRegulatingCondEq
182
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_regulating_controls import TableRegulatingControls
183
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_series_compensators import TableSeriesCompensators
184
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_shunt_compensators import TableShuntCompensators
185
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_switches import TableSwitches
186
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_tap_changer_controls import TableTapChangerControls
187
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_tap_changers import TableTapChangers
188
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_transformer_ends import TableTransformerEnds
189
+ from zepben.ewb.database.sqlite.tables.iec61970.base.wires.table_transformer_star_impedances import TableTransformerStarImpedances
190
+ from zepben.ewb.database.sqlite.tables.iec61970.infiec61970.feeder.table_circuits import TableCircuits
191
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.feeder.table_loops import TableLoops
192
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.feeder.table_lv_feeders import TableLvFeeders
193
+ from zepben.ewb.database.sqlite.tables.extensions.iec61970.base.generation.production.table_ev_charging_units import TableEvChargingUnits
194
+ from zepben.ewb.model.cim.iec61968.assetinfo.no_load_test import NoLoadTest
195
+ from zepben.ewb.model.cim.iec61968.assetinfo.open_circuit_test import OpenCircuitTest
196
+ from zepben.ewb.model.cim.iec61968.assetinfo.power_transformer_info import PowerTransformerInfo
197
+ from zepben.ewb.model.cim.iec61968.assetinfo.short_circuit_test import ShortCircuitTest
198
+ from zepben.ewb.model.cim.iec61968.assetinfo.shunt_compensator_info import ShuntCompensatorInfo
199
+ from zepben.ewb.model.cim.iec61968.assetinfo.switch_info import SwitchInfo
200
+ from zepben.ewb.model.cim.iec61968.assetinfo.transformer_end_info import TransformerEndInfo
201
+ from zepben.ewb.model.cim.iec61968.assetinfo.transformer_tank_info import TransformerTankInfo
202
+ from zepben.ewb.model.cim.iec61968.assetinfo.transformer_test import TransformerTest
203
+ from zepben.ewb.model.cim.iec61968.assetinfo.wire_info import WireInfo
204
+ from zepben.ewb.model.cim.iec61968.assetinfo.overhead_wire_info import OverheadWireInfo
205
+ from zepben.ewb.model.cim.iec61968.assetinfo.cable_info import CableInfo
206
+ from zepben.ewb.model.cim.iec61968.assetinfo.wire_material_kind import WireMaterialKind
207
+ from zepben.ewb.model.cim.iec61968.assets.asset import Asset
208
+ from zepben.ewb.model.cim.iec61968.assets.asset_container import AssetContainer
209
+ from zepben.ewb.model.cim.iec61968.assets.asset_info import AssetInfo
210
+ from zepben.ewb.model.cim.iec61968.assets.asset_organisation_role import AssetOrganisationRole
211
+ from zepben.ewb.model.cim.iec61968.assets.asset_owner import AssetOwner
212
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassets.pole import Pole
213
+ from zepben.ewb.model.cim.iec61968.assets.streetlight import Streetlight
214
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassets.streetlight_lamp_kind import StreetlightLampKind
215
+ from zepben.ewb.model.cim.iec61968.assets.structure import Structure
216
+ from zepben.ewb.model.cim.iec61968.common.location import Location
217
+ from zepben.ewb.model.cim.iec61968.common.street_address import StreetAddress
218
+ from zepben.ewb.model.cim.iec61968.common.street_detail import StreetDetail
219
+ from zepben.ewb.model.cim.iec61968.common.town_detail import TownDetail
220
+ from zepben.ewb.model.cim.iec61968.common.position_point import PositionPoint
221
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassetinfo.current_transformer_info import CurrentTransformerInfo
222
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassetinfo.potential_transformer_info import PotentialTransformerInfo
223
+ from zepben.ewb.model.cim.extensions.iec61968.assetinfo.relay_info import RelayInfo
224
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassetinfo.transformer_construction_kind import TransformerConstructionKind
225
+ from zepben.ewb.model.cim.iec61968.infiec61968.infassetinfo.transformer_function_kind import TransformerFunctionKind
226
+ from zepben.ewb.model.cim.iec61968.metering.end_device_function import EndDeviceFunction
227
+ from zepben.ewb.model.cim.iec61968.metering.meter import Meter
228
+ from zepben.ewb.model.cim.iec61968.metering.usage_point import UsagePoint
229
+ from zepben.ewb.model.cim.iec61968.metering.end_device import EndDevice
230
+ from zepben.ewb.model.cim.iec61968.operations.operational_restriction import OperationalRestriction
231
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.auxiliary_equipment import AuxiliaryEquipment
232
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.fault_indicator import FaultIndicator
233
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.current_transformer import CurrentTransformer
234
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.potential_transformer import PotentialTransformer
235
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.potential_transformer_kind import PotentialTransformerKind
236
+ from zepben.ewb.model.cim.iec61970.base.auxiliaryequipment.sensor import Sensor
237
+ from zepben.ewb.model.cim.iec61970.base.core.base_voltage import BaseVoltage
238
+ from zepben.ewb.model.cim.iec61970.base.core.conducting_equipment import ConductingEquipment
239
+ from zepben.ewb.model.cim.iec61970.base.core.connectivity_node import ConnectivityNode
240
+ from zepben.ewb.model.cim.iec61970.base.core.connectivity_node_container import ConnectivityNodeContainer
241
+ from zepben.ewb.model.cim.iec61970.base.core.equipment import Equipment
242
+ from zepben.ewb.model.cim.iec61970.base.core.equipment_container import EquipmentContainer
243
+ from zepben.ewb.model.cim.extensions.iec61970.base.core.site import Site
244
+ from zepben.ewb.model.cim.iec61970.base.core.feeder import Feeder
245
+ from zepben.ewb.model.cim.iec61970.base.core.phase_code import PhaseCode
246
+ from zepben.ewb.model.cim.iec61970.base.core.power_system_resource import PowerSystemResource
247
+ from zepben.ewb.model.cim.iec61970.base.core.sub_geographical_region import SubGeographicalRegion
248
+ from zepben.ewb.model.cim.iec61970.base.core.geographical_region import GeographicalRegion
249
+ from zepben.ewb.model.cim.iec61970.base.core.substation import Substation
250
+ from zepben.ewb.model.cim.iec61970.base.core.terminal import Terminal
251
+ from zepben.ewb.model.cim.iec61970.base.core.ac_dc_terminal import AcDcTerminal
252
+ from zepben.ewb.model.cim.iec61970.base.domain.unit_symbol import UnitSymbol
253
+ from zepben.ewb.model.cim.iec61970.base.equivalents.equivalent_branch import EquivalentBranch
254
+ from zepben.ewb.model.cim.iec61970.base.equivalents.equivalent_equipment import EquivalentEquipment
255
+ from zepben.ewb.model.cim.iec61970.base.meas.control import Control
256
+ from zepben.ewb.model.cim.iec61970.base.meas.iopoint import IoPoint
257
+ from zepben.ewb.model.cim.iec61970.base.meas.measurement import Measurement
258
+ from zepben.ewb.model.cim.iec61970.base.meas.discrete import Discrete
259
+ from zepben.ewb.model.cim.iec61970.base.meas.analog import Analog
260
+ from zepben.ewb.model.cim.iec61970.base.meas.accumulator import Accumulator
261
+ from zepben.ewb.model.cim.iec61970.base.protection.current_relay import CurrentRelay
262
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.distance_relay import DistanceRelay
263
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.protection_relay_function import ProtectionRelayFunction
264
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.protection_relay_scheme import ProtectionRelayScheme
265
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.protection_relay_system import ProtectionRelaySystem
266
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.relay_setting import RelaySetting
267
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.voltage_relay import VoltageRelay
268
+ from zepben.ewb.model.cim.iec61970.base.scada.remote_control import RemoteControl
269
+ from zepben.ewb.model.cim.iec61970.base.scada.remote_point import RemotePoint
270
+ from zepben.ewb.model.cim.iec61970.base.scada.remote_source import RemoteSource
271
+ from zepben.ewb.model.cim.iec61970.base.wires.ac_line_segment import AcLineSegment
272
+ from zepben.ewb.model.cim.iec61970.base.wires.conductor import Conductor
273
+ from zepben.ewb.model.cim.iec61970.base.wires.breaker import Breaker
274
+ from zepben.ewb.model.cim.iec61970.base.wires.connector import Connector
275
+ from zepben.ewb.model.cim.iec61970.base.wires.junction import Junction
276
+ from zepben.ewb.model.cim.iec61970.base.wires.busbar_section import BusbarSection
277
+ from zepben.ewb.model.cim.iec61970.base.wires.clamp import Clamp
278
+ from zepben.ewb.model.cim.iec61970.base.wires.cut import Cut
279
+ from zepben.ewb.model.cim.iec61970.base.wires.disconnector import Disconnector
280
+ from zepben.ewb.model.cim.iec61970.base.wires.energy_connection import EnergyConnection
281
+ from zepben.ewb.model.cim.iec61970.base.wires.regulating_cond_eq import RegulatingCondEq
282
+ from zepben.ewb.model.cim.iec61970.base.wires.energy_consumer import EnergyConsumer
283
+ from zepben.ewb.model.cim.iec61970.base.wires.energy_consumer_phase import EnergyConsumerPhase
284
+ from zepben.ewb.model.cim.iec61970.base.wires.energy_source import EnergySource
285
+ from zepben.ewb.model.cim.iec61970.base.wires.energy_source_phase import EnergySourcePhase
286
+ from zepben.ewb.model.cim.iec61970.base.wires.fuse import Fuse
287
+ from zepben.ewb.model.cim.iec61970.base.generation.production.battery_state_kind import BatteryStateKind
288
+ from zepben.ewb.model.cim.iec61970.base.generation.production.battery_unit import BatteryUnit
289
+ from zepben.ewb.model.cim.iec61970.base.generation.production.photo_voltaic_unit import PhotoVoltaicUnit
290
+ from zepben.ewb.model.cim.iec61970.base.generation.production.power_electronics_unit import PowerElectronicsUnit
291
+ from zepben.ewb.model.cim.iec61970.base.generation.production.power_electronics_wind_unit import PowerElectronicsWindUnit
292
+ from zepben.ewb.model.cim.iec61970.base.wires.ground import Ground
293
+ from zepben.ewb.model.cim.iec61970.base.wires.ground_disconnector import GroundDisconnector
294
+ from zepben.ewb.model.cim.iec61970.base.wires.jumper import Jumper
295
+ from zepben.ewb.model.cim.iec61970.base.wires.line import Line
296
+ from zepben.ewb.model.cim.iec61970.base.wires.load_break_switch import LoadBreakSwitch
297
+ from zepben.ewb.model.cim.iec61970.base.wires.per_length_sequence_impedance import PerLengthSequenceImpedance
298
+ from zepben.ewb.model.cim.iec61970.base.wires.per_length_impedance import PerLengthImpedance
299
+ from zepben.ewb.model.cim.iec61970.base.wires.per_length_line_parameter import PerLengthLineParameter
300
+ from zepben.ewb.model.cim.iec61970.base.wires.phase_shunt_connection_kind import PhaseShuntConnectionKind
301
+ from zepben.ewb.model.cim.iec61970.base.wires.power_electronics_connection import PowerElectronicsConnection
302
+ from zepben.ewb.model.cim.iec61970.base.wires.power_electronics_connection_phase import PowerElectronicsConnectionPhase
303
+ from zepben.ewb.model.cim.iec61970.base.wires.power_transformer import PowerTransformer
304
+ from zepben.ewb.model.cim.iec61970.base.wires.power_transformer_end import PowerTransformerEnd
305
+ from zepben.ewb.model.cim.iec61970.base.wires.transformer_end import TransformerEnd
306
+ from zepben.ewb.model.cim.iec61970.base.wires.ratio_tap_changer import RatioTapChanger
307
+ from zepben.ewb.model.cim.iec61970.base.wires.tap_changer import TapChanger
308
+ from zepben.ewb.model.cim.iec61970.base.wires.protected_switch import ProtectedSwitch
309
+ from zepben.ewb.model.cim.iec61970.base.wires.recloser import Recloser
310
+ from zepben.ewb.model.cim.iec61970.base.wires.regulating_control import RegulatingControl
311
+ from zepben.ewb.model.cim.iec61970.base.wires.regulating_control_mode_kind import RegulatingControlModeKind
312
+ from zepben.ewb.model.cim.iec61970.base.wires.series_compensator import SeriesCompensator
313
+ from zepben.ewb.model.cim.iec61970.base.wires.shunt_compensator import ShuntCompensator
314
+ from zepben.ewb.model.cim.iec61970.base.wires.linear_shunt_compensator import LinearShuntCompensator
315
+ from zepben.ewb.model.cim.iec61970.base.wires.single_phase_kind import SinglePhaseKind
316
+ from zepben.ewb.model.cim.iec61970.base.wires.switch import Switch
317
+ from zepben.ewb.model.cim.iec61970.base.wires.tap_changer_control import TapChangerControl
318
+ from zepben.ewb.model.cim.extensions.iec61970.base.wires.transformer_cooling_type import TransformerCoolingType
319
+ from zepben.ewb.model.cim.iec61970.base.wires.transformer_star_impedance import TransformerStarImpedance
320
+ from zepben.ewb.model.cim.extensions.iec61970.base.wires.vector_group import VectorGroup
321
+ from zepben.ewb.model.cim.iec61970.base.wires.winding_connection import WindingConnection
322
+ from zepben.ewb.model.cim.iec61970.infiec61970.feeder.circuit import Circuit
323
+ from zepben.ewb.model.cim.extensions.iec61970.base.feeder.loop import Loop
324
+ from zepben.ewb.model.cim.extensions.iec61970.base.feeder.lv_feeder import LvFeeder
325
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.power_direction_kind import PowerDirectionKind
326
+ from zepben.ewb.model.cim.extensions.iec61970.base.protection.protection_kind import ProtectionKind
327
+ from zepben.ewb.model.cim.extensions.iec61970.base.generation.production.ev_charging_unit import EvChargingUnit
328
+ from zepben.ewb.services.common import resolver
329
+ from zepben.ewb.services.network.network_service import NetworkService
330
+
331
+
332
+ class NetworkCimReader(BaseCimReader):
333
+ """
334
+ A class for reading the :class:`NetworkService` tables from the database.
335
+
336
+ :param service: The :class:`NetworkService` to populate from the database.
337
+ """
338
+
339
+ def __init__(self, service: NetworkService):
340
+ super().__init__(service)
341
+
342
+ self._service = service
343
+ """The :class:`NetworkService` used to store any items read from the database."""
344
+
345
+ ##################################
346
+ # Extensions IEC61968 Asset Info #
347
+ ##################################
348
+
349
+ def load_reclose_delay(self, table: TableRecloseDelays, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
350
+ """
351
+ Adds a delay to a :class:`RelayInfo` and populate its fields from :class:`TableRecloseDelays`.
352
+
353
+ :param table: The database table to read the delay fields from.
354
+ :param result_set: The record in the database table containing the fields for this delay.
355
+ :param set_identifier: A callback to register the mRID of this delay for logging purposes.
356
+
357
+ :return: True if the delay was successfully read from the database and added to the service.
358
+ :raises SqlException: For any errors encountered reading from the database.
359
+ """
360
+ # Note TableRecloseDelays.selectSql ensures we process ratings in the correct order.
361
+ relay_info_mrid = result_set.get_string(table.relay_info_mrid.query_index)
362
+ reclose_delay = result_set.get_float(table.reclose_delay.query_index)
363
+ set_identifier(f"{relay_info_mrid}.s{reclose_delay}")
364
+
365
+ cri = self._ensure_get(relay_info_mrid, RelayInfo)
366
+ if cri:
367
+ cri.add_delay(reclose_delay)
368
+
369
+ return True
370
+
371
+ def load_relay_info(self, table: TableRelayInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
372
+ """
373
+ Create a :class:`RelayInfo` and populate its fields from :class:`TableRelayInfo`.
374
+
375
+ :param table: The database table to read the :class:`RelayInfo` fields from.
376
+ :param result_set: The record in the database table containing the fields for this :class:`RelayInfo`.
377
+ :param set_identifier: A callback to register the mRID of this :class:`RelayInfo` for logging purposes.
378
+
379
+ :return: True if the :class:`RelayInfo` was successfully read from the database and added to the service.
380
+ :raises SqlException: For any errors encountered reading from the database.
381
+ """
382
+ relay_info = RelayInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
383
+
384
+ relay_info.curve_setting = result_set.get_string(table.curve_setting.query_index, on_none=None)
385
+ relay_info.reclose_fast = result_set.get_boolean(table.reclose_fast.query_index, on_none=None)
386
+
387
+ return self._load_asset_info(relay_info, table, result_set) and self._add_or_throw(relay_info)
388
+
389
+ ################################
390
+ # Extensions IEC61968 Metering #
391
+ ################################
392
+
393
+ def load_pan_demand_response_function(self, table: TablePanDemandResponseFunctions, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
394
+ """
395
+ Create a :class:`PanDemandResponseFunction` and populate its fields from :class:`TablePanDemandResponseFunctions`.
396
+
397
+ :param table: The database table to read the :class:`PanDemandResponseFunction` fields from.
398
+ :param result_set: The record in the database table containing the fields for this :class:`PanDemandResponseFunction`.
399
+ :param set_identifier: A callback to register the mRID of this :class:`PanDemandResponseFunction` for logging purposes.
400
+
401
+ :return: True if the :class:`PanDemandResponseFunction` was successfully read from the database and added to the service.
402
+ :raises SqlException: For any errors encountered reading from the database.
403
+ """
404
+ pan_demand_response_function = PanDemandResponseFunction(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
405
+
406
+ pan_demand_response_function.kind = EndDeviceFunctionKind[result_set.get_string(table.kind.query_index)]
407
+ pan_demand_response_function._appliance_bitmask = result_set.get_int(table.appliance.query_index, on_none=None)
408
+
409
+ return self._load_end_device_functions(pan_demand_response_function, table, result_set) and self._add_or_throw(pan_demand_response_function)
410
+
411
+ #################################
412
+ # Extensions IEC61970 Base Core #
413
+ #################################
414
+
415
+ def load_site(self, table: TableSites, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
416
+ """
417
+ Create a :class:`Site` and populate its fields from :class:`TableSites`.
418
+
419
+ :param table: The database table to read the :class:`Site` fields from.
420
+ :param result_set: The record in the database table containing the fields for this :class:`Site`.
421
+ :param set_identifier: A callback to register the mRID of this :class:`Site` for logging purposes.
422
+
423
+ :return: True if the :class:`Site` was successfully read from the database and added to the service.
424
+ :raises SqlException: For any errors encountered reading from the database.
425
+ """
426
+ site = Site(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
427
+
428
+ return self._load_equipment_container(site, table, result_set) and self._add_or_throw(site)
429
+
430
+ ###################################
431
+ # Extensions IEC61970 Base Feeder #
432
+ ###################################
433
+
434
+ def load_loop(self, table: TableLoops, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
435
+ """
436
+ Create a :class:`Loop` and populate its fields from :class:`TableLoops`.
437
+
438
+ :param table: The database table to read the :class:`Loop` fields from.
439
+ :param result_set: The record in the database table containing the fields for this :class:`Loop`.
440
+ :param set_identifier: A callback to register the mRID of this :class:`Loop` for logging purposes.
441
+
442
+ :return: True if the :class:`Loop` was successfully read from the database and added to the service.
443
+ :raises SqlException: For any errors encountered reading from the database.
444
+ """
445
+ loop = Loop(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
446
+
447
+ return self._load_identified_object(loop, table, result_set) and self._add_or_throw(loop)
448
+
449
+ def load_lv_feeder(self, table: TableLvFeeders, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
450
+ """
451
+ Create a :class:`LvFeeder` and populate its fields from :class:`TableLvFeeders`.
452
+
453
+ :param table: The database table to read the :class:`LvFeeder` fields from.
454
+ :param result_set: The record in the database table containing the fields for this :class:`LvFeeder`.
455
+ :param set_identifier: A callback to register the mRID of this :class:`LvFeeder` for logging purposes.
456
+
457
+ :return: True if the :class:`LvFeeder` was successfully read from the database and added to the service.
458
+ :raises SqlException: For any errors encountered reading from the database.
459
+ """
460
+ lv_feeder = LvFeeder(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
461
+
462
+ lv_feeder.normal_head_terminal = self._ensure_get(
463
+ result_set.get_string(table.normal_head_terminal_mrid.query_index, on_none=None),
464
+ Terminal
465
+ )
466
+
467
+ return self._load_equipment_container(lv_feeder, table, result_set) and self._add_or_throw(lv_feeder)
468
+
469
+ ##################################################
470
+ # Extensions IEC61970 Base Generation Production #
471
+ ##################################################
472
+
473
+ def load_ev_charging_unit(self, table: TableEvChargingUnits, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
474
+ """
475
+ Create an :class:`EvChargingUnit` and populate its fields from :class:`TableEvChargingUnits`.
476
+
477
+ :param table: The database table to read the :class:`EvChargingUnit` fields from.
478
+ :param result_set: The record in the database table containing the fields for this :class:`EvChargingUnit`.
479
+ :param set_identifier: A callback to register the mRID of this :class:`EvChargingUnit` for logging purposes.
480
+
481
+ :return: True if the :class:`EvChargingUnit` was successfully read from the database and added to the service.
482
+ :raises SqlException: For any errors encountered reading from the database.
483
+ """
484
+ ev_charging_unit = EvChargingUnit(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
485
+
486
+ return self._load_power_electronics_unit(ev_charging_unit, table, result_set) and self._add_or_throw(ev_charging_unit)
487
+
488
+ #######################################
489
+ # Extensions IEC61970 Base Protection #
490
+ #######################################
491
+
492
+ def load_distance_relay(self, table: TableDistanceRelays, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
493
+ """
494
+ Create a :class:`DistanceRelay` and populate its fields from :class:`TableDistanceRelays`.
495
+
496
+ :param table: The database table to read the :class:`DistanceRelay` fields from.
497
+ :param result_set: The record in the database table containing the fields for this :class:`DistanceRelay`.
498
+ :param set_identifier: A callback to register the mRID of this :class:`DistanceRelay` for logging purposes.
499
+
500
+ :return: True if the :class:`DistanceRelay` was successfully read from the database and added to the service.
501
+ :raises SqlException: For any errors encountered reading from the database.
502
+ """
503
+ distance_relay = DistanceRelay(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
504
+
505
+ distance_relay.backward_blind = result_set.get_float(table.backward_blind.query_index, on_none=None)
506
+ distance_relay.backward_reach = result_set.get_float(table.backward_reach.query_index, on_none=None)
507
+ distance_relay.backward_reactance = result_set.get_float(table.backward_reactance.query_index, on_none=None)
508
+ distance_relay.forward_blind = result_set.get_float(table.forward_blind.query_index, on_none=None)
509
+ distance_relay.forward_reach = result_set.get_float(table.forward_reach.query_index, on_none=None)
510
+ distance_relay.forward_reactance = result_set.get_float(table.forward_reactance.query_index, on_none=None)
511
+ distance_relay.operation_phase_angle1 = result_set.get_float(table.operation_phase_angle1.query_index, on_none=None)
512
+ distance_relay.operation_phase_angle2 = result_set.get_float(table.operation_phase_angle2.query_index, on_none=None)
513
+ distance_relay.operation_phase_angle3 = result_set.get_float(table.operation_phase_angle3.query_index, on_none=None)
514
+
515
+ return self._load_protection_relay_function(distance_relay, table, result_set) and self._add_or_throw(distance_relay)
516
+
517
+ def _load_protection_relay_function(
518
+ self,
519
+ protection_relay_function: ProtectionRelayFunction,
520
+ table: TableProtectionRelayFunctions,
521
+ result_set: ResultSet
522
+ ) -> bool:
523
+ protection_relay_function.asset_info = self._ensure_get(
524
+ result_set.get_string(table.relay_info_mrid.query_index, on_none=None),
525
+ RelayInfo
526
+ )
527
+ protection_relay_function.model = result_set.get_string(table.model.query_index, on_none=None)
528
+ protection_relay_function.reclosing = result_set.get_boolean(table.reclosing.query_index, on_none=None)
529
+ protection_relay_function.relay_delay_time = result_set.get_float(table.relay_delay_time.query_index, on_none=None)
530
+ protection_relay_function.protection_kind = ProtectionKind[result_set.get_string(table.protection_kind.query_index)]
531
+ protection_relay_function.directable = result_set.get_boolean(table.directable.query_index, on_none=None)
532
+ protection_relay_function.power_direction = PowerDirectionKind[result_set.get_string(table.power_direction.query_index)]
533
+
534
+ return self._load_power_system_resource(protection_relay_function, table, result_set)
535
+
536
+ def load_protection_relay_function_threshold(
537
+ self,
538
+ table: TableProtectionRelayFunctionThresholds,
539
+ result_set: ResultSet,
540
+ set_identifier: Callable[[str], str]
541
+ ) -> bool:
542
+ """
543
+ Create a :class:`RelaySetting` and populate its fields from :class:`TableProtectionRelayFunctionThresholds`.
544
+
545
+ :param table: The database table to read the :class:`RelaySetting` fields from.
546
+ :param result_set: The record in the database table containing the fields for this :class:`RelaySetting`.
547
+ :param set_identifier: A callback to register the mRID of this :class:`RelaySetting` for logging purposes.
548
+
549
+ :return: True if the :class:`RelaySetting` was successfully read from the database and added to the service.
550
+ :raises SqlException: For any errors encountered reading from the database.
551
+ """
552
+ protection_relay_function_mrid = set_identifier(result_set.get_string(table.protection_relay_function_mrid.query_index))
553
+ sequence_number = result_set.get_int(table.sequence_number.query_index)
554
+
555
+ set_identifier(f"{protection_relay_function_mrid}-threshold{sequence_number}")
556
+ protection_relay_function = self._service.get(protection_relay_function_mrid, ProtectionRelayFunction)
557
+
558
+ protection_relay_function.add_threshold(
559
+ RelaySetting(
560
+ UnitSymbol[result_set.get_string(table.unit_symbol.query_index)],
561
+ result_set.get_float(table.value.query_index),
562
+ result_set.get_string(table.name_.query_index, on_none=None)
563
+ ),
564
+ sequence_number
565
+ )
566
+
567
+ return True
568
+
569
+ def load_protection_relay_function_time_limit(
570
+ self,
571
+ table: TableProtectionRelayFunctionTimeLimits,
572
+ result_set: ResultSet,
573
+ set_identifier: Callable[[str], str]
574
+ ) -> bool:
575
+ """
576
+ Adds a time limit to a :class:`ProtectionRelayFunction` and populate its fields from :class:`TableProtectionRelayFunctionTimeLimits`.
577
+
578
+ :param table: The database table to read the time limit fields from.
579
+ :param result_set: The record in the database table containing the fields for this time limit.
580
+ :param set_identifier: A callback to register the mRID of this time limit for logging purposes.
581
+
582
+ :return: True if the time limit was successfully read from the database and added to the service.
583
+ :raises SqlException: For any errors encountered reading from the database.
584
+ """
585
+ # Note TableProtectionRelayFunctionTimeLimits.selectSql ensures we process ratings in the correct order.
586
+ protection_relay_function_mrid = set_identifier(result_set.get_string(table.protection_relay_function_mrid.query_index))
587
+ sequence_number = result_set.get_int(table.sequence_number.query_index)
588
+ time_limit = result_set.get_float(table.time_limit.query_index)
589
+
590
+ set_identifier(f"{protection_relay_function_mrid} time limit {sequence_number}")
591
+
592
+ protection_relay_function = self._service.get(protection_relay_function_mrid, ProtectionRelayFunction)
593
+ protection_relay_function.add_time_limit(time_limit)
594
+
595
+ return True
596
+
597
+ def load_protection_relay_scheme(self, table: TableProtectionRelaySchemes, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
598
+ """
599
+ Create a :class:`ProtectionRelayScheme` and populate its fields from :class:`TableProtectionRelaySchemes`.
600
+
601
+ :param table: The database table to read the :class:`ProtectionRelayScheme` fields from.
602
+ :param result_set: The record in the database table containing the fields for this :class:`ProtectionRelayScheme`.
603
+ :param set_identifier: A callback to register the mRID of this :class:`ProtectionRelayScheme` for logging purposes.
604
+
605
+ :return: True if the :class:`ProtectionRelayScheme` was successfully read from the database and added to the service.
606
+ :raises SqlException: For any errors encountered reading from the database.
607
+ """
608
+ protection_relay_scheme = ProtectionRelayScheme(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
609
+
610
+ protection_relay_scheme.system = self._ensure_get(
611
+ result_set.get_string(table.system_mrid.query_index, on_none=None),
612
+ ProtectionRelaySystem
613
+ )
614
+ if protection_relay_scheme.system:
615
+ protection_relay_scheme.system.add_scheme(protection_relay_scheme)
616
+
617
+ return self._load_identified_object(protection_relay_scheme, table, result_set) and self._add_or_throw(protection_relay_scheme)
618
+
619
+ def load_protection_relay_system(self, table: TableProtectionRelaySystems, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
620
+ """
621
+ Create a :class:`ProtectionRelaySystem` and populate its fields from :class:`TableProtectionRelaySystems`.
622
+
623
+ :param table: The database table to read the :class:`ProtectionRelaySystem` fields from.
624
+ :param result_set: The record in the database table containing the fields for this :class:`ProtectionRelaySystem`.
625
+ :param set_identifier: A callback to register the mRID of this :class:`ProtectionRelaySystem` for logging purposes.
626
+
627
+ :return: True if the :class:`ProtectionRelaySystem` was successfully read from the database and added to the service.
628
+ :raises SqlException: For any errors encountered reading from the database.
629
+ """
630
+ protection_relay_system = ProtectionRelaySystem(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
631
+
632
+ protection_relay_system.protection_kind = ProtectionKind[result_set.get_string(table.protection_kind.query_index)]
633
+
634
+ return self._load_equipment(protection_relay_system, table, result_set) and self._add_or_throw(protection_relay_system)
635
+
636
+ def load_voltage_relay(self, table: TableVoltageRelays, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
637
+ """
638
+ Create a :class:`VoltageRelay` and populate its fields from :class:`TableVoltageRelays`.
639
+
640
+ :param table: The database table to read the :class:`VoltageRelay` fields from.
641
+ :param result_set: The record in the database table containing the fields for this :class:`VoltageRelay`.
642
+ :param set_identifier: A callback to register the mRID of this :class:`VoltageRelay` for logging purposes.
643
+
644
+ :return: True if the :class:`VoltageRelay` was successfully read from the database and added to the service.
645
+ :raises SqlException: For any errors encountered reading from the database.
646
+ """
647
+ voltage_relay = VoltageRelay(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
648
+
649
+ return self._load_protection_relay_function(voltage_relay, table, result_set) and self._add_or_throw(voltage_relay)
650
+
651
+ ##################################
652
+ # Extensions IEC61970 Base Wires #
653
+ ##################################
654
+
655
+ def load_battery_controls(self, table: TableBatteryControls, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
656
+ """
657
+ Create a :class:`BatteryControl` and populate its fields from :class:`TableBatteryControls`.
658
+
659
+ :param table: The database table to read the :class:`BatteryControl` fields from.
660
+ :param result_set: The record in the database table containing the fields for this :class:`BatteryControl`.
661
+ :param set_identifier: A callback to register the mRID of this :class:`BatteryControl` for logging purposes.
662
+
663
+ :return: True if the :class:`BatteryControl` was successfully read from the database and added to the service.
664
+ :raises SqlException: For any errors encountered reading from the database.
665
+ """
666
+ battery_control = BatteryControl(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
667
+
668
+ battery_control.charging_rate = result_set.get_float(table.charging_rate.query_index, on_none=None)
669
+ battery_control.discharging_rate = result_set.get_float(table.discharging_rate.query_index, on_none=None)
670
+ battery_control.reserve_percent = result_set.get_float(table.reserve_percent.query_index, on_none=None)
671
+ battery_control.control_mode = BatteryControlMode[result_set.get_string(table.control_mode.query_index)]
672
+
673
+ return self._load_regulating_control(battery_control, table, result_set) and self._add_or_throw(battery_control)
674
+
675
+ def load_power_transformer_end_rating(self, table: TablePowerTransformerEndRatings, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
676
+ """
677
+ Adds a rating to a :class:`PowerTransformerEnd` from :class:`TablePowerTransformerEndRatings`.
678
+
679
+ :param table: The database table to read the rating fields from.
680
+ :param result_set: The record in the database table containing the fields for this rating.
681
+ :param set_identifier: A callback to register the mRID of this rating for logging purposes.
682
+
683
+ :return: True if the rating was successfully read from the database and added to the service.
684
+ :raises SqlException: For any errors encountered reading from the database.
685
+ """
686
+ # Note TablePowerTransformerEndRatings.selectSql ensures we process ratings in the correct order.
687
+ power_transformer_end_mrid = result_set.get_string(table.power_transformer_end_mrid.query_index)
688
+ rated_s = result_set.get_int(table.rated_s.query_index)
689
+ set_identifier(f"{power_transformer_end_mrid}.s{rated_s}")
690
+
691
+ pte = self._ensure_get(power_transformer_end_mrid, PowerTransformerEnd)
692
+ if pte:
693
+ cooling_type = TransformerCoolingType[result_set.get_string(table.cooling_type.query_index)]
694
+ pte.add_rating(rated_s, cooling_type)
695
+
696
+ return True
697
+
698
+ #######################
699
+ # IEC61968 Asset Info #
700
+ #######################
701
+
702
+ def load_cable_info(self, table: TableCableInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
703
+ """
704
+ Create a :class:`CableInfo` and populate its fields from :class:`TableCableInfo`.
705
+
706
+ :param table: The database table to read the :class:`CableInfo` fields from.
707
+ :param result_set: The record in the database table containing the fields for this :class:`CableInfo`.
708
+ :param set_identifier: A callback to register the mRID of this :class:`CableInfo` for logging purposes.
709
+
710
+ :return: True if the :class:`CableInfo` was successfully read from the database and added to the service.
711
+ :raises SqlException: For any errors encountered reading from the database.
712
+ """
713
+ cable_info = CableInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
714
+
715
+ return self._load_wire_info(cable_info, table, result_set) and self._add_or_throw(cable_info)
716
+
717
+ def load_no_load_test(self, table: TableNoLoadTests, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
718
+ """
719
+ Create a :class:`NoLoadTest` and populate its fields from :class:`TableNoLoadTests`.
720
+
721
+ :param table: The database table to read the :class:`NoLoadTest` fields from.
722
+ :param result_set: The record in the database table containing the fields for this :class:`NoLoadTest`.
723
+ :param set_identifier: A callback to register the mRID of this :class:`NoLoadTest` for logging purposes.
724
+
725
+ :return: True if the :class:`NoLoadTest` was successfully read from the database and added to the service.
726
+ :raises SqlException: For any errors encountered reading from the database.
727
+ """
728
+ no_load_test = NoLoadTest(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
729
+
730
+ no_load_test.energised_end_voltage = result_set.get_int(table.energised_end_voltage.query_index, on_none=None)
731
+ no_load_test.exciting_current = result_set.get_float(table.exciting_current.query_index, on_none=None)
732
+ no_load_test.exciting_current_zero = result_set.get_float(table.exciting_current_zero.query_index, on_none=None)
733
+ no_load_test.loss = result_set.get_int(table.loss.query_index, on_none=None)
734
+ no_load_test.loss_zero = result_set.get_int(table.loss_zero.query_index, on_none=None)
735
+
736
+ return self._load_transformer_test(no_load_test, table, result_set) and self._add_or_throw(no_load_test)
737
+
738
+ def load_open_circuit_test(self, table: TableOpenCircuitTests, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
739
+ """
740
+ Create an :class:`OpenCircuitTest` and populate its fields from :class:`TableOpenCircuitTests`.
741
+
742
+ :param table: The database table to read the :class:`OpenCircuitTest` fields from.
743
+ :param result_set: The record in the database table containing the fields for this :class:`OpenCircuitTest`.
744
+ :param set_identifier: A callback to register the mRID of this :class:`OpenCircuitTest` for logging purposes.
745
+
746
+ :return: True if the :class:`OpenCircuitTest` was successfully read from the database and added to the service.
747
+ :raises SqlException: For any errors encountered reading from the database.
748
+ """
749
+ open_circuit_test = OpenCircuitTest(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
750
+
751
+ open_circuit_test.energised_end_step = result_set.get_int(table.energised_end_step.query_index, on_none=None)
752
+ open_circuit_test.energised_end_voltage = result_set.get_int(table.energised_end_voltage.query_index, on_none=None)
753
+ open_circuit_test.open_end_step = result_set.get_int(table.open_end_step.query_index, on_none=None)
754
+ open_circuit_test.open_end_voltage = result_set.get_int(table.open_end_voltage.query_index, on_none=None)
755
+ open_circuit_test.phase_shift = result_set.get_float(table.phase_shift.query_index, on_none=None)
756
+
757
+ return self._load_transformer_test(open_circuit_test, table, result_set) and self._add_or_throw(open_circuit_test)
758
+
759
+ def load_overhead_wire_info(self, table: TableOverheadWireInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
760
+ """
761
+ Create an :class:`OverheadWireInfo` and populate its fields from :class:`TableOverheadWireInfo`.
762
+
763
+ :param table: The database table to read the :class:`OverheadWireInfo` fields from.
764
+ :param result_set: The record in the database table containing the fields for this :class:`OverheadWireInfo`.
765
+ :param set_identifier: A callback to register the mRID of this :class:`OverheadWireInfo` for logging purposes.
766
+
767
+ :return: True if the :class:`OverheadWireInfo` was successfully read from the database and added to the service.
768
+ :raises SqlException: For any errors encountered reading from the database.
769
+ """
770
+ overhead_wire_info = OverheadWireInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
771
+
772
+ return self._load_wire_info(overhead_wire_info, table, result_set) and self._add_or_throw(overhead_wire_info)
773
+
774
+ def load_power_transformer_info(self, table: TablePowerTransformerInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
775
+ """
776
+ Create a :class:`PowerTransformerInfo` and populate its fields from :class:`TablePowerTransformerInfo`.
777
+
778
+ :param table: The database table to read the :class:`PowerTransformerInfo` fields from.
779
+ :param result_set: The record in the database table containing the fields for this :class:`PowerTransformerInfo`.
780
+ :param set_identifier: A callback to register the mRID of this :class:`PowerTransformerInfo` for logging purposes.
781
+
782
+ :return: True if the :class:`PowerTransformerInfo` was successfully read from the database and added to the service.
783
+ :raises SqlException: For any errors encountered reading from the database.
784
+ """
785
+ power_transformer_info = PowerTransformerInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
786
+
787
+ return self._load_asset_info(power_transformer_info, table, result_set) and self._add_or_throw(power_transformer_info)
788
+
789
+ def load_short_circuit_test(self, table: TableShortCircuitTests, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
790
+ """
791
+ Create a :class:`ShortCircuitTest` and populate its fields from :class:`TableShortCircuitTests`.
792
+
793
+ :param table: The database table to read the :class:`ShortCircuitTest` fields from.
794
+ :param result_set: The record in the database table containing the fields for this :class:`ShortCircuitTest`.
795
+ :param set_identifier: A callback to register the mRID of this :class:`ShortCircuitTest` for logging purposes.
796
+
797
+ :return: True if the :class:`ShortCircuitTest` was successfully read from the database and added to the service.
798
+ :raises SqlException: For any errors encountered reading from the database.
799
+ """
800
+ short_circuit_test = ShortCircuitTest(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
801
+
802
+ short_circuit_test.current = result_set.get_float(table.current.query_index, on_none=None)
803
+ short_circuit_test.energised_end_step = result_set.get_int(table.energised_end_step.query_index, on_none=None)
804
+ short_circuit_test.grounded_end_step = result_set.get_int(table.grounded_end_step.query_index, on_none=None)
805
+ short_circuit_test.leakage_impedance = result_set.get_float(table.leakage_impedance.query_index, on_none=None)
806
+ short_circuit_test.leakage_impedance_zero = result_set.get_float(table.leakage_impedance_zero.query_index, on_none=None)
807
+ short_circuit_test.loss = result_set.get_int(table.loss.query_index, on_none=None)
808
+ short_circuit_test.loss_zero = result_set.get_int(table.loss_zero.query_index, on_none=None)
809
+ short_circuit_test.power = result_set.get_int(table.power.query_index, on_none=None)
810
+ short_circuit_test.voltage = result_set.get_float(table.voltage.query_index, on_none=None)
811
+ short_circuit_test.voltage_ohmic_part = result_set.get_float(table.voltage_ohmic_part.query_index, on_none=None)
812
+
813
+ return self._load_transformer_test(short_circuit_test, table, result_set) and self._add_or_throw(short_circuit_test)
814
+
815
+ def load_shunt_compensator_info(self, table: TableShuntCompensatorInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
816
+ """
817
+ Create a :class:`ShuntCompensatorInfo` and populate its fields from :class:`TableShuntCompensatorInfo`.
818
+
819
+ :param table: The database table to read the :class:`ShuntCompensatorInfo` fields from.
820
+ :param result_set: The record in the database table containing the fields for this :class:`ShuntCompensatorInfo`.
821
+ :param set_identifier: A callback to register the mRID of this :class:`ShuntCompensatorInfo` for logging purposes.
822
+
823
+ :return: True if the :class:`ShuntCompensatorInfo` was successfully read from the database and added to the service.
824
+ :raises SqlException: For any errors encountered reading from the database.
825
+ """
826
+ shunt_compensator_info = ShuntCompensatorInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
827
+
828
+ shunt_compensator_info.max_power_loss = result_set.get_int(table.max_power_loss.query_index, on_none=None)
829
+ shunt_compensator_info.rated_current = result_set.get_int(table.rated_current.query_index, on_none=None)
830
+ shunt_compensator_info.rated_reactive_power = result_set.get_int(table.rated_reactive_power.query_index, on_none=None)
831
+ shunt_compensator_info.rated_voltage = result_set.get_int(table.rated_voltage.query_index, on_none=None)
832
+
833
+ return self._load_asset_info(shunt_compensator_info, table, result_set) and self._add_or_throw(shunt_compensator_info)
834
+
835
+ def load_switch_info(self, table: TableSwitchInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
836
+ """
837
+ Create a :class:`SwitchInfo` and populate its fields from :class:`TableSwitchInfo`.
838
+
839
+ :param table: The database table to read the :class:`SwitchInfo` fields from.
840
+ :param result_set: The record in the database table containing the fields for this :class:`SwitchInfo`.
841
+ :param set_identifier: A callback to register the mRID of this :class:`SwitchInfo` for logging purposes.
842
+
843
+ :return: True if the :class:`SwitchInfo` was successfully read from the database and added to the service.
844
+ :raises SqlException: For any errors encountered reading from the database.
845
+ """
846
+ switch_info = SwitchInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
847
+
848
+ switch_info.rated_interrupting_time = result_set.get_float(table.rated_interrupting_time.query_index, on_none=None)
849
+
850
+ return self._load_asset_info(switch_info, table, result_set) and self._add_or_throw(switch_info)
851
+
852
+ def load_transformer_end_info(self, table: TableTransformerEndInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
853
+ """
854
+ Create a :class:`TransformerEndInfo` and populate its fields from :class:`TableTransformerEndInfo`.
855
+
856
+ :param table: The database table to read the :class:`TransformerEndInfo` fields from.
857
+ :param result_set: The record in the database table containing the fields for this :class:`TransformerEndInfo`.
858
+ :param set_identifier: A callback to register the mRID of this :class:`TransformerEndInfo` for logging purposes.
859
+
860
+ :return: True if the :class:`TransformerEndInfo` was successfully read from the database and added to the service.
861
+ :raises SqlException: For any errors encountered reading from the database.
862
+ """
863
+ transformer_end_info = TransformerEndInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
864
+
865
+ transformer_end_info.connection_kind = WindingConnection[result_set.get_string(table.connection_kind.query_index)]
866
+ transformer_end_info.emergency_s = result_set.get_int(table.emergency_s.query_index, on_none=None)
867
+ transformer_end_info.end_number = result_set.get_int(table.end_number.query_index)
868
+ transformer_end_info.insulation_u = result_set.get_int(table.insulation_u.query_index, on_none=None)
869
+ transformer_end_info.phase_angle_clock = result_set.get_int(table.phase_angle_clock.query_index, on_none=None)
870
+ transformer_end_info.r = result_set.get_float(table.r.query_index, on_none=None)
871
+ transformer_end_info.rated_s = result_set.get_int(table.rated_s.query_index, on_none=None)
872
+ transformer_end_info.rated_u = result_set.get_int(table.rated_u.query_index, on_none=None)
873
+ transformer_end_info.short_term_s = result_set.get_int(table.short_term_s.query_index, on_none=None)
874
+
875
+ transformer_end_info.transformer_tank_info = self._ensure_get(
876
+ result_set.get_string(table.transformer_tank_info_mrid.query_index, on_none=None),
877
+ TransformerTankInfo
878
+ )
879
+ transformer_end_info.energised_end_no_load_tests = self._ensure_get(
880
+ result_set.get_string(table.energised_end_no_load_tests.query_index, on_none=None),
881
+ NoLoadTest
882
+ )
883
+ transformer_end_info.energised_end_short_circuit_tests = self._ensure_get(
884
+ result_set.get_string(table.energised_end_short_circuit_tests.query_index, on_none=None),
885
+ ShortCircuitTest
886
+ )
887
+ transformer_end_info.grounded_end_short_circuit_tests = self._ensure_get(
888
+ result_set.get_string(table.grounded_end_short_circuit_tests.query_index, on_none=None),
889
+ ShortCircuitTest
890
+ )
891
+ transformer_end_info.open_end_open_circuit_tests = self._ensure_get(
892
+ result_set.get_string(table.open_end_open_circuit_tests.query_index, on_none=None),
893
+ OpenCircuitTest
894
+ )
895
+ transformer_end_info.energised_end_open_circuit_tests = self._ensure_get(
896
+ result_set.get_string(table.energised_end_open_circuit_tests.query_index, on_none=None),
897
+ OpenCircuitTest
898
+ )
899
+
900
+ if transformer_end_info.transformer_tank_info is not None:
901
+ transformer_end_info.transformer_tank_info.add_transformer_end_info(transformer_end_info)
902
+
903
+ return self._load_asset_info(transformer_end_info, table, result_set) and self._add_or_throw(transformer_end_info)
904
+
905
+ def load_transformer_tank_info(self, table: TableTransformerTankInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
906
+ """
907
+ Create a :class:`TransformerTankInfo` and populate its fields from :class:`TableTransformerTankInfo`.
908
+
909
+ :param table: The database table to read the :class:`TransformerTankInfo` fields from.
910
+ :param result_set: The record in the database table containing the fields for this :class:`TransformerTankInfo`.
911
+ :param set_identifier: A callback to register the mRID of this :class:`TransformerTankInfo` for logging purposes.
912
+
913
+ :return: True if the :class:`TransformerTankInfo` was successfully read from the database and added to the service.
914
+ :raises SqlException: For any errors encountered reading from the database.
915
+ """
916
+ transformer_tank_info = TransformerTankInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
917
+
918
+ transformer_tank_info.power_transformer_info = self._ensure_get(
919
+ result_set.get_string(table.power_transformer_info_mrid.query_index, on_none=None),
920
+ PowerTransformerInfo
921
+ )
922
+ if transformer_tank_info.power_transformer_info is not None:
923
+ transformer_tank_info.power_transformer_info.add_transformer_tank_info(transformer_tank_info)
924
+
925
+ return self._load_asset_info(transformer_tank_info, table, result_set) and self._add_or_throw(transformer_tank_info)
926
+
927
+ def _load_transformer_test(self, transformer_test: TransformerTest, table: TableTransformerTest, result_set: ResultSet) -> bool:
928
+ transformer_test.base_power = result_set.get_int(table.base_power.query_index, on_none=None)
929
+ transformer_test.temperature = result_set.get_float(table.temperature.query_index, on_none=None)
930
+
931
+ return self._load_identified_object(transformer_test, table, result_set)
932
+
933
+ def _load_wire_info(self, wire_info: WireInfo, table: TableWireInfo, result_set: ResultSet) -> bool:
934
+ wire_info.rated_current = result_set.get_int(table.rated_current.query_index, on_none=None)
935
+ wire_info.material = WireMaterialKind[result_set.get_string(table.material.query_index)]
936
+
937
+ return self._load_asset_info(wire_info, table, result_set)
938
+
939
+ ###################
940
+ # IEC61968 Assets #
941
+ ###################
942
+
943
+ def _load_asset(self, asset: Asset, table: TableAssets, result_set: ResultSet) -> bool:
944
+ asset.location = self._ensure_get(
945
+ result_set.get_string(table.location_mrid.query_index, on_none=None),
946
+ Location
947
+ )
948
+
949
+ return self._load_identified_object(asset, table, result_set)
950
+
951
+ def _load_asset_container(self, asset_container: AssetContainer, table: TableAssetContainers, result_set: ResultSet) -> bool:
952
+ return self._load_asset(asset_container, table, result_set)
953
+
954
+ def _load_asset_function(self, asset_function: AssetFunction, table: TableAssetFunctions, result_set: ResultSet) -> bool:
955
+ return self._load_identified_object(asset_function, table, result_set)
956
+
957
+ def _load_asset_info(self, asset_info: AssetInfo, table: TableAssetInfo, result_set: ResultSet) -> bool:
958
+ return self._load_identified_object(asset_info, table, result_set)
959
+
960
+ def _load_asset_organisation_role(self, asset_organisation_role: AssetOrganisationRole, table: TableAssetOrganisationRoles, result_set: ResultSet) -> bool:
961
+ return self._load_organisation_role(asset_organisation_role, table, result_set)
962
+
963
+ def load_asset_owner(self, table: TableAssetOwners, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
964
+ """
965
+ Create an :class:`AssetOwner` and populate its fields from :class:`TableAssetOwners`.
966
+
967
+ :param table: The database table to read the :class:`AssetOwner` fields from.
968
+ :param result_set: The record in the database table containing the fields for this :class:`AssetOwner`.
969
+ :param set_identifier: A callback to register the mRID of this :class:`AssetOwner` for logging purposes.
970
+
971
+ :return: True if the :class:`AssetOwner` was successfully read from the database and added to the service.
972
+ :raises SqlException: For any errors encountered reading from the database.
973
+ """
974
+ asset_owner = AssetOwner(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
975
+
976
+ return self._load_asset_organisation_role(asset_owner, table, result_set) and self._add_or_throw(asset_owner)
977
+
978
+ def load_streetlight(self, table: TableStreetlights, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
979
+ """
980
+ Create a :class:`Streetlight` and populate its fields from :class:`TableStreetlights`.
981
+
982
+ :param table: The database table to read the :class:`Streetlight` fields from.
983
+ :param result_set: The record in the database table containing the fields for this :class:`Streetlight`.
984
+ :param set_identifier: A callback to register the mRID of this :class:`Streetlight` for logging purposes.
985
+
986
+ :return: True if the :class:`Streetlight` was successfully read from the database and added to the service.
987
+ :raises SqlException: For any errors encountered reading from the database.
988
+ """
989
+ streetlight = Streetlight(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
990
+
991
+ streetlight.lamp_kind = StreetlightLampKind[result_set.get_string(table.lamp_kind.query_index)]
992
+ streetlight.light_rating = result_set.get_int(table.light_rating.query_index, on_none=None)
993
+ streetlight.pole = self._ensure_get(
994
+ result_set.get_string(table.pole_mrid.query_index, on_none=None),
995
+ Pole
996
+ )
997
+ if streetlight.pole is not None:
998
+ streetlight.pole.add_streetlight(streetlight)
999
+
1000
+ return self._load_asset(streetlight, table, result_set) and self._add_or_throw(streetlight)
1001
+
1002
+ def _load_structure(self, structure: Structure, table: TableStructures, result_set: ResultSet) -> bool:
1003
+ return self._load_asset_container(structure, table, result_set)
1004
+
1005
+ ###################
1006
+ # IEC61968 Common #
1007
+ ###################
1008
+
1009
+ def load_location(self, table: TableLocations, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1010
+ """
1011
+ Create a :class:`Location` and populate its fields from :class:`TableLocations`.
1012
+
1013
+ :param table: The database table to read the :class:`Location` fields from.
1014
+ :param result_set: The record in the database table containing the fields for this :class:`Location`.
1015
+ :param set_identifier: A callback to register the mRID of this :class:`Location` for logging purposes.
1016
+
1017
+ :return: True if the :class:`Location` was successfully read from the database and added to the service.
1018
+ :raises SqlException: For any errors encountered reading from the database.
1019
+ """
1020
+ location = Location(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1021
+
1022
+ return self._load_identified_object(location, table, result_set) and self._add_or_throw(location)
1023
+
1024
+ def load_location_street_address(self, table: TableLocationStreetAddresses, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1025
+ """
1026
+ Create a :class:`StreetAddress` and populate its fields from :class:`TableLocationStreetAddresses`.
1027
+
1028
+ :param table: The database table to read the :class:`StreetAddress` fields from.
1029
+ :param result_set: The record in the database table containing the fields for this :class:`StreetAddress`.
1030
+ :param set_identifier: A callback to register the identified of this :class:`StreetAddress` for logging purposes.
1031
+
1032
+ :return: True if the :class:`StreetAddress` was successfully read from the database and added to the service.
1033
+ :raises SqlException: For any errors encountered reading from the database.
1034
+ """
1035
+ location_mrid = set_identifier(result_set.get_string(table.location_mrid.query_index))
1036
+ field = TableLocationStreetAddressField[result_set.get_string(table.address_field.query_index)]
1037
+
1038
+ location = self._service.get(location_mrid, Location)
1039
+
1040
+ if field == TableLocationStreetAddressField.mainAddress:
1041
+ location.main_address = self._load_street_address(table, result_set)
1042
+
1043
+ return True
1044
+
1045
+ def load_position_point(self, table: TablePositionPoints, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1046
+ """
1047
+ Create a :class:`PositionPoint` and populate its fields from :class:`TablePositionPoints`.
1048
+
1049
+ :param table: The database table to read the :class:`PositionPoint` fields from.
1050
+ :param result_set: The record in the database table containing the fields for this :class:`PositionPoint`.
1051
+ :param set_identifier: A callback to register the mRID of this :class:`PositionPoint` for logging purposes.
1052
+
1053
+ :return: True if the :class:`PositionPoint` was successfully read from the database and added to the service.
1054
+ :raises SqlException: For any errors encountered reading from the database.
1055
+ """
1056
+ location_mrid = set_identifier(result_set.get_string(table.location_mrid.query_index))
1057
+ sequence_number = result_set.get_int(table.sequence_number.query_index)
1058
+
1059
+ location = self._service.get(location_mrid, Location)
1060
+
1061
+ location.insert_point(
1062
+ PositionPoint(
1063
+ result_set.get_float(table.x_position.query_index),
1064
+ result_set.get_float(table.y_position.query_index)
1065
+ ),
1066
+ sequence_number
1067
+ )
1068
+
1069
+ return True
1070
+
1071
+ def _load_street_address(self, table: TableStreetAddresses, result_set: ResultSet) -> StreetAddress:
1072
+ return StreetAddress(
1073
+ result_set.get_string(table.postal_code.query_index, on_none=""),
1074
+ self._load_town_detail(table, result_set),
1075
+ result_set.get_string(table.po_box.query_index, on_none=""),
1076
+ self._load_street_detail(table, result_set)
1077
+ )
1078
+
1079
+ @staticmethod
1080
+ def _load_street_detail(table: TableStreetAddresses, result_set: ResultSet) -> Optional[StreetDetail]:
1081
+ sd = StreetDetail(
1082
+ result_set.get_string(table.building_name.query_index, on_none=""),
1083
+ result_set.get_string(table.floor_identification.query_index, on_none=""),
1084
+ result_set.get_string(table.street_name.query_index, on_none=""),
1085
+ result_set.get_string(table.number.query_index, on_none=""),
1086
+ result_set.get_string(table.suite_number.query_index, on_none=""),
1087
+ result_set.get_string(table.type.query_index, on_none=""),
1088
+ result_set.get_string(table.display_address.query_index, on_none="")
1089
+ )
1090
+
1091
+ return sd if not sd.all_fields_empty() else None
1092
+
1093
+ @staticmethod
1094
+ def _load_town_detail(table: TableTownDetails, result_set: ResultSet) -> Optional[TownDetail]:
1095
+ td = TownDetail(
1096
+ result_set.get_string(table.town_name.query_index, on_none=None),
1097
+ result_set.get_string(table.state_or_province.query_index, on_none=None)
1098
+ )
1099
+
1100
+ return td if not td.all_fields_null_or_empty() else None
1101
+
1102
+ #####################################
1103
+ # IEC61968 InfIEC61968 InfAssetInfo #
1104
+ #####################################
1105
+
1106
+ def load_current_transformer_info(self, table: TableCurrentTransformerInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1107
+ """
1108
+ Create a :class:`CurrentTransformerInfo` and populate its fields from :class:`TableCurrentTransformerInfo`.
1109
+
1110
+ :param table: The database table to read the :class:`CurrentTransformerInfo` fields from.
1111
+ :param result_set: The record in the database table containing the fields for this :class:`CurrentTransformerInfo`.
1112
+ :param set_identifier: A callback to register the mRID of this :class:`CurrentTransformerInfo` for logging purposes.
1113
+
1114
+ :return: True if the :class:`CurrentTransformerInfo` was successfully read from the database and added to the service.
1115
+ :raises SqlException: For any errors encountered reading from the database.
1116
+ """
1117
+ current_transformer_info = CurrentTransformerInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1118
+
1119
+ current_transformer_info.accuracy_class = result_set.get_string(table.accuracy_class.query_index, on_none=None)
1120
+ current_transformer_info.accuracy_limit = result_set.get_float(table.accuracy_limit.query_index, on_none=None)
1121
+ current_transformer_info.core_count = result_set.get_int(table.core_count.query_index, on_none=None)
1122
+ current_transformer_info.ct_class = result_set.get_string(table.ct_class.query_index, on_none=None)
1123
+ current_transformer_info.knee_point_voltage = result_set.get_int(table.knee_point_voltage.query_index, on_none=None)
1124
+ current_transformer_info.max_ratio = result_set.get_ratio(table.max_ratio_numerator.query_index, table.max_ratio_denominator.query_index, on_none=None)
1125
+ current_transformer_info.nominal_ratio = result_set.get_ratio(
1126
+ table.nominal_ratio_numerator.query_index,
1127
+ table.nominal_ratio_denominator.query_index,
1128
+ on_none=None
1129
+ )
1130
+ current_transformer_info.primary_ratio = result_set.get_float(table.primary_ratio.query_index, on_none=None)
1131
+ current_transformer_info.rated_current = result_set.get_int(table.rated_current.query_index, on_none=None)
1132
+ current_transformer_info.secondary_fls_rating = result_set.get_int(table.secondary_fls_rating.query_index, on_none=None)
1133
+ current_transformer_info.secondary_ratio = result_set.get_float(table.secondary_ratio.query_index, on_none=None)
1134
+ current_transformer_info.usage = result_set.get_string(table.usage.query_index, on_none=None)
1135
+
1136
+ return self._load_asset_info(current_transformer_info, table, result_set) and self._add_or_throw(current_transformer_info)
1137
+
1138
+ def load_potential_transformer_info(self, table: TablePotentialTransformerInfo, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1139
+ """
1140
+ Create a :class:`PotentialTransformerInfo` and populate its fields from :class:`TablePotentialTransformerInfo`.
1141
+
1142
+ :param table: The database table to read the :class:`PotentialTransformerInfo` fields from.
1143
+ :param result_set: The record in the database table containing the fields for this :class:`PotentialTransformerInfo`.
1144
+ :param set_identifier: A callback to register the mRID of this :class:`PotentialTransformerInfo` for logging purposes.
1145
+
1146
+ :return: True if the :class:`PotentialTransformerInfo` was successfully read from the database and added to the service.
1147
+ :raises SqlException: For any errors encountered reading from the database.
1148
+ """
1149
+ potential_transformer_info = PotentialTransformerInfo(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1150
+
1151
+ potential_transformer_info.accuracy_class = result_set.get_string(table.accuracy_class.query_index, on_none=None)
1152
+ potential_transformer_info.nominal_ratio = result_set.get_ratio(
1153
+ table.nominal_ratio_numerator.query_index,
1154
+ table.nominal_ratio_denominator.query_index,
1155
+ on_none=None
1156
+ )
1157
+ potential_transformer_info.primary_ratio = result_set.get_float(table.primary_ratio.query_index, on_none=None)
1158
+ potential_transformer_info.pt_class = result_set.get_string(table.pt_class.query_index, on_none=None)
1159
+ potential_transformer_info.rated_voltage = result_set.get_int(table.rated_voltage.query_index, on_none=None)
1160
+ potential_transformer_info.secondary_ratio = result_set.get_float(table.secondary_ratio.query_index, on_none=None)
1161
+
1162
+ return self._load_asset_info(potential_transformer_info, table, result_set) and self._add_or_throw(potential_transformer_info)
1163
+
1164
+ ##################################
1165
+ # IEC61968 InfIEC61968 InfAssets #
1166
+ ##################################
1167
+
1168
+ def load_pole(self, table: TablePoles, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1169
+ """
1170
+ Create a :class:`Pole` and populate its fields from :class:`TablePoles`.
1171
+
1172
+ :param table: The database table to read the :class:`Pole` fields from.
1173
+ :param result_set: The record in the database table containing the fields for this :class:`Pole`.
1174
+ :param set_identifier: A callback to register the mRID of this :class:`Pole` for logging purposes.
1175
+
1176
+ :return: True if the :class:`Pole` was successfully read from the database and added to the service.
1177
+ :raises SqlException: For any errors encountered reading from the database.
1178
+ """
1179
+ pole = Pole(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1180
+
1181
+ pole.classification = result_set.get_string(table.classification.query_index, on_none="")
1182
+
1183
+ return self._load_structure(pole, table, result_set) and self._add_or_throw(pole)
1184
+
1185
+ #####################
1186
+ # IEC61968 Metering #
1187
+ #####################
1188
+
1189
+ def _load_end_device(self, end_device: EndDevice, table: TableEndDevices, result_set: ResultSet) -> bool:
1190
+ end_device.customer_mrid = result_set.get_string(table.customer_mrid.query_index, on_none=None)
1191
+ end_device.service_location = self._ensure_get(
1192
+ result_set.get_string(table.service_location_mrid.query_index, on_none=None),
1193
+ Location
1194
+ )
1195
+
1196
+ return self._load_asset_container(end_device, table, result_set)
1197
+
1198
+ def _load_end_device_functions(self, end_device_function: EndDeviceFunction, table: TableEndDeviceFunctions, result_set: ResultSet) -> bool:
1199
+ end_device_function.enabled = result_set.get_boolean(table.enabled.query_index)
1200
+
1201
+ return self._load_asset_function(end_device_function, table, result_set)
1202
+
1203
+ def load_meter(self, table: TableMeters, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1204
+ """
1205
+ Create a :class:`Meter` and populate its fields from :class:`TableMeters`.
1206
+
1207
+ :param table: The database table to read the :class:`Meter` fields from.
1208
+ :param result_set: The record in the database table containing the fields for this :class:`Meter`.
1209
+ :param set_identifier: A callback to register the mRID of this :class:`Meter` for logging purposes.
1210
+
1211
+ :return: True if the :class:`Meter` was successfully read from the database and added to the service.
1212
+ :raises SqlException: For any errors encountered reading from the database.
1213
+ """
1214
+ meter = Meter(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1215
+
1216
+ return self._load_end_device(meter, table, result_set) and self._add_or_throw(meter)
1217
+
1218
+ def load_usage_point(self, table: TableUsagePoints, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1219
+ """
1220
+ Create a :class:`UsagePoint` and populate its fields from :class:`TableUsagePoints`.
1221
+
1222
+ :param table: The database table to read the :class:`UsagePoint` fields from.
1223
+ :param result_set: The record in the database table containing the fields for this :class:`UsagePoint`.
1224
+ :param set_identifier: A callback to register the mRID of this :class:`UsagePoint` for logging purposes.
1225
+
1226
+ :return: True if the :class:`UsagePoint` was successfully read from the database and added to the service.
1227
+ :raises SqlException: For any errors encountered reading from the database.
1228
+ """
1229
+ usage_point = UsagePoint(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1230
+
1231
+ usage_point.usage_point_location = self._ensure_get(
1232
+ result_set.get_string(table.location_mrid.query_index, on_none=None),
1233
+ Location
1234
+ )
1235
+ usage_point.is_virtual = result_set.get_boolean(table.is_virtual.query_index)
1236
+ usage_point.connection_category = result_set.get_string(table.connection_category.query_index, on_none=None)
1237
+ usage_point.rated_power = result_set.get_int(table.rated_power.query_index, on_none=None)
1238
+ usage_point.approved_inverter_capacity = result_set.get_int(table.approved_inverter_capacity.query_index, on_none=None)
1239
+
1240
+ usage_point.phase_code = PhaseCode[result_set.get_string(table.phase_code.query_index)]
1241
+
1242
+ return self._load_identified_object(usage_point, table, result_set) and self._add_or_throw(usage_point)
1243
+
1244
+ #######################
1245
+ # IEC61968 Operations #
1246
+ #######################
1247
+
1248
+ def load_operational_restriction(self, table: TableOperationalRestrictions, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1249
+ """
1250
+ Create an :class:`OperationalRestriction` and populate its fields from :class:`TableOperationalRestrictions`.
1251
+
1252
+ :param table: The database table to read the :class:`OperationalRestriction` fields from.
1253
+ :param result_set: The record in the database table containing the fields for this :class:`OperationalRestriction`.
1254
+ :param set_identifier: A callback to register the mRID of this :class:`OperationalRestriction` for logging purposes.
1255
+
1256
+ :return: True if the :class:`OperationalRestriction` was successfully read from the database and added to the service.
1257
+ :raises SqlException: For any errors encountered reading from the database.
1258
+ """
1259
+ operational_restriction = OperationalRestriction(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1260
+
1261
+ return self._load_document(operational_restriction, table, result_set) and self._add_or_throw(operational_restriction)
1262
+
1263
+ #####################################
1264
+ # IEC61970 Base Auxiliary Equipment #
1265
+ #####################################
1266
+
1267
+ def _load_auxiliary_equipment(self, auxiliary_equipment: AuxiliaryEquipment, table: TableAuxiliaryEquipment, result_set: ResultSet) -> bool:
1268
+ auxiliary_equipment.terminal = self._ensure_get(
1269
+ result_set.get_string(table.terminal_mrid.query_index, on_none=None),
1270
+ Terminal
1271
+ )
1272
+
1273
+ return self._load_equipment(auxiliary_equipment, table, result_set)
1274
+
1275
+ def load_current_transformer(self, table: TableCurrentTransformers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1276
+ """
1277
+ Create a :class:`CurrentTransformer` and populate its fields from :class:`TableCurrentTransformers`.
1278
+
1279
+ :param table: The database table to read the :class:`CurrentTransformer` fields from.
1280
+ :param result_set: The record in the database table containing the fields for this :class:`CurrentTransformer`.
1281
+ :param set_identifier: A callback to register the mRID of this :class:`CurrentTransformer` for logging purposes.
1282
+
1283
+ :return: True if the :class:`CurrentTransformer` was successfully read from the database and added to the service.
1284
+ :raises SqlException: For any errors encountered reading from the database.
1285
+ """
1286
+ current_transformer = CurrentTransformer(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1287
+
1288
+ current_transformer.asset_info = self._ensure_get(
1289
+ result_set.get_string(table.current_transformer_info_mrid.query_index, on_none=None),
1290
+ CurrentTransformerInfo
1291
+ )
1292
+ current_transformer.core_burden = result_set.get_int(table.core_burden.query_index, on_none=None)
1293
+
1294
+ return self._load_sensor(current_transformer, table, result_set) and self._add_or_throw(current_transformer)
1295
+
1296
+ def load_fault_indicator(self, table: TableFaultIndicators, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1297
+ """
1298
+ Create a :class:`FaultIndicator` and populate its fields from :class:`TableFaultIndicators`.
1299
+
1300
+ :param table: The database table to read the :class:`FaultIndicator` fields from.
1301
+ :param result_set: The record in the database table containing the fields for this :class:`FaultIndicator`.
1302
+ :param set_identifier: A callback to register the mRID of this :class:`FaultIndicator` for logging purposes.
1303
+
1304
+ :return: True if the :class:`FaultIndicator` was successfully read from the database and added to the service.
1305
+ :raises SqlException: For any errors encountered reading from the database.
1306
+ """
1307
+ fault_indicator = FaultIndicator(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1308
+
1309
+ return self._load_auxiliary_equipment(fault_indicator, table, result_set) and self._add_or_throw(fault_indicator)
1310
+
1311
+ def load_potential_transformer(self, table: TablePotentialTransformers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1312
+ """
1313
+ Create a :class:`PotentialTransformer` and populate its fields from :class:`TablePotentialTransformers`.
1314
+
1315
+ :param table: The database table to read the :class:`PotentialTransformer` fields from.
1316
+ :param result_set: The record in the database table containing the fields for this :class:`PotentialTransformer`.
1317
+ :param set_identifier: A callback to register the mRID of this :class:`PotentialTransformer` for logging purposes.
1318
+
1319
+ :return: True if the :class:`PotentialTransformer` was successfully read from the database and added to the service.
1320
+ :raises SqlException: For any errors encountered reading from the database.
1321
+ """
1322
+ potential_transformer = PotentialTransformer(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1323
+
1324
+ potential_transformer.asset_info = self._ensure_get(
1325
+ result_set.get_string(table.potential_transformer_info_mrid.query_index, on_none=None),
1326
+ PotentialTransformerInfo
1327
+ )
1328
+ potential_transformer.type = PotentialTransformerKind[result_set.get_string(table.type.query_index)]
1329
+
1330
+ return self._load_sensor(potential_transformer, table, result_set) and self._add_or_throw(potential_transformer)
1331
+
1332
+ def _load_sensor(self, sensor: Sensor, table: TableSensors, result_set: ResultSet) -> bool:
1333
+ return self._load_auxiliary_equipment(sensor, table, result_set)
1334
+
1335
+ ######################
1336
+ # IEC61970 Base Core #
1337
+ ######################
1338
+
1339
+ def _load_ac_dc_terminal(self, ac_dc_terminal: AcDcTerminal, table: TableAcDcTerminals, result_set: ResultSet) -> bool:
1340
+ return self._load_identified_object(ac_dc_terminal, table, result_set)
1341
+
1342
+ def load_base_voltage(self, table: TableBaseVoltages, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1343
+ """
1344
+ Create a :class:`BaseVoltage` and populate its fields from :class:`TableBaseVoltages`.
1345
+
1346
+ :param table: The database table to read the :class:`BaseVoltage` fields from.
1347
+ :param result_set: The record in the database table containing the fields for this :class:`BaseVoltage`.
1348
+ :param set_identifier: A callback to register the mRID of this :class:`BaseVoltage` for logging purposes.
1349
+
1350
+ :return: True if the :class:`BaseVoltage` was successfully read from the database and added to the service.
1351
+ :raises SqlException: For any errors encountered reading from the database.
1352
+ """
1353
+ base_voltage = BaseVoltage(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1354
+
1355
+ base_voltage.nominal_voltage = result_set.get_int(table.nominal_voltage.query_index)
1356
+
1357
+ return self._load_identified_object(base_voltage, table, result_set) and self._add_or_throw(base_voltage)
1358
+
1359
+ def _load_conducting_equipment(self, conducting_equipment: ConductingEquipment, table: TableConductingEquipment, result_set: ResultSet) -> bool:
1360
+ conducting_equipment.base_voltage = self._ensure_get(
1361
+ result_set.get_string(table.base_voltage_mrid.query_index, on_none=None),
1362
+ BaseVoltage
1363
+ )
1364
+
1365
+ return self._load_equipment(conducting_equipment, table, result_set)
1366
+
1367
+ def load_connectivity_node(self, table: TableConnectivityNodes, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1368
+ """
1369
+ Create a :class:`ConnectivityNode` and populate its fields from :class:`TableConnectivityNodes`.
1370
+
1371
+ :param table: The database table to read the :class:`ConnectivityNode` fields from.
1372
+ :param result_set: The record in the database table containing the fields for this :class:`ConnectivityNode`.
1373
+ :param set_identifier: A callback to register the mRID of this :class:`ConnectivityNode` for logging purposes.
1374
+
1375
+ :return: True if the :class:`ConnectivityNode` was successfully read from the database and added to the service.
1376
+ :raises SqlException: For any errors encountered reading from the database.
1377
+ """
1378
+ connectivity_node = ConnectivityNode(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1379
+
1380
+ return self._load_identified_object(connectivity_node, table, result_set) and self._add_or_throw(connectivity_node)
1381
+
1382
+ def _load_connectivity_node_container(
1383
+ self,
1384
+ connectivity_node_container: ConnectivityNodeContainer,
1385
+ table: TableConnectivityNodeContainers,
1386
+ result_set: ResultSet
1387
+ ) -> bool:
1388
+ return self._load_power_system_resource(connectivity_node_container, table, result_set)
1389
+
1390
+ def _load_curve(self, curve: Curve, table: TableCurves, result_set: ResultSet) -> bool:
1391
+ return self._load_identified_object(curve, table, result_set)
1392
+
1393
+ def load_curve_data(self, table: TableCurveData, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1394
+ """
1395
+ Create a :class:`CurveData` and populate its fields from :class:`TableConnectivityNodes`.
1396
+
1397
+ :param table: The database table to read the :class:`CurveData` fields from.
1398
+ :param result_set: The record in the database table containing the fields for this :class:`CurveData`.
1399
+ :param set_identifier: A callback to register the mRID of this :class:`CurveData` for logging purposes.
1400
+
1401
+ :return: True if the :class:`CurveData` was successfully read from the database and added to the service.
1402
+ :raises SqlException: For any errors encountered reading from the database.
1403
+ """
1404
+ curve_mrid = result_set.get_string(table.curve_mrid.query_index)
1405
+ set_identifier(f"{curve_mrid}-x-{result_set.get_float(table.x_value.query_index)}")
1406
+
1407
+ curve = self._service.get(curve_mrid, Curve)
1408
+
1409
+ curve.add_data(
1410
+ result_set.get_float(table.x_value.query_index),
1411
+ result_set.get_float(table.y1_value.query_index),
1412
+ result_set.get_float(table.y2_value.query_index, on_none=None),
1413
+ result_set.get_float(table.y3_value.query_index, on_none=None)
1414
+ )
1415
+
1416
+ return True
1417
+
1418
+ def _load_equipment(self, equipment: Equipment, table: TableEquipment, result_set: ResultSet) -> bool:
1419
+ equipment.normally_in_service = result_set.get_boolean(table.normally_in_service.query_index)
1420
+ equipment.in_service = result_set.get_boolean(table.in_service.query_index)
1421
+ equipment.commissioned_date = result_set.get_instant(table.commissioned_date.query_index, on_none=None)
1422
+
1423
+ return self._load_power_system_resource(equipment, table, result_set)
1424
+
1425
+ def _load_equipment_container(self, equipment_container: EquipmentContainer, table: TableEquipmentContainers, result_set: ResultSet) -> bool:
1426
+ return self._load_connectivity_node_container(equipment_container, table, result_set)
1427
+
1428
+ def load_feeder(self, table: TableFeeders, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1429
+ """
1430
+ Create a :class:`Feeder` and populate its fields from :class:`TableFeeders`.
1431
+
1432
+ :param table: The database table to read the :class:`Feeder` fields from.
1433
+ :param result_set: The record in the database table containing the fields for this :class:`Feeder`.
1434
+ :param set_identifier: A callback to register the mRID of this :class:`Feeder` for logging purposes.
1435
+
1436
+ :return: True if the :class:`Feeder` was successfully read from the database and added to the service.
1437
+ :raises SqlException: For any errors encountered reading from the database.
1438
+ """
1439
+ feeder = Feeder(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1440
+
1441
+ feeder.normal_head_terminal = self._ensure_get(
1442
+ result_set.get_string(table.normal_head_terminal_mrid.query_index, on_none=None),
1443
+ Terminal
1444
+ )
1445
+ feeder.normal_energizing_substation = self._ensure_get(
1446
+ result_set.get_string(table.normal_energizing_substation_mrid.query_index, on_none=None),
1447
+ Substation
1448
+ )
1449
+
1450
+ if feeder.normal_energizing_substation:
1451
+ feeder.normal_energizing_substation.add_feeder(feeder)
1452
+
1453
+ return self._load_equipment_container(feeder, table, result_set) and self._add_or_throw(feeder)
1454
+
1455
+ def load_geographical_region(self, table: TableGeographicalRegions, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1456
+ """
1457
+ Create a :class:`GeographicalRegion` and populate its fields from :class:`TableGeographicalRegions`.
1458
+
1459
+ :param table: The database table to read the :class:`GeographicalRegion` fields from.
1460
+ :param result_set: The record in the database table containing the fields for this :class:`GeographicalRegion`.
1461
+ :param set_identifier: A callback to register the mRID of this :class:`GeographicalRegion` for logging purposes.
1462
+
1463
+ :return: True if the :class:`GeographicalRegion` was successfully read from the database and added to the service.
1464
+ :raises SqlException: For any errors encountered reading from the database.
1465
+ """
1466
+ geographical_region = GeographicalRegion(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1467
+
1468
+ return self._load_identified_object(geographical_region, table, result_set) and self._add_or_throw(geographical_region)
1469
+
1470
+ def _load_power_system_resource(self, power_system_resource: PowerSystemResource, table: TablePowerSystemResources, result_set: ResultSet) -> bool:
1471
+ power_system_resource.location = self._ensure_get(
1472
+ result_set.get_string(table.location_mrid.query_index, on_none=None),
1473
+ Location
1474
+ )
1475
+ power_system_resource.num_controls = result_set.get_int(table.num_controls.query_index)
1476
+
1477
+ return self._load_identified_object(power_system_resource, table, result_set)
1478
+
1479
+ def load_sub_geographical_region(self, table: TableSubGeographicalRegions, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1480
+ """
1481
+ Create a :class:`SubGeographicalRegion` and populate its fields from :class:`TableSubGeographicalRegions`.
1482
+
1483
+ :param table: The database table to read the :class:`SubGeographicalRegion` fields from.
1484
+ :param result_set: The record in the database table containing the fields for this :class:`SubGeographicalRegion`.
1485
+ :param set_identifier: A callback to register the mRID of this :class:`SubGeographicalRegion` for logging purposes.
1486
+
1487
+ :return: True if the :class:`SubGeographicalRegion` was successfully read from the database and added to the service.
1488
+ :raises SqlException: For any errors encountered reading from the database.
1489
+ """
1490
+ sub_geographical_region = SubGeographicalRegion(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1491
+
1492
+ sub_geographical_region.geographical_region = self._ensure_get(
1493
+ result_set.get_string(table.geographical_region_mrid.query_index, on_none=None),
1494
+ GeographicalRegion
1495
+ )
1496
+
1497
+ if sub_geographical_region.geographical_region:
1498
+ sub_geographical_region.geographical_region.add_sub_geographical_region(sub_geographical_region)
1499
+
1500
+ return self._load_identified_object(sub_geographical_region, table, result_set) and self._add_or_throw(sub_geographical_region)
1501
+
1502
+ def load_substation(self, table: TableSubstations, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1503
+ """
1504
+ Create a :class:`Substation` and populate its fields from :class:`TableSubstations`.
1505
+
1506
+ :param table: The database table to read the :class:`Substation` fields from.
1507
+ :param result_set: The record in the database table containing the fields for this :class:`Substation`.
1508
+ :param set_identifier: A callback to register the mRID of this :class:`Substation` for logging purposes.
1509
+
1510
+ :return: True if the :class:`Substation` was successfully read from the database and added to the service.
1511
+ :raises SqlException: For any errors encountered reading from the database.
1512
+ """
1513
+ substation = Substation(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1514
+
1515
+ substation.sub_geographical_region = self._ensure_get(
1516
+ result_set.get_string(table.sub_geographical_region_mrid.query_index, on_none=None),
1517
+ SubGeographicalRegion
1518
+ )
1519
+
1520
+ if substation.sub_geographical_region:
1521
+ substation.sub_geographical_region.add_substation(substation)
1522
+
1523
+ return self._load_equipment_container(substation, table, result_set) and self._add_or_throw(substation)
1524
+
1525
+ def load_terminal(self, table: TableTerminals, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1526
+ """
1527
+ Create a :class:`Terminal` and populate its fields from :class:`TableTerminals`.
1528
+
1529
+ :param table: The database table to read the :class:`Terminal` fields from.
1530
+ :param result_set: The record in the database table containing the fields for this :class:`Terminal`.
1531
+ :param set_identifier: A callback to register the mRID of this :class:`Terminal` for logging purposes.
1532
+
1533
+ :return: True if the :class:`Terminal` was successfully read from the database and added to the service.
1534
+ :raises SqlException: For any errors encountered reading from the database.
1535
+ """
1536
+ terminal = Terminal(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1537
+
1538
+ terminal.sequence_number = result_set.get_int(table.sequence_number.query_index)
1539
+ terminal.conducting_equipment = self._ensure_get(
1540
+ result_set.get_string(table.conducting_equipment_mrid.query_index, on_none=None),
1541
+ ConductingEquipment
1542
+ )
1543
+ terminal.phases = PhaseCode[result_set.get_string(table.phases.query_index)]
1544
+
1545
+ if terminal.conducting_equipment:
1546
+ terminal.conducting_equipment.add_terminal(terminal)
1547
+
1548
+ self._service.connect_by_mrid(terminal, result_set.get_string(table.connectivity_node_mrid.query_index, on_none=None))
1549
+
1550
+ return self._load_ac_dc_terminal(terminal, table, result_set) and self._add_or_throw(terminal)
1551
+
1552
+ #############################
1553
+ # IEC61970 Base Equivalents #
1554
+ #############################
1555
+
1556
+ def load_equivalent_branch(self, table: TableEquivalentBranches, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1557
+ """
1558
+ Create an :class:`EquivalentBranch` and populate its fields from :class:`TableEquivalentBranches`.
1559
+
1560
+ :param table: The database table to read the :class:`EquivalentBranch` fields from.
1561
+ :param result_set: The record in the database table containing the fields for this :class:`EquivalentBranch`.
1562
+ :param set_identifier: A callback to register the mRID of this :class:`EquivalentBranch` for logging purposes.
1563
+
1564
+ :return: True if the :class:`EquivalentBranch` was successfully read from the database and added to the service.
1565
+ :raises SqlException: For any errors encountered reading from the database.
1566
+ """
1567
+ equivalent_branch = EquivalentBranch(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1568
+
1569
+ equivalent_branch.negative_r12 = result_set.get_float(table.negative_r12.query_index, on_none=None)
1570
+ equivalent_branch.negative_r21 = result_set.get_float(table.negative_r21.query_index, on_none=None)
1571
+ equivalent_branch.negative_x12 = result_set.get_float(table.negative_x12.query_index, on_none=None)
1572
+ equivalent_branch.negative_x21 = result_set.get_float(table.negative_x21.query_index, on_none=None)
1573
+ equivalent_branch.positive_r12 = result_set.get_float(table.positive_r12.query_index, on_none=None)
1574
+ equivalent_branch.positive_r21 = result_set.get_float(table.positive_r21.query_index, on_none=None)
1575
+ equivalent_branch.positive_x12 = result_set.get_float(table.positive_x12.query_index, on_none=None)
1576
+ equivalent_branch.positive_x21 = result_set.get_float(table.positive_x21.query_index, on_none=None)
1577
+ equivalent_branch.r = result_set.get_float(table.r.query_index, on_none=None)
1578
+ equivalent_branch.r21 = result_set.get_float(table.r21.query_index, on_none=None)
1579
+ equivalent_branch.x = result_set.get_float(table.x.query_index, on_none=None)
1580
+ equivalent_branch.x21 = result_set.get_float(table.x21.query_index, on_none=None)
1581
+ equivalent_branch.zero_r12 = result_set.get_float(table.zero_r12.query_index, on_none=None)
1582
+ equivalent_branch.zero_r21 = result_set.get_float(table.zero_r21.query_index, on_none=None)
1583
+ equivalent_branch.zero_x12 = result_set.get_float(table.zero_x12.query_index, on_none=None)
1584
+ equivalent_branch.zero_x21 = result_set.get_float(table.zero_x21.query_index, on_none=None)
1585
+
1586
+ return self._load_equivalent_equipment(equivalent_branch, table, result_set) and self._add_or_throw(equivalent_branch)
1587
+
1588
+ def _load_equivalent_equipment(self, equivalent_equipment: EquivalentEquipment, table: TableEquivalentEquipment, result_set: ResultSet) -> bool:
1589
+ return self._load_conducting_equipment(equivalent_equipment, table, result_set)
1590
+
1591
+ #######################################
1592
+ # IEC61970 Base Generation Production #
1593
+ #######################################
1594
+
1595
+ def load_battery_unit(self, table: TableBatteryUnits, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1596
+ """
1597
+ Create a :class:`BatteryUnit` and populate its fields from :class:`TableBatteryUnits`.
1598
+
1599
+ :param table: The database table to read the :class:`BatteryUnit` fields from.
1600
+ :param result_set: The record in the database table containing the fields for this :class:`BatteryUnit`.
1601
+ :param set_identifier: A callback to register the mRID of this :class:`BatteryUnit` for logging purposes.
1602
+
1603
+ :return: True if the :class:`BatteryUnit` was successfully read from the database and added to the service.
1604
+ :raises SqlException: For any errors encountered reading from the database.
1605
+ """
1606
+ battery_unit = BatteryUnit(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1607
+
1608
+ battery_unit.battery_state = BatteryStateKind[result_set.get_string(table.battery_state.query_index)]
1609
+ battery_unit.rated_e = result_set.get_int(table.rated_e.query_index, on_none=None)
1610
+ battery_unit.stored_e = result_set.get_int(table.stored_e.query_index, on_none=None)
1611
+
1612
+ return self._load_power_electronics_unit(battery_unit, table, result_set) and self._add_or_throw(battery_unit)
1613
+
1614
+ def load_photo_voltaic_unit(self, table: TablePhotoVoltaicUnits, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1615
+ """
1616
+ Create a :class:`PhotoVoltaicUnit` and populate its fields from :class:`TablePhotoVoltaicUnits`.
1617
+
1618
+ :param table: The database table to read the :class:`PhotoVoltaicUnit` fields from.
1619
+ :param result_set: The record in the database table containing the fields for this :class:`PhotoVoltaicUnit`.
1620
+ :param set_identifier: A callback to register the mRID of this :class:`PhotoVoltaicUnit` for logging purposes.
1621
+
1622
+ :return: True if the :class:`PhotoVoltaicUnit` was successfully read from the database and added to the service.
1623
+ :raises SqlException: For any errors encountered reading from the database.
1624
+ """
1625
+ photo_voltaic_unit = PhotoVoltaicUnit(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1626
+
1627
+ return self._load_power_electronics_unit(photo_voltaic_unit, table, result_set) and self._add_or_throw(photo_voltaic_unit)
1628
+
1629
+ def _load_power_electronics_unit(self, power_electronics_unit: PowerElectronicsUnit, table: TablePowerElectronicsUnits, result_set: ResultSet) -> bool:
1630
+ power_electronics_unit.power_electronics_connection = self._ensure_get(
1631
+ result_set.get_string(table.power_electronics_connection_mrid.query_index, on_none=None),
1632
+ PowerElectronicsConnection
1633
+ )
1634
+ power_electronics_unit.max_p = result_set.get_int(table.max_p.query_index, on_none=None)
1635
+ power_electronics_unit.min_p = result_set.get_int(table.min_p.query_index, on_none=None)
1636
+
1637
+ if power_electronics_unit.power_electronics_connection:
1638
+ power_electronics_unit.power_electronics_connection.add_unit(power_electronics_unit)
1639
+
1640
+ return self._load_equipment(power_electronics_unit, table, result_set)
1641
+
1642
+ def load_power_electronics_wind_unit(self, table: TablePowerElectronicsWindUnits, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1643
+ """
1644
+ Create a :class:`PowerElectronicsWindUnit` and populate its fields from :class:`TablePowerElectronicsWindUnits`.
1645
+
1646
+ :param table: The database table to read the :class:`PowerElectronicsWindUnit` fields from.
1647
+ :param result_set: The record in the database table containing the fields for this :class:`PowerElectronicsWindUnit`.
1648
+ :param set_identifier: A callback to register the mRID of this :class:`PowerElectronicsWindUnit` for logging purposes.
1649
+
1650
+ :return: True if the :class:`PowerElectronicsWindUnit` was successfully read from the database and added to the service.
1651
+ :raises SqlException: For any errors encountered reading from the database.
1652
+ """
1653
+ power_electronics_wind_unit = PowerElectronicsWindUnit(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1654
+
1655
+ return self._load_power_electronics_unit(power_electronics_wind_unit, table, result_set) and self._add_or_throw(power_electronics_wind_unit)
1656
+
1657
+ ######################
1658
+ # IEC61970 Base Meas #
1659
+ ######################
1660
+
1661
+ def load_accumulator(self, table: TableAccumulators, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1662
+ """
1663
+ Create an :class:`Accumulator` and populate its fields from :class:`TableAccumulators`.
1664
+
1665
+ :param table: The database table to read the :class:`Accumulator` fields from.
1666
+ :param result_set: The record in the database table containing the fields for this :class:`Accumulator`.
1667
+ :param set_identifier: A callback to register the mRID of this :class:`Accumulator` for logging purposes.
1668
+
1669
+ :return: True if the :class:`Accumulator` was successfully read from the database and added to the service.
1670
+ :raises SqlException: For any errors encountered reading from the database.
1671
+ """
1672
+ meas = Accumulator(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1673
+
1674
+ return self._load_measurement(meas, table, result_set) and self._add_or_throw(meas)
1675
+
1676
+ def load_analog(self, table: TableAnalogs, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1677
+ """
1678
+ Create an :class:`Analog` and populate its fields from :class:`TableAnalogs`.
1679
+
1680
+ :param table: The database table to read the :class:`Analog` fields from.
1681
+ :param result_set: The record in the database table containing the fields for this :class:`Analog`.
1682
+ :param set_identifier: A callback to register the mRID of this :class:`Analog` for logging purposes.
1683
+
1684
+ :return: True if the :class:`Analog` was successfully read from the database and added to the service.
1685
+ :raises SqlException: For any errors encountered reading from the database.
1686
+ """
1687
+ meas = Analog(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1688
+
1689
+ meas.positive_flow_in = result_set.get_boolean(table.positive_flow_in.query_index)
1690
+
1691
+ return self._load_measurement(meas, table, result_set) and self._add_or_throw(meas)
1692
+
1693
+ def load_control(self, table: TableControls, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1694
+ """
1695
+ Create a :class:`Control` and populate its fields from :class:`TableControls`.
1696
+
1697
+ :param table: The database table to read the :class:`Control` fields from.
1698
+ :param result_set: The record in the database table containing the fields for this :class:`Control`.
1699
+ :param set_identifier: A callback to register the mRID of this :class:`Control` for logging purposes.
1700
+
1701
+ :return: True if the :class:`Control` was successfully read from the database and added to the service.
1702
+ :raises SqlException: For any errors encountered reading from the database.
1703
+ """
1704
+ control = Control(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1705
+
1706
+ control.power_system_resource_mrid = result_set.get_string(table.power_system_resource_mrid.query_index, on_none=None)
1707
+
1708
+ return self._load_io_point(control, table, result_set) and self._add_or_throw(control)
1709
+
1710
+ def load_discrete(self, table: TableDiscretes, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1711
+ """
1712
+ Create a :class:`Discrete` and populate its fields from :class:`TableDiscretes`.
1713
+
1714
+ :param table: The database table to read the :class:`Discrete` fields from.
1715
+ :param result_set: The record in the database table containing the fields for this :class:`Discrete`.
1716
+ :param set_identifier: A callback to register the mRID of this :class:`Discrete` for logging purposes.
1717
+
1718
+ :return: True if the :class:`Discrete` was successfully read from the database and added to the service.
1719
+ :raises SqlException: For any errors encountered reading from the database.
1720
+ """
1721
+ meas = Discrete(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1722
+
1723
+ return self._load_measurement(meas, table, result_set) and self._add_or_throw(meas)
1724
+
1725
+ def _load_io_point(self, io_point: IoPoint, table: TableIoPoints, result_set: ResultSet) -> bool:
1726
+ return self._load_identified_object(io_point, table, result_set)
1727
+
1728
+ def _load_measurement(self, measurement: Measurement, table: TableMeasurements, result_set: ResultSet) -> bool:
1729
+ measurement.power_system_resource_mrid = result_set.get_string(table.power_system_resource_mrid.query_index, on_none=None)
1730
+ measurement.remote_source = self._ensure_get(
1731
+ result_set.get_string(table.remote_source_mrid.query_index, on_none=None),
1732
+ RemoteSource
1733
+ )
1734
+ measurement.terminal_mrid = result_set.get_string(table.terminal_mrid.query_index, on_none=None)
1735
+ measurement.phases = PhaseCode[result_set.get_string(table.phases.query_index)]
1736
+ measurement.unit_symbol = UnitSymbol[result_set.get_string(table.unit_symbol.query_index)]
1737
+
1738
+ if measurement.remote_source:
1739
+ measurement.remote_source.measurement = measurement
1740
+
1741
+ return self._load_identified_object(measurement, table, result_set)
1742
+
1743
+ ############################
1744
+ # IEC61970 Base Protection #
1745
+ ############################
1746
+
1747
+ def load_current_relay(self, table: TableCurrentRelays, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1748
+ """
1749
+ Create a :class:`CurrentRelay` and populate its fields from :class:`TableCurrentRelays`.
1750
+
1751
+ :param table: The database table to read the :class:`CurrentRelay` fields from.
1752
+ :param result_set: The record in the database table containing the fields for this :class:`CurrentRelay`.
1753
+ :param set_identifier: A callback to register the mRID of this :class:`CurrentRelay` for logging purposes.
1754
+
1755
+ :return: True if the :class:`CurrentRelay` was successfully read from the database and added to the service.
1756
+ :raises SqlException: For any errors encountered reading from the database.
1757
+ """
1758
+ current_relay = CurrentRelay(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1759
+
1760
+ current_relay.current_limit_1 = result_set.get_float(table.current_limit_1.query_index, on_none=None)
1761
+ current_relay.inverse_time_flag = result_set.get_boolean(table.inverse_time_flag.query_index, on_none=None)
1762
+ current_relay.time_delay_1 = result_set.get_float(table.time_delay_1.query_index, on_none=None)
1763
+
1764
+ return self._load_protection_relay_function(current_relay, table, result_set) and self._add_or_throw(current_relay)
1765
+
1766
+ #######################
1767
+ # IEC61970 Base Scada #
1768
+ #######################
1769
+
1770
+ def load_remote_control(self, table: TableRemoteControls, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1771
+ """
1772
+ Create a :class:`RemoteControl` and populate its fields from :class:`TableRemoteControls`.
1773
+
1774
+ :param table: The database table to read the :class:`RemoteControl` fields from.
1775
+ :param result_set: The record in the database table containing the fields for this :class:`RemoteControl`.
1776
+ :param set_identifier: A callback to register the mRID of this :class:`RemoteControl` for logging purposes.
1777
+
1778
+ :return: True if the :class:`RemoteControl` was successfully read from the database and added to the service.
1779
+ :raises SqlException: For any errors encountered reading from the database.
1780
+ """
1781
+ remote_control = RemoteControl(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1782
+
1783
+ remote_control.control = self._ensure_get(
1784
+ result_set.get_string(table.control_mrid.query_index, on_none=None),
1785
+ Control
1786
+ )
1787
+ if remote_control.control:
1788
+ remote_control.control.remote_control = remote_control
1789
+
1790
+ return self._load_remote_point(remote_control, table, result_set) and self._add_or_throw(remote_control)
1791
+
1792
+ def _load_remote_point(self, remote_point: RemotePoint, table: TableRemotePoints, result_set: ResultSet) -> bool:
1793
+ return self._load_identified_object(remote_point, table, result_set)
1794
+
1795
+ def load_remote_source(self, table: TableRemoteSources, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1796
+ """
1797
+ Create a :class:`RemoteSource` and populate its fields from :class:`TableRemoteSources`.
1798
+
1799
+ :param table: The database table to read the :class:`RemoteSource` fields from.
1800
+ :param result_set: The record in the database table containing the fields for this :class:`RemoteSource`.
1801
+ :param set_identifier: A callback to register the mRID of this :class:`RemoteSource` for logging purposes.
1802
+
1803
+ :return: True if the :class:`RemoteSource` was successfully read from the database and added to the service.
1804
+ :raises SqlException: For any errors encountered reading from the database.
1805
+ """
1806
+ remote_source = RemoteSource(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1807
+
1808
+ return self._load_remote_point(remote_source, table, result_set) and self._add_or_throw(remote_source)
1809
+
1810
+ #######################
1811
+ # IEC61970 Base Wires #
1812
+ #######################
1813
+
1814
+ def load_ac_line_segment(self, table: TableAcLineSegments, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1815
+ """
1816
+ Create an :class:`AcLineSegment` and populate its fields from :class:`TableAcLineSegments`.
1817
+
1818
+ :param table: The database table to read the :class:`AcLineSegment` fields from.
1819
+ :param result_set: The record in the database table containing the fields for this :class:`AcLineSegment`.
1820
+ :param set_identifier: A callback to register the mRID of this :class:`AcLineSegment` for logging purposes.
1821
+
1822
+ :return: True if the :class:`AcLineSegment` was successfully read from the database and added to the service.
1823
+ :raises SqlException: For any errors encountered reading from the database.
1824
+ """
1825
+ ac_line_segment = AcLineSegment(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1826
+
1827
+ ac_line_segment.per_length_impedance = self._ensure_get(
1828
+ result_set.get_string(table.per_length_impedance_mrid.query_index, on_none=None),
1829
+ PerLengthImpedance
1830
+ )
1831
+
1832
+ return self._load_conductor(ac_line_segment, table, result_set) and self._add_or_throw(ac_line_segment)
1833
+
1834
+ def load_breaker(self, table: TableBreakers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1835
+ """
1836
+ Create a :class:`Breaker` and populate its fields from :class:`TableBreakers`.
1837
+
1838
+ :param table: The database table to read the :class:`Breaker` fields from.
1839
+ :param result_set: The record in the database table containing the fields for this :class:`Breaker`.
1840
+ :param set_identifier: A callback to register the mRID of this :class:`Breaker` for logging purposes.
1841
+
1842
+ :return: True if the :class:`Breaker` was successfully read from the database and added to the service.
1843
+ :raises SqlException: For any errors encountered reading from the database.
1844
+ """
1845
+ breaker = Breaker(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1846
+
1847
+ breaker.in_transit_time = result_set.get_float(table.in_transit_time.query_index, on_none=None)
1848
+
1849
+ return self._load_protected_switch(breaker, table, result_set) and self._add_or_throw(breaker)
1850
+
1851
+ def load_busbar_section(self, table: TableBusbarSections, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1852
+ """
1853
+ Create a :class:`BusbarSection` and populate its fields from :class:`TableBusbarSections`.
1854
+
1855
+ :param table: The database table to read the :class:`BusbarSection` fields from.
1856
+ :param result_set: The record in the database table containing the fields for this :class:`BusbarSection`.
1857
+ :param set_identifier: A callback to register the mRID of this :class:`BusbarSection` for logging purposes.
1858
+
1859
+ :return: True if the :class:`BusbarSection` was successfully read from the database and added to the service.
1860
+ :raises SqlException: For any errors encountered reading from the database.
1861
+ """
1862
+ busbar_section = BusbarSection(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1863
+
1864
+ return self._load_connector(busbar_section, table, result_set) and self._add_or_throw(busbar_section)
1865
+
1866
+ def load_clamp(self, table: TableClamps, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1867
+ """
1868
+ Create a :class:`Clamp` and populate its fields from :class:`TableClamps`.
1869
+
1870
+ :param table: The database table to read the :class:`Clamp` fields from.
1871
+ :param result_set: The record in the database table containing the fields for this :class:`Clamp`.
1872
+ :param set_identifier: A callback to register the mRID of this :class:`Clamp` for logging purposes.
1873
+
1874
+ :return: True if the :class:`Clamp` was successfully read from the database and added to the service.
1875
+ :raises SqlException: For any errors encountered reading from the database.
1876
+ """
1877
+ clamp = Clamp(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1878
+
1879
+ clamp.length_from_terminal_1 = result_set.get_float(table.length_from_terminal_1.query_index, on_none=None)
1880
+ clamp.ac_line_segment = self._ensure_get(result_set.get_string(table.ac_line_segment_mrid.query_index, on_none=None), AcLineSegment)
1881
+
1882
+ if clamp.ac_line_segment:
1883
+ clamp.ac_line_segment.add_clamp(clamp)
1884
+
1885
+ return self._load_conducting_equipment(clamp, table, result_set) and self._add_or_throw(clamp)
1886
+
1887
+ def _load_conductor(self, conductor: Conductor, table: TableConductors, result_set: ResultSet) -> bool:
1888
+ conductor.length = result_set.get_float(table.length.query_index, on_none=None)
1889
+ conductor.design_temperature = result_set.get_int(table.design_temperature.query_index, on_none=None)
1890
+ conductor.design_rating = result_set.get_float(table.design_rating.query_index, on_none=None)
1891
+ conductor.asset_info = self._ensure_get(
1892
+ result_set.get_string(table.wire_info_mrid.query_index, on_none=None),
1893
+ WireInfo
1894
+ )
1895
+
1896
+ return self._load_conducting_equipment(conductor, table, result_set)
1897
+
1898
+ def _load_connector(self, connector: Connector, table: TableConnectors, result_set: ResultSet) -> bool:
1899
+ return self._load_conducting_equipment(connector, table, result_set)
1900
+
1901
+ def load_cut(self, table: TableCuts, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1902
+ """
1903
+ Create a :class:`Cut` and populate its fields from :class:`TableCuts`.
1904
+
1905
+ :param table: The database table to read the :class:`Cut` fields from.
1906
+ :param result_set: The record in the database table containing the fields for this :class:`Cut`.
1907
+ :param set_identifier: A callback to register the mRID of this :class:`Cut` for logging purposes.
1908
+
1909
+ :return: True if the :class:`Cut` was successfully read from the database and added to the service.
1910
+ :raises SqlException: For any errors encountered reading from the database.
1911
+ """
1912
+ cut = Cut(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1913
+
1914
+ cut.length_from_terminal_1 = result_set.get_float(table.length_from_terminal_1.query_index, on_none=None)
1915
+ cut.ac_line_segment = self._ensure_get(result_set.get_string(table.ac_line_segment_mrid.query_index, on_none=None), AcLineSegment)
1916
+
1917
+ if cut.ac_line_segment:
1918
+ cut.ac_line_segment.add_cut(cut)
1919
+
1920
+ return self._load_switch(cut, table, result_set) and self._add_or_throw(cut)
1921
+
1922
+ def load_disconnector(self, table: TableDisconnectors, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1923
+ """
1924
+ Create a :class:`Disconnector` and populate its fields from :class:`TableDisconnectors`.
1925
+
1926
+ :param table: The database table to read the :class:`Disconnector` fields from.
1927
+ :param result_set: The record in the database table containing the fields for this :class:`Disconnector`.
1928
+ :param set_identifier: A callback to register the mRID of this :class:`Disconnector` for logging purposes.
1929
+
1930
+ :return: True if the :class:`Disconnector` was successfully read from the database and added to the service.
1931
+ :raises SqlException: For any errors encountered reading from the database.
1932
+ """
1933
+ disconnector = Disconnector(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1934
+
1935
+ return self._load_switch(disconnector, table, result_set) and self._add_or_throw(disconnector)
1936
+
1937
+ def _load_earth_fault_compensator(self, earth_fault_compensator: EarthFaultCompensator, table: TableEarthFaultCompensators, result_set: ResultSet) -> bool:
1938
+ earth_fault_compensator.r = result_set.get_float(table.r.query_index, on_none=None)
1939
+
1940
+ return self._load_conducting_equipment(earth_fault_compensator, table, result_set)
1941
+
1942
+ def _load_energy_connection(self, energy_connection: EnergyConnection, table: TableEnergyConnections, result_set: ResultSet) -> bool:
1943
+ return self._load_conducting_equipment(energy_connection, table, result_set)
1944
+
1945
+ def load_energy_consumer(self, table: TableEnergyConsumers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1946
+ """
1947
+ Create an :class:`EnergyConsumer` and populate its fields from :class:`TableEnergyConsumers`.
1948
+
1949
+ :param table: The database table to read the :class:`EnergyConsumer` fields from.
1950
+ :param result_set: The record in the database table containing the fields for this :class:`EnergyConsumer`.
1951
+ :param set_identifier: A callback to register the mRID of this :class:`EnergyConsumer` for logging purposes.
1952
+
1953
+ :return: True if the :class:`EnergyConsumer` was successfully read from the database and added to the service.
1954
+ :raises SqlException: For any errors encountered reading from the database.
1955
+ """
1956
+ energy_consumer = EnergyConsumer(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1957
+
1958
+ energy_consumer.customer_count = result_set.get_int(table.customer_count.query_index, on_none=None)
1959
+ energy_consumer.grounded = result_set.get_boolean(table.grounded.query_index)
1960
+ energy_consumer.p = result_set.get_float(table.p.query_index, on_none=None)
1961
+ energy_consumer.q = result_set.get_float(table.q.query_index, on_none=None)
1962
+ energy_consumer.p_fixed = result_set.get_float(table.p_fixed.query_index, on_none=None)
1963
+ energy_consumer.q_fixed = result_set.get_float(table.q_fixed.query_index, on_none=None)
1964
+ energy_consumer.phase_connection = PhaseShuntConnectionKind[result_set.get_string(table.phase_connection.query_index)]
1965
+
1966
+ return self._load_energy_connection(energy_consumer, table, result_set) and self._add_or_throw(energy_consumer)
1967
+
1968
+ def load_energy_consumer_phase(self, table: TableEnergyConsumerPhases, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1969
+ """
1970
+ Create an :class:`EnergyConsumerPhase` and populate its fields from :class:`TableEnergyConsumerPhases`.
1971
+
1972
+ :param table: The database table to read the :class:`EnergyConsumerPhase` fields from.
1973
+ :param result_set: The record in the database table containing the fields for this :class:`EnergyConsumerPhase`.
1974
+ :param set_identifier: A callback to register the mRID of this :class:`EnergyConsumerPhase` for logging purposes.
1975
+
1976
+ :return: True if the :class:`EnergyConsumerPhase` was successfully read from the database and added to the service.
1977
+ :raises SqlException: For any errors encountered reading from the database.
1978
+ """
1979
+ energy_consumer_phase = EnergyConsumerPhase(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
1980
+
1981
+ energy_consumer_phase.energy_consumer = self._ensure_get(
1982
+ result_set.get_string(table.energy_consumer_mrid.query_index),
1983
+ EnergyConsumer
1984
+ )
1985
+ energy_consumer_phase.phase = SinglePhaseKind[result_set.get_string(table.phase.query_index)]
1986
+ energy_consumer_phase.p = result_set.get_float(table.p.query_index, on_none=None)
1987
+ energy_consumer_phase.q = result_set.get_float(table.q.query_index, on_none=None)
1988
+ energy_consumer_phase.p_fixed = result_set.get_float(table.p_fixed.query_index, on_none=None)
1989
+ energy_consumer_phase.q_fixed = result_set.get_float(table.q_fixed.query_index, on_none=None)
1990
+
1991
+ if energy_consumer_phase.energy_consumer:
1992
+ energy_consumer_phase.energy_consumer.add_phase(energy_consumer_phase)
1993
+
1994
+ return self._load_power_system_resource(energy_consumer_phase, table, result_set) and self._add_or_throw(energy_consumer_phase)
1995
+
1996
+ def load_energy_source(self, table: TableEnergySources, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
1997
+ """
1998
+ Create an :class:`EnergySource` and populate its fields from :class:`TableEnergySources`.
1999
+
2000
+ :param table: The database table to read the :class:`EnergySource` fields from.
2001
+ :param result_set: The record in the database table containing the fields for this :class:`EnergySource`.
2002
+ :param set_identifier: A callback to register the mRID of this :class:`EnergySource` for logging purposes.
2003
+
2004
+ :return: True if the :class:`EnergySource` was successfully read from the database and added to the service.
2005
+ :raises SqlException: For any errors encountered reading from the database.
2006
+ """
2007
+ energy_source = EnergySource(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2008
+
2009
+ energy_source.active_power = result_set.get_float(table.active_power.query_index, on_none=None)
2010
+ energy_source.reactive_power = result_set.get_float(table.reactive_power.query_index, on_none=None)
2011
+ energy_source.voltage_angle = result_set.get_float(table.voltage_angle.query_index, on_none=None)
2012
+ energy_source.voltage_magnitude = result_set.get_float(table.voltage_magnitude.query_index, on_none=None)
2013
+ energy_source.p_max = result_set.get_float(table.p_max.query_index, on_none=None)
2014
+ energy_source.p_min = result_set.get_float(table.p_min.query_index, on_none=None)
2015
+ energy_source.r = result_set.get_float(table.r.query_index, on_none=None)
2016
+ energy_source.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2017
+ energy_source.rn = result_set.get_float(table.rn.query_index, on_none=None)
2018
+ energy_source.x = result_set.get_float(table.x.query_index, on_none=None)
2019
+ energy_source.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2020
+ energy_source.xn = result_set.get_float(table.xn.query_index, on_none=None)
2021
+ energy_source.is_external_grid = result_set.get_boolean(table.is_external_grid.query_index)
2022
+ energy_source.r_min = result_set.get_float(table.r_min.query_index, on_none=None)
2023
+ energy_source.rn_min = result_set.get_float(table.rn_min.query_index, on_none=None)
2024
+ energy_source.r0_min = result_set.get_float(table.r0_min.query_index, on_none=None)
2025
+ energy_source.x_min = result_set.get_float(table.x_min.query_index, on_none=None)
2026
+ energy_source.xn_min = result_set.get_float(table.xn_min.query_index, on_none=None)
2027
+ energy_source.x0_min = result_set.get_float(table.x0_min.query_index, on_none=None)
2028
+ energy_source.r_max = result_set.get_float(table.r_max.query_index, on_none=None)
2029
+ energy_source.rn_max = result_set.get_float(table.rn_max.query_index, on_none=None)
2030
+ energy_source.r0_max = result_set.get_float(table.r0_max.query_index, on_none=None)
2031
+ energy_source.x_max = result_set.get_float(table.x_max.query_index, on_none=None)
2032
+ energy_source.xn_max = result_set.get_float(table.xn_max.query_index, on_none=None)
2033
+ energy_source.x0_max = result_set.get_float(table.x0_max.query_index, on_none=None)
2034
+
2035
+ return self._load_energy_connection(energy_source, table, result_set) and self._add_or_throw(energy_source)
2036
+
2037
+ def load_energy_source_phase(self, table: TableEnergySourcePhases, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2038
+ """
2039
+ Create an :class:`EnergySourcePhase` and populate its fields from :class:`TableEnergySourcePhases`.
2040
+
2041
+ :param table: The database table to read the :class:`EnergySourcePhase` fields from.
2042
+ :param result_set: The record in the database table containing the fields for this :class:`EnergySourcePhase`.
2043
+ :param set_identifier: A callback to register the mRID of this :class:`EnergySourcePhase` for logging purposes.
2044
+
2045
+ :return: True if the :class:`EnergySourcePhase` was successfully read from the database and added to the service.
2046
+ :raises SqlException: For any errors encountered reading from the database.
2047
+ """
2048
+ energy_source_phase = EnergySourcePhase(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2049
+
2050
+ energy_source_phase.energy_source = self._ensure_get(
2051
+ result_set.get_string(table.energy_source_mrid.query_index),
2052
+ EnergySource
2053
+ )
2054
+ energy_source_phase.phase = SinglePhaseKind[result_set.get_string(table.phase.query_index)]
2055
+
2056
+ if energy_source_phase.energy_source:
2057
+ energy_source_phase.energy_source.add_phase(energy_source_phase)
2058
+
2059
+ return self._load_power_system_resource(energy_source_phase, table, result_set) and self._add_or_throw(energy_source_phase)
2060
+
2061
+ def load_fuse(self, table: TableFuses, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2062
+ """
2063
+ Create a :class:`Fuse` and populate its fields from :class:`TableFuses`.
2064
+
2065
+ :param table: The database table to read the :class:`Fuse` fields from.
2066
+ :param result_set: The record in the database table containing the fields for this :class:`Fuse`.
2067
+ :param set_identifier: A callback to register the mRID of this :class:`Fuse` for logging purposes.
2068
+
2069
+ :return: True if the :class:`Fuse` was successfully read from the database and added to the service.
2070
+ :raises SqlException: For any errors encountered reading from the database.
2071
+ """
2072
+ fuse = Fuse(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2073
+
2074
+ fuse.function = self._ensure_get(
2075
+ result_set.get_string(table.function_mrid.query_index, on_none=None),
2076
+ ProtectionRelayFunction
2077
+ )
2078
+
2079
+ return self._load_switch(fuse, table, result_set) and self._add_or_throw(fuse)
2080
+
2081
+ def load_ground(self, table: TableGrounds, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2082
+ """
2083
+ Create a :class:`Ground` and populate its fields from :class:`TableGrounds`.
2084
+
2085
+ :param table: The database table to read the :class:`Ground` fields from.
2086
+ :param result_set: The record in the database table containing the fields for this :class:`Ground`.
2087
+ :param set_identifier: A callback to register the mRID of this :class:`Ground` for logging purposes.
2088
+
2089
+ :return: True if the :class:`Ground` was successfully read from the database and added to the service.
2090
+ :raises SqlException: For any errors encountered reading from the database.
2091
+ """
2092
+ ground = Ground(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2093
+
2094
+ return self._load_conducting_equipment(ground, table, result_set) and self._add_or_throw(ground)
2095
+
2096
+ def load_ground_disconnector(self, table: TableGroundDisconnectors, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2097
+ """
2098
+ Create a :class:`GroundDisconnector` and populate its fields from :class:`TableGroundDisconnectors`.
2099
+
2100
+ :param table: The database table to read the :class:`GroundDisconnector` fields from.
2101
+ :param result_set: The record in the database table containing the fields for this :class:`GroundDisconnector`.
2102
+ :param set_identifier: A callback to register the mRID of this :class:`GroundDisconnector` for logging purposes.
2103
+
2104
+ :return: True if the :class:`GroundDisconnector` was successfully read from the database and added to the service.
2105
+ :raises SqlException: For any errors encountered reading from the database.
2106
+ """
2107
+ ground_disconnector = GroundDisconnector(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2108
+
2109
+ return self._load_switch(ground_disconnector, table, result_set) and self._add_or_throw(ground_disconnector)
2110
+
2111
+ def load_grounding_impedance(self, table: TableGroundingImpedances, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2112
+ """
2113
+ Create a :class:`GroundingImpedance` and populate its fields from :class:`TableGroundingImpedances`.
2114
+
2115
+ :param table: The database table to read the :class:`GroundingImpedance` fields from.
2116
+ :param result_set: The record in the database table containing the fields for this :class:`GroundingImpedance`.
2117
+ :param set_identifier: A callback to register the mRID of this :class:`GroundingImpedance` for logging purposes.
2118
+
2119
+ :return: True if the :class:`GroundingImpedance` was successfully read from the database and added to the service.
2120
+ :raises SqlException: For any errors encountered reading from the database.
2121
+ """
2122
+ grounding_impedance = GroundingImpedance(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2123
+
2124
+ grounding_impedance.x = result_set.get_float(table.x.query_index, on_none=None)
2125
+
2126
+ return self._load_earth_fault_compensator(grounding_impedance, table, result_set) and self._add_or_throw(grounding_impedance)
2127
+
2128
+ def load_jumper(self, table: TableJumpers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2129
+ """
2130
+ Create a :class:`Jumper` and populate its fields from :class:`TableJumpers`.
2131
+
2132
+ :param table: The database table to read the :class:`Jumper` fields from.
2133
+ :param result_set: The record in the database table containing the fields for this :class:`Jumper`.
2134
+ :param set_identifier: A callback to register the mRID of this :class:`Jumper` for logging purposes.
2135
+
2136
+ :return: True if the :class:`Jumper` was successfully read from the database and added to the service.
2137
+ :raises SqlException: For any errors encountered reading from the database.
2138
+ """
2139
+ jumper = Jumper(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2140
+
2141
+ return self._load_switch(jumper, table, result_set) and self._add_or_throw(jumper)
2142
+
2143
+ def load_junction(self, table: TableJunctions, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2144
+ """
2145
+ Create a :class:`Junction` and populate its fields from :class:`TableJunctions`.
2146
+
2147
+ :param table: The database table to read the :class:`Junction` fields from.
2148
+ :param result_set: The record in the database table containing the fields for this :class:`Junction`.
2149
+ :param set_identifier: A callback to register the mRID of this :class:`Junction` for logging purposes.
2150
+
2151
+ :return: True if the :class:`Junction` was successfully read from the database and added to the service.
2152
+ :raises SqlException: For any errors encountered reading from the database.
2153
+ """
2154
+ junction = Junction(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2155
+
2156
+ return self._load_connector(junction, table, result_set) and self._add_or_throw(junction)
2157
+
2158
+ def _load_line(self, line: Line, table: TableLines, result_set: ResultSet) -> bool:
2159
+ return self._load_equipment_container(line, table, result_set)
2160
+
2161
+ def load_linear_shunt_compensator(self, table: TableLinearShuntCompensators, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2162
+ """
2163
+ Create a :class:`LinearShuntCompensator` and populate its fields from :class:`TableLinearShuntCompensators`.
2164
+
2165
+ :param table: The database table to read the :class:`LinearShuntCompensator` fields from.
2166
+ :param result_set: The record in the database table containing the fields for this :class:`LinearShuntCompensator`.
2167
+ :param set_identifier: A callback to register the mRID of this :class:`LinearShuntCompensator` for logging purposes.
2168
+
2169
+ :return: True if the :class:`LinearShuntCompensator` was successfully read from the database and added to the service.
2170
+ :raises SqlException: For any errors encountered reading from the database.
2171
+ """
2172
+ linear_shunt_compensator = LinearShuntCompensator(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2173
+
2174
+ linear_shunt_compensator.b0_per_section = result_set.get_float(table.b0_per_section.query_index, on_none=None)
2175
+ linear_shunt_compensator.b_per_section = result_set.get_float(table.b_per_section.query_index, on_none=None)
2176
+ linear_shunt_compensator.g0_per_section = result_set.get_float(table.g0_per_section.query_index, on_none=None)
2177
+ linear_shunt_compensator.g_per_section = result_set.get_float(table.g_per_section.query_index, on_none=None)
2178
+
2179
+ return self._load_shunt_compensator(linear_shunt_compensator, table, result_set) and self._add_or_throw(linear_shunt_compensator)
2180
+
2181
+ def load_load_break_switch(self, table: TableLoadBreakSwitches, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2182
+ """
2183
+ Create a :class:`LoadBreakSwitch` and populate its fields from :class:`TableLoadBreakSwitches`.
2184
+
2185
+ :param table: The database table to read the :class:`LoadBreakSwitch` fields from.
2186
+ :param result_set: The record in the database table containing the fields for this :class:`LoadBreakSwitch`.
2187
+ :param set_identifier: A callback to register the mRID of this :class:`LoadBreakSwitch` for logging purposes.
2188
+
2189
+ :return: True if the :class:`LoadBreakSwitch` was successfully read from the database and added to the service.
2190
+ :raises SqlException: For any errors encountered reading from the database.
2191
+ """
2192
+ load_break_switch = LoadBreakSwitch(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2193
+
2194
+ return self._load_protected_switch(load_break_switch, table, result_set) and self._add_or_throw(load_break_switch)
2195
+
2196
+ def _load_per_length_impedance(self, per_length_impedance: PerLengthImpedance, table: TablePerLengthImpedances, result_set: ResultSet) -> bool:
2197
+ return self._load_per_length_line_parameter(per_length_impedance, table, result_set)
2198
+
2199
+ def _load_per_length_line_parameter(
2200
+ self,
2201
+ per_length_line_parameter: PerLengthLineParameter,
2202
+ table: TablePerLengthLineParameters,
2203
+ result_set: ResultSet
2204
+ ) -> bool:
2205
+ return self._load_identified_object(per_length_line_parameter, table, result_set)
2206
+
2207
+ def load_per_length_phase_impedance(self, table: TablePerLengthPhaseImpedances, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2208
+ """
2209
+ Create a :class:`PerLengthPhaseImpedance` and populate its fields from :class:`TablePerLengthPhaseImpedances`.
2210
+
2211
+ :param table: The database table to read the :class:`PerLengthPhaseImpedance` fields from.
2212
+ :param result_set: The record in the database table containing the fields for this :class:`PerLengthPhaseImpedance`.
2213
+ :param set_identifier: A callback to register the mRID of this :class:`PerLengthPhaseImpedance` for logging purposes.
2214
+
2215
+ :return: True if the :class:`PerLengthPhaseImpedance` was successfully read from the database and added to the service.
2216
+ :raises SqlException: For any errors encountered reading from the database.
2217
+ """
2218
+ per_length_phase_impedance = PerLengthPhaseImpedance(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2219
+
2220
+ return self._load_per_length_impedance(per_length_phase_impedance, table, result_set) and self._add_or_throw(per_length_phase_impedance)
2221
+
2222
+ def load_per_length_sequence_impedance(self, table: TablePerLengthSequenceImpedances, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2223
+ """
2224
+ Create a :class:`PerLengthSequenceImpedance` and populate its fields from :class:`TablePerLengthSequenceImpedances`.
2225
+
2226
+ :param table: The database table to read the :class:`PerLengthSequenceImpedance` fields from.
2227
+ :param result_set: The record in the database table containing the fields for this :class:`PerLengthSequenceImpedance`.
2228
+ :param set_identifier: A callback to register the mRID of this :class:`PerLengthSequenceImpedance` for logging purposes.
2229
+
2230
+ :return: True if the :class:`PerLengthSequenceImpedance` was successfully read from the database and added to the service.
2231
+ :raises SqlException: For any errors encountered reading from the database.
2232
+ """
2233
+ per_length_sequence_impedance = PerLengthSequenceImpedance(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2234
+
2235
+ per_length_sequence_impedance.r = result_set.get_float(table.r.query_index, on_none=None)
2236
+ per_length_sequence_impedance.x = result_set.get_float(table.x.query_index, on_none=None)
2237
+ per_length_sequence_impedance.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2238
+ per_length_sequence_impedance.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2239
+ per_length_sequence_impedance.bch = result_set.get_float(table.bch.query_index, on_none=None)
2240
+ per_length_sequence_impedance.gch = result_set.get_float(table.gch.query_index, on_none=None)
2241
+ per_length_sequence_impedance.b0ch = result_set.get_float(table.b0ch.query_index, on_none=None)
2242
+ per_length_sequence_impedance.g0ch = result_set.get_float(table.g0ch.query_index, on_none=None)
2243
+
2244
+ return self._load_per_length_impedance(per_length_sequence_impedance, table, result_set) and self._add_or_throw(per_length_sequence_impedance)
2245
+
2246
+ def load_petersen_coil(self, table: TablePetersenCoils, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2247
+ """
2248
+ Create a :class:`PetersenCoil` and populate its fields from :class:`TablePetersenCoils`.
2249
+
2250
+ :param table: The database table to read the :class:`PetersenCoil` fields from.
2251
+ :param result_set: The record in the database table containing the fields for this :class:`PetersenCoil`.
2252
+ :param set_identifier: A callback to register the mRID of this :class:`PetersenCoil` for logging purposes.
2253
+
2254
+ :return: True if the :class:`PetersenCoil` was successfully read from the database and added to the service.
2255
+ :raises SqlException: For any errors encountered reading from the database.
2256
+ """
2257
+ petersen_coil = PetersenCoil(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2258
+
2259
+ petersen_coil.x_ground_nominal = result_set.get_float(table.x_ground_nominal.query_index, on_none=None)
2260
+
2261
+ return self._load_earth_fault_compensator(petersen_coil, table, result_set) and self._add_or_throw(petersen_coil)
2262
+
2263
+ def load_phase_impedance_data(self, table: TablePhaseImpedanceData, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2264
+ """
2265
+ Create a :class:`PhaseImpedanceData` and populate its fields from :class:`TableConnectivityNodes`.
2266
+
2267
+ :param table: The database table to read the :class:`PhaseImpedanceData` fields from.
2268
+ :param result_set: The record in the database table containing the fields for this :class:`PhaseImpedanceData`.
2269
+ :param set_identifier: A callback to register the mRID of this :class:`PhaseImpedanceData` for logging purposes.
2270
+
2271
+ :return: True if the :class:`PhaseImpedanceData` was successfully read from the database and added to the service.
2272
+ :raises SqlException: For any errors encountered reading from the database.
2273
+ """
2274
+ per_length_phase_impedance_mrid = result_set.get_string(table.per_length_phase_impedance_mrid.query_index)
2275
+ set_identifier(result_set.get_string(table.per_length_phase_impedance_mrid.query_index))
2276
+
2277
+ per_length_phase_impedance = self._service.get(per_length_phase_impedance_mrid, PerLengthPhaseImpedance)
2278
+
2279
+ per_length_phase_impedance.add_data(
2280
+ PhaseImpedanceData(
2281
+ SinglePhaseKind[result_set.get_string(table.from_phase.query_index)],
2282
+ SinglePhaseKind[result_set.get_string(table.to_phase.query_index)],
2283
+ result_set.get_float(table.b.query_index, on_none=None),
2284
+ result_set.get_float(table.g.query_index, on_none=None),
2285
+ result_set.get_float(table.r.query_index, on_none=None),
2286
+ result_set.get_float(table.x.query_index, on_none=None),
2287
+ )
2288
+ )
2289
+
2290
+ return True
2291
+
2292
+ def load_power_electronics_connection(self, table: TablePowerElectronicsConnections, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2293
+ """
2294
+ Create a :class:`PowerElectronicsConnection` and populate its fields from :class:`TablePowerElectronicsConnections`.
2295
+
2296
+ :param table: The database table to read the :class:`PowerElectronicsConnection` fields from.
2297
+ :param result_set: The record in the database table containing the fields for this :class:`PowerElectronicsConnection`.
2298
+ :param set_identifier: A callback to register the mRID of this :class:`PowerElectronicsConnection` for logging purposes.
2299
+
2300
+ :return: True if the :class:`PowerElectronicsConnection` was successfully read from the database and added to the service.
2301
+ :raises SqlException: For any errors encountered reading from the database.
2302
+ """
2303
+ power_electronics_connection = PowerElectronicsConnection(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2304
+
2305
+ power_electronics_connection.max_i_fault = result_set.get_int(table.max_i_fault.query_index, on_none=None)
2306
+ power_electronics_connection.max_q = result_set.get_float(table.max_q.query_index, on_none=None)
2307
+ power_electronics_connection.min_q = result_set.get_float(table.min_q.query_index, on_none=None)
2308
+ power_electronics_connection.p = result_set.get_float(table.p.query_index, on_none=None)
2309
+ power_electronics_connection.q = result_set.get_float(table.q.query_index, on_none=None)
2310
+ power_electronics_connection.rated_u = result_set.get_int(table.rated_u.query_index, on_none=None)
2311
+ power_electronics_connection.rated_s = result_set.get_int(table.rated_s.query_index, on_none=None)
2312
+ power_electronics_connection.inverter_standard = result_set.get_string(table.inverter_standard.query_index, on_none=None)
2313
+ power_electronics_connection.sustain_op_overvolt_limit = result_set.get_int(table.sustain_op_overvolt_limit.query_index, on_none=None)
2314
+ power_electronics_connection.stop_at_over_freq = result_set.get_float(table.stop_at_over_freq.query_index, on_none=None)
2315
+ power_electronics_connection.stop_at_under_freq = result_set.get_float(table.stop_at_under_freq.query_index, on_none=None)
2316
+ power_electronics_connection.inv_volt_watt_resp_mode = result_set.get_boolean(table.inv_volt_watt_resp_mode.query_index, on_none=None)
2317
+ power_electronics_connection.inv_watt_resp_v1 = result_set.get_int(table.inv_watt_resp_v1.query_index, on_none=None)
2318
+ power_electronics_connection.inv_watt_resp_v2 = result_set.get_int(table.inv_watt_resp_v2.query_index, on_none=None)
2319
+ power_electronics_connection.inv_watt_resp_v3 = result_set.get_int(table.inv_watt_resp_v3.query_index, on_none=None)
2320
+ power_electronics_connection.inv_watt_resp_v4 = result_set.get_int(table.inv_watt_resp_v4.query_index, on_none=None)
2321
+ power_electronics_connection.inv_watt_resp_p_at_v1 = result_set.get_float(table.inv_watt_resp_p_at_v1.query_index, on_none=None)
2322
+ power_electronics_connection.inv_watt_resp_p_at_v2 = result_set.get_float(table.inv_watt_resp_p_at_v2.query_index, on_none=None)
2323
+ power_electronics_connection.inv_watt_resp_p_at_v3 = result_set.get_float(table.inv_watt_resp_p_at_v3.query_index, on_none=None)
2324
+ power_electronics_connection.inv_watt_resp_p_at_v4 = result_set.get_float(table.inv_watt_resp_p_at_v4.query_index, on_none=None)
2325
+ power_electronics_connection.inv_volt_var_resp_mode = result_set.get_boolean(table.inv_volt_var_resp_mode.query_index, on_none=None)
2326
+ power_electronics_connection.inv_var_resp_v1 = result_set.get_int(table.inv_var_resp_v1.query_index, on_none=None)
2327
+ power_electronics_connection.inv_var_resp_v2 = result_set.get_int(table.inv_var_resp_v2.query_index, on_none=None)
2328
+ power_electronics_connection.inv_var_resp_v3 = result_set.get_int(table.inv_var_resp_v3.query_index, on_none=None)
2329
+ power_electronics_connection.inv_var_resp_v4 = result_set.get_int(table.inv_var_resp_v4.query_index, on_none=None)
2330
+ power_electronics_connection.inv_var_resp_q_at_v1 = result_set.get_float(table.inv_var_resp_q_at_v1.query_index, on_none=None)
2331
+ power_electronics_connection.inv_var_resp_q_at_v2 = result_set.get_float(table.inv_var_resp_q_at_v2.query_index, on_none=None)
2332
+ power_electronics_connection.inv_var_resp_q_at_v3 = result_set.get_float(table.inv_var_resp_q_at_v3.query_index, on_none=None)
2333
+ power_electronics_connection.inv_var_resp_q_at_v4 = result_set.get_float(table.inv_var_resp_q_at_v4.query_index, on_none=None)
2334
+ power_electronics_connection.inv_reactive_power_mode = result_set.get_boolean(table.inv_reactive_power_mode.query_index, on_none=None)
2335
+ power_electronics_connection.inv_fix_reactive_power = result_set.get_float(table.inv_fix_reactive_power.query_index, on_none=None)
2336
+
2337
+ return self._load_regulating_cond_eq(power_electronics_connection, table, result_set) and self._add_or_throw(power_electronics_connection)
2338
+
2339
+ def load_power_electronics_connection_phase(
2340
+ self,
2341
+ table: TablePowerElectronicsConnectionPhases,
2342
+ result_set: ResultSet,
2343
+ set_identifier: Callable[[str], str]
2344
+ ) -> bool:
2345
+ """
2346
+ Create a :class:`PowerElectronicsConnectionPhase` and populate its fields from :class:`TablePowerElectronicsConnectionPhases`.
2347
+
2348
+ :param table: The database table to read the :class:`PowerElectronicsConnectionPhase` fields from.
2349
+ :param result_set: The record in the database table containing the fields for this :class:`PowerElectronicsConnectionPhase`.
2350
+ :param set_identifier: A callback to register the mRID of this :class:`PowerElectronicsConnectionPhase` for logging purposes.
2351
+
2352
+ :return: True if the :class:`PowerElectronicsConnectionPhase` was successfully read from the database and added to the service.
2353
+ :raises SqlException: For any errors encountered reading from the database.
2354
+ """
2355
+ power_electronics_connection_phase = PowerElectronicsConnectionPhase(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2356
+
2357
+ power_electronics_connection_phase.power_electronics_connection = self._ensure_get(
2358
+ result_set.get_string(table.power_electronics_connection_mrid.query_index, on_none=None),
2359
+ PowerElectronicsConnection
2360
+ )
2361
+ power_electronics_connection_phase.phase = SinglePhaseKind[result_set.get_string(table.phase.query_index)]
2362
+ power_electronics_connection_phase.p = result_set.get_float(table.p.query_index, on_none=None)
2363
+ power_electronics_connection_phase.phase = SinglePhaseKind[result_set.get_string(table.phase.query_index)]
2364
+ power_electronics_connection_phase.q = result_set.get_float(table.q.query_index, on_none=None)
2365
+
2366
+ if power_electronics_connection_phase.power_electronics_connection:
2367
+ power_electronics_connection_phase.power_electronics_connection.add_phase(power_electronics_connection_phase)
2368
+
2369
+ return self._load_power_system_resource(power_electronics_connection_phase, table, result_set) and self._add_or_throw(
2370
+ power_electronics_connection_phase)
2371
+
2372
+ def load_power_transformer(self, table: TablePowerTransformers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2373
+ """
2374
+ Create a :class:`PowerTransformer` and populate its fields from :class:`TablePowerTransformers`.
2375
+
2376
+ :param table: The database table to read the :class:`PowerTransformer` fields from.
2377
+ :param result_set: The record in the database table containing the fields for this :class:`PowerTransformer`.
2378
+ :param set_identifier: A callback to register the mRID of this :class:`PowerTransformer` for logging purposes.
2379
+
2380
+ :return: True if the :class:`PowerTransformer` was successfully read from the database and added to the service.
2381
+ :raises SqlException: For any errors encountered reading from the database.
2382
+ """
2383
+ power_transformer = PowerTransformer(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2384
+
2385
+ power_transformer.vector_group = VectorGroup[result_set.get_string(table.vector_group.query_index)]
2386
+ power_transformer.transformer_utilisation = result_set.get_float(table.transformer_utilisation.query_index, on_none=None)
2387
+ power_transformer.construction_kind = TransformerConstructionKind[result_set.get_string(table.construction_kind.query_index)]
2388
+ power_transformer.function = TransformerFunctionKind[result_set.get_string(table.function.query_index)]
2389
+ power_transformer.asset_info = self._ensure_get(
2390
+ result_set.get_string(table.power_transformer_info_mrid.query_index, on_none=None),
2391
+ PowerTransformerInfo
2392
+ )
2393
+
2394
+ return self._load_conducting_equipment(power_transformer, table, result_set) and self._add_or_throw(power_transformer)
2395
+
2396
+ def load_power_transformer_end(self, table: TablePowerTransformerEnds, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2397
+ """
2398
+ Create a :class:`PowerTransformerEnd` and populate its fields from :class:`TablePowerTransformerEnds`.
2399
+
2400
+ :param table: The database table to read the :class:`PowerTransformerEnd` fields from.
2401
+ :param result_set: The record in the database table containing the fields for this :class:`PowerTransformerEnd`.
2402
+ :param set_identifier: A callback to register the mRID of this :class:`PowerTransformerEnd` for logging purposes.
2403
+
2404
+ :return: True if the :class:`PowerTransformerEnd` was successfully read from the database and added to the service.
2405
+ :raises SqlException: For any errors encountered reading from the database.
2406
+ """
2407
+ power_transformer_end = PowerTransformerEnd(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2408
+
2409
+ power_transformer_end.end_number = result_set.get_int(table.end_number.query_index)
2410
+ power_transformer_end.power_transformer = self._ensure_get(
2411
+ result_set.get_string(table.power_transformer_mrid.query_index, on_none=None),
2412
+ PowerTransformer
2413
+ )
2414
+ power_transformer_end.connection_kind = WindingConnection[result_set.get_string(table.connection_kind.query_index)]
2415
+ power_transformer_end.phase_angle_clock = result_set.get_int(table.phase_angle_clock.query_index, on_none=None)
2416
+ power_transformer_end.b = result_set.get_float(table.b.query_index, on_none=None)
2417
+ power_transformer_end.b0 = result_set.get_float(table.b0.query_index, on_none=None)
2418
+ power_transformer_end.g = result_set.get_float(table.g.query_index, on_none=None)
2419
+ power_transformer_end.g0 = result_set.get_float(table.g0.query_index, on_none=None)
2420
+ power_transformer_end.r = result_set.get_float(table.r.query_index, on_none=None)
2421
+ power_transformer_end.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2422
+ power_transformer_end.rated_u = result_set.get_int(table.rated_u.query_index, on_none=None)
2423
+ power_transformer_end.x = result_set.get_float(table.x.query_index, on_none=None)
2424
+ power_transformer_end.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2425
+
2426
+ if power_transformer_end.power_transformer:
2427
+ power_transformer_end.power_transformer.add_end(power_transformer_end)
2428
+
2429
+ return self._load_transformer_end(power_transformer_end, table, result_set) and self._add_or_throw(power_transformer_end)
2430
+
2431
+ def _load_protected_switch(self, protected_switch: ProtectedSwitch, table: TableProtectedSwitches, result_set: ResultSet) -> bool:
2432
+ protected_switch.breaking_capacity = result_set.get_int(table.breaking_capacity.query_index, on_none=None)
2433
+
2434
+ return self._load_switch(protected_switch, table, result_set)
2435
+
2436
+ def load_ratio_tap_changer(self, table: TableRatioTapChangers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2437
+ """
2438
+ Create a :class:`RatioTapChanger` and populate its fields from :class:`TableRatioTapChangers`.
2439
+
2440
+ :param table: The database table to read the :class:`RatioTapChanger` fields from.
2441
+ :param result_set: The record in the database table containing the fields for this :class:`RatioTapChanger`.
2442
+ :param set_identifier: A callback to register the mRID of this :class:`RatioTapChanger` for logging purposes.
2443
+
2444
+ :return: True if the :class:`RatioTapChanger` was successfully read from the database and added to the service.
2445
+ :raises SqlException: For any errors encountered reading from the database.
2446
+ """
2447
+ ratio_tap_changer = RatioTapChanger(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2448
+
2449
+ ratio_tap_changer.transformer_end = self._ensure_get(
2450
+ result_set.get_string(table.transformer_end_mrid.query_index, on_none=None),
2451
+ TransformerEnd
2452
+ )
2453
+ ratio_tap_changer.step_voltage_increment = result_set.get_float(table.step_voltage_increment.query_index, on_none=None)
2454
+
2455
+ if ratio_tap_changer.transformer_end:
2456
+ ratio_tap_changer.transformer_end.ratio_tap_changer = ratio_tap_changer
2457
+
2458
+ return self._load_tap_changer(ratio_tap_changer, table, result_set) and self._add_or_throw(ratio_tap_changer)
2459
+
2460
+ def load_reactive_capability_curve(self, table: TableReactiveCapabilityCurves, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2461
+ """
2462
+ Create a :class:`ReactiveCapabilityCurve` and populate its fields from :class:`TableReactiveCapabilityCurves`.
2463
+
2464
+ :param table: The database table to read the :class:`ReactiveCapabilityCurve` fields from.
2465
+ :param result_set: The record in the database table containing the fields for this :class:`ReactiveCapabilityCurve`.
2466
+ :param set_identifier: A callback to register the mRID of this :class:`ReactiveCapabilityCurve` for logging purposes.
2467
+
2468
+ :return: True if the :class:`ReactiveCapabilityCurve` was successfully read from the database and added to the service.
2469
+ :raises SqlException: For any errors encountered reading from the database.
2470
+ """
2471
+ reactive_capability_curve = ReactiveCapabilityCurve(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2472
+
2473
+ return self._load_curve(reactive_capability_curve, table, result_set) and self._add_or_throw(reactive_capability_curve)
2474
+
2475
+ def load_recloser(self, table: TableReclosers, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2476
+ """
2477
+ Create a :class:`Recloser` and populate its fields from :class:`TableReclosers`.
2478
+
2479
+ :param table: The database table to read the :class:`Recloser` fields from.
2480
+ :param result_set: The record in the database table containing the fields for this :class:`Recloser`.
2481
+ :param set_identifier: A callback to register the mRID of this :class:`Recloser` for logging purposes.
2482
+
2483
+ :return: True if the :class:`Recloser` was successfully read from the database and added to the service.
2484
+ :raises SqlException: For any errors encountered reading from the database.
2485
+ """
2486
+ recloser = Recloser(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2487
+
2488
+ return self._load_protected_switch(recloser, table, result_set) and self._add_or_throw(recloser)
2489
+
2490
+ def _load_regulating_cond_eq(self, regulating_cond_eq: RegulatingCondEq, table: TableRegulatingCondEq, result_set: ResultSet) -> bool:
2491
+ regulating_cond_eq.control_enabled = result_set.get_boolean(table.control_enabled.query_index)
2492
+ # We use a resolver here because there is an ordering conflict between terminals, RegulatingCondEq, and RegulatingControls
2493
+ # We check this resolver has actually been resolved in the postLoad of the database read and throw there if it hasn't.
2494
+ self._service.resolve_or_defer_reference(
2495
+ resolver.rce_regulating_control(regulating_cond_eq),
2496
+ result_set.get_string(table.regulating_control_mrid.query_index, on_none=None)
2497
+ )
2498
+
2499
+ return self._load_energy_connection(regulating_cond_eq, table, result_set)
2500
+
2501
+ def _load_regulating_control(self, regulating_control: RegulatingControl, table: TableRegulatingControls, result_set: ResultSet) -> bool:
2502
+ regulating_control.discrete = result_set.get_boolean(table.discrete.query_index, on_none=None)
2503
+ regulating_control.mode = RegulatingControlModeKind[result_set.get_string(table.mode.query_index)]
2504
+ regulating_control.monitored_phase = PhaseCode[result_set.get_string(table.monitored_phase.query_index)]
2505
+ regulating_control.target_deadband = result_set.get_float(table.target_deadband.query_index, on_none=None)
2506
+ regulating_control.target_value = result_set.get_float(table.target_value.query_index, on_none=None)
2507
+ regulating_control.enabled = result_set.get_boolean(table.enabled.query_index, on_none=None)
2508
+ regulating_control.max_allowed_target_value = result_set.get_float(table.max_allowed_target_value.query_index, on_none=None)
2509
+ regulating_control.min_allowed_target_value = result_set.get_float(table.min_allowed_target_value.query_index, on_none=None)
2510
+ regulating_control.rated_current = result_set.get_float(table.rated_current.query_index, on_none=None)
2511
+ regulating_control.terminal = self._ensure_get(
2512
+ result_set.get_string(table.terminal_mrid.query_index, on_none=None),
2513
+ Terminal
2514
+ )
2515
+ # ZBEX
2516
+ regulating_control.ct_primary = result_set.get_float(table.ct_primary.query_index, on_none=None)
2517
+ # ZBEX
2518
+ regulating_control.min_target_deadband = result_set.get_float(table.min_target_deadband.query_index, on_none=None)
2519
+
2520
+ return self._load_power_system_resource(regulating_control, table, result_set)
2521
+
2522
+ def _load_rotating_machine(self, rotating_machine: RotatingMachine, table: TableRotatingMachines, result_set: ResultSet) -> bool:
2523
+ rotating_machine.rated_power_factor = result_set.get_float(table.rated_power_factor.query_index, on_none=None)
2524
+ rotating_machine.rated_s = result_set.get_float(table.rated_s.query_index, on_none=None)
2525
+ rotating_machine.rated_u = result_set.get_int(table.rated_u.query_index, on_none=None)
2526
+ rotating_machine.p = result_set.get_float(table.p.query_index, on_none=None)
2527
+ rotating_machine.q = result_set.get_float(table.q.query_index, on_none=None)
2528
+
2529
+ return self._load_regulating_cond_eq(rotating_machine, table, result_set)
2530
+
2531
+ def load_series_compensator(self, table: TableSeriesCompensators, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2532
+ """
2533
+ Create a :class:`SeriesCompensator` and populate its fields from :class:`TableSeriesCompensators`.
2534
+
2535
+ :param table: The database table to read the :class:`SeriesCompensator` fields from.
2536
+ :param result_set: The record in the database table containing the fields for this :class:`SeriesCompensator`.
2537
+ :param set_identifier: A callback to register the mRID of this :class:`SeriesCompensator` for logging purposes.
2538
+
2539
+ :return: True if the :class:`SeriesCompensator` was successfully read from the database and added to the service.
2540
+ :raises SqlException: For any errors encountered reading from the database.
2541
+ """
2542
+ series_compensator = SeriesCompensator(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2543
+
2544
+ series_compensator.r = result_set.get_float(table.r.query_index, on_none=None)
2545
+ series_compensator.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2546
+ series_compensator.x = result_set.get_float(table.x.query_index, on_none=None)
2547
+ series_compensator.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2548
+ series_compensator.varistor_rated_current = result_set.get_int(table.varistor_rated_current.query_index, on_none=None)
2549
+ series_compensator.varistor_voltage_threshold = result_set.get_int(table.varistor_voltage_threshold.query_index, on_none=None)
2550
+
2551
+ return self._load_conducting_equipment(series_compensator, table, result_set) and self._add_or_throw(series_compensator)
2552
+
2553
+ def _load_shunt_compensator(self, shunt_compensator: ShuntCompensator, table: TableShuntCompensators, result_set: ResultSet) -> bool:
2554
+ shunt_compensator.asset_info = self._ensure_get(
2555
+ result_set.get_string(table.shunt_compensator_info_mrid.query_index, on_none=None),
2556
+ ShuntCompensatorInfo
2557
+ )
2558
+
2559
+ shunt_compensator.grounded = result_set.get_boolean(table.grounded.query_index)
2560
+ shunt_compensator.nom_u = result_set.get_int(table.nom_u.query_index, on_none=None)
2561
+ shunt_compensator.phase_connection = PhaseShuntConnectionKind[result_set.get_string(table.phase_connection.query_index)]
2562
+ shunt_compensator.sections = result_set.get_float(table.sections.query_index, on_none=None)
2563
+
2564
+ return self._load_regulating_cond_eq(shunt_compensator, table, result_set)
2565
+
2566
+ def load_static_var_compensator(self, table: TableStaticVarCompensators, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2567
+ """
2568
+ Create a :class:`StaticVarCompensator` and populate its fields from :class:`TableStaticVarCompensators`.
2569
+
2570
+ :param table: The database table to read the :class:`StaticVarCompensator` fields from.
2571
+ :param result_set: The record in the database table containing the fields for this :class:`StaticVarCompensator`.
2572
+ :param set_identifier: A callback to register the mRID of this :class:`StaticVarCompensator` for logging purposes.
2573
+
2574
+ :return: True if the :class:`StaticVarCompensator` was successfully read from the database and added to the service.
2575
+ :raises SqlException: For any errors encountered reading from the database.
2576
+ """
2577
+ static_var_compensator = StaticVarCompensator(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2578
+
2579
+ static_var_compensator.capacitive_rating = result_set.get_float(table.capacitive_rating.query_index, on_none=None)
2580
+ static_var_compensator.inductive_rating = result_set.get_float(table.inductive_rating.query_index, on_none=None)
2581
+ static_var_compensator.q = result_set.get_float(table.q.query_index, on_none=None)
2582
+ static_var_compensator.svc_control_mode = SVCControlMode[result_set.get_string(table.svc_control_mode.query_index, on_none=None)]
2583
+ static_var_compensator.voltage_set_point = result_set.get_int(table.voltage_set_point.query_index, on_none=None)
2584
+
2585
+ return self._load_regulating_cond_eq(static_var_compensator, table, result_set) and self._add_or_throw(static_var_compensator)
2586
+
2587
+ def _load_switch(self, switch: Switch, table: TableSwitches, result_set: ResultSet) -> bool:
2588
+ switch.asset_info = self._ensure_get(
2589
+ result_set.get_string(table.switch_info_mrid.query_index, on_none=None),
2590
+ SwitchInfo
2591
+ )
2592
+ switch.rated_current = result_set.get_float(table.rated_current.query_index, on_none=None)
2593
+ switch._normally_open = result_set.get_int(table.normal_open.query_index)
2594
+ switch._open = result_set.get_int(table.open.query_index)
2595
+
2596
+ return self._load_conducting_equipment(switch, table, result_set)
2597
+
2598
+ def load_synchronous_machine(self, table: TableSynchronousMachines, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2599
+ """
2600
+ Create a :class:`SynchronousMachine` and populate its fields from :class:`TableSynchronousMachines`.
2601
+
2602
+ :param table: The database table to read the :class:`SynchronousMachine` fields from.
2603
+ :param result_set: The record in the database table containing the fields for this :class:`SynchronousMachine`.
2604
+ :param set_identifier: A callback to register the mRID of this :class:`SynchronousMachine` for logging purposes.
2605
+
2606
+ :return: True if the :class:`SynchronousMachine` was successfully read from the database and added to the service.
2607
+ :raises SqlException: For any errors encountered reading from the database.
2608
+ """
2609
+ synchronous_machine = SynchronousMachine(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2610
+
2611
+ synchronous_machine.base_q = result_set.get_float(table.base_q.query_index, on_none=None)
2612
+ synchronous_machine.condenser_p = result_set.get_int(table.condenser_p.query_index, on_none=None)
2613
+ synchronous_machine.earthing = result_set.get_boolean(table.earthing.query_index)
2614
+ synchronous_machine.earthing_star_point_r = result_set.get_float(table.earthing_star_point_r.query_index, on_none=None)
2615
+ synchronous_machine.earthing_star_point_x = result_set.get_float(table.earthing_star_point_x.query_index, on_none=None)
2616
+ synchronous_machine.ikk = result_set.get_float(table.ikk.query_index, on_none=None)
2617
+ synchronous_machine.max_q = result_set.get_float(table.max_q.query_index, on_none=None)
2618
+ synchronous_machine.max_u = result_set.get_int(table.max_u.query_index, on_none=None)
2619
+ synchronous_machine.min_q = result_set.get_float(table.min_q.query_index, on_none=None)
2620
+ synchronous_machine.min_u = result_set.get_int(table.min_u.query_index, on_none=None)
2621
+ synchronous_machine.mu = result_set.get_float(table.mu.query_index, on_none=None)
2622
+ synchronous_machine.r = result_set.get_float(table.r.query_index, on_none=None)
2623
+ synchronous_machine.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2624
+ synchronous_machine.r2 = result_set.get_float(table.r2.query_index, on_none=None)
2625
+ synchronous_machine.sat_direct_subtrans_x = result_set.get_float(table.sat_direct_subtrans_x.query_index, on_none=None)
2626
+ synchronous_machine.sat_direct_sync_x = result_set.get_float(table.sat_direct_sync_x.query_index, on_none=None)
2627
+ synchronous_machine.sat_direct_trans_x = result_set.get_float(table.sat_direct_trans_x.query_index, on_none=None)
2628
+ synchronous_machine.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2629
+ synchronous_machine.x2 = result_set.get_float(table.x2.query_index, on_none=None)
2630
+ synchronous_machine.type = SynchronousMachineKind[result_set.get_string(table.type.query_index)]
2631
+ synchronous_machine.operating_mode = SynchronousMachineKind[result_set.get_string(table.operating_mode.query_index)]
2632
+
2633
+ return self._load_rotating_machine(synchronous_machine, table, result_set) and self._add_or_throw(synchronous_machine)
2634
+
2635
+ def _load_tap_changer(self, tap_changer: TapChanger, table: TableTapChangers, result_set: ResultSet) -> bool:
2636
+ tap_changer.control_enabled = result_set.get_boolean(table.control_enabled.query_index)
2637
+ tap_changer.high_step = result_set.get_int(table.high_step.query_index, on_none=None)
2638
+ tap_changer.low_step = result_set.get_int(table.low_step.query_index, on_none=None)
2639
+ tap_changer.neutral_step = result_set.get_int(table.neutral_step.query_index, on_none=None)
2640
+ tap_changer.neutral_u = result_set.get_int(table.neutral_u.query_index, on_none=None)
2641
+ tap_changer.normal_step = result_set.get_int(table.normal_step.query_index, on_none=None)
2642
+ tap_changer.step = result_set.get_float(table.step.query_index, on_none=None)
2643
+ tap_changer.tap_changer_control = self._ensure_get(
2644
+ result_set.get_string(table.tap_changer_control_mrid.query_index, on_none=None),
2645
+ TapChangerControl
2646
+ )
2647
+
2648
+ return self._load_power_system_resource(tap_changer, table, result_set)
2649
+
2650
+ def load_tap_changer_control(self, table: TableTapChangerControls, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2651
+ """
2652
+ Create a :class:`TapChangerControl` and populate its fields from :class:`TableTapChangerControls`.
2653
+
2654
+ :param table: The database table to read the :class:`TapChangerControl` fields from.
2655
+ :param result_set: The record in the database table containing the fields for this :class:`TapChangerControl`.
2656
+ :param set_identifier: A callback to register the mRID of this :class:`TapChangerControl` for logging purposes.
2657
+
2658
+ :return: True if the :class:`TapChangerControl` was successfully read from the database and added to the service.
2659
+ :raises SqlException: For any errors encountered reading from the database.
2660
+ """
2661
+ tap_changer_control = TapChangerControl(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2662
+
2663
+ tap_changer_control.limit_voltage = result_set.get_int(table.limit_voltage.query_index, on_none=None)
2664
+ tap_changer_control.line_drop_compensation = result_set.get_boolean(table.line_drop_compensation.query_index, on_none=None)
2665
+ tap_changer_control.line_drop_r = result_set.get_float(table.line_drop_r.query_index, on_none=None)
2666
+ tap_changer_control.line_drop_x = result_set.get_float(table.line_drop_x.query_index, on_none=None)
2667
+ tap_changer_control.reverse_line_drop_r = result_set.get_float(table.reverse_line_drop_r.query_index, on_none=None)
2668
+ tap_changer_control.reverse_line_drop_x = result_set.get_float(table.reverse_line_drop_x.query_index, on_none=None)
2669
+ tap_changer_control.forward_ldc_blocking = result_set.get_boolean(table.forward_ldc_blocking.query_index, on_none=None)
2670
+ tap_changer_control.time_delay = result_set.get_float(table.time_delay.query_index, on_none=None)
2671
+ tap_changer_control.co_generation_enabled = result_set.get_boolean(table.co_generation_enabled.query_index, on_none=None)
2672
+
2673
+ return self._load_regulating_control(tap_changer_control, table, result_set) and self._add_or_throw(tap_changer_control)
2674
+
2675
+ def _load_transformer_end(self, transformer_end: TransformerEnd, table: TableTransformerEnds, result_set: ResultSet) -> bool:
2676
+ transformer_end.terminal = self._ensure_get(
2677
+ result_set.get_string(table.terminal_mrid.query_index, on_none=None),
2678
+ Terminal
2679
+ )
2680
+ transformer_end.base_voltage = self._ensure_get(
2681
+ result_set.get_string(table.base_voltage_mrid.query_index, on_none=None),
2682
+ BaseVoltage
2683
+ )
2684
+ transformer_end.grounded = result_set.get_boolean(table.grounded.query_index)
2685
+ transformer_end.r_ground = result_set.get_float(table.r_ground.query_index, on_none=None)
2686
+ transformer_end.x_ground = result_set.get_float(table.x_ground.query_index, on_none=None)
2687
+ transformer_end.star_impedance = self._ensure_get(
2688
+ result_set.get_string(table.star_impedance_mrid.query_index, on_none=None),
2689
+ TransformerStarImpedance
2690
+ )
2691
+
2692
+ return self._load_identified_object(transformer_end, table, result_set)
2693
+
2694
+ def load_transformer_star_impedance(self, table: TableTransformerStarImpedances, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2695
+ """
2696
+ Create a :class:`TransformerStarImpedance` and populate its fields from :class:`TableTransformerStarImpedances`.
2697
+
2698
+ :param table: The database table to read the :class:`TransformerStarImpedance` fields from.
2699
+ :param result_set: The record in the database table containing the fields for this :class:`TransformerStarImpedance`.
2700
+ :param set_identifier: A callback to register the mRID of this :class:`TransformerStarImpedance` for logging purposes.
2701
+
2702
+ :return: True if the :class:`TransformerStarImpedance` was successfully read from the database and added to the service.
2703
+ :raises SqlException: For any errors encountered reading from the database.
2704
+ """
2705
+ transformer_star_impedance = TransformerStarImpedance(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2706
+
2707
+ transformer_star_impedance.r = result_set.get_float(table.r.query_index, on_none=None)
2708
+ transformer_star_impedance.r0 = result_set.get_float(table.r0.query_index, on_none=None)
2709
+ transformer_star_impedance.x = result_set.get_float(table.x.query_index, on_none=None)
2710
+ transformer_star_impedance.x0 = result_set.get_float(table.x0.query_index, on_none=None)
2711
+
2712
+ transformer_star_impedance.transformer_end_info = self._ensure_get(
2713
+ result_set.get_string(table.transformer_end_info_mrid.query_index, on_none=None),
2714
+ TransformerEndInfo
2715
+ )
2716
+ if transformer_star_impedance.transformer_end_info:
2717
+ transformer_star_impedance.transformer_end_info.transformer_star_impedance = transformer_star_impedance
2718
+
2719
+ return self._load_identified_object(transformer_star_impedance, table, result_set) and self._add_or_throw(transformer_star_impedance)
2720
+
2721
+ ###############################
2722
+ # IEC61970 InfIEC61970 Feeder #
2723
+ ###############################
2724
+
2725
+ def load_circuit(self, table: TableCircuits, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2726
+ """
2727
+ Create a :class:`Circuit` and populate its fields from :class:`TableCircuits`.
2728
+
2729
+ :param table: The database table to read the :class:`Circuit` fields from.
2730
+ :param result_set: The record in the database table containing the fields for this :class:`Circuit`.
2731
+ :param set_identifier: A callback to register the mRID of this :class:`Circuit` for logging purposes.
2732
+
2733
+ :return: True if the :class:`Circuit` was successfully read from the database and added to the service.
2734
+ :raises SqlException: For any errors encountered reading from the database.
2735
+ """
2736
+ circuit = Circuit(mrid=set_identifier(result_set.get_string(table.mrid.query_index)))
2737
+
2738
+ circuit.loop = self._ensure_get(
2739
+ result_set.get_string(table.loop_mrid.query_index, on_none=None),
2740
+ Loop
2741
+ )
2742
+ if circuit.loop:
2743
+ circuit.loop.add_circuit(circuit)
2744
+
2745
+ return self._load_line(circuit, table, result_set) and self._add_or_throw(circuit)
2746
+
2747
+ ################
2748
+ # Associations #
2749
+ ################
2750
+
2751
+ def load_asset_organisation_roles_asset(
2752
+ self,
2753
+ table: TableAssetOrganisationRolesAssets,
2754
+ result_set: ResultSet,
2755
+ set_identifier: Callable[[str], str]
2756
+ ) -> bool:
2757
+ """
2758
+ Create a :class:`AssetOrganisationRole` to :class:`Asset` association from :class:`TableAssetOrganisationRolesAssets`.
2759
+
2760
+ :param table: The database table to read the association from.
2761
+ :param result_set: The record in the database table containing the fields for this association.
2762
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2763
+
2764
+ :return: True if the association was successfully read from the database and added to the service.
2765
+ :raises SqlException: For any errors encountered reading from the database.
2766
+ """
2767
+ asset_organisation_role_mrid = result_set.get_string(table.asset_organisation_role_mrid.query_index)
2768
+ set_identifier(f"{asset_organisation_role_mrid}-to-UNKNOWN")
2769
+
2770
+ asset_mrid = result_set.get_string(table.asset_mrid.query_index)
2771
+ set_identifier(f"{asset_organisation_role_mrid}-to-{asset_mrid}")
2772
+
2773
+ asset_organisation_role = self._service.get(asset_organisation_role_mrid, AssetOrganisationRole)
2774
+ asset = self._service.get(asset_mrid, Asset)
2775
+
2776
+ asset.add_organisation_role(asset_organisation_role)
2777
+
2778
+ return True
2779
+
2780
+ def load_asset_power_system_resources(
2781
+ self,
2782
+ table: TableAssetsPowerSystemResources,
2783
+ result_set: ResultSet,
2784
+ set_identifier: Callable[[str], str]
2785
+ ) -> bool:
2786
+ """
2787
+ Create a :class:`Asset` to :class:`PowerSystemResource` association from :class:`TableAssetPowerSystemResources`.
2788
+
2789
+ :param table: The database table to read the association from.
2790
+ :param result_set: The record in the database table containing the fields for this association.
2791
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2792
+
2793
+ :return: True if the association was successfully read from the database and added to the service.
2794
+ :raises SqlException: For any errors encountered reading from the database.
2795
+ """
2796
+ asset_mrid = result_set.get_string(table.asset_mrid.query_index)
2797
+ set_identifier(f"{asset_mrid}-to-UNKNOWN")
2798
+
2799
+ power_system_resource_mrid = result_set.get_string(table.power_system_resource_mrid.query_index)
2800
+ set_identifier(f"{asset_mrid}-to-{power_system_resource_mrid}")
2801
+
2802
+ asset = self._service.get(asset_mrid, Asset)
2803
+ power_system_resource = self._service.get(power_system_resource_mrid, PowerSystemResource)
2804
+
2805
+ asset.add_power_system_resource(power_system_resource)
2806
+ power_system_resource.add_asset(asset)
2807
+
2808
+ return True
2809
+
2810
+ def load_battery_units_battery_controls(self, table: TableBatteryUnitsBatteryControls, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2811
+ """
2812
+ Create a :class:`BatteryUnit` to :class:`BatteryControl` association from :class:`TableBatteryUnitsBatteryControls`.
2813
+
2814
+ :param table: The database table to read the association from.
2815
+ :param result_set: The record in the database table containing the fields for this association.
2816
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2817
+
2818
+ :return: True if the association was successfully read from the database and added to the service.
2819
+ :raises SqlException: For any errors encountered reading from the database.
2820
+ """
2821
+ battery_unit_mrid = result_set.get_string(table.battery_unit_mrid.query_index)
2822
+ set_identifier(f"{battery_unit_mrid}-to-UNKNOWN")
2823
+
2824
+ battery_control_mrid = result_set.get_string(table.battery_control_mrid.query_index)
2825
+ set_identifier(f"{battery_unit_mrid}-to-{battery_control_mrid}")
2826
+
2827
+ battery_unit = self._service.get(battery_unit_mrid, BatteryUnit)
2828
+ battery_control = self._service.get(battery_control_mrid, BatteryControl)
2829
+
2830
+ battery_unit.add_control(battery_control)
2831
+
2832
+ return True
2833
+
2834
+ def load_circuits_substation(self, table: TableCircuitsSubstations, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2835
+ """
2836
+ Create a :class:`Circuit` to :class:`Substation` association from :class:`TablePricingStructuresTariffsTableCircuitsSubstations.
2837
+
2838
+ :param table: The database table to read the association from.
2839
+ :param result_set: The record in the database table containing the fields for this association.
2840
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2841
+
2842
+ :return: True if the association was successfully read from the database and added to the service.
2843
+ :raises SqlException: For any errors encountered reading from the database.
2844
+ """
2845
+ circuit_mrid = result_set.get_string(table.circuit_mrid.query_index)
2846
+ set_identifier(f"{circuit_mrid}-to-UNKNOWN")
2847
+
2848
+ substation_mrid = result_set.get_string(table.substation_mrid.query_index)
2849
+ set_identifier(f"{circuit_mrid}-to-{substation_mrid}")
2850
+
2851
+ circuit = self._service.get(circuit_mrid, Circuit)
2852
+ substation = self._service.get(substation_mrid, Substation)
2853
+
2854
+ substation.add_circuit(circuit)
2855
+ circuit.add_end_substation(substation)
2856
+
2857
+ return True
2858
+
2859
+ def load_circuits_terminal(self, table: TableCircuitsTerminals, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2860
+ """
2861
+ Create a :class:`Circuit` to :class:`Terminal` association from :class:`TablePricingStructuresTariffsTableCircuitsTerminals.
2862
+
2863
+ :param table: The database table to read the association from.
2864
+ :param result_set: The record in the database table containing the fields for this association.
2865
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2866
+
2867
+ :return: True if the association was successfully read from the database and added to the service.
2868
+ :raises SqlException: For any errors encountered reading from the database.
2869
+ """
2870
+ circuit_mrid = result_set.get_string(table.circuit_mrid.query_index)
2871
+ set_identifier(f"{circuit_mrid}-to-UNKNOWN")
2872
+
2873
+ terminal_mrid = result_set.get_string(table.terminal_mrid.query_index)
2874
+ set_identifier(f"{circuit_mrid}-to-{terminal_mrid}")
2875
+
2876
+ circuit = self._service.get(circuit_mrid, Circuit)
2877
+ terminal = self._service.get(terminal_mrid, Terminal)
2878
+
2879
+ circuit.add_end_terminal(terminal)
2880
+
2881
+ return True
2882
+
2883
+ def load_end_devices_end_device_functions(self, table: TableEndDevicesEndDeviceFunctions, result_set: ResultSet,
2884
+ set_identifier: Callable[[str], str]) -> bool:
2885
+ """
2886
+ Create a :class:`EndDevice` to :class:`EndDeviceFunction` association from :class:`TableEndDevicesEndDeviceFunctions`.
2887
+
2888
+ :param table: The database table to read the association from.
2889
+ :param result_set: The record in the database table containing the fields for this association.
2890
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2891
+
2892
+ :return: True if the association was successfully read from the database and added to the service.
2893
+ :raises SqlException: For any errors encountered reading from the database.
2894
+ """
2895
+ end_device_mrid = result_set.get_string(table.end_device_mrid.query_index)
2896
+ set_identifier(f"{end_device_mrid}-to-UNKNOWN")
2897
+
2898
+ end_device_function_mrid = result_set.get_string(table.end_device_function_mrid.query_index)
2899
+ set_identifier(f"{end_device_mrid}-to-{end_device_function_mrid}")
2900
+
2901
+ end_device = self._service.get(end_device_mrid, EndDevice)
2902
+ end_device_function = self._service.get(end_device_function_mrid, EndDeviceFunction)
2903
+
2904
+ end_device.add_function(end_device_function)
2905
+
2906
+ return True
2907
+
2908
+ def load_equipment_equipment_container(
2909
+ self,
2910
+ table: TableEquipmentEquipmentContainers,
2911
+ result_set: ResultSet,
2912
+ set_identifier: Callable[[str], str]
2913
+ ) -> bool:
2914
+ """
2915
+ Create a :class:`Equipment` to :class:`EquipmentContainer` association from :class:`TableEquipmentEquipmentContainers`.
2916
+
2917
+ :param table: The database table to read the association from.
2918
+ :param result_set: The record in the database table containing the fields for this association.
2919
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2920
+
2921
+ :return: True if the association was successfully read from the database and added to the service.
2922
+ :raises SqlException: For any errors encountered reading from the database.
2923
+ """
2924
+ equipment_mrid = result_set.get_string(table.equipment_mrid.query_index)
2925
+ set_identifier(f"{equipment_mrid}-to-UNKNOWN")
2926
+
2927
+ equipment_container_mrid = result_set.get_string(table.equipment_container_mrid.query_index)
2928
+ set_identifier(f"{equipment_mrid}-to-{equipment_container_mrid}")
2929
+
2930
+ equipment = self._service.get(equipment_mrid, Equipment)
2931
+ equipment_container = self._service.get(equipment_container_mrid, EquipmentContainer)
2932
+
2933
+ equipment_container.add_equipment(equipment)
2934
+ equipment.add_container(equipment_container)
2935
+
2936
+ return True
2937
+
2938
+ def load_equipment_operational_restriction(
2939
+ self,
2940
+ table: TableEquipmentOperationalRestrictions,
2941
+ result_set: ResultSet,
2942
+ set_identifier: Callable[[str], str]
2943
+ ) -> bool:
2944
+ """
2945
+ Create a :class:`Equipment` to :class:`OperationalRestriction` association from :class:`TableEquipmentOperationalRestrictions`.
2946
+
2947
+ :param table: The database table to read the association from.
2948
+ :param result_set: The record in the database table containing the fields for this association.
2949
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2950
+
2951
+ :return: True if the association was successfully read from the database and added to the service.
2952
+ :raises SqlException: For any errors encountered reading from the database.
2953
+ """
2954
+ equipment_mrid = result_set.get_string(table.equipment_mrid.query_index)
2955
+ set_identifier(f"{equipment_mrid}-to-UNKNOWN")
2956
+
2957
+ operational_restriction_mrid = result_set.get_string(table.operational_restriction_mrid.query_index)
2958
+ set_identifier(f"{equipment_mrid}-to-{operational_restriction_mrid}")
2959
+
2960
+ equipment = self._service.get(equipment_mrid, Equipment)
2961
+ operational_restriction = self._service.get(operational_restriction_mrid, OperationalRestriction)
2962
+
2963
+ operational_restriction.add_equipment(equipment)
2964
+ equipment.add_operational_restriction(operational_restriction)
2965
+
2966
+ return True
2967
+
2968
+ def load_equipment_usage_point(self, table: TableEquipmentUsagePoints, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2969
+ """
2970
+ Create a :class:`Equipment` to :class:`UsagePoint` association from :class:`TablePricingStructuresTariffsTableEquipmentUsagePoints.
2971
+
2972
+ :param table: The database table to read the association from.
2973
+ :param result_set: The record in the database table containing the fields for this association.
2974
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
2975
+
2976
+ :return: True if the association was successfully read from the database and added to the service.
2977
+ :raises SqlException: For any errors encountered reading from the database.
2978
+ """
2979
+ equipment_mrid = result_set.get_string(table.equipment_mrid.query_index)
2980
+ set_identifier(f"{equipment_mrid}-to-UNKNOWN")
2981
+
2982
+ usage_point_mrid = result_set.get_string(table.usage_point_mrid.query_index)
2983
+ set_identifier(f"{equipment_mrid}-to-{usage_point_mrid}")
2984
+
2985
+ equipment = self._service.get(equipment_mrid, Equipment)
2986
+ usage_point = self._service.get(usage_point_mrid, UsagePoint)
2987
+
2988
+ usage_point.add_equipment(equipment)
2989
+ equipment.add_usage_point(usage_point)
2990
+
2991
+ return True
2992
+
2993
+ def load_loops_substation(self, table: TableLoopsSubstations, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
2994
+ """
2995
+ Create a :class:`Loop` to :class:`Substation` association from :class:`TablePricingStructuresTariffsTableLoopsSubstations.
2996
+
2997
+ :param table: The database table to read the association from.
2998
+ :param result_set: The record in the database table containing the fields for this association.
2999
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3000
+
3001
+ :return: True if the association was successfully read from the database and added to the service.
3002
+ :raises SqlException: For any errors encountered reading from the database.
3003
+ """
3004
+ asset_organisation_role_mrid = result_set.get_string(table.loop_mrid.query_index)
3005
+ set_identifier(f"{asset_organisation_role_mrid}-to-UNKNOWN")
3006
+
3007
+ asset_mrid = result_set.get_string(table.substation_mrid.query_index)
3008
+ set_identifier(f"{asset_organisation_role_mrid}-to-{asset_mrid}")
3009
+
3010
+ loop = self._service.get(asset_organisation_role_mrid, Loop)
3011
+ substation = self._service.get(asset_mrid, Substation)
3012
+
3013
+ relationship = LoopSubstationRelationship[result_set.get_string(table.relationship.query_index)]
3014
+ if relationship is LoopSubstationRelationship.LOOP_ENERGIZES_SUBSTATION:
3015
+ substation.add_loop(loop)
3016
+ loop.add_substation(substation)
3017
+ elif relationship is LoopSubstationRelationship.SUBSTATION_ENERGIZES_LOOP:
3018
+ substation.add_energized_loop(loop)
3019
+ loop.add_energizing_substation(substation)
3020
+ else:
3021
+ assert_never(relationship)
3022
+
3023
+ return True
3024
+
3025
+ def load_protection_relay_functions_protected_switch(
3026
+ self,
3027
+ table: TableProtectionRelayFunctionsProtectedSwitches,
3028
+ result_set: ResultSet,
3029
+ set_identifier: Callable[[str], str]
3030
+ ) -> bool:
3031
+ """
3032
+ Create a :class:`ProtectionRelayFunction` to :class:`ProtectedSwitch` association from :class:`TableProtectionRelayFunctionsProtectedSwitches`.
3033
+
3034
+ :param table: The database table to read the association from.
3035
+ :param result_set: The record in the database table containing the fields for this association.
3036
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3037
+
3038
+ :return: True if the association was successfully read from the database and added to the service.
3039
+ :raises SqlException: For any errors encountered reading from the database.
3040
+ """
3041
+ protection_relay_function_mrid = result_set.get_string(table.protection_relay_function_mrid.query_index)
3042
+ set_identifier(f"{protection_relay_function_mrid}-to-UNKNOWN")
3043
+
3044
+ protected_switch_mrid = result_set.get_string(table.protected_switch_mrid.query_index)
3045
+ set_identifier(f"{protection_relay_function_mrid}-to-{protected_switch_mrid}")
3046
+
3047
+ protection_relay_function = self._service.get(protection_relay_function_mrid, ProtectionRelayFunction)
3048
+ protected_switch = self._service.get(protected_switch_mrid, ProtectedSwitch)
3049
+
3050
+ protection_relay_function.add_protected_switch(protected_switch)
3051
+ protected_switch.add_relay_function(protection_relay_function)
3052
+
3053
+ return True
3054
+
3055
+ def load_protection_relay_functions_sensor(
3056
+ self,
3057
+ table: TableProtectionRelayFunctionsSensors,
3058
+ result_set: ResultSet,
3059
+ set_identifier: Callable[[str], str]
3060
+ ) -> bool:
3061
+ """
3062
+ Create a :class:`ProtectionRelayFunction` to :class:`Sensor` association from :class:`TableProtectionRelayFunctionsSensors`.
3063
+
3064
+ :param table: The database table to read the association from.
3065
+ :param result_set: The record in the database table containing the fields for this association.
3066
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3067
+
3068
+ :return: True if the association was successfully read from the database and added to the service.
3069
+ :raises SqlException: For any errors encountered reading from the database.
3070
+ """
3071
+ protection_relay_function_mrid = result_set.get_string(table.protection_relay_function_mrid.query_index)
3072
+ set_identifier(f"{protection_relay_function_mrid}-to-UNKNOWN")
3073
+
3074
+ sensor_mrid = result_set.get_string(table.sensor_mrid.query_index)
3075
+ set_identifier(f"{protection_relay_function_mrid}-to-{sensor_mrid}")
3076
+
3077
+ protection_relay_function = self._service.get(protection_relay_function_mrid, ProtectionRelayFunction)
3078
+ sensor = self._service.get(sensor_mrid, Sensor)
3079
+
3080
+ protection_relay_function.add_sensor(sensor)
3081
+ sensor.add_relay_function(protection_relay_function)
3082
+
3083
+ return True
3084
+
3085
+ def load_protection_relay_schemes_protection_relay_function(
3086
+ self,
3087
+ table: TableProtectionRelaySchemesProtectionRelayFunctions,
3088
+ result_set: ResultSet,
3089
+ set_identifier: Callable[[str], str]
3090
+ ) -> bool:
3091
+ """
3092
+ Create a :class:`ProtectionRelayScheme` to :class:`ProtectionRelayFunction` association from :class:`TableProtectionRelaySchemesProtectionRelayFunctions`.
3093
+
3094
+ :param table: The database table to read the association from.
3095
+ :param result_set: The record in the database table containing the fields for this association.
3096
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3097
+
3098
+ :return: True if the association was successfully read from the database and added to the service.
3099
+ :raises SqlException: For any errors encountered reading from the database.
3100
+ """
3101
+ protection_relay_scheme_mrid = result_set.get_string(table.protection_relay_scheme_mrid.query_index)
3102
+ set_identifier(f"{protection_relay_scheme_mrid}-to-UNKNOWN")
3103
+
3104
+ protection_relay_function_mrid = result_set.get_string(table.protection_relay_function_mrid.query_index)
3105
+ set_identifier(f"{protection_relay_scheme_mrid}-to-{protection_relay_function_mrid}")
3106
+
3107
+ protection_relay_scheme = self._service.get(protection_relay_scheme_mrid, ProtectionRelayScheme)
3108
+ protection_relay_function = self._service.get(protection_relay_function_mrid, ProtectionRelayFunction)
3109
+
3110
+ protection_relay_scheme.add_function(protection_relay_function)
3111
+ protection_relay_function.add_scheme(protection_relay_scheme)
3112
+
3113
+ return True
3114
+
3115
+ def load_synchronous_machines_reactive_capability_curve(
3116
+ self,
3117
+ table: TableSynchronousMachinesReactiveCapabilityCurves,
3118
+ result_set: ResultSet,
3119
+ set_identifier: Callable[[str], str]
3120
+ ) -> bool:
3121
+ """
3122
+ Create a :class:`SynchronousMachine` to :class:`ReactiveCapabilityCurve` association from :class:`TableSynchronousMachinesReactiveCapabilityCurves`.
3123
+
3124
+ :param table: The database table to read the association from.
3125
+ :param result_set: The record in the database table containing the fields for this association.
3126
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3127
+
3128
+ :return: True if the association was successfully read from the database and added to the service.
3129
+ :raises SqlException: For any errors encountered reading from the database.
3130
+ """
3131
+ synchronous_machine_mrid = result_set.get_string(table.synchronous_machine_mrid.query_index)
3132
+ set_identifier(f"{synchronous_machine_mrid}-to-UNKNOWN")
3133
+
3134
+ reactive_capability_curve_mrid = result_set.get_string(table.reactive_capability_curve_mrid.query_index)
3135
+ set_identifier(f"{synchronous_machine_mrid}-to-{reactive_capability_curve_mrid}")
3136
+
3137
+ synchronous_machine = self._service.get(synchronous_machine_mrid, SynchronousMachine)
3138
+ reactive_capability_curve = self._service.get(reactive_capability_curve_mrid, ReactiveCapabilityCurve)
3139
+
3140
+ synchronous_machine.add_curve(reactive_capability_curve)
3141
+
3142
+ return True
3143
+
3144
+ def load_usage_points_end_device(self, table: TableUsagePointsEndDevices, result_set: ResultSet, set_identifier: Callable[[str], str]) -> bool:
3145
+ """
3146
+ Create a :class:`UsagePoint` to :class:`EndDevice` association from :class:`TablePricingStructuresTariffsTableUsagePointsEndDevices.
3147
+
3148
+ :param table: The database table to read the association from.
3149
+ :param result_set: The record in the database table containing the fields for this association.
3150
+ :param set_identifier: A callback to register the identifier of this association for logging purposes.
3151
+
3152
+ :return: True if the association was successfully read from the database and added to the service.
3153
+ :raises SqlException: For any errors encountered reading from the database.
3154
+ """
3155
+ usage_point_mrid = result_set.get_string(table.usage_point_mrid.query_index)
3156
+ set_identifier(f"{usage_point_mrid}-to-UNKNOWN")
3157
+
3158
+ end_device_mrid = result_set.get_string(table.end_device_mrid.query_index)
3159
+ set_identifier(f"{usage_point_mrid}-to-{end_device_mrid}")
3160
+
3161
+ usage_point = self._service.get(usage_point_mrid, UsagePoint)
3162
+ end_device = self._service.get(end_device_mrid, EndDevice)
3163
+
3164
+ end_device.add_usage_point(usage_point)
3165
+ usage_point.add_end_device(end_device)
3166
+
3167
+ return True