-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hasan Eroglu <[email protected]>
- Loading branch information
1 parent
c03e13a
commit 41ed9c8
Showing
40 changed files
with
180 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ let thingModel; | |
|
||
if (tmPath != null && tmPath !== "") { | ||
thingModel = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, tmPath)).toString(), | ||
fs.readFileSync(path.join(__dirname, tmPath)).toString() | ||
); | ||
} | ||
|
||
|
@@ -99,7 +99,7 @@ servient.addServer( | |
new HttpServer({ | ||
baseUri: `http://${hostname}:${portNumber}`, | ||
port: portNumber, | ||
}), | ||
}) | ||
); | ||
|
||
servient | ||
|
@@ -126,15 +126,15 @@ servient | |
|
||
thing.setPropertyReadHandler( | ||
"allAvailableResources", | ||
async () => allAvailableResources, | ||
async () => allAvailableResources | ||
); | ||
thing.setPropertyReadHandler( | ||
"possibleDrinks", | ||
async () => possibleDrinks, | ||
async () => possibleDrinks | ||
); | ||
thing.setPropertyReadHandler( | ||
"maintenanceNeeded", | ||
async () => maintenanceNeeded, | ||
async () => maintenanceNeeded | ||
); | ||
thing.setPropertyReadHandler("schedules", async () => schedules); | ||
|
||
|
@@ -150,7 +150,7 @@ servient | |
// (the notify function here simply logs a message to the console) | ||
notify( | ||
"[email protected]", | ||
`maintenanceNeeded property has changed, new value is: ${maintenanceNeeded}`, | ||
`maintenanceNeeded property has changed, new value is: ${maintenanceNeeded}` | ||
); | ||
} | ||
}); | ||
|
@@ -181,7 +181,7 @@ servient | |
} | ||
} | ||
throw Error("Please specify id variable as uriVariables."); | ||
}, | ||
} | ||
); | ||
|
||
// Override a read handler for availableResourceLevel property, | ||
|
@@ -205,7 +205,7 @@ servient | |
} | ||
} | ||
throw Error("Please specify id variable as uriVariables."); | ||
}, | ||
} | ||
); | ||
|
||
// Set up a handler for makeDrink action | ||
|
@@ -291,30 +291,30 @@ servient | |
newResources.water -= Math.ceil( | ||
quantity * | ||
sizeQuantifiers[size] * | ||
drinkRecipes[drinkId].water, | ||
drinkRecipes[drinkId].water | ||
); | ||
newResources.milk -= Math.ceil( | ||
quantity * | ||
sizeQuantifiers[size] * | ||
drinkRecipes[drinkId].milk, | ||
drinkRecipes[drinkId].milk | ||
); | ||
newResources.chocolate -= Math.ceil( | ||
quantity * | ||
sizeQuantifiers[size] * | ||
drinkRecipes[drinkId].chocolate, | ||
drinkRecipes[drinkId].chocolate | ||
); | ||
newResources.coffeeBeans -= Math.ceil( | ||
quantity * | ||
sizeQuantifiers[size] * | ||
drinkRecipes[drinkId].coffeeBeans, | ||
drinkRecipes[drinkId].coffeeBeans | ||
); | ||
|
||
// Check if the amount of available resources is sufficient to make a drink | ||
for (const resource in newResources) { | ||
if (newResources[resource] <= 0) { | ||
thing.emitEvent( | ||
"outOfResource", | ||
`Low level of ${resource}: ${newResources[resource]}%`, | ||
`Low level of ${resource}: ${newResources[resource]}%` | ||
); | ||
return { | ||
result: false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.