Merge remote-tracking branch 'origin/master'

This commit is contained in:
Marco Zeisler 2021-06-17 23:51:26 +02:00
commit dd802d3eb5
11 changed files with 117 additions and 24 deletions

View File

@ -1,3 +1,4 @@
import os
from bson import json_util from bson import json_util
from flask import Flask, request from flask import Flask, request
from flask_pymongo import PyMongo from flask_pymongo import PyMongo
@ -6,6 +7,38 @@ app = Flask(__name__)
app.config["MONGO_URI"] = "mongodb://mongo:27017/entities" app.config["MONGO_URI"] = "mongodb://mongo:27017/entities"
mongo = PyMongo(app) mongo = PyMongo(app)
CAR1_SV = int(os.environ.get('DSE2021_CAR1_SV', 130))
CAR2_SV = int(os.environ.get('DSE2021_CAR2_SV', 130))
CAR3_SV = int(os.environ.get('DSE2021_CAR3_SV', 130))
CAR1_SD = int(os.environ.get('DSE2021_CAR1_SD', 300))
CAR2_SD = int(os.environ.get('DSE2021_CAR2_SD', 500))
CAR3_SD = int(os.environ.get('DSE2021_CAR3_SD', 400))
CAR1_ST = int(os.environ.get('DSE2021_CAR1_ST', 10))
CAR2_ST = int(os.environ.get('DSE2021_CAR2_ST', 15))
CAR3_ST = int(os.environ.get('DSE2021_CAR3_ST', 25))
TL1_R = int(os.environ.get('DSE2021_TL1_R', 2000))
TL2_R = int(os.environ.get('DSE2021_TL2_R', 800))
TL3_R = int(os.environ.get('DSE2021_TL3_R', 1000))
mongo.db.trafficLights.update_one({"id": "1"}, {"$set": {"range": TL1_R}})
mongo.db.trafficLights.update_one({"id": "2"}, {"$set": {"range": TL2_R}})
mongo.db.trafficLights.update_one({"id": "3"}, {"$set": {"range": TL3_R}})
mongo.db.cars.update_one({"vin": "SCBFR7ZA5CC072256"}, {"$set": {"startingVelocity": CAR1_SV}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812715"}, {"$set": {"startingVelocity": CAR2_SV}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812716"}, {"$set": {"startingVelocity": CAR3_SV}})
mongo.db.cars.update_one({"vin": "SCBFR7ZA5CC072256"}, {"$set": {"startingDistance": CAR1_SD}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812715"}, {"$set": {"startingDistance": CAR2_SD}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812716"}, {"$set": {"startingDistance": CAR3_SD}})
mongo.db.cars.update_one({"vin": "SCBFR7ZA5CC072256"}, {"$set": {"startingTime": CAR1_ST}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812715"}, {"$set": {"startingTime": CAR2_ST}})
mongo.db.cars.update_one({"vin": "5GZCZ43D13S812716"}, {"$set": {"startingTime": CAR3_ST}})
@app.route('/api/v1/resources/cars', methods=['GET']) @app.route('/api/v1/resources/cars', methods=['GET'])
def get_cars(): def get_cars():

View File

@ -3,24 +3,15 @@
"oem": "BENTLEY", "oem": "BENTLEY",
"modelType": "Continental", "modelType": "Continental",
"vin": "SCBFR7ZA5CC072256", "vin": "SCBFR7ZA5CC072256",
"startingVelocity": 130,
"startingDistance": 300,
"startingTime": 10
}, },
{ {
"oem": "SATURN", "oem": "SATURN",
"modelType": "Vue", "modelType": "Vue",
"vin": "5GZCZ43D13S812715", "vin": "5GZCZ43D13S812715",
"startingVelocity": 130,
"startingDistance": 500,
"startingTime": 15
}, },
{ {
"oem": "SATURN", "oem": "SATURN",
"modelType": "Vue2", "modelType": "Vue2",
"vin": "5GZCZ43D13S812716", "vin": "5GZCZ43D13S812716",
"startingVelocity": 130,
"startingDistance": 400,
"startingTime": 25
} }
] ]

View File

@ -2,21 +2,18 @@
{ {
"id": "1", "id": "1",
"location": [16.20719, 47.89584], "location": [16.20719, 47.89584],
"range": 2000,
"switchingTime": 26, "switchingTime": 26,
"color": "RED" "color": "RED"
}, },
{ {
"id": "2", "id": "2",
"location": [16.20814, 47.90937], "location": [16.20814, 47.90937],
"range": 800,
"switchingTime": 16, "switchingTime": 16,
"color": "GREEN" "color": "GREEN"
}, },
{ {
"id": "3", "id": "3",
"location": [16.20917, 47.92703], "location": [16.20917, 47.92703],
"range": 1000,
"switchingTime": 20, "switchingTime": 20,
"color": "RED" "color": "RED"
} }

View File

@ -1,6 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: scaling-configmap
data:
DSE2021_SCALING: "2"

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: simulation-parameters-configmap
data:
DSE2021_SCALING: "2"
DSE2021_CAR1_SV: "130"
DSE2021_CAR2_SV: "130"
DSE2021_CAR3_SV: "130"
DSE2021_CAR1_SD: "300"
DSE2021_CAR2_SD: "500"
DSE2021_CAR3_SD: "400"
DSE2021_CAR1_ST: "10"
DSE2021_CAR2_ST: "15"
DSE2021_CAR3_ST: "25"
DSE2021_TL1_R: "2000"
DSE2021_TL2_R: "800"
DSE2021_TL3_R: "1000"

View File

@ -26,7 +26,7 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""

View File

@ -26,8 +26,68 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
- name: DSE2021_CAR1_SV
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR1_SV
- name: DSE2021_CAR2_SV
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR2_SV
- name: DSE2021_CAR3_SV
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR3_SV
- name: DSE2021_CAR1_SD
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR1_SD
- name: DSE2021_CAR2_SD
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR2_SD
- name: DSE2021_CAR3_SD
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR3_SD
- name: DSE2021_CAR1_ST
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR1_ST
- name: DSE2021_CAR2_ST
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR2_ST
- name: DSE2021_CAR3_ST
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_CAR3_ST
- name: DSE2021_TL1_R
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_TL1_R
- name: DSE2021_TL2_R
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_TL2_R
- name: DSE2021_TL3_R
valueFrom:
configMapKeyRef:
name: simulation-parameters-configmap
key: DSE2021_TL3_R
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""
volumes: null volumes: null

View File

@ -26,7 +26,7 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""

View File

@ -24,7 +24,7 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""

View File

@ -24,7 +24,7 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""

View File

@ -26,7 +26,7 @@ spec:
- name: DSE2021_SCALING - name: DSE2021_SCALING
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: scaling-configmap name: simulation-parameters-configmap
key: DSE2021_SCALING key: DSE2021_SCALING
restartPolicy: Always restartPolicy: Always
serviceAccountName: "" serviceAccountName: ""