Skip to content

Commit 24c8020

Browse files
authored
Swap "power" for "electrical" in complexity and flow shapes (#425)
* power -> electrical for complexity + flow shapes; * fix property * update usage in example * switching to electrical complex power
1 parent fe931ec commit 24c8020

File tree

5 files changed

+94
-27
lines changed

5 files changed

+94
-27
lines changed

bricksrc/definitions.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ https://brickschema.org/schema/Brick#System_Status,Indicates properties of the a
10291029
https://brickschema.org/schema/Brick#TABS_Panel,See Thermally_Activated_Building_System_Panel,
10301030
https://brickschema.org/schema/Brick#TETRA_Room,"A room used for local two-way radio networks, e.g. the portable radios carried by facilities staff",
10311031
https://brickschema.org/schema/Brick#TVOC_Level_Sensor,A sensor measuring the level of all VOCs in air,
1032-
https://brickschema.org/schema/Brick#Tablet,"A flat, handheld mobile computer, usually with a touchscreen"
1032+
https://brickschema.org/schema/Brick#Tablet,"A flat, handheld mobile computer, usually with a touchscreen",
10331033
https://brickschema.org/schema/Brick#Tank,A container designed to hold or store fluids for various applications within a system.,
10341034
https://brickschema.org/schema/Brick#Team_Room,An office used by multiple team members for specific work tasks. Distinct from Conference Room,
10351035
https://brickschema.org/schema/Brick#Telecom_Room,A class of spaces used to support telecommuncations and IT equipment,

bricksrc/deprecations.ttl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@prefix bacnet: <http://data.ashrae.org/bacnet/2020#> .
2+
@prefix brick: <https://brickschema.org/schema/Brick#> .
3+
@prefix bsh: <https://brickschema.org/schema/BrickShape#> .
4+
@prefix dcterms: <http://purl.org/dc/terms#> .
5+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
6+
@prefix qudt: <http://qudt.org/schema/qudt/> .
7+
@prefix qudtqk: <http://qudt.org/vocab/quantitykind/> .
8+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
9+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
10+
@prefix sdo: <http://schema.org/> .
11+
@prefix sh: <http://www.w3.org/ns/shacl#> .
12+
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
13+
@prefix sosa: <http://www.w3.org/ns/sosa/> .
14+
@prefix tag: <https://brickschema.org/schema/BrickTag#> .
15+
@prefix unit: <http://qudt.org/vocab/unit/> .
16+
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
17+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
18+
19+
# deprecations.ttl is reserved for non-class deprecations, e.g. entity properties
20+
21+
brick:powerComplexity brick:deprecation [
22+
brick:deprecatedInVersion "1.3.1" ;
23+
brick:deprecationMitigationMessage "powerComplexity is deprecated in favor of electricalComplexPower because the latter is more clear";
24+
brick:deprecationMigitationRule [
25+
a sh:NodeShape ;
26+
sh:rule [
27+
a sh:SPARQLRule ;
28+
sh:construct """
29+
CONSTRUCT {
30+
$this brick:electricalComplexPower ?prop .
31+
} WHERE {
32+
$this brick:powerComplexity ?prop .
33+
}""" ;
34+
sh:prefixes brick: ;
35+
] ;
36+
sh:targetSubjectsOf brick:powerComplexity ;
37+
] ;
38+
] .
39+
40+
brick:powerFlow brick:deprecation [
41+
brick:deprecatedInVersion "1.3.1" ;
42+
brick:deprecationMitigationMessage "powerFlow is deprecated in favor of electricalFlow as the latter is more clear";
43+
brick:deprecationMigitationRule [
44+
a sh:NodeShape ;
45+
sh:rule [
46+
a sh:SPARQLRule ;
47+
sh:construct """
48+
CONSTRUCT {
49+
$this brick:electricalFlow ?prop .
50+
} WHERE {
51+
$this brick:powerFlow ?prop .
52+
}""" ;
53+
sh:prefixes brick: ;
54+
] ;
55+
sh:targetSubjectsOf brick:powerFlow ;
56+
] ;
57+
] .

bricksrc/entity_properties.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@
7777
"property_of": [BRICK.Equipment, BRICK.Location],
7878
},
7979
# electrical properties
80-
BRICK.powerComplexity: {
81-
SKOS.definition: Literal("Entity has this power complexity"),
82-
SH.node: BSH.PowerComplexityShape,
83-
RDFS.label: Literal("Power complexity"),
80+
BRICK.electricalComplexPower: {
81+
SKOS.definition: Literal("Associated electrical complexity with the entity"),
82+
SH.node: BSH.ElectricalComplexPowerShape,
83+
RDFS.label: Literal("electrical complex power type"),
8484
"property_of": [BRICK.Equipment, BRICK.Point],
8585
},
86-
BRICK.powerFlow: {
86+
BRICK.electricalFlow: {
8787
SKOS.definition: Literal(
88-
"Entity has this power flow relative to the building'"
88+
"Entity has this electrical flow relative to the building'"
8989
),
90-
SH.node: BSH.PowerFlowShape,
91-
RDFS.label: Literal("Power flow"),
90+
SH.node: BSH.ElectricalFlowShape,
91+
RDFS.label: Literal("Electrical flow direction"),
9292
"property_of": [BRICK.Equipment, BRICK.Point],
9393
},
9494
BRICK.electricalPhases: {
@@ -448,8 +448,8 @@
448448
},
449449
},
450450
BSH.VolumeShape: {"units": [UNIT.FT3, UNIT.M3], "datatype": BSH.NumericValue},
451-
BSH.PowerComplexityShape: {"values": ["real", "reactive", "apparent"]},
452-
BSH.PowerFlowShape: {"values": ["import", "export", "net", "absolute"]},
451+
BSH.ElectricalComplexPowerShape: {"values": ["real", "reactive", "apparent"]},
452+
BSH.ElectricalFlowShape: {"values": ["import", "export", "net", "absolute"]},
453453
BSH.PhasesShape: {"values": ["A", "B", "C", "AB", "BC", "AC", "ABC"]},
454454
BSH.PhaseCountShape: {"values": ["1", "2", "3", "Total"]},
455455
BSH.CurrentFlowTypeShape: {"values": ["AC", "DC"]},

examples/solar_array/solar_array.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ site:pv_meter a brick:Electrical_Meter ;
104104
site:pv_daily_peak_power .
105105

106106
site:pv_power a brick:Electric_Power_Sensor ;
107-
brick:powerFlow [ brick:value "export"^^xsd:string ] ;
107+
brick:electricalFlow [ brick:value "export"^^xsd:string ] ;
108108
brick:hasUnit unit:KiloW .
109109

110110
site:pv_energy a brick:Energy_Sensor ;
111-
brick:powerFlow [ brick:value "export"^^xsd:string ] ;
111+
brick:electricalFlow [ brick:value "export"^^xsd:string ] ;
112112
brick:hasUnit unit:KiloW-HR .
113113

114114
site:pv_daily_peak_power a brick:Power_Sensor ;
115115
brick:hasUnit unit:KiloW ;
116-
brick:powerFlow [ brick:value "export"^^xsd:string ] ;
116+
brick:electricalFlow [ brick:value "export"^^xsd:string ] ;
117117
brick:aggregate [
118118
brick:aggregationFunction "max" ;
119119
brick:aggregationInterval "RP1D" ;

generate_brick.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
from rdflib.namespace import XSD
1212
from rdflib.collection import Collection
1313

14-
from bricksrc.ontology import define_ontology, ontology_imports, define_extension, BRICK_IRI_VERSION
14+
from bricksrc.ontology import (
15+
define_ontology,
16+
ontology_imports,
17+
define_extension,
18+
BRICK_IRI_VERSION,
19+
)
1520

1621

1722
from bricksrc.namespaces import (
@@ -321,7 +326,9 @@ def define_classes(definitions, parent, pun_classes=False, graph=G):
321326
graph.add((alias, OWL.equivalentClass, classname))
322327
graph.add((alias, BRICK.aliasOf, classname))
323328
if not has_label(alias, graph=graph):
324-
graph.add((alias, RDFS.label, Literal(alias.split("#")[-1].replace("_", " "))))
329+
graph.add(
330+
(alias, RDFS.label, Literal(alias.split("#")[-1].replace("_", " ")))
331+
)
325332

326333
# all other key-value pairs in the definition are
327334
# property-object pairs
@@ -383,8 +390,8 @@ def define_entity_properties(definitions, superprop=None, graph=G):
383390
assert (
384391
"property_of" in defn
385392
), f"{entprop} missing a 'property_of' annotation so Brick doesn't know where this property can be used"
386-
assert (
387-
_allowed_annotations.intersection(defn.keys())
393+
assert _allowed_annotations.intersection(
394+
defn.keys()
388395
), f"{entprop} missing at least one of {_allowed_annotations} so Brick doesn't know what the values of this property can be"
389396
assert RDFS.label in defn, f"{entprop} missing a RDFS.label annotation"
390397
graph.add((entprop, A, BRICK.EntityProperty))
@@ -530,7 +537,9 @@ def define_shape_properties(definitions, graph=G):
530537
vals = defn.pop("values")
531538
if isinstance(vals[0], str):
532539
Collection(
533-
graph, enumeration, map(lambda x: Literal(x, datatype=XSD.string), vals)
540+
graph,
541+
enumeration,
542+
map(lambda x: Literal(x, datatype=XSD.string), vals),
534543
)
535544
elif isinstance(vals[0], int):
536545
Collection(
@@ -945,7 +954,10 @@ def handle_deprecations():
945954

946955
G.remove((BRICK.value, A, OWL.ObjectProperty))
947956

957+
# handle class deprecations
948958
handle_deprecations()
959+
# handle non-class deprecations
960+
G.parse("bricksrc/deprecations.ttl")
949961

950962
logging.info("Adding class definitions")
951963
add_definitions()
@@ -974,9 +986,7 @@ def handle_deprecations():
974986
G.add((rule, SH.prefixes, BRICK_IRI_VERSION))
975987

976988
# remove ontology declarations
977-
for ontology in G.subjects(
978-
predicate=RDF.type, object=OWL.Ontology
979-
):
989+
for ontology in G.subjects(predicate=RDF.type, object=OWL.Ontology):
980990
if ontology != BRICK_IRI_VERSION:
981991
G.remove((ontology, RDF.type, OWL.Ontology))
982992
G.remove((ontology, OWL.imports, None))
@@ -989,17 +999,17 @@ def handle_deprecations():
989999
# TODO: add ontology definition
9901000
print(f"Reading in entity properties and/or class definitions from {filename}")
9911001
mod = importlib.import_module(filename)
992-
if hasattr(mod, 'entity_properties'):
1002+
if hasattr(mod, "entity_properties"):
9931003
define_entity_properties(mod.entity_properties, graph=extension_graph)
994-
if hasattr(mod, 'classes'):
1004+
if hasattr(mod, "classes"):
9951005
for parent, tree in mod.classes.items():
9961006
define_classes(tree, parent, graph=extension_graph)
997-
if hasattr(mod, 'property_value_shapes'):
1007+
if hasattr(mod, "property_value_shapes"):
9981008
define_shape_properties(mod.property_value_shapes, graph=extension_graph)
999-
if hasattr(mod, 'ontology_definition'):
1009+
if hasattr(mod, "ontology_definition"):
10001010
define_extension(extension_graph, mod.ontology_definition)
10011011

1002-
parts = Path('/'.join(filename.split('.')))
1012+
parts = Path("/".join(filename.split(".")))
10031013
dest = Path("extensions") / parts.with_suffix(".ttl")
10041014
os.makedirs(dest.parent, exist_ok=True)
10051015
print(f"Writing extension graph to {dest}")

0 commit comments

Comments
 (0)