Skip to content

Commit 82f7f7a

Browse files
authored
Merge pull request #1227 from eclipse-thingweb/ege-testthing-fixes
TestThing fixes
2 parents 22cfb3a + 7b435dd commit 82f7f7a

2 files changed

Lines changed: 76 additions & 28 deletions

File tree

examples/testthing/testthing.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,44 @@ WoT.produce({
3939
title: "TestThing",
4040
properties: {
4141
bool: {
42-
title: "true/false",
42+
title: "Boolean",
43+
description: "Property that can be set to true or false",
4344
type: "boolean",
4445
},
4546
int: {
46-
title: "Integer number",
47+
title: "Integer",
48+
description: "An integer value that can be read and written",
4749
type: "integer",
4850
},
4951
num: {
50-
title: "Floating point",
52+
title: "Number",
53+
description: "A floating point value that can be read and written",
5154
type: "number",
5255
},
5356
string: {
57+
title: "String",
58+
description: "A string value that can be read and written",
5459
type: "string",
5560
},
5661
array: {
57-
title: "Tuple",
62+
title: "Array",
63+
description: "An Array (List) with no structure that can be read and written",
5864
type: "array",
5965
items: {},
6066
},
6167
object: {
62-
title: "ID-name",
63-
description: "Object with ID and name",
68+
title: "Object",
69+
description: "An object with id and name that can be read and written",
6470
type: "object",
6571
properties: {
6672
id: {
6773
title: "ID",
68-
description: "Internal identifier",
74+
description: "Integer identifier",
6975
type: "integer",
7076
},
7177
name: {
7278
title: "Name",
73-
description: "Public name",
79+
description: "Name associated to the identifier",
7480
type: "string",
7581
},
7682
},
@@ -133,18 +139,33 @@ WoT.produce({
133139
},
134140
events: {
135141
"on-bool": {
136-
title: "on-bool Event",
137-
description: "Event with boolean data",
142+
title: "Bool Property Change",
143+
description: "Event with boolean data that is emitted when the bool property is written to",
138144
data: { type: "boolean" },
139145
},
140146
"on-int": {
141-
title: "on-int Event",
142-
description: "Event with integer data",
147+
title: "Int Property Change",
148+
description: "Event with integer data that is emitted when the int property is written to ",
143149
data: { type: "integer" },
144150
},
145151
"on-num": {
146-
title: "on-num Event",
147-
description: "Event with number data",
152+
title: "Num Property Change",
153+
description: "Event with number data that is emitted when the num property is written to",
154+
data: { type: "number" },
155+
},
156+
"on-string": {
157+
title: "String Property Change",
158+
description: "Event with number data that is emitted when the string property is written to",
159+
data: { type: "number" },
160+
},
161+
"on-array": {
162+
title: "Array Property Change",
163+
description: "Event with number data that is emitted when the array property is written to",
164+
data: { type: "number" },
165+
},
166+
"on-object": {
167+
title: "Object Property Change",
168+
description: "Event with number data that is emitted when the object property is written to",
148169
data: { type: "number" },
149170
},
150171
},
@@ -182,6 +203,7 @@ WoT.produce({
182203
const localString = await value.value();
183204
checkPropertyWrite("string", typeof localString);
184205
string = localString;
206+
thing.emitEvent("on-string", string);
185207
})
186208
.setPropertyReadHandler("string", async () => string)
187209
.setPropertyWriteHandler("array", async (value) => {
@@ -192,6 +214,7 @@ WoT.produce({
192214
checkPropertyWrite("array", typeof localArray);
193215
}
194216
array = localArray;
217+
thing.emitEvent("on-array", array);
195218
})
196219
.setPropertyReadHandler("array", async () => array)
197220
.setPropertyWriteHandler("object", async (value) => {
@@ -202,6 +225,7 @@ WoT.produce({
202225
checkPropertyWrite("object", typeof localObject);
203226
}
204227
object = localObject;
228+
thing.emitEvent("on-object", object);
205229
})
206230
.setPropertyReadHandler("object", async () => object);
207231
// set action handlers

packages/examples/src/testthing/testthing.ts

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,44 @@ WoT.produce({
4343
title: "TestThing",
4444
properties: {
4545
bool: {
46-
title: "true/false",
46+
title: "Boolean",
47+
description: "Property that can be set to true or false",
4748
type: "boolean",
4849
},
4950
int: {
50-
title: "Integer number",
51+
title: "Integer",
52+
description: "An integer value that can be read and written",
5153
type: "integer",
5254
},
5355
num: {
54-
title: "Floating point",
56+
title: "Number",
57+
description: "A floating point value that can be read and written",
5558
type: "number",
5659
},
5760
string: {
61+
title: "String",
62+
description: "A string value that can be read and written",
5863
type: "string",
5964
},
6065
array: {
61-
title: "Tuple",
66+
title: "Array",
67+
description: "An Array (List) with no structure that can be read and written",
6268
type: "array",
6369
items: {},
6470
},
6571
object: {
66-
title: "ID-name",
67-
description: "Object with ID and name",
72+
title: "Object",
73+
description: "An object with id and name that can be read and written",
6874
type: "object",
6975
properties: {
7076
id: {
7177
title: "ID",
72-
description: "Internal identifier",
78+
description: "Integer identifier",
7379
type: "integer",
7480
},
7581
name: {
7682
title: "Name",
77-
description: "Public name",
83+
description: "Name associated to the identifier",
7884
type: "string",
7985
},
8086
},
@@ -137,18 +143,33 @@ WoT.produce({
137143
},
138144
events: {
139145
"on-bool": {
140-
title: "on-bool Event",
141-
description: "Event with boolean data",
146+
title: "Bool Property Change",
147+
description: "Event with boolean data that is emitted when the bool property is written to",
142148
data: { type: "boolean" },
143149
},
144150
"on-int": {
145-
title: "on-int Event",
146-
description: "Event with integer data",
151+
title: "Int Property Change",
152+
description: "Event with integer data that is emitted when the int property is written to ",
147153
data: { type: "integer" },
148154
},
149155
"on-num": {
150-
title: "on-num Event",
151-
description: "Event with number data",
156+
title: "Num Property Change",
157+
description: "Event with number data that is emitted when the num property is written to",
158+
data: { type: "number" },
159+
},
160+
"on-string": {
161+
title: "String Property Change",
162+
description: "Event with number data that is emitted when the string property is written to",
163+
data: { type: "number" },
164+
},
165+
"on-array": {
166+
title: "Array Property Change",
167+
description: "Event with number data that is emitted when the array property is written to",
168+
data: { type: "number" },
169+
},
170+
"on-object": {
171+
title: "Object Property Change",
172+
description: "Event with number data that is emitted when the object property is written to",
152173
data: { type: "number" },
153174
},
154175
},
@@ -187,6 +208,7 @@ WoT.produce({
187208
const localString = await value.value();
188209
checkPropertyWrite("string", typeof localString);
189210
string = localString as string;
211+
thing.emitEvent("on-string", string);
190212
})
191213
.setPropertyReadHandler("string", async () => string)
192214
.setPropertyWriteHandler("array", async (value) => {
@@ -197,6 +219,7 @@ WoT.produce({
197219
checkPropertyWrite("array", typeof localArray);
198220
}
199221
array = localArray as unknown[];
222+
thing.emitEvent("on-array", array);
200223
})
201224
.setPropertyReadHandler("array", async () => array)
202225
.setPropertyWriteHandler("object", async (value) => {
@@ -207,6 +230,7 @@ WoT.produce({
207230
checkPropertyWrite("object", typeof localObject);
208231
}
209232
object = localObject as Record<string, unknown>;
233+
thing.emitEvent("on-object", object);
210234
})
211235
.setPropertyReadHandler("object", async () => object);
212236

0 commit comments

Comments
 (0)