Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 4a85e01

Browse files
authored
Merge pull request #1 from Autodesk-Forge/synthetic-gateway
Updating Synthetic Gateway and upgrading package dependencies
2 parents 28041b8 + 2f28f90 commit 4a85e01

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const { Y } = require("forge-dataviz-iot-data-modules/server");
3333

3434
This package contains client-side and server-side modules. Server-side modules (or gateways) interact with the corresponding data provider. For example, AzureGateway interacts with Azure Time Series Insights API in order to retrieve specific sensor data.
3535

36-
Client-side modules convert the data obtained from the corresponding DataGateway object into a consistent data format. For more details on how the client-side and server-side IoT data modules interact, see [Creating a Custom Data Adapter]( https://forge.autodesk.com/en/docs/dataviz/v1/developers_guide/advanced_topics/custom_data_adapter/)
36+
Client-side modules convert the data obtained from the corresponding DataGateway object into a consistent data format. For more details on how the client-side and server-side IoT data modules interact, see [Creating a Custom Data Adapter](https://forge.autodesk.com/en/docs/dataviz/v1/developers_guide/advanced_topics/custom_data_adapter/)
3737

3838
### Client-side modules:
3939

package.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "forge-dataviz-iot-data-modules",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "IoT data modules used by https://github.com/Autodesk-Forge/forge-dataviz-iot-reference-app",
55
"author": "Autodesk Inc",
66
"license": "Apache-2.0",
@@ -9,33 +9,33 @@
99
"url": "https://github.com/Autodesk-Forge/forge-dataviz-iot-data-modules"
1010
},
1111
"dependencies": {
12-
"@azure/arm-iothub": "^4.0.0",
13-
"@azure/digital-twins-core": "^1.0.3",
14-
"@azure/event-hubs": "^5.3.1",
15-
"@azure/identity": "^1.2.3",
16-
"@azure/ms-rest-nodeauth": "^3.0.6",
17-
"aws-sdk": "^2.708.0",
18-
"azure-iothub": "^1.13.0",
19-
"body-parser": "^1.19.0",
20-
"bufferutil": "^4.0.1",
21-
"dotenv": "^8.2.0",
22-
"event-stream": "^4.0.1",
23-
"express": "4.16.2",
24-
"forge-apis": "^0.7.3",
25-
"mime": "^2.4.6",
26-
"node-rsa": "^1.1.1",
27-
"q": "^1.5.1",
28-
"timestring": "^6.0.0",
29-
"tween-functions": "^1.2.0",
30-
"utf-8-validate": "^5.0.2",
31-
"uuid": "^8.3.1"
12+
"@azure/arm-iothub": "^4.0.0",
13+
"@azure/digital-twins-core": "^1.0.3",
14+
"@azure/event-hubs": "^5.3.1",
15+
"@azure/identity": "^1.2.3",
16+
"@azure/ms-rest-nodeauth": "^3.0.6",
17+
"aws-sdk": "^2.708.0",
18+
"azure-iothub": "^1.13.0",
19+
"body-parser": "^1.19.0",
20+
"bufferutil": "^4.0.1",
21+
"dotenv": "^8.2.0",
22+
"event-stream": "^4.0.1",
23+
"express": "4.16.2",
24+
"forge-apis": "^0.8.4",
25+
"mime": "^2.4.6",
26+
"node-rsa": "^1.1.1",
27+
"q": "^1.5.1",
28+
"timestring": "^6.0.0",
29+
"tween-functions": "^1.2.0",
30+
"utf-8-validate": "^5.0.2",
31+
"uuid": "^8.3.1"
3232
},
3333
"devDependencies": {
34-
"@babel/core": "^7.0.0-beta.41",
35-
"@babel/plugin-transform-spread": "^7.13.0",
36-
"@babel/preset-env": "7.12.11",
37-
"babel-loader": "^8.1.0",
38-
"webpack": "^5.11.0",
39-
"webpack-cli": "^4.5.0"
34+
"@babel/core": "^7.0.0-beta.41",
35+
"babel-loader": "^8.1.0",
36+
"@babel/preset-env": "7.12.11",
37+
"@babel/plugin-transform-spread": "^7.13.0",
38+
"webpack": "^5.11.0",
39+
"webpack-cli": "^4.5.0"
4040
}
41-
}
41+
}

server/gateways/Hyperion.Server.SyntheticGateway.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Synthetic {
3838
* @param {string} configFile File path to config file defining the data stops and range values used to generate synthetic data. For an example, refer to https://github.com/Autodesk-Forge/forge-dataviz-iot-reference-app/blob/main/server/gateways/synthetic-data/config.js
3939
*/
4040
constructor(configFile) {
41-
this.config = require(configFile);
41+
this.configFile = configFile;
4242
}
4343

4444
nextStop(stops, index, direction) {
@@ -68,7 +68,8 @@ class Synthetic {
6868
return sensorConfig[day][week];
6969
}
7070

71-
value(sensorType, currentTime, interval) {
71+
async value(sensorType, currentTime, interval) {
72+
if (!this.config) this.config = await loadJSONFile(this.configFile);
7273
let hour = this._timeToDecimal(currentTime);
7374
let self = this;
7475
let stops = this._getStops(sensorType, currentTime);
@@ -128,7 +129,7 @@ class SyntheticGateway extends DataGateway {
128129
}
129130

130131
async getDeviceModels() {
131-
return loadJSONFile(this.deviceModelFile);
132+
return await loadJSONFile(this.deviceModelFile);
132133
}
133134

134135
async getDevicesInModel(deviceModelId) {
@@ -180,7 +181,7 @@ class SyntheticGateway extends DataGateway {
180181
let intervalToHour = gapSeconds / 60 / 60;
181182
for (let i = 0; i < 32; i++) {
182183
let time = new Date(Math.round((currSecond + step * i) * 1000));
183-
let v = synthetic.value(propertyId, time, intervalToHour);
184+
let v = await synthetic.value(propertyId, time, intervalToHour);
184185
values.push(v);
185186
}
186187

0 commit comments

Comments
 (0)