Code Monkey home page Code Monkey logo

ref-schema's Introduction

Ref Schema

Docs are here

Extending Ref Schema

Here's a short description of how to add a new external reference to ref schema

  1. Create a new file under models/ to contain the statements; create a new ontology URI that extends the ref URI. The base ref URI is https://brickschema.org/schema/Brick/ref#, so if you were creating an extension for a new protocol, say Modbus, then you might choose a URI of https://brickschema.org/schema/Brick/ref/modbus#

  2. Ensure the new file contains an ontology declaration using that URI:

     @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
     @prefix ref: <https://brickschema.org/schema/Brick/ref#> .
     @prefix sh: <http://www.w3.org/ns/shacl#> .
     @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
     @prefix owl: <http://www.w3.org/2002/07/owl#> .
     @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
     @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
     @prefix modbus: <https://brickschema.org/schema/Brick/ref/modbus#> .
    
     modbus: a owl:Ontology .
  3. Inside the new file, define all of the owl:ObjectProperty and owl:DatatypeProperty properties that would exist on the external reference shape. For Modbus, one might have:

    • IP address (for Modbus/TCP)
    • data type (one of coil, contact, register, ...)
    • address offset

    These properties should be in the ref: namespace, but the property names should start with some indication of the protocol (e.g. modbus*). You should have an skos:definitions and rdfs:label on each of these. You can use SHACL Property Shapes to further refine these definitions as well; (see step 6)

    # continuation of above .ttl file
    ref:modbusIPAddress a owl:DatatypeProperty
        rdfs:label "Modbus IP address" ;
        skos:definition "IP address of Modbus TCP/IP server where the item exists" .
    ref:modbusDataType a owl:DatatypeProperty ;
        rdfs:label "Modbus data type" ;
        skos:definition "Data type of the modbus item being referenced" .
    ref:modbusAddressOffset a owl:DatatypeProperty ;
        rdfs:label "Modbus address offset" ;
        skos:definition "Offset into the modbus address space where the referenced item exists" .
  4. Define a <EXTERNAL REFERENCE>ReferenceShape Node Shape in this new file which performs reflection on the reference in order to add the correct type annotation. This will refer to the ref:<EXTERNAL REFERENCE>Reference shape that we will define below. Here is an example of what this would look like for our Modbus shape:

     ref:ModbusReferenceShape a sh:NodeShape ;
         skos:definition "Infers a ModbusReference instance from the object of an hasExternalReference." ;
         sh:targetObjectsOf ref:hasExternalReference ;
         sh:rule [
           a sh:TripleRule ;
           sh:condition ref:ModbusReference ;
           sh:subject sh:this ;
           sh:predicate rdf:type ;
           sh:object ref:ModbusReference ;
         ] ;
     .
  5. Define a has<EXTERNAL REF>Reference owl:ObjectProperty to the new file; this should point to the Reference shape defined below and be a subproperty (rdfs:subPropertyOf) of ref:hasExternalReference:

    ref:hasModbusReference a owl:ObjectProperty ;
      rdfs:range ref:ModbusReference ;
      rdfs:subPropertyOf ref:hasExternalReference ;
      rdfs:label "has modbus reference" ;
      skos:definition "Metadata for accessing a modbus item" .
  6. In model/all.ttl, add your new Reference shape. This should be both an owl:Class and sh:NodeShape and a subclass of ref:ExternalReference. Use all of the propery shapes you defined above; you can decide if they are optional or necessary. The Reference shape should exist in the ref: namespace. You should include a skos:definition and rdfs:label. For our Modbus example:

    ref:ModbusReference a owl:Class, sh:NodeShape ;
        rdfs:subClassOf ref:ExternalReference ;
        rdfs:label "Modbus Reference" ;
        skos:definition "Refers to a modbus item over TCP/IP" ;
        sh:property [
         sh:path ref:modbusIPAddress ;
         sh:minCount 1 ;
         sh:maxCount 1 ;
         sh:datatype xsd:string ;
        ] ;
        sh:property [
         sh:path ref:modbusDataType ;
         sh:minCount 1 ;
         sh:maxCount 1 ;
         sh:datatype xsd:string ;
         sh:in ("coil" "contact" "register")
        ] ;
        sh:property [
         sh:path ref:modbusAddressOffset ;
         sh:minCount 1 ;
         sh:maxCount 1 ;
         sh:datatype xsd:nonNegativeInteger ;
        ] ;
     .
  7. Finally add an import to your graph in model/all.ttl:

    <https://brickschema.org/schema/Brick/ref> a owl:Ontology ;
        dcterms:title "Ref Schema" ;
        dcterms:creator ( [ a sdo:Person ;
                    sdo:email "[email protected]" ;
                    sdo:name "Gabe Fierro" ] ) ;
        owl:imports <https://brickschema.org/schema/Brick/ref/core#> ;
        owl:imports <https://brickschema.org/schema/Brick/ref/bacnet#> ;
        owl:imports <https://brickschema.org/schema/Brick/ref/ifc#> ;
        owl:imports <https://brickschema.org/schema/Brick/ref/tsdb#> ;
        owl:imports <https://brickschema.org/schema/Brick/ref/modbus#> ; # <--- added!
    .

ref-schema's People

Contributors

gtfierro avatar bradestacio avatar joelbender avatar

Stargazers

Rocco Giudice avatar Roberto Chiosa avatar  avatar Entrapta Jones avatar Shreyas Nagare avatar

Watchers

 avatar James Cloos avatar  avatar Shreyas Nagare avatar  avatar

ref-schema's Issues

Modbus

For a particular point:

  • address of the Modbus controller
    • some routing information required for hierarchical organizations (e.g., gateway?)
  • register number
  • bitmask? other deserialization information?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.