-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uploading python files on my local computer to dedicated remote repos…
…itory
- Loading branch information
Showing
43 changed files
with
40,661 additions
and
0 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,13 @@ | ||
FROM python:3 | ||
|
||
WORKDIR /serverapp | ||
|
||
ENV FLASK_APP=server.py | ||
|
||
COPY . . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["python", "server.py"] |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Here, models like the submodel, and descriptors will be build according to | ||
# information InterfaceSetup module. | ||
|
||
import string | ||
import random | ||
''' | ||
### Submodel object (json) modelling workflow. | ||
1. In each of the datapoints in InterfaceSetup module, there is a | ||
mapping enpoint object. if the submodelId endpoint is empty, | ||
then a random one will be generated and assigned to the submodel object | ||
being developed and the submodelId endpoint for future requests. | ||
2. If the submodel element path is empty, a submodel element is build with IdShort | ||
similar to the datapoint "name" | ||
3. The submodel Type helps know what type of submodel element to attach to | ||
the submodel payload. This field here is adviced not tobe left empty | ||
''' | ||
|
||
|
||
Submodel = { | ||
"idShort": "SourceDataSink", | ||
"id": "https://example.com/ids/sm/5552_0182_8042_8250", | ||
"semanticId": { | ||
"type": "ModelReference", | ||
"keys": [ | ||
{ | ||
"type": "Submodel", | ||
"value": "https://admin-shell.io/sinksubmodel" | ||
} | ||
] | ||
}, | ||
"submodelElements": [], | ||
"modelType": "Submodel" | ||
} | ||
|
||
BlobSubmodelElement = { | ||
"idShort": "", | ||
"value": "", | ||
"semanticId": { | ||
"type": "ModelReference", | ||
"keys": [ | ||
{ | ||
"type": "GlobalReference", | ||
"value": "0173-1#02-AAM556#002" | ||
} | ||
] | ||
}, | ||
"contentType": "application/csv", | ||
"modelType": "Blob" | ||
} | ||
|
||
PropertySubmodelElement = { | ||
"category": "PARAMETER", | ||
"idShort": "", | ||
"description": [], | ||
"semanticId": { | ||
"type": "ModelReference", | ||
"keys": [ | ||
{ | ||
"type": "GlobalReference", | ||
"value": "0173-1#02-AAM556#002" | ||
} | ||
] | ||
}, | ||
"valueType": "xs:string", | ||
"value": "", | ||
"modelType": "Property" | ||
} | ||
|
||
aasDescriptor = { | ||
"kind" : "instance", | ||
"idshort" : "Component-" + ' '.join(random.choices(string.ascii_uppercase, k=1)), | ||
"id" : "https://example.com/ids/sm/" + random.randint(0, 100000), | ||
"globalAssetId" : "", | ||
"submodelDescriptors": [ | ||
|
||
] | ||
|
||
} | ||
|
||
submodelDescriptor = { | ||
"endpoints" : [ | ||
{ | ||
"protocolInformation": { | ||
"href": "https://localhost:1234/api/v3.0/submodels", | ||
"endpointProtocol": "HTTP", | ||
"endpointProtocolVersion": [ | ||
"1.1" | ||
] | ||
}, | ||
"interface": "AAS-3.0" | ||
} | ||
], | ||
"idShort" : "data_sink", | ||
"id" : "https://factoryxTP204.com/submodel-for-data-sink" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from flask import Flask, request | ||
from flask_cors import cross_origin | ||
import json | ||
import InterfaceSetup | ||
import httpx | ||
|
||
# Flask constructor takes the name of | ||
# current module (__name__) as argument. | ||
app = Flask(__name__) | ||
|
||
#Interface object | ||
|
||
aasmapper = InterfaceSetup.AasMapper() | ||
ui_origin_localhost = "http://localhost:3000" | ||
ui_origin_docker = "http://client:3000" | ||
|
||
# The route() function of the Flask class is a decorator, | ||
# which tells the application which URL should call | ||
# the associated function. | ||
@app.route("/") | ||
# ‘/’ URL is bound with hello_world() function. | ||
def hello_world(): | ||
return "Hello World" | ||
|
||
|
||
@app.route("/adddatapoint/", methods=["POST"]) | ||
@cross_origin(origins=[ui_origin_localhost]) | ||
#/add-datapoint is bound with addDatapoint() function to add new datapoint | ||
def addDatapoint(): | ||
data = json.loads(request.data) | ||
assets = aasmapper.add_datapoint(data) | ||
return {"assets":assets} | ||
|
||
@app.route("/getdatapoints", methods=["GET"]) | ||
@cross_origin(origins=[ui_origin_localhost]) | ||
# ‘/’ URL is bound with hello_world() function. | ||
def getDatapoints(): | ||
|
||
datapoints = aasmapper.interfaces["assets"] | ||
endpoints = aasmapper.interfaces["endpoints"] | ||
return {"assets": datapoints, "endpoints": endpoints} | ||
|
||
|
||
@app.route("/readdatapoint/", methods=["GET"]) | ||
@cross_origin(origins=[ui_origin_localhost]) | ||
# ‘/’ URL is bound with hello_world() function. | ||
def readDatapoint(): | ||
id = request.args.get("id") | ||
assetId = request.args.get("assetId") | ||
|
||
payload = aasmapper.read_datapoint_from_source(assetId=assetId, id=id) | ||
|
||
|
||
return payload | ||
|
||
|
||
@app.route("/configinfo", methods=["POST"]) | ||
@cross_origin(origins=[ui_origin_localhost]) | ||
# ‘/’ URL is bound with hello_world() function. | ||
def submitConfigInfo(): | ||
data = json.loads(request.data) | ||
print(data) | ||
configData = aasmapper.add_configdata(data) | ||
endpoints = configData["endpoints"] | ||
assets = configData["assets"] | ||
|
||
return { | ||
"assets": assets, | ||
"endpoints": endpoints, | ||
} | ||
|
||
|
||
# main driver function | ||
if __name__ == "__main__": | ||
|
||
# run() method of Flask class runs the application | ||
# on the local development server. | ||
app.run(debug=True, host="0.0.0.0") |
Binary file not shown.
Oops, something went wrong.