Skip to content

Commit

Permalink
Merge pull request #268 from smartfog/development
Browse files Browse the repository at this point in the history
new features prepared for FIWARE v8.0
  • Loading branch information
showersky authored Jun 4, 2021
2 parents e396ef0 + 3a0f290 commit 0c0a567
Show file tree
Hide file tree
Showing 229 changed files with 15,457 additions and 3,646 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
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

77 changes: 54 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push,pull_request]
jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2

Expand All @@ -14,47 +14,77 @@ jobs:
with:
go-version: 1.15

- name: Gosec - Code Analyser
continue-on-error: true
run: |
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest
gosec ./...
- name: Docker Build Job
run: |
export GOBIN=/home/runner/go/bin
docker --version
echo "build discovery"
cd discovery
pwd
sh build
sh build development
echo "build broker"
cd ../broker
pwd
sh build
sh build development
echo "build worker"
cd ../worker
pwd
sh build
sh build development
echo "build master"
cd ../master
pwd
sh build
sh build development
echo "build designer"
cd ../master
cd ../designer
pwd
sh build

sh build development
echo "build k8sWorker"
cd ../k8sWorker
pwd
sh build development
- name: Setting Up Environment
run: |
sudo apt-get update
sudo apt-get install jq
sudo apt-get install python-pip
sudo apt install python-pip
pip -V
sudo pip install --upgrade pip
pip install setuptools
pip install Flask
pip install requests
pip install -U pytest
pip install pytest-cov
pip install pyflakes
sudo npm install -g eslint
sudo apt-get install curl
- name: Running Linters [GoLint - a linter for golang, Pyflakes - a linter for python, ESLint - for Javascript]
run: |
#For go directories
go get -u golang.org/x/lint/golint
export GOBIN=/home/runner/go/bin
cd discovery/
golint
cd ../broker
golint
cd ../master
golint
cd ../worker
golint
cd ../
echo "For python files"
pyflakes . || true
echo "For Javascript files"
eslint . --no-eslintrc --format table || true
- name: Launching Docker containers
run: |
sudo docker run -it -d -p 8082:8080 -p 9082:9080 -p 8000:8000 -v ~/dgraph:/dgraph fogflow/dgraph:latest
Expand Down Expand Up @@ -88,26 +118,27 @@ jobs:
cd discovery/
screen -d -m ./discovery
cd ../broker/
screen -d -m ./broker
cd ../designer/
screen -d -m node main.js
cd ../test/UnitTest/
screen -d -m python accumulator.py
echo "NGSI-v2 Testing !!!"
cd ../UnitTest/v2/
pytest -s -v
pytest -s -v test_casesNGSIv2.py
echo "NGSI-v1 Testing !!!"
cd ../v1/
pytest -s -v
pytest -s -v test_casesNGSIv1.py

echo "NGSI-LD Testing !!!"
cd ../NGSI-LD/
pytest -s -v
pytest -s -v test_casesNGSI-LD.py

echo "Persistance Testing !!!"
cd ../persistance/
pytest -s -v
pytest -s -v test_persistance.py

echo "Testing Done !!!"
echo "Testing Done !!!!!"
Binary file modified FogFlow-Entity.pdf
Binary file not shown.
Binary file modified FogFlow-Individual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[![Documentation badge](https://img.shields.io/readthedocs/fogflow.svg)](http://fogflow.readthedocs.org/en/latest/)
![Status](https://nexus.lab.fiware.org/repository/raw/public/static/badges/statuses/fogflow.svg)
[![Swagger Validator](https://img.shields.io/swagger/valid/2.0/https/raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-expanded.json.svg)](https://app.swaggerhub.com/apis/fogflow/broker/1.0.0)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4798/badge)](https://bestpractices.coreinfrastructure.org/projects/4798)

FogFlow is an IoT edge computing framework to automatically orchestrate dynamic
data processing flows over cloud and edges driven by context, including system
Expand Down Expand Up @@ -117,4 +118,4 @@ follows:
- B. Cheng, G. Solmaz, F. Cirillo, E. Kovacs, K. Terasawa and A. Kitazawa, “[FogFlow: Easy Programming of IoT Services Over Cloud and Edges for Smart Cities](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8022859),” in IEEE Internet of Things Journal, vol. 5, no. 2, pp. 696-707, April 2018, doi: 10.1109/JIOT.2017.2747214. [IoT Journal, 2020 Best Paper Award Runner-Up](https://ieee-iotj.org/awards/)
- Cheng, Bin, Jonathan Fuerst, Gurkan Solmaz, and Takuya Sanada. "[Fog function: Serverless fog computing for data intensive iot services](https://arxiv.org/pdf/1907.08278)." In 2019 IEEE International Conference on Services Computing (SCC), pp. 28-35. IEEE, 2019. [IEEE SCC, 2019 Best Paper Award](https://conferences.computer.org/services/2019/proceedings/bestpapers2019.html)

© 2021 NEC
© 2021 NEC
2 changes: 2 additions & 0 deletions application/operator/NGSI-LD-operator/WaterPumpFog/build
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 application/operator/NGSI-LD-operator/WaterPumpFog/config.json
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 application/operator/NGSI-LD-operator/WaterPumpFog/dockerfile
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 application/operator/NGSI-LD-operator/WaterPumpFog/function.js
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

};

Loading

0 comments on commit 0c0a567

Please sign in to comment.