Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gtf-add-evse
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Sep 27, 2023
2 parents 269a4c3 + 513a1e8 commit df09343
Show file tree
Hide file tree
Showing 47 changed files with 15,379 additions and 804 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.9', '3.10']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -42,7 +42,3 @@ jobs:
# -s flag: do not capture output (avoids killing test after 10 min)
run: |
pytest -s -vvvv --durations=0 -n auto tests
- name: Do integration tests
run: |
cd tests/integration
bash run_integration_tests.sh
2 changes: 1 addition & 1 deletion .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.10'
architecture: x64
- name: Set up AllegroGraph (Docker)
run: |
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ format:

test: Brick.ttl
pytest -s -vvvv -n auto tests
cd tests/integration && bash run_integration_tests.sh

quantity-test: Brick.ttl
pytest -s -vvvv tests/test_quantities.py
Expand Down
1 change: 1 addition & 0 deletions bricksrc/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"Cooling_Command": {"tags": [TAG.Point, TAG.Cool, TAG.Command]},
"Heating_Command": {"tags": [TAG.Point, TAG.Heat, TAG.Command]},
"Preheat_Command": {"tags": [TAG.Point, TAG.Preheat, TAG.Command]},
"Reheat_Command": {"tags": [TAG.Point, TAG.Reheat, TAG.Command]},
"Luminance_Command": {"tags": [TAG.Point, TAG.Luminance, TAG.Command]},
"Bypass_Command": {"tags": [TAG.Point, TAG.Bypass, TAG.Command]},
"Damper_Command": {
Expand Down
28 changes: 18 additions & 10 deletions bricksrc/definitions.csv

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions bricksrc/deprecations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,84 @@
from .namespaces import BRICK, RDFS, SKOS, A

deprecations = {
BRICK.Solar_Radiance_Sensor: {
"version": "1.3.0",
"mitigation_message": "The class 'Solar_Radiance_Sensor' is deprecated in favor of 'Solar_Irradiance_Sensor'. The new name better reflects the standard unit of measurement, watts per square meter (W/m²), and aligns with the terminology commonly used in solar applications.",
"replace_with": BRICK.Solar_Irradiance_Sensor,
RDFS.subClassOf: BRICK.Sensor,
},
BRICK.Occupied_Air_Temperature_Cooling_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Occupied_Air_Temperature_Cooling_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Occupied_Cooling_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Occupied_Air_Temperature_Setpoint,
},
BRICK.Occupied_Air_Temperature_Heating_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Occupied_Air_Temperature_Heating_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Occupied_Heating_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Occupied_Air_Temperature_Setpoint,
},
BRICK.Unoccupied_Air_Temperature_Cooling_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Unoccupied_Air_Temperature_Cooling_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Unoccupied_Cooling_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Unoccupied_Air_Temperature_Setpoint,
},
BRICK.Unoccupied_Air_Temperature_Heating_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Unoccupied_Air_Temperature_Heating_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Unoccupied_Heating_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Unoccupied_Air_Temperature_Setpoint,
},
BRICK.Effective_Air_Temperature_Cooling_Setpoint: {
"version": "1.3.0",
"mitigation_message": "The class 'Effective_Air_Temperature_Cooling_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Effective_Cooling_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Effective_Air_Temperature_Setpoint,
},
BRICK.Effective_Air_Temperature_Heating_Setpoint: {
"version": "1.3.0",
"mitigation_message": "The class 'Effective_Air_Temperature_Heating_Setpoint' is deprecated in favor of further specifying that it is a zone air setpoint.",
"replace_with": BRICK.Effective_Heating_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Effective_Air_Temperature_Setpoint,
},
BRICK.Zone_Air_Temperature_Setpoint: {
"version": "1.3.0",
"mitigation_message": "The class 'Zone_Air_Temperature_Setpoint' is deprecated in favor of more explicit class names to distinguish target and cooling/heating setpoints.",
"replace_with": BRICK.Target_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Air_Temperature_Setpoint,
},
BRICK.Effective_Zone_Air_Temperature_Setpoint: {
"version": "1.3.0",
"mitigation_message": "The class 'Effective_Zone_Air_Temperature_Setpoint' is deprecated and replaced to better represent its function as a target setpoint",
"replace_with": BRICK.Effective_Target_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Zone_Air_Temperature_Setpoint,
},
BRICK.Occupied_Zone_Air_Temperaure_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Occupied_Zone_Air_Temperature_Setpoint' is deprecated in favor of further specifying that it is a target setpoint",
"replace_with": BRICK.Occupied_Target_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Zone_Air_Temperature_Setpoint,
},
BRICK.Unoccupied_Zone_Air_Temperature_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Unoccupied_Zone_Air_Temperature_Setpoint' is deprecated in favor of further specifying that it is a target setpoint",
"replace_with": BRICK.Unoccupied_Target_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Zone_Air_Temperature_Setpoint,
},
BRICK.Zone_Air_Cooling_Temperature_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Zone_Air_Cooling_Temperature_Setpoint' is deprecated to support new naming convention, which reorders intended behaviour (cooling) before the substance (zone air).",
"replace_with": BRICK.Cooling_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Zone_Air_Temperature_Setpoint,
},
BRICK.Zone_Air_Heating_Temperature_Setpoint: {
"version": "1.3.0",
"mitigation_message": "'Zone_Air_Heating_Temperature_Setpoint' is deprecated to support new naming convention, whic reorders intended behaviour (heating) before the substance (zone air)",
"replace_with": BRICK.Heating_Zone_Air_Temperature_Setpoint,
RDFS.subClassOf: BRICK.Zone_Air_Temperature_Setpoint,
},
BRICK.Fresh_Air_Fan: {
"version": "1.3.0",
"mitigation_message": "Fresh Air Fan is deprecated in favor of Outside Fan because the latter is a more accurate representation",
Expand Down
32 changes: 26 additions & 6 deletions bricksrc/equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@
},
},
},
"Inverter": {"tags": [TAG.Inverter, TAG.Equipment]},
"Inverter": {
"tags": [TAG.Inverter, TAG.Equipment],
"subclasses": {
"Photovoltaic_Inverter": {
"tags": [TAG.Photovoltaic, TAG.Inverter, TAG.Equipment]
}
},
},
"PlugStrip": {"tags": [TAG.PlugStrip, TAG.Equipment]},
"Disconnect_Switch": {"tags": [TAG.Disconnect, TAG.Switch, TAG.Equipment]},
"Switchgear": {"tags": [TAG.Switchgear, TAG.Equipment]},
Expand All @@ -86,7 +93,13 @@
"tags": [TAG.Equipment, TAG.Motor],
"subclasses": {
"Variable_Frequency_Drive": {
"tags": [TAG.Equipment, TAG.Variable, TAG.Frequency, TAG.Drive, TAG.VFD],
"tags": [
TAG.Equipment,
TAG.Variable,
TAG.Frequency,
TAG.Drive,
TAG.VFD,
],
"aliases": [BRICK["VFD"]],
"subclasses": {
"Heat_Wheel_VFD": {
Expand Down Expand Up @@ -560,7 +573,14 @@
},
"Condenser": {"tags": [TAG.Equipment, TAG.Condenser]},
"Computer_Room_Air_Conditioning": {
"tags": [TAG.Equipment, TAG.Computer, TAG.Room, TAG.Air, TAG.Conditioning, TAG.CRAC],
"tags": [
TAG.Equipment,
TAG.Computer,
TAG.Room,
TAG.Air,
TAG.Conditioning,
TAG.CRAC,
],
"aliases": [BRICK["CRAC"]],
"subclasses": {
"Standby_CRAC": {"tags": [TAG.Equipment, TAG.CRAC, TAG.Standby]},
Expand Down Expand Up @@ -628,8 +648,8 @@
"Air_Handling_Unit": {
"tags": [TAG.Equipment, TAG.Air, TAG.Handling, TAG.Handler, TAG.Unit, TAG.AHU],
"aliases": [
BRICK["AHU"],
BRICK["Air_Handler_Unit"], # here for historical purposes
BRICK["AHU"],
BRICK["Air_Handler_Unit"], # here for historical purposes
],
"subclasses": {
"Dedicated_Outdoor_Air_System_Unit": {
Expand Down Expand Up @@ -657,7 +677,7 @@
},
"Pre-Cooling_Air_Unit": {
"tags": [TAG.Equipment, TAG.PAU],
"aliases": [BRICK["PAU"]]
"aliases": [BRICK["PAU"]],
},
},
},
Expand Down
20 changes: 16 additions & 4 deletions bricksrc/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@
"Ablutions_Room": {
"tags": [TAG.Ablutions, TAG.Room, TAG.Space, TAG.Location]
},
"Breakroom": {
"tags": [TAG.Breakroom, TAG.Break, TAG.Room, TAG.Space, TAG.Location],
"aliases": [BRICK["Break_Room"]],
"Break_Room": {
"tags": [
TAG.Breakroom,
TAG.Break,
TAG.Room,
TAG.Space,
TAG.Location,
],
"aliases": [BRICK["Breakroom"]],
},
"Conference_Room": {
"tags": [TAG.Conference, TAG.Room, TAG.Space, TAG.Location]
Expand Down Expand Up @@ -368,7 +374,13 @@
"tags": [TAG.Reception, TAG.Room, TAG.Space, TAG.Location]
},
"Restroom": {
"tags": [TAG.Restroom, TAG.Rest, TAG.Room, TAG.Space, TAG.Location],
"tags": [
TAG.Restroom,
TAG.Rest,
TAG.Room,
TAG.Space,
TAG.Location,
],
"aliases": [BRICK["Rest_Room"]],
},
"Retail_Room": {
Expand Down
63 changes: 54 additions & 9 deletions bricksrc/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"currency": "http://qudt.org/2.1/vocab/currency",
"quantitykind": "http://qudt.org/2.1/vocab/quantitykind",
"dimensionvector": "http://qudt.org/2.1/vocab/dimensionvector",
"shacl": "http://www.w3.org/ns/shacl#",
"bacnet": "http://data.ashrae.org/bacnet/2020",
}

Expand Down Expand Up @@ -79,11 +78,11 @@
},
]

BRICK_IRI_VERSION = URIRef(f"https://brickschema.org/schema/{BRICK_VERSION}/Brick")

def define_ontology(G):
brick_iri_version = URIRef(f"https://brickschema.org/schema/{BRICK_VERSION}/Brick")
G.add((brick_iri_version, RDF.type, OWL.Ontology))
G.add((brick_iri_version, RDFS.isDefinedBy, brick_iri_version))
G.add((BRICK_IRI_VERSION, RDF.type, OWL.Ontology))
G.add((BRICK_IRI_VERSION, RDFS.isDefinedBy, BRICK_IRI_VERSION))

# add creators from ontology markup above
creators = []
Expand All @@ -96,23 +95,69 @@ def define_ontology(G):

# add publisher info
publisher = BNode("publisher")
G.add((brick_iri_version, DCTERMS.publisher, publisher))
G.add((BRICK_IRI_VERSION, DCTERMS.publisher, publisher))
for k, v in ontology.pop(DCTERMS.publisher).items():
G.add((publisher, k, v))
Collection(G, creator_list, creators)
G.add((brick_iri_version, DCTERMS.creator, creator_list))
G.add((BRICK_IRI_VERSION, DCTERMS.creator, creator_list))

# add other simple attributes
for k, v in ontology.items():
G.add((brick_iri_version, k, v))
G.add((BRICK_IRI_VERSION, k, v))

# add imports
for imp in ontology_imports.values():
G.add((brick_iri_version, OWL.imports, URIRef(imp)))
G.add((BRICK_IRI_VERSION, OWL.imports, URIRef(imp)))

# add SHACL namespace/prefix declarations for SHACL rules
for declaration in shacl_namespace_declarations:
decl = BNode()
G.add((brick_iri_version, SH.declare, decl))
G.add((BRICK_IRI_VERSION, SH.declare, decl))
for k, v in declaration.items():
G.add((decl, k, v))


def define_extension(graph, defn):
graph_name = URIRef(defn["namespace"])
graph.add((graph_name, RDF.type, OWL.Ontology))
graph.add((graph_name, RDFS.isDefinedBy, graph_name))

# add creators from ontology markup above
creators = []
creator_list = BNode("ontology_creators")
for creator in ontology.pop(DCTERMS.creator, []):
if not creator:
break
creator1 = BNode(f"ontology_creator_{creator[SDO.name]}")
creators.append(creator1)
for k, v in creator.items():
graph.add((creator1, k, v))
if creators:
Collection(graph, creator_list, creators)
graph.add((graph_name, DCTERMS.creator, creator_list))

# add publisher info
publisher = BNode("publisher")
publishers = ontology.pop(DCTERMS.publisher, {})
for k, v in publishers.items():
graph.add((publisher, k, v))
if publishers:
graph.add((graph_name, DCTERMS.publisher, publisher))

# add imports
ontology_imports = defn.pop("imports", {})
for ns, imp in ontology_imports.items():
graph.add((graph_name, OWL.imports, URIRef(imp)))
graph.bind(ns, imp)

# add other simple attributes
for k, v in ontology.items():
graph.add((graph_name, k, v))

# add SHACL namespace/prefix declarations for SHACL rules
for pfx, ns in defn.pop("decls", {}).items():
decl = BNode()
graph.add((graph_name, SH.declare, decl))
graph.bind(pfx, ns)
graph.add((decl, SH.prefix, Literal(pfx)))
graph.add((decl, SH.namespace, Literal(str(ns), datatype=XSD.anyURI)))
6 changes: 6 additions & 0 deletions bricksrc/quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,5 +770,11 @@ def all_units():
},
"Torque": {BRICK.hasQUDTReference: QUDTQK["Torque"]},
# TODO: https://ci.mines-stetienne.fr/seas/WeatherOntology-0.9#AirTemperature ?
"Volume": {
BRICK.hasQUDTReference: QUDTQK["Volume"],
QUDT.applicableUnit: [UNIT["M3"], UNIT["FT3"], UNIT["IN3"], UNIT["YD3"]],
QUDT.hasDimensionVector: QUDTDV["A0E0L3I0M0H0T0D0"],
RDFS.label: Literal("Volume"),
},
"Weather_Condition": {},
}
12 changes: 4 additions & 8 deletions bricksrc/relationships.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rdflib import Literal
from .namespaces import A, OWL, RDFS, BRICK, VCARD, UNIT, QUDT, SDO, RDF, S223, BSH, XSD
from .namespaces import A, OWL, RDFS, BRICK, VCARD, UNIT, QUDT, SDO, RDF, BSH, XSD

"""
Defining Brick relationships
Expand All @@ -13,19 +13,19 @@
},
"hasSubstance": {
A: [OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Has QUDT reference"),
RDFS.label: Literal("Has Substance"),
"range": BRICK.Substance,
"domain": [BRICK.Point, BRICK.Meter],
},
"hasQuantity": {
A: [OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Has QUDT reference"),
RDFS.label: Literal("Has Quantity"),
RDFS.subPropertyOf: QUDT.hasQuantityKind,
"range": BRICK.Quantity,
"domain": BRICK.Point,
},
"value": {
RDFS.subPropertyOf: [QUDT.value, S223.hasValue],
RDFS.subPropertyOf: QUDT.value,
RDFS.label: Literal("Value"),
A: [RDF.Property],
"range": RDFS.Resource,
Expand Down Expand Up @@ -107,10 +107,6 @@
"range": [
BRICK.Equipment,
BRICK.Location,
S223.ConnectionPoint,
S223.Connection,
S223.Connectable,
S223.Segment,
],
RDFS.label: Literal("Is point of"),
},
Expand Down
Loading

0 comments on commit df09343

Please sign in to comment.