Skip to content

Commit b79a6db

Browse files
authored
Docs (#28)
1 parent 1abf4b5 commit b79a6db

File tree

165 files changed

+746
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+746
-721
lines changed

docs/DeveloperGuide.md

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,40 @@ Key objectives of this SDK:
3535
These are the major steps you'll take when creating a link:
3636

3737
1. Copy example link.
38-
2. Create nodes.
38+
2. Create application nodes.
3939

4040
## Copy Example Link
4141

4242
Copy the
4343
[dslink-java-v2-example](https://github.com/iot-dsa-v2/dslink-java-v2-example)
4444
project to create a new repository. It's README provides
45-
further instructions for customization.
45+
detailed instructions for customization.
4646

4747
The example link is a very simple but fully functioning link with a single root node. It is
4848
recommended you get that running within a broker before continuing with this documentation.
4949

50-
## Create Nodes
50+
## Create Application Nodes
5151

5252
Nodes are where application specific logic is bound to the link architecture. Node developers
5353
will use various lifecycle callbacks to trigger their logic.
5454

55-
First you must create a root node. It is the hook for the rest of your functionality. The
56-
convention is to name it MainNode, but make sure it is in a unique package so that multiple links
55+
First you must create a root application node. It is the hook for the rest of your functionality.
56+
The convention is to name it MainNode, but make sure it is in a unique package so that multiple links
5757
can be run in the same process.
5858

5959
Then you will probably create additional nodes that will be descendants in the tree rooted by your
60-
root node.
60+
main node.
6161

6262
### Main Node
6363

64-
All links require a single root node and it must subclass
64+
All links require a single root data node and it must subclass
6565
[org.iot.dsa.dslink.DSMainNode](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/dslink/DSMainNode.html).
6666
The convention is to name the class MainNode but the package must be unique from any other
67-
MainNodes so that multiple links can be run in the same process.
67+
MainNodes (other links) so that multiple links can be run in the same process.
6868

69-
When a link launches the first time, the type of the root node is looked up **dslink.json**.
70-
The config _mainType_ must store the fully qualified class name of the root node. After the first
71-
launch, the configuration database is serialized and the _mainType_ config will longer have an
69+
When a link launches the first time, the type of the main node is looked up **dslink.json**.
70+
The config _handler_class_ must store the fully qualified class name of the root node. After the first
71+
launch, the configuration database is serialized and the _handler_class_ config will longer have an
7272
impact.
7373

7474
### Additional Nodes
@@ -89,8 +89,11 @@ instantiated when deserializing the configuration database.
8989

9090
### Defaults
9191

92-
Every subtype of DSNode has a private default instance, all other instances are copies of the
93-
default instance. This is why you should never perform application logic unless
92+
Every subclass of DSNode has a private default instance, all other instances are copies of the
93+
default instance. It is an instanced based inheritance scheme that will allow subtypes to remove or
94+
reorder 'fields' declared in super classes.
95+
96+
Since there is a default instance in memory, You should never perform application logic unless
9497
triggered by a callback and your node is running (started or stable).
9598

9699
If a DSNode subtype needs to have specific child nodes or values (most will), it should override
@@ -138,7 +141,7 @@ When a link is stopped, an attempt to stop the tree will be made, but it cannot
138141

139142
**Started**
140143

141-
After the node tree is fully deserialized it will be started. A nodes onStart method will be
144+
After the node tree is fully deserialized it will be started. A node's onStart method will be
142145
called after all of its child nodes have been started. The only guarantee is that all child
143146
nodes have been started.
144147

@@ -147,15 +150,15 @@ Nodes will also started when they are added to an already running parent node.
147150
**Stable**
148151

149152
Stable is called after the entire tree has been started. The first time the node tree is loaded,
150-
there is a stable delay of 5 seconds. This is configurable as **stableDelay** in _dslink.json_.
153+
there is a stable delay of 5 seconds.
151154

152155
Nodes added to an already stable parent will have onStart and onStable called immediately.
153156

154157
When in doubt of whether to use onStarted or onStable, use onStable.
155158

156-
**Other Callbacks**
159+
**Callbacks**
157160

158-
When a node is stable, there are several other callbacks for various state changes. All callbacks
161+
When a node is stable, there are several callbacks for various state changes. All callbacks
159162
begin with **on** such as _onChildAdded()_. See the
160163
[DSNode Javadoc](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/node/DSNode.html)
161164
for a complete list.
@@ -178,10 +181,11 @@ there are multiple subscribers, this is only called when the last one unsubscrib
178181
Values mostly represent leaf members of the node tree. There are two types of values:
179182

180183
1. [org.io.dsa.node.DSElement](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/node/DSElement.html) -
181-
These map to the JSON type system and represent leaf members of the node tree.
184+
These are the primitives that mostly map to the JSON type system and will be leaf members of the tree.
182185
2. [org.io.dsa.node.DSIValue](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/node/DSIValue.html) -
183-
These don't have to map to the JSON type system, and it is possible for nodes to implement this
184-
interface. This allows for values with children.
186+
These have to be able to convert to DSElements, but they carry additional meaning such as timestamp.
187+
Nodes can implement this to have both a value and children. DSValueNode is a convenience abstract
188+
class for this purpose.
185189

186190
The node model encourages values to be immutable and singletons. This is for efficiency, the same
187191
value instance (e.g. DSBoolean.TRUE) can be stored in many nodes.
@@ -192,7 +196,7 @@ a value.
192196

193197
### Actions
194198

195-
Actions allow allow responders to expose functionality that can't be modeled as values.
199+
Actions allow allow responders to expose functionality in DSA that can't be modeled as values.
196200

197201
Add actions to your node using
198202
[org.iot.dsa.node.action.DSAction](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/node/action/DSAction.html).
@@ -222,6 +226,9 @@ Override DSNode.onInvoke to handle invocations.
222226
}
223227
```
224228

229+
DSAction can be subclassed. Actions should also be singleton instances for efficiency. For
230+
parameter-less actions that have no return value, use the DSAction.DEFAULT instance.
231+
225232
### DSInfo
226233

227234
All node children have corresponding DSInfo instances. This type serves serves two purposes:
@@ -287,18 +294,22 @@ To simplify configuring metadata, use the utility class
287294

288295
Use [org.iot.dsa.DSRuntime](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/DSRuntime.html).
289296

290-
Create your own threads for long lived activities and make them daemon as well.
297+
Please avoid using Java executors if possible. In the future we will probably monitor DSRuntime
298+
to help determine when a system is becoming overloaded.
299+
300+
Creating your own threads for long lived activities is perfectly acceptable but not necessary.
291301

292302
## Logging
293303

294304
Use Java Util Logging (JUL). A high performance async logger is automatically installed as the
295-
root logger and it also manages backups.
305+
root logger.
296306

297307
Most types subclass
298308
[org.iot.dsa.logging.DSLogger](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/logging/DSLogger.html)
299309
as a convenience.
300310

301-
Without DSLogger:
311+
The most efficient logging will not submit a log message if the level isn't enabled. This is
312+
how it is normally achieved with JUL:
302313

303314
```java
304315
if (myLogger.isLoggable(Level.FINE)) {
@@ -307,20 +318,26 @@ Without DSLogger:
307318
```
308319

309320

310-
With DSLogger
321+
DSLogger enables the same but with more concise syntax:
311322

312323
```java
313324
fine(fine() ? someMessage() : null);
314325
```
315326

316327

328+
DSA has it's own log levels (there can be links in many different languages). All standard
329+
Java log level are mapped into it, but try to use the DSA levels:
330+
317331
<b>Level Guidelines</b>
318332

319-
- finest = verbose or trace
320-
- finer = debug
321-
- fine = minor and/or frequent event
322-
- config = configuration info
323-
- info = major and infrequent event
324-
- warn = unusual and infrequent, not critical
325-
- severe = critical / fatal error or event
333+
DSA Level = Java Level
334+
335+
- trace = Level.FINEST;
336+
- debug = Level.FINER;
337+
- fine = Level.FINE;
338+
- warn = custom
339+
- info = Level.INFO;
340+
- error = Level.WARNING;
341+
- admin = custom
342+
- fatal = Level.SEVERE;
326343

docs/javadoc/allclasses-frame.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_40) on Mon Mar 05 09:54:10 PST 2018 -->
6-
<title>All Classes (dslink-core 0.19.0 API)</title>
7-
<meta name="date" content="2018-03-05">
5+
<!-- Generated by javadoc (1.8.0_40) on Wed Mar 21 10:34:28 PDT 2018 -->
6+
<title>All Classes (dslink-core 0.20.0 API)</title>
7+
<meta name="date" content="2018-03-21">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

docs/javadoc/allclasses-noframe.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_40) on Mon Mar 05 09:54:10 PST 2018 -->
6-
<title>All Classes (dslink-core 0.19.0 API)</title>
7-
<meta name="date" content="2018-03-05">
5+
<!-- Generated by javadoc (1.8.0_40) on Wed Mar 21 10:34:28 PDT 2018 -->
6+
<title>All Classes (dslink-core 0.20.0 API)</title>
7+
<meta name="date" content="2018-03-21">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

docs/javadoc/constant-values.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_40) on Mon Mar 05 09:54:10 PST 2018 -->
6-
<title>Constant Field Values (dslink-core 0.19.0 API)</title>
7-
<meta name="date" content="2018-03-05">
5+
<!-- Generated by javadoc (1.8.0_40) on Wed Mar 21 10:34:27 PDT 2018 -->
6+
<title>Constant Field Values (dslink-core 0.20.0 API)</title>
7+
<meta name="date" content="2018-03-21">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>
1111
<body>
1212
<script type="text/javascript"><!--
1313
try {
1414
if (location.href.indexOf('is-external=true') == -1) {
15-
parent.document.title="Constant Field Values (dslink-core 0.19.0 API)";
15+
parent.document.title="Constant Field Values (dslink-core 0.20.0 API)";
1616
}
1717
}
1818
catch(err) {
@@ -290,91 +290,91 @@ <h2 title="org.iot">org.iot.*</h2>
290290
<!-- -->
291291
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
292292
<td><code><a href="org/iot/dsa/node/DSMetadata.html#BOOLEAN_RANGE">BOOLEAN_RANGE</a></code></td>
293-
<td class="colLast"><code>"booleanRange"</code></td>
293+
<td class="colLast"><code>"$booleanRange"</code></td>
294294
</tr>
295295
<tr class="rowColor">
296296
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.DECIMAL_PLACES">
297297
<!-- -->
298298
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
299299
<td><code><a href="org/iot/dsa/node/DSMetadata.html#DECIMAL_PLACES">DECIMAL_PLACES</a></code></td>
300-
<td class="colLast"><code>"decimalPlaces"</code></td>
300+
<td class="colLast"><code>"$decimalPlaces"</code></td>
301301
</tr>
302302
<tr class="altColor">
303303
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.DEFAULT">
304304
<!-- -->
305305
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
306306
<td><code><a href="org/iot/dsa/node/DSMetadata.html#DEFAULT">DEFAULT</a></code></td>
307-
<td class="colLast"><code>"default"</code></td>
307+
<td class="colLast"><code>"$default"</code></td>
308308
</tr>
309309
<tr class="rowColor">
310310
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.DESCRIPTION">
311311
<!-- -->
312312
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
313313
<td><code><a href="org/iot/dsa/node/DSMetadata.html#DESCRIPTION">DESCRIPTION</a></code></td>
314-
<td class="colLast"><code>"description"</code></td>
314+
<td class="colLast"><code>"$description"</code></td>
315315
</tr>
316316
<tr class="altColor">
317317
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.DISPLAY_NAME">
318318
<!-- -->
319319
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
320320
<td><code><a href="org/iot/dsa/node/DSMetadata.html#DISPLAY_NAME">DISPLAY_NAME</a></code></td>
321-
<td class="colLast"><code>"displayName"</code></td>
321+
<td class="colLast"><code>"$displayName"</code></td>
322322
</tr>
323323
<tr class="rowColor">
324324
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.EDITOR">
325325
<!-- -->
326326
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
327327
<td><code><a href="org/iot/dsa/node/DSMetadata.html#EDITOR">EDITOR</a></code></td>
328-
<td class="colLast"><code>"editor"</code></td>
328+
<td class="colLast"><code>"$editor"</code></td>
329329
</tr>
330330
<tr class="altColor">
331331
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.ENUM_RANGE">
332332
<!-- -->
333333
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
334334
<td><code><a href="org/iot/dsa/node/DSMetadata.html#ENUM_RANGE">ENUM_RANGE</a></code></td>
335-
<td class="colLast"><code>"enumRange"</code></td>
335+
<td class="colLast"><code>"$enumRange"</code></td>
336336
</tr>
337337
<tr class="rowColor">
338338
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.MAX_VALUE">
339339
<!-- -->
340340
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
341341
<td><code><a href="org/iot/dsa/node/DSMetadata.html#MAX_VALUE">MAX_VALUE</a></code></td>
342-
<td class="colLast"><code>"maxValue"</code></td>
342+
<td class="colLast"><code>"$maxValue"</code></td>
343343
</tr>
344344
<tr class="altColor">
345345
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.MIN_VALUE">
346346
<!-- -->
347347
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
348348
<td><code><a href="org/iot/dsa/node/DSMetadata.html#MIN_VALUE">MIN_VALUE</a></code></td>
349-
<td class="colLast"><code>"minValue"</code></td>
349+
<td class="colLast"><code>"$minValue"</code></td>
350350
</tr>
351351
<tr class="rowColor">
352352
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.NAME">
353353
<!-- -->
354354
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
355355
<td><code><a href="org/iot/dsa/node/DSMetadata.html#NAME">NAME</a></code></td>
356-
<td class="colLast"><code>"name"</code></td>
356+
<td class="colLast"><code>"$name"</code></td>
357357
</tr>
358358
<tr class="altColor">
359359
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.PLACEHOLDER">
360360
<!-- -->
361361
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
362362
<td><code><a href="org/iot/dsa/node/DSMetadata.html#PLACEHOLDER">PLACEHOLDER</a></code></td>
363-
<td class="colLast"><code>"placeholder"</code></td>
363+
<td class="colLast"><code>"$placeholder"</code></td>
364364
</tr>
365365
<tr class="rowColor">
366366
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.TYPE">
367367
<!-- -->
368368
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
369369
<td><code><a href="org/iot/dsa/node/DSMetadata.html#TYPE">TYPE</a></code></td>
370-
<td class="colLast"><code>"type"</code></td>
370+
<td class="colLast"><code>"$type"</code></td>
371371
</tr>
372372
<tr class="altColor">
373373
<td class="colFirst"><a name="org.iot.dsa.node.DSMetadata.UNIT">
374374
<!-- -->
375375
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
376376
<td><code><a href="org/iot/dsa/node/DSMetadata.html#UNIT">UNIT</a></code></td>
377-
<td class="colLast"><code>"unit"</code></td>
377+
<td class="colLast"><code>"$unit"</code></td>
378378
</tr>
379379
</tbody>
380380
</table>

docs/javadoc/deprecated-list.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_40) on Mon Mar 05 09:54:10 PST 2018 -->
6-
<title>Deprecated List (dslink-core 0.19.0 API)</title>
7-
<meta name="date" content="2018-03-05">
5+
<!-- Generated by javadoc (1.8.0_40) on Wed Mar 21 10:34:28 PDT 2018 -->
6+
<title>Deprecated List (dslink-core 0.20.0 API)</title>
7+
<meta name="date" content="2018-03-21">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>
1111
<body>
1212
<script type="text/javascript"><!--
1313
try {
1414
if (location.href.indexOf('is-external=true') == -1) {
15-
parent.document.title="Deprecated List (dslink-core 0.19.0 API)";
15+
parent.document.title="Deprecated List (dslink-core 0.20.0 API)";
1616
}
1717
}
1818
catch(err) {

docs/javadoc/help-doc.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_40) on Mon Mar 05 09:54:10 PST 2018 -->
6-
<title>API Help (dslink-core 0.19.0 API)</title>
7-
<meta name="date" content="2018-03-05">
5+
<!-- Generated by javadoc (1.8.0_40) on Wed Mar 21 10:34:28 PDT 2018 -->
6+
<title>API Help (dslink-core 0.20.0 API)</title>
7+
<meta name="date" content="2018-03-21">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>
1111
<body>
1212
<script type="text/javascript"><!--
1313
try {
1414
if (location.href.indexOf('is-external=true') == -1) {
15-
parent.document.title="API Help (dslink-core 0.19.0 API)";
15+
parent.document.title="API Help (dslink-core 0.20.0 API)";
1616
}
1717
}
1818
catch(err) {

0 commit comments

Comments
 (0)