Skip to content

Commit

Permalink
Additional 1.3.0 fixes (#440)
Browse files Browse the repository at this point in the history
* fix file encoding handling for sort definitions

* Make small sensor changes:

- natural gas flow sensor moves under flow sensor
- peak demand sensor now only a demand sensor, not power sensor
- rain duration sensor now only a duration sensor, not rain sensor

* additional changes from discussion

* more typos

* adjust definitions
  • Loading branch information
gtfierro authored Oct 10, 2022
1 parent b86a86c commit 4142900
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 78 deletions.
4 changes: 2 additions & 2 deletions bricksrc/definitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ https://brickschema.org/schema/Brick#Parking_Space,An area large enough to park
https://brickschema.org/schema/Brick#Parking_Structure,A building or part of a building devoted to vehicle parking,
https://brickschema.org/schema/Brick#Particulate_Matter_Sensor,Detects pollutants in the ambient air,
https://brickschema.org/schema/Brick#Passive_Chilled_Beam,A chilled beam that does not have an integral air supply and instead relies on natural convection to draw air through the device.,
https://brickschema.org/schema/Brick#Peak_Demand_Sensor,The peak power consumed by a process over some period of time,
https://brickschema.org/schema/Brick#Peak_Power,Tracks the highest (peak) observed power in some interval,
https://brickschema.org/schema/Brick#Peak_Power_Demand_Sensor,The peak power consumed by a process over some period of time,
https://brickschema.org/schema/Brick#Photovoltaic_Array,A collection of photovoltaic panels,
https://brickschema.org/schema/Brick#Photovoltaic_Current_Output_Sensor,Senses the amperes of electrical current produced as output by a photovoltaic device,
https://brickschema.org/schema/Brick#Piezoelectric_Sensor,"Senses changes pressure, acceleration, temperature, force or strain via the piezoelectric effect",
Expand Down Expand Up @@ -852,7 +852,7 @@ https://brickschema.org/schema/Brick#Radiator,Heat exchangers designed to transf
https://brickschema.org/schema/Brick#Radioactivity_Concentration_Sensor,Measures the concentration of radioactivity,
https://brickschema.org/schema/Brick#Radon_Concentration_Sensor,Measures the concentration of radioactivity due to radon,
https://brickschema.org/schema/Brick#Rain_Duration_Sensor,Measures the duration of precipitation within some time frame,
https://brickschema.org/schema/Brick#Rain_Sensor,Measures the amount of precipitation fallen,
https://brickschema.org/schema/Brick#Rain_Level_Sensor,Measures the amount of precipitation fallen,
https://brickschema.org/schema/Brick#Rated_Speed_Setpoint,Sets rated speed,
https://brickschema.org/schema/Brick#Reactive_Energy_Sensor,Measures the integral of reactive power,
https://brickschema.org/schema/Brick#Reactive_Power,"Reactive Power}, for a linear two-terminal element or two-terminal circuit, under sinusoidal conditions, is the quantity equal to the product of the apparent power (S) and the sine of the displacement angle (\psi). The absolute value of the reactive power is equal to the non-active power. The ISO (and SI) unit for reactive power is the voltampere. The special name var and symbol \textit{var are given in IEC 60027 1.",
Expand Down
19 changes: 19 additions & 0 deletions bricksrc/deprecations.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,22 @@ brick:Exhaust_Fan_Enable_Command brick:deprecation [
sh:targetClass brick:Exhaust_Fan_Enable_Command ;
] ;
] .

brick:Rain_Sensor brick:deprecation [
brick:deprecatedInVersion "1.3.0" ;
brick:deprecationMitigationMessage "Rain_Sensor is deprecated in favor of Rain_Level_Sensor as the former term is ambiguous" ;
brick:deprecationMigitationRule [
a sh:NodeShape ;
sh:rule [
a sh:SPARQLRule ;
sh:construct """
CONSTRUCT {
$this rdf:type brick:Rain_Level_Sensor .
} WHERE {
$this rdf:type brick:Rain_Sensor.
}""" ;
sh:prefixes rdf:, brick: ;
] ;
sh:targetClass brick:Rain_Sensor ;
] ;
] .
41 changes: 14 additions & 27 deletions bricksrc/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
},
},
},
"Natural_Gas_Flow_Sensor": {
BRICK.hasSubstance: BRICK.Natural_Gas,
BRICK.hasQuantity: BRICK.Flow,
"tags": [TAG.Point, TAG.Sensor, TAG.Natural, TAG.Gas, TAG.Flow],
},
"Air_Quality_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Air, TAG.Quality],
"subclasses": {
Expand Down Expand Up @@ -397,6 +392,17 @@
"Demand_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Demand],
"subclasses": {
"Peak_Demand_Sensor": {
"tags": [
TAG.Point,
TAG.Peak,
TAG.Power,
TAG.Demand,
TAG.Sensor,
TAG.Electric,
],
BRICK.hasQuantity: BRICK.Peak_Power,
},
"Cooling_Demand_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Demand, TAG.Cool],
"subclasses": {
Expand Down Expand Up @@ -575,8 +581,9 @@
BRICK.hasQuantity: BRICK.Flow,
"subclasses": {
"Natural_Gas_Flow_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Flow, TAG.Natural, TAG.Gas],
BRICK.hasSubstance: BRICK.Natural_Gas,
BRICK.hasQuantity: BRICK.Flow,
"tags": [TAG.Point, TAG.Sensor, TAG.Natural, TAG.Gas, TAG.Flow],
},
"Air_Flow_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Flow, TAG.Air],
Expand Down Expand Up @@ -1038,9 +1045,6 @@
"Occupancy_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Occupancy],
BRICK.hasQuantity: BRICK.Occupancy,
"subclasses": {
"PIR_Sensor": {"tags": [TAG.Point, TAG.PIR, TAG.Sensor]}
},
},
"Occupancy_Count_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Occupancy, TAG.Count],
Expand Down Expand Up @@ -1359,31 +1363,14 @@
],
BRICK.hasQuantity: BRICK.Active_Power,
},
"Peak_Power_Demand_Sensor": {
"tags": [
TAG.Point,
TAG.Peak,
TAG.Power,
TAG.Demand,
TAG.Sensor,
TAG.Electric,
],
BRICK.hasQuantity: BRICK.Peak_Power,
"parents": [BRICK.Demand_Sensor],
},
},
},
},
},
"Rain_Sensor": {
"Rain_Level_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Rain],
# TODO: substances
BRICK.hasQuantity: BRICK.Precipitation,
"subclasses": {
"Rain_Duration_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Rain, TAG.Duration],
}
},
},
"Duration_Sensor": {
"tags": [TAG.Point, TAG.Sensor, TAG.Duration],
Expand Down
63 changes: 16 additions & 47 deletions shacl/BrickShape.ttl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix bsh: <https://brickschema.org/schema/BrickShape#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

Expand Down Expand Up @@ -56,7 +56,7 @@ bsh:hasLocationRangeShape a sh:NodeShape ;
sh:path brick:hasLocation ] ;
sh:targetSubjectsOf brick:hasLocation .

bsh:hasLocationShape a sh:Nodeshape ;
bsh:hasLocationShape a sh:NodeShape ;
sh:message "Points are a virtual concept and always belonging to a physical device, represented by Equipment. Thus, it cannot have a Location alone." ;
sh:not [ sh:class brick:Point ] ;
sh:targetSubjectsOf brick:hasLocation .
Expand Down Expand Up @@ -91,7 +91,7 @@ bsh:hasTagRangeShape a sh:NodeShape ;
sh:targetSubjectsOf brick:hasTag .

bsh:hasUnitRangeShape a sh:NodeShape ;
sh:property [ sh:class unit:Unit ;
sh:property [ sh:class qudt:Unit ;
sh:message "Property hasUnit has object with incorrect type" ;
sh:path brick:hasUnit ] ;
sh:targetSubjectsOf brick:hasUnit .
Expand Down Expand Up @@ -152,15 +152,9 @@ brick:Collection a sh:NodeShape ;
sh:not [ sh:class brick:Quantity ] ] [ sh:message "Collection is an exclusive top class." ;
sh:not [ sh:class brick:Point ] ] ) ;
sh:message "Collection is an exclusive top class." ;
sh:or ( sh:property [ sh:class brick:Equipment ;
sh:message "A Collection can be associated with Equipments, Locations, Points, and other Collections." ;
sh:path brick:hasPart ] sh:property [ sh:class brick:Location ;
sh:message "A Collection can be associated with Equipments, Locations, Points, and other Collections." ;
sh:path brick:hasPart ] sh:property [ sh:class brick:Point ;
sh:message "A Collection can be associated with Equipments, Locations, Points, and other Collections." ;
sh:path brick:hasPart ] sh:property [ sh:class brick:Collection ;
sh:message "A Collection can be associated with Equipments, Locations, Points, and other Collections." ;
sh:path brick:hasPart ] ) .
sh:property [ sh:message "A Collection can be associated with Equipments, Locations, Points, and other Collections." ;
sh:or ( [ sh:class brick:Equipment ] [ sh:class brick:Location ] [ sh:class brick:Point ] [ sh:class brick:Collection ] ) ;
sh:path brick:hasPart ] .

brick:Equipment a sh:NodeShape ;
sh:and ( [ sh:message "Equipment is an exclusive top class." ;
Expand All @@ -170,24 +164,18 @@ brick:Equipment a sh:NodeShape ;
sh:not [ sh:class brick:Quantity ] ] [ sh:message "Equipment is an exclusive top class." ;
sh:not [ sh:class brick:Collection ] ] ) ;
sh:message "Equipment is an exclusive top class." ;
sh:or ( sh:property [ sh:class brick:System ;
sh:message "Equipment can be part of a Collection, System or other Equipment" ;
sh:path brick:isPartOf ] sh:property [ sh:class brick:Equipment ;
sh:message "Equipment can be part of a Collection, System or other Equipment" ;
sh:path brick:isPartOf ] sh:property [ sh:class brick:Collection ;
sh:message "Equipment can be part of a Collection, System or other Equipment" ;
sh:path brick:isPartOf ] ),
( sh:property [ sh:class brick:Equipment ;
sh:message "A piece of Equipment can feed a Equipment" ;
sh:path brick:feeds ] sh:property [ sh:class brick:Location ;
sh:message "A piece of Equipment can feed a Location" ;
sh:path brick:feeds ] ) ;
sh:property [ sh:class brick:Equipment ;
sh:message "A piece of Equipment's parts should be always other Equipment." ;
sh:path brick:hasPart ],
[ sh:message "Equipment can be part of a Collection, System or other Equipment." ;
sh:or ( [ sh:class brick:System ] [ sh:class brick:Equipment ] [ sh:class brick:Collection ] ) ;
sh:path brick:isPartOf ],
[ sh:class brick:Location ;
sh:message "A piece of Equipment can be located only at a Location" ;
sh:path brick:hasLocation ],
[ sh:message "A piece of Equipment can feed a Equipment or Location." ;
sh:or ( [ sh:class brick:Equipment ] [ sh:class brick:Location ] ) ;
sh:path brick:feeds ],
[ sh:class brick:Point ;
sh:message "A piece of Equipment may have associated Points" ;
sh:path brick:hasPoint ] .
Expand All @@ -200,25 +188,18 @@ brick:Point a sh:NodeShape ;
sh:not [ sh:class brick:Quantity ] ] [ sh:message "Point is an exclusive top class." ;
sh:not [ sh:class brick:Collection ] ] ) ;
sh:message "Point is an exclusive top class." ;
sh:or ( sh:property [ sh:class brick:Location ;
sh:message "A point can be associated with Locations or Equipment" ;
sh:path brick:isPointOf ] sh:property [ sh:class brick:Equipment ;
sh:message "A point can be associated with Locations or Equipment" ;
sh:path brick:isPointOf ] ) .
sh:property [ sh:message "A point can be associated with Locations or Equipment." ;
sh:or ( [ sh:class brick:Location ] [ sh:class brick:Equipment ] ) ;
sh:path brick:isPointOf ] .

brick:Location a sh:NodeShape ;
sh:and ( [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Point ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Equipment ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Substance ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Quantity ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Collection ] ] ),
( [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Point ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Equipment ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Substance ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Quantity ] ] [ sh:message "Location is an exclusive top class." ;
sh:not [ sh:class brick:Collection ] ] ) ;
sh:message "Location is an exclusive top class." ;
sh:property [ sh:class brick:Location ;
sh:message "A Location's parts should be always Locations." ;
sh:path brick:hasPart ],
Expand All @@ -228,18 +209,6 @@ brick:Location a sh:NodeShape ;
[ sh:class brick:Equipment ;
sh:message "Locations can be fed only by other Equipment." ;
sh:path brick:isFedBy ],
[ sh:class brick:Point ;
sh:message "A Location may have associated Points" ;
sh:path brick:hasPoint ],
[ sh:class brick:Location ;
sh:message "A Location's parts should be always Locations." ;
sh:path brick:hasPart ],
[ sh:class brick:Location ;
sh:message "A Location's parts should be always Locations." ;
sh:path brick:isPartOf ],
[ sh:class brick:Equipment ;
sh:message "Locations can be fed only by other Equipment." ;
sh:path brick:isFedBy ],
[ sh:class brick:Point ;
sh:message "A Location may have associated Points" ;
sh:path brick:hasPoint ] .
4 changes: 2 additions & 2 deletions tools/sort_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
print("Usage: python sort_definitions.py <input_file>")
sys.exit(1)

with open(sys.argv[1], "r") as f:
with open(sys.argv[1], "r", encoding="utf-8") as f:
reader = csv.reader(f)
data = list(reader)
# remove duplicates
Expand All @@ -20,6 +20,6 @@
# sort by term
terms = sorted(terms, key=lambda tup: tup[0])

with open(sys.argv[1], "w") as f:
with open(sys.argv[1], "w", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerows(terms)

0 comments on commit 4142900

Please sign in to comment.