Table of Contents |
---|
Anchor | ||||
---|---|---|---|---|
|
Create and enter a new directory:
$ mkdir gumband-example && cd gumband-example
Initialize an npm project:
$ npm init
...
Code Block |
---|
package name: (gumband-example) version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) |
Anchor | ||||
---|---|---|---|---|
|
Add the Gumband npm module: $ npm i -S @deeplocal/gumband-node-sdk
Anchor | ||||
---|---|---|---|---|
|
All manifests contain one top level key “manifest” and three child keys “statuses”, “controls”, and “settings”. All of these keys must exist and point to an array (even if empty). Save the file as manifest.json.
Code Block | ||
---|---|---|
| ||
{ "manifest": { "statuses": [], "controls": [], "settings": [] } } |
Anchor | ||||
---|---|---|---|---|
|
Create a New Exhibit in the Gumband UI
Create a new js file called ‘sample.js’ and initialize a new instance of the Gumband SDK, providing the exhibit id, exhibit token. The exhibit id and token should have been generated in the previous step. The endpoint id identifies the environment in which the exhibit was created:
...
Handling these websocket events is described in more detail below.
Anchor | ||||
---|---|---|---|---|
|
There are two operating modes your Exhibit can be in: on or off. These are updated in the gumband UI with the large toggle next to the Exhibit name.
...
After restarting the node service, if you toggle the op mode on and off in the Gumband UI, you will see the following in the console:
...
Anchor | ||||
---|---|---|---|---|
|
Now we will create a status. Open your manifest file and add the following example status to the “statuses” array:
...
Code Block |
---|
gb.on(Sockets.READY, async() => { console.log('Gumband READY!'); // Called with the id in the manifest file. await gb.setStatus('example_status', 'the very different status'); const status = await gb.getStatus('example_status'); console.log(status.value); }); |
...
Types of Exhibit Statuses
To learn about the different types of Exhibit Statuses, see: https://deeplocal.atlassian.net/wiki/spaces/GS/pages/179306526/Exhibit+Manifest+Configuration#Exhibit-Status-Types
Anchor | ||||
---|---|---|---|---|
|
Similar to creating a status, we will add a control. Open your manifest file and add the following control to the “controls” array:
Code Block |
---|
{ "manifest": { "statuses": [], "controls": [ { "id": "reload", "type": "Single", "display": "Reload", "order": 0, "enabledOpMode": "On" } ], "settings": [] } } |
Id is a unique id for this control
Type indicates how you want the control to be rendered in the Gumband UI - in our case a single button
Display is the text you want to appear on the control - in our case we will use this to “reload” our Exhibit
Order is the order in which you want this status to be rendered on the Gumband UI in relation to other controls
EnabledOpMode indicates when this control should be active. In our case reload only makes sense when the Exhibit is on but you can imagine that running a homing procedure for a robot might be something you would only do if the Exhibit was off.
...
Click the reload button in the Gumband UI to see the console message.
...
the Gumband UI to see the console message.
...
Types of Exhibit Controls
To learn about the different types of Exhibit Controls, see: https://deeplocal.atlassian.net/wiki/spaces/GS/pages/179306526/Exhibit+Manifest+Configuration#Exhibit-Control-Types
Anchor | ||||
---|---|---|---|---|
|
Just like the last two sections, we will start this one by updating the manifest file.
...
In your console you will now see:
...
Types of Exhibit Settings
To learn about the different types of Exhibit Settings, see: https://deeplocal.atlassian.net/wiki/spaces/GS/pages/179306526/Exhibit+Manifest+Configuration#Exhibit-Setting-Types
Anchor | ||||
---|---|---|---|---|
|
Add the following log lines to your application code:
...
Restart sample.js and navigate to the Gumband UI “Logs” tab and you should see your logs
...
Anchor | ||||
---|---|---|---|---|
|
Recording events is extremely easy with the Gumband SDK. To do so add some code similar to the following:
...
Allow a minute for the new events to be added to the reporting system and then navigate to the reports tab on the UI. You will see a graph similar to this:
...
Anchor | ||||
---|---|---|---|---|
|
You can initialize the Gumband SDK with a few parameters:
...
Check the content folder for your Exhibit, which should now contain your file.
Sending Custom Exhibit Email Notifications
You can view the categories of email notifications you can subscribe to on the “Notifications” tab of the Gumband UI
...