You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dj...@apache.org on 2016/03/08 19:18:27 UTC

[6/7] incubator-quarks git commit: Cleanup for IotDevice

Cleanup for IotDevice


Project: http://git-wip-us.apache.org/repos/asf/incubator-quarks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quarks/commit/25136d81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quarks/tree/25136d81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quarks/diff/25136d81

Branch: refs/heads/quarks-4
Commit: 25136d81c3fef04c98dc61a85d9702d05fe66184
Parents: 23379c5
Author: Dan Debrunner <dj...@apache.org>
Authored: Tue Mar 8 10:07:21 2016 -0800
Committer: Dan Debrunner <dj...@apache.org>
Committed: Tue Mar 8 10:07:21 2016 -0800

----------------------------------------------------------------------
 .../java/quarks/connectors/iot/IotDevice.java   | 52 +++++++++++++++++---
 .../quarks/connectors/iot/package-info.java     |  8 ++-
 2 files changed, 52 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/25136d81/connectors/iot/src/main/java/quarks/connectors/iot/IotDevice.java
----------------------------------------------------------------------
diff --git a/connectors/iot/src/main/java/quarks/connectors/iot/IotDevice.java b/connectors/iot/src/main/java/quarks/connectors/iot/IotDevice.java
index c98673a..70d0664 100644
--- a/connectors/iot/src/main/java/quarks/connectors/iot/IotDevice.java
+++ b/connectors/iot/src/main/java/quarks/connectors/iot/IotDevice.java
@@ -17,6 +17,11 @@ import quarks.topology.TopologyElement;
  * Generic Internet of Things device connector.
  */
 public interface IotDevice extends TopologyElement {
+    
+    /**
+     * Device event and command identifiers starting with {@value} are reserved for use by Quarks.
+     */
+    String RESERVED_ID_PREFIX = "quarks";
 
     /**
      * Publish a stream's tuples as device events.
@@ -35,7 +40,7 @@ public interface IotDevice extends TopologyElement {
      *            function to supply the event's delivery Quality of Service.
      * @return TSink sink element representing termination of this stream.
      */
-    public TSink<JsonObject> events(TStream<JsonObject> stream, Function<JsonObject, String> eventId,
+    TSink<JsonObject> events(TStream<JsonObject> stream, Function<JsonObject, String> eventId,
             UnaryOperator<JsonObject> payload,
             Function<JsonObject, Integer> qos) ;
     
@@ -53,17 +58,50 @@ public interface IotDevice extends TopologyElement {
      *            Event's delivery Quality of Service.
      * @return TSink sink element representing termination of this stream.
      */
-    public TSink<JsonObject> events(TStream<JsonObject> stream, String eventId, int qos) ;
+    TSink<JsonObject> events(TStream<JsonObject> stream, String eventId, int qos) ;
+    
+    /**
+     * Command identifier key.
+     * Key is {@value}.
+     * 
+     * @see #commands(String...)
+     */
+    String CMD_ID = "command";
+    
+    /**
+     * Command timestamp (in milliseconds) key.
+     * Key is {@value}.
+     * 
+     * @see #commands(String...)
+     */
+    String CMD_TS = "tsms";
+    /**
+     * Command format key.
+     * Key is {@value}.
+     * 
+     * @see #commands(String...)
+     */
+    String CMD_FORMAT = "format";
+    /**
+     * Command payload key.
+     * If the command format is {@code json} then
+     * the key's value will be a {@code JsonObject},
+     * otherwise a {@code String}.
+     * Key is {@value}.
+     * 
+     * @see #commands(String...)
+     */
+    String CMD_PAYLOAD = "payload";
 
     /**
      * Create a stream of device commands as JSON objects.
      * Each command sent to the device matching {@code commands} will result in a tuple
      * on the stream. The JSON object has these keys:
      * <UL>
-     * <LI>{@code command} - Command identifier as a String</LI>
-     * <LI>{@code tsms} - Timestamp of the command in milliseconds since the 1970/1/1 epoch.</LI>
-     * <LI>{@code format} - Format of the command as a String</LI>
-     * <LI>{@code payload} - Payload of the command</LI>
+     * <LI>{@link #CMD_ID command} - Command identifier as a String</LI>
+     * <LI>{@link #CMD_TS tsms} - Timestamp of the command in milliseconds since the 1970/1/1 epoch.</LI>
+     * <LI>{@link #CMD_FORMAT format} - Format of the command as a String</LI>
+     * <LI>{@link #CMD_PAYLOAD payload} - Payload of the command</LI>
      * <UL>
      * <LI>If {@code format} is {@code json} then {@code payload} is JSON</LI>
      * <LI>Otherwise {@code payload} is String
@@ -75,5 +113,5 @@ public interface IotDevice extends TopologyElement {
      * stream will contain all device commands.
      * @return Stream containing device commands.
      */
-    public TStream<JsonObject> commands(String... commands);
+    TStream<JsonObject> commands(String... commands);
 }

http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/25136d81/connectors/iot/src/main/java/quarks/connectors/iot/package-info.java
----------------------------------------------------------------------
diff --git a/connectors/iot/src/main/java/quarks/connectors/iot/package-info.java b/connectors/iot/src/main/java/quarks/connectors/iot/package-info.java
index 8845516..1416f9c 100644
--- a/connectors/iot/src/main/java/quarks/connectors/iot/package-info.java
+++ b/connectors/iot/src/main/java/quarks/connectors/iot/package-info.java
@@ -23,6 +23,7 @@
  * The format for the payload is JSON, support for other payload formats may be added
  * in the future.
  * </LI>
+ * <P>
  * <LI>
  * <B>Device Commands</B> - A device {@link quarks.connectors.iot.IotDevice#commands(String...) subscribes} to <em>commands</em> from back-end systems
  * through the message hub. A device command consists of:
@@ -34,8 +35,13 @@
  * Device commands can be used to perform any action on the device including displaying information,
  * controlling the device (e.g. reduce maximum engine revolutions), controlling the Quarks application, etc.
  * </LI>
- * </UL>
  * The format for the payload is typically JSON, though other formats may be used.
+ * </UL>
+ * </P>
+ * <P>
+ * Device event and command identifiers starting with "{@link quarks.connectors.iot.IotDevice#RESERVED_ID_PREFIX quarks}"
+ * are reserved for use by Quarks.
+ * </P>
  */
 package quarks.connectors.iot;