-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add datatype constraints to lastKnownValue #433
base: master
Are you sure you want to change the base?
Conversation
@hammar does this look like it will address your needs? |
Thanks for your work on this! I'm only looking at the generated SHACL, not the Python source (yet). I have a couple of concerns:
The goal for us isn't necessarily to prescribe a schema for every possible type of point, but to give something one step more fine-grained than every lastKnownValue being a string. I hope I'm not complicating your work too much. If so I could look into implementing this as some sort of shim on our end instead. Best, Karl |
Below is an excerpt from my preliminary shim that achieves what I'm looking for. As mentioned, if this isn't in line with your own preferences, no worries -- we can do it on our end in our brickpatches.ttl, full of hacks that we graft on. :-)
|
Hi again, So, it turns out user/customer demands vary more on this than I initially understood. I'm spending a bit of time thinking on how to bend SHACL/RDF + DTDL to my will, but I don't have any great solutions yet. So this is just to say that my previous posts with suggested solutions are not complete from a REC point-of-view and I'd be happy to keep this discussion alive once I've understood a bit more about the options. Will get back to you. Karl |
@hammar let me know if you'd like to pick this conversation up again! |
It turns out this touches also upon the REC need to expose observations/readings on points as events, in order to generate API endpoints for ingesting/emitting such readings. The schema for such events is a natural candidate for lastKnownValue, as they are essentially (typed) values/timestamps. Here's what we're leaning towards in REC 4 GA (grafting on some statements on Brick sensors and/or other Points):
This is combined with:
We're presently only grafting the first PropertyShape above onto a reasonable selection of Point classes, due to the aforementioned problem of DTDL translation not allowing field overloading. We're targeting those Points where it is reasonable to assume that all subclasses will have the same representation of lastKnownValue, i.e., we're placing it as low as possible, but no lower. For the current work in progress on which points that are covered, see RealEstateCore/rec#204. If Brick wants to copy part of this design upstream, you're more than welcome of course. But I realize this may be bending a bit too much toward the design criteria of DTDL rather than SHACL, so if you prefer not to go this way, we can maintain it in our set of patches to Brick instead. |
Add "preferredDatatype" annotations to Quantities in
bricksrc/quantities.py
:This will create subshapes of
bsh:LastKnownValue
which have the datatype constraints:and then these will be added as optional properties on relevant Point types:
brick:Temperature_Sensor sh:property [ sh:maxCount 1 ; sh:node bsh:LastKnownTemperatureValueShape ; sh:path brick:lastKnownValue ] ;