fromvrdfimportDB, BRICK, AfromrdflibimportNamespaceBLDG=Namespace("urn:bldg#")
db=DB("test.db")
# using logical timestamps here (0, 1, 2, 3, ...). If these are# ommitted it defaults to the current system time.withdb.new_changeset("my-building", 1) ascs:
cs.add((BLDG.vav1, A, BRICK.VAV))
cs.add((BLDG.vav1, BRICK.feeds, BLDG.zone1))
cs.add((BLDG.zone1, A, BRICK.HVAC_Zone))
cs.add((BLDG.zone1, BRICK.hasPart, BLDG.room1))
# WARNING: this is slow for nowwithdb.new_changeset("brick", 1) ascs:
# 'cs' is a rdflib.Graph that supports queries -- updates on it# are buffered in the transaction and cannot be queried until# the transaction is committed (at the end of the context block)cs.load_file(
"https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl"
)
withdb.new_changeset("my-building", 2) ascs:
cs.add((BLDG.vav2, A, BRICK.VAV))
cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone1))
cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))
cs.remove((BLDG.zone1, BRICK.hasPart, BLDG.room1))
withdb.new_changeset("my-building", 3) ascs:
cs.add((BLDG.vav2, A, BRICK.VAV))
cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone1))
cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))
cs.remove((BLDG.zone1, BRICK.hasPart, BLDG.room1))
withdb.new_changeset("my-building", 4) ascs:
cs.remove((BLDG.vav2, BRICK.feeds, BLDG.zone1))
cs.add((BLDG.vav2, BRICK.feeds, BLDG.zone2))
print("LATEST!")
fortindb.latest("my-building"):
print(t)
forlogical_tsinrange(1, 5):
print("LOGICAL TS:", logical_ts)
fortindb.graph_at("my-building", logical_ts):
print(t)
db.close()
Owner
Gabe Fierro
Asst Prof @ Colorado School of Mines // NREL // CS PhD @ UC Berkeley //
Databases, Systems, Semantic Interop, Cyber-Physical Systems
🐸 Identify anything. pyWhat easily lets you identify emails, IP addresses, and more. Feed it a .pcap file or some text and it'll tell you what it is! 🧙♀️