-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from smartfog/development
new features prepared for FIWARE v8.0
- Loading branch information
Showing
229 changed files
with
15,457 additions
and
3,646 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/docker | ||
/debug | ||
/doc | ||
/deployment | ||
/release | ||
/test | ||
/designer/node_modules | ||
/application | ||
/yaml | ||
/helm | ||
/helm_with_RBAC | ||
|
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
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
npm install | ||
docker build -t "fogflow/overspeedvechile" . |
16 changes: 16 additions & 0 deletions
16
application/operator/NGSI-LD-operator/WaterPumpFog/config.json
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[{ | ||
"command": "CONNECT_BROKER", | ||
"brokerURL": "http://180.179.214.202:8070" | ||
}, { | ||
"command": "SET_OUTPUTS", | ||
"id": "urn:ngsi-ld:Vehicle:A103", | ||
"type": "Vehicle" | ||
}, { | ||
"command": "SET_INPUTS", | ||
"id": "urn:ngsi-ld:Vehicle:A103", | ||
"type": "Vehicle" | ||
}, { | ||
"command": "SET_REFERENCE", | ||
"url": "http://180.179.214.202:8888/notifyContext" | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
application/operator/NGSI-LD-operator/WaterPumpFog/dockerfile
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM mhart/alpine-node | ||
|
||
WORKDIR /app | ||
ADD . /app | ||
ENTRYPOINT [ "node", "main.js", "-o"] |
85 changes: 85 additions & 0 deletions
85
application/operator/NGSI-LD-operator/WaterPumpFog/function.js
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
var current_observation = "" | ||
var previous_observation = "" | ||
var pon_observation = "" | ||
var onHasCreated = "false" | ||
var publishStatus = "false" | ||
//var startTime = new Date().getTime(); | ||
// contextEntity: the received entities | ||
// publish, query, and subscribe are the callback functions for your own function to interact with the assigned nearby broker | ||
// publish: publish the generated entity, which could be a new entity or the update of an existing entity | ||
// query: query addtional information from the assigned nearby broker | ||
// subscribe: subscribe addtional infromation from the assigned nearby broker | ||
|
||
function sleep(milliseconds) { | ||
const date = Date.now(); | ||
let currentDate = null; | ||
do { | ||
currentDate = Date.now(); | ||
} while (currentDate - date < milliseconds); | ||
} | ||
|
||
|
||
exports.handler = function(contextEntity, publish, query, subscribe) | ||
{ | ||
console.log("enter into the user-defined fog function"); | ||
if (contextEntity == null) { | ||
return; | ||
} | ||
|
||
// ============================== processing ====================================================== | ||
// processing the received ContextEntity: | ||
|
||
|
||
console.log('ContextEntity.......',contextEntity); | ||
var updateEntity = {}; | ||
for (var key in contextEntity) { | ||
updateEntity[key] = contextEntity[key] | ||
} | ||
|
||
var con_observation = "" | ||
|
||
if("on_status" in contextEntity) { | ||
var con_observation = contextEntity.on_status.observedAt | ||
} | ||
current_observation = con_observation | ||
if (current_observation != previous_observation) { | ||
previous_observation = current_observation | ||
if (con_observation != "" && onHasCreated == "false") { | ||
console.log("=====initial timer has been created======") | ||
value = "off" | ||
onHasCreated = "true" | ||
createDate = con_observation.split("T") | ||
publishStatus = "true" | ||
} | ||
|
||
if (publishStatus == "true") { | ||
for(var i = 0 ; i<60 ;i++) { | ||
console.log("Wait for publish") | ||
sleep(1000); | ||
} | ||
updateEntity["command"] = {"type":"Property", "value": value} | ||
publish(updateEntity) | ||
publishStatus = "false" | ||
onHasCreated = "false" | ||
} | ||
} else { | ||
console.log("Status is already off") | ||
} | ||
|
||
// ============================== subscribe ====================================================== | ||
// if you want to subscribe addtional infromation from the assigned nearby broker, please refer to the following example | ||
|
||
/* | ||
var subscribeCtxReq = {}; | ||
subscribeCtxReq.entities = [{type: 'Device', isPattern: true}]; | ||
subscribeCtxReq.type = 'Subscription' | ||
LdSubscription.notification.format = "normalized" | ||
LdSubscription.notification.endpoint.uri = my_ip + ":" + myport+ "/notifyContext" | ||
subscribe(subscribeCtxReq); | ||
*/ | ||
|
||
// For more information about subscription please refer fogflow doc for NGSILD | ||
|
||
}; | ||
|
Oops, something went wrong.