diff --git a/examples/proxy-scripts/$DO_NOT_EDIT_JS_FILES.md b/examples/proxy-scripts/$DO_NOT_EDIT_JS_FILES.md deleted file mode 100644 index 559d22eae..000000000 --- a/examples/proxy-scripts/$DO_NOT_EDIT_JS_FILES.md +++ /dev/null @@ -1,3 +0,0 @@ -# Note - -The JavaScript files in this folder are generated by the workflow described [here](https://github.com/eclipse/thingweb.node-wot/tree/master/packages/examples#workflow). diff --git a/examples/proxy-scripts/bridge-servient.conf.json b/examples/proxy-scripts/bridge-servient.conf.json deleted file mode 100644 index 0967ef424..000000000 --- a/examples/proxy-scripts/bridge-servient.conf.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/proxy-scripts/festo-fake.js b/examples/proxy-scripts/festo-fake.js deleted file mode 100644 index 74cdcbbad..000000000 --- a/examples/proxy-scripts/festo-fake.js +++ /dev/null @@ -1,96 +0,0 @@ -WoT.produce({ - title: "FestoFake", - id: "urn:dev:wot:siemens:festofake", - "iotcs:deviceModel": "urn:com:siemens:wot:festo", - properties: { - PumpStatus: { - type: "boolean", - readOnly: true, - }, - ValveStatus: { - type: "boolean", - readOnly: true, - }, - Tank102LevelValue: { - type: "number", - readOnly: true, - }, - Tank102OverflowStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MaximumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MinimumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101OverflowStatus: { - type: "boolean", - readOnly: true, - }, - }, - actions: { - StartPump: {}, - StopPump: {}, - OpenValve: {}, - CloseValve: {}, - }, -}) - .then((thing) => { - console.log("Produced " + thing.getThingDescription().title); - // init property values - thing.writeProperty("PumpStatus", false); - thing.writeProperty("ValveStatus", false); - // upper tank (102) - thing.writeProperty("Tank102LevelValue", 0.0); - thing.writeProperty("Tank102OverflowStatus", false); - // lower tank (101) - thing.writeProperty("Tank101MaximumLevelStatus", false); - thing.writeProperty("Tank101MinimumLevelStatus", false); - thing.writeProperty("Tank101OverflowStatus", false); - // set action handlers - thing.setActionHandler("StartPump", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Startung pump!"); - resolve(); - }); - }); - thing.setActionHandler("StopPump", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Stopping pump!"); - resolve(); - }); - }); - thing.setActionHandler("OpenValve", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Opening valve!"); - resolve(); - }); - }); - thing.setActionHandler("CloseValve", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Closing valve!"); - resolve(); - }); - }); - thing.expose().then(() => { - console.info(thing.getThingDescription().title + " ready"); - setInterval(() => { - thing.writeProperty("PumpStatus", Math.random() < 0.5 ? true : false); - thing.writeProperty("ValveStatus", Math.random() < 0.5 ? true : false); - let level102 = Math.random() * 150; - thing.writeProperty("Tank102LevelValue", level102); - thing.writeProperty("Tank102OverflowStatus", level102 > 140); - let level101 = 150 - level102; - thing.writeProperty("Tank101MaximumLevelStatus", level101 > 100); - thing.writeProperty("Tank101MinimumLevelStatus", level101 > 10); - thing.writeProperty("Tank101OverflowStatus", level101 > 140); - }, 5000); - }); - }) - .catch((e) => { - console.log(e); - }); diff --git a/examples/proxy-scripts/festo-live.js b/examples/proxy-scripts/festo-live.js deleted file mode 100644 index 8759d5810..000000000 --- a/examples/proxy-scripts/festo-live.js +++ /dev/null @@ -1,205 +0,0 @@ -console.debug = () => {}; -console.log = () => {}; -let PumpP101, ValveV102; -let thingExposed; -// fetch and consume NodeMCU Things -let fetchArray = [ - WoTHelpers.fetch("file://./tdPumpP101.jsonld"), - WoTHelpers.fetch("file://./tdValveV102.jsonld"), - WoTHelpers.fetch("file://./tdUltrasonicSensorB101.jsonld"), - WoTHelpers.fetch("file://./tdB114.jsonld"), - WoTHelpers.fetch("file://./tdB113.jsonld"), - WoTHelpers.fetch("file://./tdS111.jsonld"), - WoTHelpers.fetch("file://./tdS112.jsonld"), -]; -Promise.all(fetchArray).then(async (tdArray) => { - // order must match order of jsonld files - let [tdPumpP101, tdValveV102, tdUltrasonicSensorB101, tdB114, tdB113, tdS111, tdS112] = tdArray; - PumpP101 = await WoT.consume(tdPumpP101); // Status - ValveV102 = await WoT.consume(tdValveV102); // Status - let UltrasonicSensorB101 = await WoT.consume(tdUltrasonicSensorB101); // level - let LevelSensorB114 = await WoT.consume(tdB114); // maxlevel101 - let LevelSensorB113 = await WoT.consume(tdB113); // minlevel101 - let LevelSwitchS111 = await WoT.consume(tdS111); // overflow101 - let FloatSwitchS112 = await WoT.consume(tdS112); // overflow102 - // regularly sync state to exposed Thing - setInterval(() => { - PumpP101.readProperty("status") - .then((value) => { - console.info("+++ PumpStatus " + value); - thingExposed.writeProperty("PumpStatus", value === "ON" ? true : false); - }) - .catch((err) => { - console.error("--- PumpStatus read error: " + err); - }); - ValveV102.readProperty("status") - .then((value) => { - console.info("+++ ValveStatus " + value); - thingExposed.writeProperty("ValveStatus", value === "OPEN" ? true : false); - }) - .catch((err) => { - console.error("--- ValveStatus read error: " + err); - }); - UltrasonicSensorB101.readProperty("levelvalue") - .then((value) => { - console.info("+++ Tank102LevelValue " + value); - thingExposed.writeProperty("Tank102LevelValue", value); - }) - .catch((err) => { - console.error("--- Tank102LevelValue read error: " + err); - }); - FloatSwitchS112.readProperty("overflow102") - .then((value) => { - console.info("+++ Tank102OverflowStatus " + value); - thingExposed.writeProperty("Tank102OverflowStatus", value); - }) - .catch((err) => { - console.error("--- Tank102OverflowStatus read error: " + err); - }); - LevelSensorB114.readProperty("maxlevel101") - .then((value) => { - console.info("+++ Tank101MaximumLevelStatus " + value); - thingExposed.writeProperty("Tank101MaximumLevelStatus", value); - }) - .catch((err) => { - console.error("--- Tank101MaximumLevelStatus read error: " + err); - }); - LevelSensorB113.readProperty("minlevel101") - .then((value) => { - console.info("+++ Tank101MinimumLevelStatus " + value); - thingExposed.writeProperty("Tank101MinimumLevelStatus", value); - }) - .catch((err) => { - console.error("--- Tank101MinimumLevelStatus read error: " + err); - }); - LevelSwitchS111.readProperty("overflow101") - .then((value) => { - console.info("+++ Tank101OverflowStatus " + value); - thingExposed.writeProperty("Tank101OverflowStatus", value); - }) - .catch((err) => { - console.error("--- Tank101OverflowStatus read error: " + err); - }); - }, 5000); -}); -// exposed Thing toward IoT Cloud Service -WoT.produce({ - title: "FestoLive", - id: "urn:dev:wot:siemens:festolive", - "iotcs:deviceModel": "urn:com:siemens:wot:festo", - properties: { - PumpStatus: { - type: "boolean", - readOnly: true, - }, - ValveStatus: { - type: "boolean", - readOnly: true, - }, - Tank102LevelValue: { - type: "number", - readOnly: true, - }, - Tank102OverflowStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MaximumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MinimumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101OverflowStatus: { - type: "boolean", - readOnly: true, - }, - }, - actions: { - StartPump: {}, - StopPump: {}, - OpenValve: {}, - CloseValve: {}, - }, -}) - .then((thing) => { - console.log("Produced " + thing.getThingDescription().title); - thingExposed = thing; - // init property values - // actuator state - thing.writeProperty("PumpStatus", false); - thing.writeProperty("ValveStatus", false); - // upper tank (102) - thing.writeProperty("Tank102LevelValue", 0.0); - thing.writeProperty("Tank102OverflowStatus", false); - // lower tank (101) - thing.writeProperty("Tank101MaximumLevelStatus", false); - thing.writeProperty("Tank101MinimumLevelStatus", false); - thing.writeProperty("Tank101OverflowStatus", false); - // set action handlers - thing.setActionHandler("StartPump", () => { - return new Promise((resolve, reject) => { - console.info(">>> Startung pump!"); - PumpP101.invokeAction("on") - .then(() => { - resolve(); - }) - .catch((err) => { - console.error("--- StartPump invoke error: " + err); - reject(err); - }); - resolve(); - }); - }); - thing.setActionHandler("StopPump", () => { - return new Promise((resolve, reject) => { - console.info(">>> Stopping pump!"); - PumpP101.invokeAction("off") - .then(() => { - resolve(); - }) - .catch((err) => { - console.error("--- StopPump invoke error: " + err); - reject(err); - }); - resolve(); - }); - }); - thing.setActionHandler("OpenValve", () => { - return new Promise((resolve, reject) => { - console.info(">>> Opening valve!"); - ValveV102.invokeAction("open") - .then(() => { - resolve(); - }) - .catch((err) => { - console.error("--- OpenValve invoke error: " + err); - reject(err); - }); - resolve(); - }); - }); - thing.setActionHandler("CloseValve", () => { - return new Promise((resolve, reject) => { - console.info(">>> Closing valve!"); - ValveV102.invokeAction("close") - .then(() => { - resolve(); - }) - .catch((err) => { - console.error("--- CloseValve invoke error: " + err); - reject(err); - }); - resolve(); - }); - }); - // expose the thing - thing.expose().then(() => { - console.info(thing.getThingDescription().title + " ready"); - }); - }) - .catch((e) => { - console.log(e); - }); diff --git a/examples/proxy-scripts/tdB113.jsonld b/examples/proxy-scripts/tdB113.jsonld deleted file mode 100644 index d614d3844..000000000 --- a/examples/proxy-scripts/tdB113.jsonld +++ /dev/null @@ -1,20 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:b113", - "title": "LevelSensorB113", - "base": "coap://192.168.0.113:5683/b113/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "minlevel101": { - "type": "boolean", - "writable": false, - "observable": false, - "forms": [{ - "href": "tank101MinLevelStatus", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdB114.jsonld b/examples/proxy-scripts/tdB114.jsonld deleted file mode 100644 index 699e4a6f2..000000000 --- a/examples/proxy-scripts/tdB114.jsonld +++ /dev/null @@ -1,20 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:b114", - "title": "LevelSensorB114", - "base": "coap://192.168.0.113:5683/b114/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "maxlevel101": { - "type": "boolean", - "writable": false, - "observable": false, - "forms": [{ - "href": "tank101MaxLevelStatus", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdPumpP101.jsonld b/examples/proxy-scripts/tdPumpP101.jsonld deleted file mode 100644 index 73d85ae05..000000000 --- a/examples/proxy-scripts/tdPumpP101.jsonld +++ /dev/null @@ -1,34 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:p101", - "title": "Pump", - "base": "coap://192.168.0.101:5683/pumpp101/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "status": { - "type": "string", - "writable": false, - "observable": false, - "forms": [{ - "href": "status", - "mediaType": "application/json" - }] - } - }, - "actions": { - "on": { - "forms": [{ - "href": "on", - "mediaType": "application/json" - }] - }, - "off": { - "forms": [{ - "href": "off", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdS111.jsonld b/examples/proxy-scripts/tdS111.jsonld deleted file mode 100644 index c0b8618e5..000000000 --- a/examples/proxy-scripts/tdS111.jsonld +++ /dev/null @@ -1,20 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:s111", - "title": "FloatSensorS111", - "base": "coap://192.168.0.111:5683/floatsensors111/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "overflow101": { - "type": "boolean", - "writable": false, - "observable": false, - "forms": [{ - "href": "tank101Overflowstatus", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdS112.jsonld b/examples/proxy-scripts/tdS112.jsonld deleted file mode 100644 index 94ed5a1f7..000000000 --- a/examples/proxy-scripts/tdS112.jsonld +++ /dev/null @@ -1,20 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:s112", - "title": "FloatSwitchS112", - "base": "coap://192.168.0.112:5683/floatswitchs112/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "overflow102": { - "type": "boolean", - "writable": false, - "observable": false, - "forms": [{ - "href": "tank102OverflowStatus", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdUltrasonicSensorB101.jsonld b/examples/proxy-scripts/tdUltrasonicSensorB101.jsonld deleted file mode 100644 index dcafde07f..000000000 --- a/examples/proxy-scripts/tdUltrasonicSensorB101.jsonld +++ /dev/null @@ -1,20 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:b101", - "title": "myUltrasonicSensorB101", - "base": "coap://192.168.0.110:5683/ultrasonicsensorb101/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "levelvalue": { - "type": "number", - "writable": false, - "observable": false, - "forms": [{ - "href": "levelvalue", - "mediaType": "application/json" - }] - } - } -} diff --git a/examples/proxy-scripts/tdValveV102.jsonld b/examples/proxy-scripts/tdValveV102.jsonld deleted file mode 100644 index 8807c7144..000000000 --- a/examples/proxy-scripts/tdValveV102.jsonld +++ /dev/null @@ -1,34 +0,0 @@ -{ - "@context": "https://www.w3.org/2019/wot/td/v1", - "@type": ["Thing"], - "id": "urn:dev:wot:com:siemens:festolive:v102", - "title": "Valve", - "base": "coap://192.168.0.102:5683/", - "securityDefinitions": { "nosec_sc": { "scheme": "nosec" }}, - "security": "nosec_sc", - "properties": { - "status": { - "type": "string", - "writable": false, - "observable": false, - "forms": [{ - "href": "status", - "mediaType": "application/json" - }] - } - }, - "actions": { - "open": { - "forms": [{ - "href": "open", - "mediaType": "application/json" - }] - }, - "close": { - "forms": [{ - "href": "close", - "mediaType": "application/json" - }] - } - } -} diff --git a/packages/examples/src/proxy-scripts/festo-fake.ts b/packages/examples/src/proxy-scripts/festo-fake.ts deleted file mode 100644 index 29f9cdf11..000000000 --- a/packages/examples/src/proxy-scripts/festo-fake.ts +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2020 - 2021 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and - * Document License (2015-05-13) which is available at - * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document. - * - * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 - ********************************************************************************/ -import "wot-typescript-definitions"; - -WoT.produce({ - title: "FestoFake", - id: "urn:dev:wot:siemens:festofake", - "iotcs:deviceModel": "urn:com:siemens:wot:festo", - properties: { - PumpStatus: { - type: "boolean", - readOnly: true, - }, - ValveStatus: { - type: "boolean", - readOnly: true, - }, - Tank102LevelValue: { - type: "number", - readOnly: true, - }, - Tank102OverflowStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MaximumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MinimumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101OverflowStatus: { - type: "boolean", - readOnly: true, - }, - }, - actions: { - StartPump: {}, - StopPump: {}, - OpenValve: {}, - CloseValve: {}, - }, -}) - .then((thing) => { - console.log("Produced " + thing.getThingDescription().title); - - // TODO FIX after v0.8 API changes are in place - console.error("TODO FIX after v0.8 API changes are in place"); - - /* - // init property values - thing.writeProperty("PumpStatus", false); - thing.writeProperty("ValveStatus", false); - // upper tank (102) - thing.writeProperty("Tank102LevelValue", 0.0); - thing.writeProperty("Tank102OverflowStatus", false); - // lower tank (101) - thing.writeProperty("Tank101MaximumLevelStatus", false); - thing.writeProperty("Tank101MinimumLevelStatus", false); - thing.writeProperty("Tank101OverflowStatus", false); - - // set action handlers - thing.setActionHandler("StartPump", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Startung pump!"); - resolve(); - }); - }); - thing.setActionHandler("StopPump", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Stopping pump!"); - resolve(); - }); - }); - thing.setActionHandler("OpenValve", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Opening valve!"); - resolve(); - }); - }); - thing.setActionHandler("CloseValve", () => { - return new Promise((resolve, reject) => { - console.warn(">>> Closing valve!"); - resolve(); - }); - }); - - thing.expose().then( () => { - console.info(thing.getThingDescription().title + " ready"); - - setInterval( () => { - thing.writeProperty("PumpStatus", Math.random()<0.5 ? true : false); - thing.writeProperty("ValveStatus", Math.random()<0.5 ? true : false); - let level102 = Math.random() * 150; - thing.writeProperty("Tank102LevelValue", level102); - thing.writeProperty("Tank102OverflowStatus", level102 > 140); - let level101 = 150 - level102; - thing.writeProperty("Tank101MaximumLevelStatus", level101 > 100); - thing.writeProperty("Tank101MinimumLevelStatus", level101 > 10); - thing.writeProperty("Tank101OverflowStatus", level101 > 140); - }, 5000); - }); - */ - }) - .catch((e) => { - console.log(e); - }); diff --git a/packages/examples/src/proxy-scripts/festo-live.ts b/packages/examples/src/proxy-scripts/festo-live.ts deleted file mode 100644 index 0c1296d45..000000000 --- a/packages/examples/src/proxy-scripts/festo-live.ts +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2020 - 2021 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and - * Document License (2015-05-13) which is available at - * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document. - * - * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 - ********************************************************************************/ - -import { Helpers } from "@node-wot/core"; -import { ThingDescription } from "wot-typescript-definitions"; - -let WoTHelpers: Helpers; - -console.debug = () => { - /* empty */ -}; -console.log = () => { - /* empty */ -}; - -let PumpP101: WoT.ConsumedThing, ValveV102: WoT.ConsumedThing; - -let thingExposed: WoT.ExposedThing; - -// fetch and consume NodeMCU Things -const fetchArray = [ - WoTHelpers.fetch("file://./tdPumpP101.jsonld"), - WoTHelpers.fetch("file://./tdValveV102.jsonld"), - WoTHelpers.fetch("file://./tdUltrasonicSensorB101.jsonld"), - WoTHelpers.fetch("file://./tdB114.jsonld"), - WoTHelpers.fetch("file://./tdB113.jsonld"), - WoTHelpers.fetch("file://./tdS111.jsonld"), - WoTHelpers.fetch("file://./tdS112.jsonld"), -]; - -Promise.all(fetchArray).then(async (tdArray: ThingDescription[]) => { - // order must match order of jsonld files - const [tdPumpP101, tdValveV102, tdUltrasonicSensorB101, tdB114, tdB113, tdS111, tdS112] = tdArray; - - PumpP101 = await WoT.consume(tdPumpP101); // Status - ValveV102 = await WoT.consume(tdValveV102); // Status - - const UltrasonicSensorB101 = await WoT.consume(tdUltrasonicSensorB101); // level - const LevelSensorB114 = await WoT.consume(tdB114); // maxlevel101 - const LevelSensorB113 = await WoT.consume(tdB113); // minlevel101 - - const LevelSwitchS111 = await WoT.consume(tdS111); // overflow101 - const FloatSwitchS112 = await WoT.consume(tdS112); // overflow102 - - // regularly sync state to exposed Thing - setInterval(() => { - // TODO FIX after v0.8 API changes are in place - console.error("TODO FIX after v0.8 API changes are in place"); - - /* - PumpP101.readProperty("status") - .then(async value => { - let valuep = await Helpers.parseInteractionOutput(value); - console.info("+++ PumpStatus " + valuep); - thingExposed.writeProperty("PumpStatus", valuep === "ON" ? true : false); - }) - .catch(err => { console.error("--- PumpStatus read error: " + err); }); - - ValveV102.readProperty("status") - .then(async value => { - let valuep = await Helpers.parseInteractionOutput(value); - console.info("+++ ValveStatus " + valuep); - thingExposed.writeProperty("ValveStatus", valuep === "OPEN" ? true : false); - }) - .catch(err => { console.error("--- ValveStatus read error: " + err); }); - - UltrasonicSensorB101.readProperty("levelvalue") - .then(value => { - console.info("+++ Tank102LevelValue " + value); - thingExposed.writeProperty("Tank102LevelValue", value); - }) - .catch(err => { console.error("--- Tank102LevelValue read error: " + err); }); - - FloatSwitchS112.readProperty("overflow102") - .then(value => { - console.info("+++ Tank102OverflowStatus " + value); - thingExposed.writeProperty("Tank102OverflowStatus", value); - }) - .catch(err => { console.error("--- Tank102OverflowStatus read error: " + err); }); - - LevelSensorB114.readProperty("maxlevel101") - .then(value => { - console.info("+++ Tank101MaximumLevelStatus " + value); - thingExposed.writeProperty("Tank101MaximumLevelStatus", value); - }) - .catch(err => { console.error("--- Tank101MaximumLevelStatus read error: " + err); }); - - LevelSensorB113.readProperty("minlevel101") - .then(value => { - console.info("+++ Tank101MinimumLevelStatus " + value); - thingExposed.writeProperty("Tank101MinimumLevelStatus", value); - }) - .catch(err => { console.error("--- Tank101MinimumLevelStatus read error: " + err); }); - - LevelSwitchS111.readProperty("overflow101") - .then(value => { - console.info("+++ Tank101OverflowStatus " + value); - thingExposed.writeProperty("Tank101OverflowStatus", value); - }) - .catch(err => { console.error("--- Tank101OverflowStatus read error: " + err); }); - */ - }, 5000); -}); - -// exposed Thing toward IoT Cloud Service -WoT.produce({ - title: "FestoLive", - id: "urn:dev:wot:siemens:festolive", - "iotcs:deviceModel": "urn:com:siemens:wot:festo", - properties: { - PumpStatus: { - type: "boolean", - readOnly: true, - }, - ValveStatus: { - type: "boolean", - readOnly: true, - }, - Tank102LevelValue: { - type: "number", - readOnly: true, - }, - Tank102OverflowStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MaximumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101MinimumLevelStatus: { - type: "boolean", - readOnly: true, - }, - Tank101OverflowStatus: { - type: "boolean", - readOnly: true, - }, - }, - actions: { - StartPump: {}, - StopPump: {}, - OpenValve: {}, - CloseValve: {}, - }, -}) - .then((thing) => { - console.log("Produced " + thing.getThingDescription().title); - thingExposed = thing; - - // TODO FIX after v0.8 API changes are in place - console.error("TODO FIX after v0.8 API changes are in place"); - - /* - // init property values - // actuator state - thing.writeProperty("PumpStatus", false); - thing.writeProperty("ValveStatus", false); - // upper tank (102) - thing.writeProperty("Tank102LevelValue", 0.0); - thing.writeProperty("Tank102OverflowStatus", false); - // lower tank (101) - thing.writeProperty("Tank101MaximumLevelStatus", false); - thing.writeProperty("Tank101MinimumLevelStatus", false); - thing.writeProperty("Tank101OverflowStatus", false); - - // set action handlers - thing.setActionHandler("StartPump", () => { - return new Promise((resolve, reject) => { - console.info(">>> Startung pump!"); - PumpP101.invokeAction("on") - .then(() => { resolve(); }) - .catch((err) => { console.error("--- StartPump invoke error: " + err); reject(err); }); - resolve(); - }); - }); - thing.setActionHandler("StopPump", () => { - return new Promise((resolve, reject) => { - console.info(">>> Stopping pump!"); - PumpP101.invokeAction("off") - .then(() => { resolve(); }) - .catch((err) => { console.error("--- StopPump invoke error: " + err); reject(err); }); - resolve(); - }); - }); - thing.setActionHandler("OpenValve", () => { - return new Promise((resolve, reject) => { - console.info(">>> Opening valve!"); - ValveV102.invokeAction("open") - .then(() => { resolve(); }) - .catch((err) => { console.error("--- OpenValve invoke error: " + err); reject(err); }); - resolve(); - }); - }); - thing.setActionHandler("CloseValve", () => { - return new Promise((resolve, reject) => { - console.info(">>> Closing valve!"); - ValveV102.invokeAction("close") - .then(() => { resolve(); }) - .catch((err) => { console.error("--- CloseValve invoke error: " + err); reject(err); }); - resolve(); - }); - }); - - // expose the thing - thing.expose().then( () => { console.info(thing.getThingDescription().title + " ready"); } ); - */ - }) - .catch((e) => { - console.log(e); - });