Commit 600de362 authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Documentation for v4.0. Some new links, images etc.

parent 14cdf759
Copyright 2019, oneM2M Partners Type 1
Copyright 2020, oneM2M Partners Type 1
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
......
......@@ -12,12 +12,12 @@ Any contributions made to the Smart Device Template format must comply with the
![](SDT/schema4.0/docs/images/SDT_simplified.png)
The Smart Device Template (SDT) is a template which is used to model the capabilities, actions and events of connected devices. The intent of the SDT is to be able to model any type of connected device using a well accepted and standardised format. The main application of SDT is to enable a uniformly structured Application Programmer's Interface (API) to applications that need to interact with connected devices. Usually, these applications would communicate to devices using an abstraction layer as an intermediary logic. The abstraction layer "hides" the technology-specific, native language format of devices of different technology type from the applications.
The Smart Device Template (SDT) is a template method which is used to model the capabilities, actions and events of connected devices. The intent of the SDT is to be able to model any type of connected device using a well accepted and standardised format. The main application of SDT is to enable a uniformly structured Application Programmer's Interface (API) for applications that need to interact with connected devices. Usually, these applications would communicate to devices using an abstraction or service layer, or cloud platform as an intermediary logic. This layer usually "hides" the technology-specific, native language format of devices of different technology type from the applications.
[Read the full Introduction.](SDT/schema4.0/docs/Introduction.md)
## Quick Links
- [UML Diagram of the SDT 4.0](SDT/schema4.0/docs/UML%20Diagram.md) ([Umlet source](SDT/schema4.0/docs/SDT_UML.uxf)) : This UML diagram describes the various components of the SDT and their relations.
- [UML Diagrams of the SDT 4.0](SDT/schema4.0/docs/UML%20Diagram.md) ([Umlet source](SDT/schema4.0/docs/SDT_UML.uxf)) : These UML diagram describes the various components of the SDT and their relations.
- ['domain.xsd' Version 4.0](SDT/schema4.0/src/domain.xsd) : This is the XSD schema file that defines the SDT XML Schema.
......
......@@ -13,6 +13,7 @@
- Added ``optional`` attribute to ``<Arg>``.
- Added ``default`` attribute to ``<Arg>``.
- Added ``default`` attribute to ``<DataPoint``.
- Added `minOccurs`` and ``maxOccurs`` to SubDevice and ModuleClass
- Unified all component identifiers, names etc to XSD type ``name``.
- Introduced JSON serialization guidelines.
- Changed case of ``<Imports>`` element.
......
......@@ -7,23 +7,24 @@
1. [ModuleClasses Definition](#echonetExampleMC)
2. [DeviceClass Definition](#echonetExampleDC)
3. [The full SDT](#echonetExampleFull)
3. [More examples](#moreExamples)
<a name="simpleExample"></a>
<a id="simpleExample"></a>
## A simple SDT example
The following example shows a very simple device that represents a light that can be switched on and off. It contains just a single ModuleClass "Switch", which contains a single boolean data point "status" to control the on/off status of the device.
The following example shows a very simple device that represents a light that can be switched on and off. It contains just a single [ModuleClass](SDT_Components.md#ModuleClass) "Switch", which contains a single boolean [data point](SDT_Components.md#DataPoint) "status" to control the on/off status of the device.
It is a stand-alone definition without using previously defined ModuleClasses. A more sophisticated use is presented in the next example.
It is a stand-alone definition without using previously defined [ModuleClasses](SDT_Components.md#ModuleClass). A more sophisticated use is presented in the next example.
The structure and the according SDT looks like this:
|SimpleExample.xml | |
|:--------------|-|
|Namespace information | SimpleExample |
|DeviceClasses |<ul><li>Light</li><ul><li>Switch<ul><li>status</li></ul></li></ul></ul>|
|DeviceClasses |<ul><li>Light ([DeviceClass](SDT_Components.md#DeviceClass))</li><ul><li>Switch ([ModuleClass](SDT_Components.md#ModuleClass))<ul><li>status ([DataPoint](SDT_Components.md#DataPoint)</li></ul></li></ul></ul>|
The following code section shows the fully integrated template. The source code can be found in [SimpleExample.xml](../test/SimpleExample.xml) in the "test" directory.
The following code section shows the fully integrated template. The source code can be found in [SimpleExample.xml](../test/SimpleExample.xml) in the [test](../test) directory.
```xml
<?xml version="1.0" encoding="iso-8859-1"?>
......@@ -48,28 +49,28 @@ The following code section shows the fully integrated template. The source code
</Domain>
```
<a name="echonetExample"></a>
<a id="echonetExample"></a>
## A more sophisticated example
In the ideal case, a large organization or SDO would define a widely-applicable set of [ModuleClasses](SDT_Components.md#ModuleClass), each of which could be used as needed to compose the description of a complex device. In order to show the approach, this section will create a few example ModuleClasses based on - or inspired by - features in the Echonet Lite protocol. Please note that the examples shown in this document are very "cut down" and by no means represent a true representation of Echonet Lite[^echonet].
In the ideal case, a large organization or SDO would define a widely-applicable set of [ModuleClasses](SDT_Components.md#ModuleClass), each of which could be used as needed to compose the description of a complex device. In order to show the approach, this section will create a few example [ModuleClasses](SDT_Components.md#ModuleClass) based on - or inspired by - features in the Echonet Lite protocol. Please note that the examples shown in this document are very "cut down" and by no means represent a true representation of Echonet Lite[^echonet].
[^echonet]: The Echonet Consortium has standardized their specifications within IEC/ISO (IEC62394, ISO/IEC24767-1, ISO/IEC24767-2, IEC62480, ISO/IEC14543-4-1, ISO/IEC14543-4-2, IEC62457) and they provide a comprehensive collection of various types of home appliances relevant to SmartGrid applications as ECHONET Device objects (see [https://echonet.jp/spec_object_rf_en/](https://echonet.jp/spec_object_rf_en/) ).
The source code can be found in [EchonetLiteExamples.xml](../test/EchonetLiteExamples.xml) in the "test" directory.
<a name="echonetExampleMC"></a>
<a id="echonetExampleMC"></a>
### ModuleClasses
For the example in this section, to show re-use of ModuleClass definitions, two complex devices are chosen which have some common features and hence could be expected to both use some of the same ModuleClasses: an air conditioner and a washing machine.
For the example in this section, to show re-use of [ModuleClass](SDT_Components.md#ModuleClass) definitions, two complex devices are chosen which have some common features and hence could be expected to both use some of the same [ModuleClasses](SDT_Components.md#ModuleClass): an air conditioner and a washing machine.
|Functionality | Air Conditioner | Washing Machine |
|:------------|:----------------|:----------------|
|operationStatus |operates on/off |operates on/off |
|measuredCumulativePowerConsumption |the cumulative power consumption |the cumulative power consumption |
|installationLocation |this sets/reads a string text describing the location (room) of the air-conditioner |this sets/reads a string text describing the location (room) of the washing machine |
|setTimer |(not applicable. there is no preset start for an air-conditioner) |This sets/reads use the on/off timer |
|setTimer |not applicable (there is no preset start for an air-conditioner) |This sets/reads use the on/off timer |
|temperatureSensorDataPoints | this reads the measured temperature | this reads the measured temperature |
Based on the simplified example above, the two appliances will need the ModuleClasses below:
Based on the simplified example above, the two appliances will need the [ModuleClasses](SDT_Components.md#ModuleClass) below:
- *air-conditioner*: operationStatus, measuredCumulativePowerConsumption, installationLocation;
- *washing-machine*: operationStatus, measuredCumulativePowerConsumption, setTimer, temperatureSensorDataPoints.
......@@ -129,11 +130,11 @@ Based on the simplified example above, the two appliances will need the ModuleCl
```
<a name="echonetExampleDC"></a>
<a id="echonetExampleDC"></a>
### DeviceClass
To define a device one would now reference those ModuleClass definitions in a new DeviceClass. For the sake of simplicity only the "SimpleWashingMachine" is implemented here.
To define a device one would now reference those [ModuleClass](SDT_Components.md#ModuleClass) definitions in a new [DeviceClass](SDT_Components.md#DeviceClass). For the sake of simplicity only the "SimpleWashingMachine" is implemented here.
In addition to the previously defined ModuleClasses this "SimpleWashingMachine" DeviceClass extends the existing ModuleClass "operationStatus" with an event. It also adds a new ModuleClass "washingMachineDataPoints" with model-specific DataPoints.
In addition to the previously defined [ModuleClasses](SDT_Components.md#ModuleClass) this "SimpleWashingMachine" [DeviceClass](SDT_Components.md#DeviceClass) extends the existing [ModuleClass](SDT_Components.md#ModuleClass) "operationStatus" with an event. It also adds a new [ModuleClass](SDT_Components.md#ModuleClass) "washingMachineDataPoints" with model-specific [DataPoints](SDT_Components.md#DataPoint).
At the beginning of the definition some device Properties are defined.
......@@ -242,15 +243,15 @@ At the beginning of the definition some device Properties are defined.
</DeviceClass>
```
<a name="echonetExampleFull"></a>
<a id="echonetExampleFull"></a>
### The full SDT
The structure and the according SDT now looks like this:
|EchonetLiteExamples.xml | |
|:--------------|-|
|Namespace information | example.based.on.echonetLite |
|ModuleClasses |<ul><li>operationStatus<ul><li>operationStatus</li></ul></li><li>measuredCumulativePowerConsumption<ul><li>measuredInstantaneousPowerConsumption</li></ul></li><li>installationLocation<ul><li>installationLocation</li></ul></li><li>temperatureSensorDataPoints<ul><li>measuredTemperatureValue</li></ul></li></ul>|
|DeviceClasses |<ul><li>SimpleWaschingMachine</li><ul><li>installationLocation --> installationLocation</li><li>measuredCumulativePowerConsumption --> measuredCumulativePowerConsumption</li><li>temperatureSensorDataPoints --> temperatureSensorDataPoints</li><li>operationStatus --> washingMachineOperationStatus</li><li>washingMachineDataPoints</li><ul><li>door_CoverOpen_CloseStatus</li><li>washingMachineSetting</li><li>currentStageOfWashingCycle</li><li>timeRemainingToCompleteWashingCycle</li><li>onTimerReservationSetting</li><li>onTimerSetting</li><li>relativeTimeBasedOnTimerSetting</li></ul></ul></ul>|
|[ModuleClasses](SDT_Components.md#ModuleClass) |<ul><li>operationStatus<ul><li>operationStatus</li></ul></li><li>measuredCumulativePowerConsumption<ul><li>measuredInstantaneousPowerConsumption</li></ul></li><li>installationLocation<ul><li>installationLocation</li></ul></li><li>temperatureSensorDataPoints<ul><li>measuredTemperatureValue</li></ul></li></ul>|
|[DeviceClasses](SDT_Components.md#DeviceClass) |<ul><li>SimpleWaschingMachine</li><ul><li>installationLocation --> installationLocation</li><li>measuredCumulativePowerConsumption --> measuredCumulativePowerConsumption</li><li>temperatureSensorDataPoints --> temperatureSensorDataPoints</li><li>operationStatus --> washingMachineOperationStatus</li><li>washingMachineDataPoints</li><ul><li>door_CoverOpen_CloseStatus</li><li>washingMachineSetting</li><li>currentStageOfWashingCycle</li><li>timeRemainingToCompleteWashingCycle</li><li>onTimerReservationSetting</li><li>onTimerSetting</li><li>relativeTimeBasedOnTimerSetting</li></ul></ul></ul>|
The following code section shows the fully integrated template.
......@@ -433,6 +434,8 @@ The following code section shows the fully integrated template.
</DeviceClass>
</DeviceClasses>
</Domain>
```
<a id="moreExample"></a>
## More Examples
More examples that also show specific features of the SDT are available in the [test](../test) directory.
......@@ -9,14 +9,14 @@
2. [How to validate own templates](#validate)
3. [Are there tools to work with the SDT?](#tools)
<a name="general"></a>
<a id="general"></a>
## General
<a name="WhatistheSDT"></a>
<a id="WhatistheSDT"></a>
### What is the SDT?
The Smart Device Template (SDT) is a template which is used to model the capabilities, actions and events of connected devices. The intent of the SDT is to be able to model any type of connected device using a well accepted and standardised format. The main application of SDT is to enable a uniformly structured Application Programmer’s Interface (API) to applications that need to interact with connected devices.
<a name="WhatisoneM2M"></a>
<a id="WhatisoneM2M"></a>
### What is oneM2M?
oneM2M is a global organization that creates requirements, architecture, API specifications, security solutions and interoperability for Machine-to-Machine and IoT technologies.
......@@ -38,22 +38,24 @@ Service Layer aspects with high level and detailed service architecture, in ligh
[http://www.onem2m.org](http://www.onem2m.org)
<a name="working"></a>
<a id="working"></a>
## Working with the SDT
<a name="working"></a>
<a id="working"></a>
### How to build the SDT
Please follow the instructions for the [SDT Build System](SDT/schema4.0/docs/SDT%20Build%20System.md).
In short:
- Clone the SDT repository from [https://git.onem2m.org/MAS/SDT.git](https://git.onem2m.org/MAS/SDT.git)
- Install Apache ant
- In a terminal, go to the directoy *SDT/schema4.0*
- Run the command:
```sh
$ ant
```
<a name="validate"></a>
<a id="validate"></a>
### How to validate own templates
Please follow the instructions for the [SDT Build System](SDT/schema4.0/docs/SDT%20Build%20System.md).
......@@ -66,7 +68,7 @@ In short:
$ ant validate
```
<a name="tools"></a>
<a id="tools"></a>
### Are there tools to work with the SDT?
You can use the SDTTool to read and convert templates in SDT format to various output formats, e.g. XSD, SVG, markdown, Java code, etc.
......
......@@ -6,19 +6,20 @@
3. [How should SDT work?](#Work)
4. [Related aspects which are out of scope of the SDT](#related)
<a name="Introduction"/></a>
<a id="Introduction"/></a>
## Introduction
The Smart Device Template (SDT) is an initiative from [oneM2M](http://www.onem2m.org) to find consensus amongst various SDOs and industry alliances to derive a common approach for device modeling. oneM2M and partners have the approach to agree on a set of automation functionalities, following a common syntax, which are sufficient to model most device functions.
Originally initiated by the [Home Gateway Initiative (HGI)](http://www.homegatewayinitiative.org), oneM2M is now the owner and maintainer of the SDT.
At the time of writing, every software developed for Internet-of-Things gateways, for example gateways for home automation, needs to be capable of using various different protocols (ZigBee, ZWave, KNX, OPC UA, EchonetLite, DECT ULE, etc) to interact with a range of devices designed for the IoT environment. This adds extreme overheads in integrating, checking and updating code. The purpose of SDT is to describe devices and device services in a way which is independent of the LAN technology and protocols, in a format which is convenient and reliable for integration in modern code (Java, C/C++, Go, Python, ...).
At the time of writing, every software developed for Internet-of-Things gateways and applications, for example gateways for home or building automation, needs to be capable of using various different protocols (ZigBee, ZWave, KNX, OPC UA, EchonetLite, DECT ULE, etc) to interact with a range of devices designed for the IoT environment. This adds extreme overheads in integrating, testing and updating code. The purpose of the SDT is to describe devices and device services in a way which is independent of the LAN technology and protocols, in a format which is convenient and reliable for integration in modern code (C/C++, Go, Java, Javascript, Python, ...).
### Goals
The key goals of the SDT are:
1. keep it simple, especially for manufacturers to contribute device information;
2. modularity for functions and device types;
2. enable and support modularity for functions and device types;
3. make it easy for developers to create unified APIs;
4. be independent of underlying LAN technologies and protocols;
5. enable extendibility of the system in place without service interruption;
......@@ -26,62 +27,66 @@ The key goals of the SDT are:
In general a description of device (or complex appliance) behaviour can be made in many ways, with various kinds of constraints:
1. no constraints (e.g. using OWL 2.0 or even more "flexibly" RDF)
1. no constraints (e.g. using OWL 2.0 or RDF)
2. moderate constraints (e.g. using XML and a related extensible XSD template)
3. strict constraints (typical for a device certified to interoperate with a specific LAN protocol)
oneM2M chose to use the approach "moderate constraints" (XSD based) because for software development it offers ease of use and a good compromise. In particular, if there are few or no constraints on control parameters then few automatic checks can be made to detect if the software parameters are appropriate for each device integrated. XML and XSD languages were chosen because they are familiar to many developers, can be parsed and validated with common software tools, and can still be created and interpreted by humans if necessary. SDT intended use is for modeling, not as a presentation layer protocol, therefore the size of individual templates is not important.
### Guidelines for Structured Information Models
oneM2M believes that Device information models based on XML and extensible XSD need some guidelines. If every possible feature of every existing LAN technology and appliance were allowed to be described in any formally correct way, then the results would be a modern Babel, no better than today's system of widely different and wildly competing automation protocols.
Therefore oneM2M proposes to recommend a certain structure (or template) for the information model(s), but to allow extensions. Naturally, the more industry consensus is achieved for a single recommended template, the greater the utility for software developers (and in the end users and customers).
The SDT approach is to define re-usable basic functions (or services), labelled "ModuleClass" in the figure below, which can represent the typical functions found in many IoT systems, such as "on/off", "dim a lamp", "receive events from sensor", "read data from sensor", etc. Each ModuleClass is composed of a (preferable small) number of actions, datapoint read/write operations, or asynchronous events. For example, an "on/off" ModuleClass would consist perhaps of just one Action, but a "ReadKeypad" Action might have a number of possible events, each with some data value and (usually) a sequence-ID or timestamp start/stop to indicate when and how long each key was pressed.
The SDT approach is to define re-usable basic functions (or services), labelled "[ModuleClass](SDT_Components.md#ModuleClass)" in the figure below, which can represent the typical functions found in many IoT systems, such as "on/off", "dim a lamp", "receive events from sensor", "read data from sensor", etc. Each ModuleClass is composed of a (preferable small) number of actions, datapoint read/write operations, or asynchronous events. For example, an "on/off" ModuleClass would consist perhaps of just one [Action](SDT_Components.md#Action), but a "ReadKeypad" Action might have a number of possible events, each with some data value and (usually) a sequence-ID or timestamp start/stop to indicate when and how long each key was pressed.
![SmartHome Device Template for a generic device (UML, basic entities)](images/SDT_simplified.png)
**SmartHome Device Template for a generic device (UML, basic entities)**
The SDT represents the device models introduced in the above figure by using an XSD schema to allow formal checking of compliance for XML device descriptions of specific appliances. The modularity goal in the schema is achieved with re-usable XML fragments (for example the "ModuleClass" in the figure).
Complex devices or appliances can then be described by an appropriate set or collection of the agreed ModuleClasses, as indicated in the figure, which also shows an optional "Property" fragment to allow noting of static information such as device manufacturer name, device firmware version, etc.
Complex [Devices](SDT_Components.md#Devices), appliances or even [Products](SDT_Components.md#Products) can then be described by an appropriate set or collection of the agreed [ModuleClasses](SDT_Components.md#ModuleClass), as indicated in the figure, which also shows an optional "[Property](SDT_Components.md#Property)" fragment to allow noting of static information such as device manufacturer name, device firmware version, etc.
oneM2M has discussed with many SDOs to validate these concepts. SDT is designed to take into account the list of "services" compiled by the [SAREF project](https://sites.google.com/site/smartappliancesproject/home).
The SDT supports the use of a set of templates for generic devices or appliances (e.g. for a *dimmable lamp*, a basic *washing machine*, etc), which would be specific instances of the "DeviceClass", which form the basis of APIs used by application developers. These templates can also be referenced by manufacturers creating XML documents to describe their specific Products. For example, the SDT enables specification of a generic washing machine template, with *on/off*, *set-wash-temperature*, *pause* and a few other commands, which could be referenced and extended by a manufacturer as the schema for an XML description of a specific washing machine product. The SDT allows for vendor-specific additional commands (ModuleClasses) to suit specific product types.
The SDT supports the use of a set of templates for generic devices or appliances (e.g. for a *dimmable lamp*, a basic *washing machine*, etc), which would be specific instances of the "[DeviceClass](SDT_Components.md#DeviceClass)", which form the basis of APIs used by application developers. These templates can also be referenced by manufacturers creating XML documents to describe their specific Products. For example, the SDT enables specification of a generic washing machine template, with *on/off*, *set-wash-temperature*, *pause* and a few other commands, which could be referenced and extended by a manufacturer as the schema for an XML description of a specific washing machine product. The SDT allows for vendor-specific additional commands (ModuleClasses) to suit specific product types.
The interoperability benefits can potentially partially be obtained even without a fully complete interoperability of the SDT. For example, the most common functions can be modeled with SDT, and more particular functions can be modeled with technology-specific, proprietary, or seldom-used aspects.
Various details about the recommended structure for SDTs are described in the next sections. The key point to keep in mind is that oneM2M sought a compromise between, at the one extreme, complete flexibility (which could describe any device, of any complexity) and, at the other extreme, a rigid structure which could be 100% validated and lead to validated software APIs.
<a name="Definitions"/></a>
<a id="Definitions"/></a>
## Definitions
This section provides an overview about high-level SDT 4.0 definitions and element hierarchy. Terms to be described in detail in this section are:
| Term | Definition |
|------|------------|
|Domain | Unique name, or "wrapper" which acts like a namespace, set by the organization, company, or project creating the template, allowing reference to a package of definitions for the contained ModuleClasses and device definitions. Can be referenced when extending Products, ModuleClasses, and data types. It has two possible uses: to select the scope of a technology domain, or to set the scope of a use case domain (like Home, SmartGrid, etc) |
|ProductClass | A concrete device model with deterministic device Properties and ModuleClasses, without optionality. It is deemed as a specialized implementation of a DeviceClass that can be manufactured. |
|DeviceClass | A physical, addressable, identifiable appliance, sensor, or actuator. |
|Sub-Device | A device (usually one of several) which may be embedded in or attached to a (full) device. It is not designed to be operated as a standalone device. |
| ModuleClass | Specification of a single service with one or more service methods, the involved abstracted data model and related events. The expectation is that each separate service which may be used in many kinds of devices (like *PowerON/OFF*, *Open/Close*, ...) will be described by a ModuleClass which can be re-used in many *DeviceClass* or *ProductClass* definitions. |
|[Domain](SDT_Components.md#Domain) | Unique name, or "wrapper" which acts like a namespace, set by the organization, company, or project creating the template, allowing reference to a package of definitions for the contained ModuleClasses and device definitions. Can be referenced when extending Products, ModuleClasses, and data types. It has two possible uses: to select the scope of a technology domain, or to set the scope of a use case domain (like Home, SmartGrid, etc) |
|[ProductClass](SDT_Components.md#ProductClass) | A concrete device model with deterministic device Properties and ModuleClasses, without optionality. It is deemed as a specialized implementation of a DeviceClass that can be manufactured. |
|[DeviceClass](SDT_Components.md#DeviceClass) | A physical, addressable, identifiable appliance, sensor, or actuator. |
|[Sub-Device](SDT_Components.md#SubDevice) | A device (usually one of several) which may be embedded in or attached to a (full) device. It is not designed to be operated as a standalone device. |
| [ModuleClass](SDT_Components.md#ModuleClass) | Specification of a single service with one or more service methods, the involved abstracted data model and related events. The expectation is that each separate service which may be used in many kinds of devices (like *PowerON/OFF*, *Open/Close*, ...) will be described by a ModuleClass which can be re-used in many *DeviceClass* or *ProductClass* definitions. |
A major decision, facilitating validation of code and signaling, was to describe services (functionality) of devices in terms of [ModuleClasses](SDT_Components.md#ModuleClass) made up of combinations of three kinds of elements:
A major decision, facilitating validation of code and signaling, was to describe services (functionality) of devices in terms of ModuleClasses made up of combinations of three kinds of elements:
1. [DataPoints](SDT_Components.md#DataPoint) which are aspects of a functionality that can be read and/or written,
2. [Actions](SDT_Components.md#Action) which consist of more complex sequences of operations;
3. [Events](SDT_Components.md#Event) which can be signaled ("published") by devices asynchronously.
1. DataPoints which are aspects of a functionality that can be read and/or written,
2. Actions which consist of more complex sequences of operations;
3. Events which can be signaled ("published") by devices asynchronously.
Any of these elements is optional.
The ModuleClass structure is a major part of the SDT which is illustrated in detail in the following figure:
This [ModuleClass](SDT_Components.md#ModuleClass) structure is a major part of the SDT which is illustrated in detail in the following figure:
![UML description of device functionality in terms of DataPoints, Actions, and Events](images/MC.Action.DataPoint.Event.png)
**UML description of device functionality in terms of DataPoints, Actions, and Events**
<a name="Work"/></a>
<a id="Work"/></a>
## How should SDT work?
The basic concept is that a manufacturer, organisation or global SDO would define its preferred Smart Device Template, in XML, specified by and based on an XSD. Using that XSD, manufacturers or indeed hobbyists could "describe" existing or new devices by means of XML files, specifying the capabilities and the parameters needed to control the devices.
The basic concept is that a manufacturer, organisation, service provider or global SDO would define its preferred Smart Device Template, in XML, specified by and based on an XSD. Using that XSD, manufacturers or indeed hobbyists could "describe" existing or new devices by means of XML files, specifying the capabilities and the parameters needed to control the devices.
Assuming that the XML files conform to the specified XSD and to some guidelines described in this document, software developers could readily create APIs able to "parse" the XML-descriptions of devices and (assuming the underlying LAN technology of the device is supported by the software/hardware environment in the gateway) operate the equipment.
......@@ -89,12 +94,12 @@ The key to making software reliably interoperate with various technologies is to
For the convenience of users and developers, it would also be possible to collect the device descriptions of common "modules" (types of) appliances so that the operations of "a generic air-conditioner" could be agreed and re-used often, adapting descriptions of special models with just some special features added as local extensions. Agreeing on the definition of "a generic XYZ appliance" is rather time-consuming, so such "repository" may not become standardised, however the basic approach has huge benefits even if such an archive (also known as a "hierarchical ontology") is never formally agreed.
<a name="related"/></a>
<a id="related"/></a>
## Related aspects which are out of scope of the SDT
The SDT defines the structure of all compliant XML descriptions. Each XML description of a specific device is definable at the time of manufacture of the device and can therefore only contain "static" information: (a) manufacturer data in the form of documentation elements and properties, and (b) device capability information detailing the firmware operations and types/meanings of input/output variables.
NOT directly part of this work is a related but separate aspect of every gateway software development: a "device abstraction layer" which can translate between (a) software APIs written based on a particular SDT and (b) the "commands" expected by several different LAN protocols and their hardware controllers.
NOT directly part of this work is a related but separate aspect of every (gateway) software development: a "device abstraction layer" (or "service layer") which can translate between (a) software APIs written based on a particular SDT and (b) the "commands" expected by several different LAN protocols and their hardware controllers.
Programmers developing a "device abstraction layer" for software in a gateway need to create run-time representations of all the recognized devices, their operations and their actual states. This internal "information model" needs to be updated in real time as the devices and the users interact. Programmers may be tempted to use the SDT structure to organize their real-time information model, adding additional information elements for the current state of each device, for some kind of "history" of commands sent/acknowledged, the user etc.
......
......@@ -3,9 +3,6 @@
## Smart Device Template
- **SDT Repository** : [https://git.onem2m.org/MAS/SDT](https://git.onem2m.org/MAS/SDT)
## Further Information
- **TR-0039 Introduction to IPE and SDT** : [http://www.onem2m.org/tr-0039/ipe-and-sdt](http://www.onem2m.org/tr-0039/ipe-and-sdt)
- **The oneM2M Smart Device Template (SDT)** (BrightTALK) : [https://www.brighttalk.com/webcast/11949/340004/the-onem2m-smart-device-template-sdt](https://www.brighttalk.com/webcast/11949/340004/the-onem2m-smart-device-template-sdt)
......
......@@ -7,7 +7,7 @@ The following third-party libraries and components are used in the build system
3. [antSetLogLevel.JAR](#antSetLogLevel)
<a name="trang"/></a>
<a id="trang"/></a>
## trang.jar
[https://relaxng.org/jclark/trang.html](https://relaxng.org/jclark/trang.html)
......@@ -53,7 +53,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<a name="antcontrib"/></a>
<a id="antcontrib"/></a>
## Ant-Contrib Tasks
[http://ant-contrib.sourceforge.net](http://ant-contrib.sourceforge.net)
......@@ -64,7 +64,7 @@ The *Ant-Contrib* project is a collection of tasks (and at one point maybe types
This Software is distributed under the Apache Software License.
<a name="antSetLogLevel"/></a>
<a id="antSetLogLevel"/></a>
## antSetLogLevel.jar
GUI dialog for Ant tasks.
......
# SDT Build System
This document describes the SDT build system and how to build the SDT and validate new templates and contributions.
This document describes the SDT build system and how to build the SDT schema and validate new templates and contributions.
The files referenced in this document point to version **4.0** of the SDT.
......@@ -11,12 +11,13 @@ The files referenced in this document point to version **4.0** of the SDT.
2. [Validating SDT Templates](#BuildingValidate)
4. [Editing the Schema](#Editing)
<a name="Structure"/></a>
<a id="Structure"/></a>
## Directory Structure and Important Files
- [SDT/schema4.0/](../..) : Base directory
- [SDT/schema4.0/src/](../src/) : Source files of the SDT.
- [domain.rng](../src/domain.rng) : RELAX NG file with the SDT schema definition. This is the source file that is converted to the actual schema definition *domain.xsd* during the build. See also [http://en.wikipedia.org/wiki/RELAX_NG](http://en.wikipedia.org/wiki/RELAX_NG).
**Only edit this file when you want to make changes to the SDT!** See also [Editing the Schema](#Editing) below.
**Only edit this file when you want to make changes to the SDT! Changes to XSD file will be overwritten the next time you run the *ant* command.**
See also [Editing the Schema](#Editing) below.
- [domain.xsd](../src/domain.xsd) : The actual SDT schema definition that is generated from *domain.rng*.
- [xml.xsd](../src/xml.xsd) : General schema definitions for the SDT
- [SDT/schema4.0/test/](../test/) : This directory contains XML files with SDT definitions that should be validated whether they conform to the SDT schema.
......@@ -29,7 +30,7 @@ This could be example definitions or new templates and contributions. If you wan
- [SDT/schema4.0/etc/schema.xmlns](../etc/schema.xmlns) : This file defines the target namespace for the schema.
- [SDT/schema4.0/lib/](../lib/) : Tasks for the ant-based build system. See also [SDT Build System Components and Licenses](SDT%20Build%20System%20Components%20and%20Licenses.md).
<a name="Installation"/></a>
<a id="Installation"/></a>
## Installation
### Prerequisites
......@@ -41,18 +42,18 @@ This could be example definitions or new templates and contributions. If you wan
$ git clone https://git.onem2m.org/MAS/SDT.git
<a name="Building"/></a>
<a id="Building"/></a>
## How to Use the Build System
After cloning the repository go to the directory *SDT/schema4.0* and run commands depending on what you want to achieve.
<a name="BuildingSchema"/></a>
<a id="BuildingSchema"/></a>
### Building the Schema
Running *ant* without any parameter builds the schema definition from the rng-definition [SDT/schema4.0/src/domain.rng](../src/domain.rng) and writes it to [SDT/schema4.0/src/domain.xsd](../src/domain.xsd)
$ cd SDT/schema4.0
$ ant
<a name="BuildingValidate"/></a>
<a id="BuildingValidate"/></a>
### Validating SDT Templates
You can use the build system to validate new SDT definitions or changes made to existing ones by running the following command:
......@@ -65,12 +66,12 @@ The output after a successful validation should look similar this:
>BUILD SUCCESSFUL
>Total time: 1 second
Otherwise you most likely receive a stack trace or some other error messages. Search the output for the line *BUILD FAILED*. Above this line you will find some helpful hints for the filename and line number on which the error occurred (here: file *mseeb.xml* on line 66) and a reason:
Otherwise you most likely receive a stack trace and some other error messages. Search the output for the line *BUILD FAILED*. Above this line you will find some helpful hints for the filename and line number on which the error occurred (here: file *mseeb.xml* on line 66) and a reason:
>[schemavalidate] /Users/someone/Sources/git/SmartDeviceTemplate/SDT/schema/test/mseeb.xml:66:18: cvc-elt.1: Cannot find the declaration of element 'Domain'.
>BUILD FAILED
<a name="Editing"/></a>
<a id="Editing"/></a>
## Editing the Schema
As mentioned above, the actual schema definition is defined in the file [src/domain.rng](../src/domain.rng) and converted to the XML schema definition [src/domain.xsd](../src/domain.xsd) during the build process.
......
This diff is collapsed.
......@@ -17,10 +17,10 @@
<a name="introduction"/></a>
<a id="introduction"/></a>
## Introduction
When SDT was introduced, XML was the favorite encoding format for schemas. Since then, JSON became more popular in the developers' communities, especially in the context of RESTful implementation.
When the Smart Device Template was introduced, XML was the favorite encoding format for schemas. Since then, JSON became more popular in developers' communities, especially in the context of RESTful implementations.
JSON is more concise and human-readable comparing to XML, but has less capability of formal schema definition and validation (such as the XML Schema as defined in [domain.xsd](../src/domain.xsd)).
......@@ -30,44 +30,46 @@ There are some open tools such as [JSON Schema](http://json-schema.org/) that mi
In this release, we chose to define the JSON serialization by the documentation below, while borrowing some valuable aspects from JSON Schema (e.g. data types and validation keywords). Full endorsement of [JSON Schema](http://json-schema.org/) may be considered in the future.
The general JSON structure follows the general SDT structure presented in [SDT_UML.md](SDT_UML.md) and described in [SDT_Components.md](SDT_Components.md).
The general JSON structure follows the general SDT structure presented in [SDT_UML.uxf](SDT_UML.uxf) and described in [SDT_Components.md](SDT_Components.md).
<a name="mappings"/></a>
<a id="mappings"/></a>
## SDT mapping to JSON
<a name="elements"/></a>
<a id="elements"/></a>
### Elements mapping
| SDT XML Elements | JSON Key Words | Remark |
|------------------|----------------|--------|
|Action | Action | |
|Actions | Actions | This element is an array of *Action* structures. |
|Arg | Arg | |
|Args | Args | This element is an array of *Arg* structures. |
|Constraint | Constraint | |
|Constraints | Constraints | This element is an array of *Constraint* structures. |
|Data | Data | This element is an array of *DataPoint* structures. |
|DataPoint | DataPoint | |
|DataType | DataType | |
|DataTypes | DataTypes | This element is an array of *DataType* structures. |
|DeviceClass | DeviceClass | |
|DeviceClasses | DeviceClasses | This element is an array of *DeviceClass* structures. |
|Doc |Doc | |
|Domain | Domain | |
|Event | Event | |
|Events | Events | This element is an array of *Event* structures. |
|Exclude | Exclude | |
|Extend | Extend | |
|Imports |Imports| This element is an array of *Include* structures. |
|Include | Include | |
|ModuleClass | ModuleClass | |
|ModuleClasses | ModuleClasses | This element is an array of *ModuleClass* structures. |
|ProductClass | ProductClass | |
|ProductClasses | ProductClasses | This element is an array of *ProductClasses* structures. |
|Properties | Properties | This element is an array of *Property* structures. |
|Property | Property | |
|SubDevice | SubDevice | |
|SubDevices | SubDevices | This element is an array of *SubDevice* structures. |
| SDT XML Elements | JSON Key Words | Remark |
|:-----------------------------------------------|:---------------|:----------------------------------------------------------|
| [Action](SDT_Components.md#Action) | Action | |
| Actions | Actions | This element is an array of *Action* structures. |
| [Arg](SDT_Components.md#Arg) | Arg | |
| Args | Args | This element is an array of *Arg* structures. |
| Constraint | Constraint | |
| Constraints | Constraints | This element is an array of *Constraint* structures. |
| Data | Data | This element is an array of *DataPoint* structures. |
| [DataPoint](SDT_Components.md#DataPoint) | DataPoint | |
| [DataType](SDT_Components.md#DataType) | DataType | |
| [DataTypes](SDT_Components.md#DataTypes) | DataTypes | This element is an array of *DataType* structures. |
| [DeviceClass](SDT_Components.md#DeviceClass) | DeviceClass | |
| DeviceClasses | DeviceClasses | This element is an array of *DeviceClass* structures. |
| [Doc](SDT_Components.md#Documentation) | Doc | |
| [Domain](SDT_Components.md#Domain) | Domain | |
| [Event](SDT_Components.md#Event) | Event | |
| Events | Events | This element is an array of *Event* structures. |
| Exclude | Exclude | |
| Excludes | Excludes | This element is an array of *Exclude* structures. |
| [Extend](SDT_Components.md#Extending) | Extend | |
| Imports | Imports | This is an array of URLs or file URLs to files to import. |
| Include | Include | |
| Includes | Includes | This element is an array of *Include* structures. |
| [ModuleClass](SDT_Components.md#ModuleClass) | ModuleClass | |
| ModuleClasses | ModuleClasses | This element is an array of *ModuleClass* structures. |
| [ProductClass](SDT_Components.md#ProductClass) | ProductClass | |
| ProductClasses | ProductClasses | This element is an array of *ProductClasses* structures. |
| Properties | Properties | This element is an array of *Property* structures. |
| [Property](SDT_Components.md#Property) | Property | |
| [SubDevice](SDT_Components.md#SubDevice) | SubDevice | |
| SubDevices | SubDevices | This element is an array of *SubDevice* structures. |
#### Example
......@@ -132,33 +134,36 @@ The following example defines a simple *Light* device.
}
```
<a name="attributes"/></a>
<a id="attributes"/></a>
### Attributes mapping
There are common attributes (e.g. *@id, @name, @optional*) used in several SDT components (e.g. in *DeviceClass, ModuleClass*) as well as attributes used only in certain components (e.g. *@entity* in *Extend*). The mapping of those attributes to JSON follows the rules as below.
There are common attributes (e.g. *@id, @name, @optional*) used in several SDT components (e.g. in *DeviceClass, ModuleClass*) as well as attributes used only in certain components (e.g. *@entity* in *Extend*). XML attributes are represented as normal fields in JSON. The mapping of those attributes to JSON follows the rules as below.
| SDT XML Attributes | JSON Key Word |
|----------------|-------------|
|@default | default |
|@domain |domain |
|@entity |entity |
|@eventable | eventable|
|@href | href |
|@id |id |
|@name |name |
|@optional | optional|
|@parse | parse |
|@readable | readable|
|@semanticURI | semanticURI |
|@value |value |
|@writable | writable|
|@type | type |
|@unitOfMeasure | unitOfMeasure |
<a name="imports"/></a>
|:-------------------|:--------------|
| @default | default |
| @domain | domain |
| @entity | entity |
| @eventable | eventable |
| @href | href |
| @id | id |
| @maxOccurs | maxOccurs |
| @minOccurs | minOccurs |
| @name | name |
| @optional | optional |
| @parse | parse |
| @readable | readable |
| @semanticURI | semanticURI |
| @type | type |
| @unitOfMeasure | unitOfMeasure |
| @value | value |
| @writable | writable |
<a id="imports"/></a>
### Import mapping
The imports are mapped to an array of *Include* structures. Each *Include* structure contains a *href* and a *parse* element.
The imports are mapped to an array of *Include* structures. Each *Include* structure contains a *href* and a *parse* element.
A parser must make sure to import and regard the definitions in the referenced files.
#### Example
......@@ -178,46 +183,47 @@ The imports are mapped to an array of *Include* structures. Each *Include* struc
{ "Include" : { "href" : "anotherSDT.xml", "parse" : "json" } }
]
```
<a name="ExtendType"/></a>
<a id="ExtendType"/></a>
### ExtendType mapping
In the *Include* and *Exclude* elements one may specify the type of the element to be included or excluded. The following table shows the mapping of *ExtendType*.
In the *Include* and *Exclude* elements one may specify the type of the element to be included or excluded. The following table shows the mapping of [ExtendType](SDT_Components.md#ExtendType).
| SDT ExtendType | JSON Key Word |
|----------------|---------------|
|action | action |
|datapoint | datapoint |
|event | event |
|moduleclass | moduleclass |
|property | property |
|device | device |
|subdevice |subdevice |
|:---------------|:--------------|
| action | action |
| datapoint | datapoint |
| event | event |
| moduleclass | moduleclass |
| property | property |
| device | device |
| subdevice | subdevice |
<a name="dataTypes"/></a>
<a id="dataTypes"/></a>
### Data Type mapping
Data types are defined in [SDT_Components.md](SDT_Components.md).
The mapping of the different kind of data types to JSON happens directly to JSON structures. The identifier for the data type kind is the name of that structure. This means that the data type definition is not wrapped by a *DataType* structure.