diff --git a/Node-RED/svg.save b/Node-RED/svg.save deleted file mode 100644 index 643b9c6e0c728bef6ed287ed1ce9995d0d224139..0000000000000000000000000000000000000000 --- a/Node-RED/svg.save +++ /dev/null @@ -1,14 +0,0 @@ - <g id="fanuc1"> - <rect id="fanuc1" - x="1000" y="-2000" - style="fill:rosybrown;stroke:black;stroke-width:1px" - width="1600" height="800" - transform="matrix(1 0 0 1 -800 -400)" - /> - <text id="fanuc1" - x="1000" y="-2000" - style="fill:black;font-family:Arial;font-size:350px" - xml:space="preserve" - transform="matrix(1 0 0 1 -600 0)">Fanuc 1 - </text> - </g> \ No newline at end of file diff --git a/RPI4/ISO SAC40/.gitkeep b/RPI4/ISO SAC40/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/data_processing/computeDataFunc.py b/data_processing/computeDataFunc.py deleted file mode 100755 index fe233483ac50fef613ab00af981b09aa95a09807..0000000000000000000000000000000000000000 --- a/data_processing/computeDataFunc.py +++ /dev/null @@ -1,33 +0,0 @@ -import json -import numpy as np - -def compute2Point(P1,P2,offset): - centre = [(P2["x"] - P1["x"])/2 + P1["x"], (P2["y"] - P1["y"])/2 + P1["y"]] - v = [(P2["x"] - P1["x"]), P2["y"] - P1["y"]] - - theta = np.arctan2(v[0],v[1]) - #print(theta*180/np.pi) - #vecteur = [v[0] * np.cos(theta) - v[1]*np.sin(theta),v[0] * np.cos(theta) + v[1]*np.sin(theta)] - #centre.append(np.arctan2(vecteur[0],vecteur[1])*(180/np.pi)) - #centre.append(vecteur) - centre.append((theta*180/np.pi) - offset) - - #print("angle = ",centre[2]) - return centre - -def getDataPos(client,org,tag : str): - dataPos = {} - query = f'''from(bucket: "SAC40") - |> range(start: -1m, stop: now()) - |> filter(fn: (r) => r["_measurement"] == "Position") - |> filter(fn: (r) => r["TAG_ID"] == "{tag}") - |> filter(fn: (r) => r["_field"] == "json") - |> aggregateWindow(every: 10m, fn: last, createEmpty: false) - |> yield(name: "last")''' - #print(query) - tables = client.query_api().query(query, org) - for table in tables: - for row in table.records: - dataPos = json.loads(row.values["_value"]) - #print(dataPos) - return dataPos \ No newline at end of file diff --git a/data_processing/jsCompute.js b/data_processing/jsCompute.js index 370ccbada2268ff3000f90e8c270165a5c676d50..193b3de5ce65937f73bf4d7496fa3cdb82a5e249 100644 --- a/data_processing/jsCompute.js +++ b/data_processing/jsCompute.js @@ -1,14 +1,30 @@ -// def compute2Point(P1,P2,offset): -// centre = [(P2["x"] - P1["x"])/2 + P1["x"], (P2["y"] - P1["y"])/2 + P1["y"]] -// v = [(P2["x"] - P1["x"]), P2["y"] - P1["y"]] - -// theta = np.arctan2(v[0],v[1]) -// #print(theta*180/np.pi) -// vecteur = [v[0] * np.cos(theta) - v[1]*np.sin(theta),v[0] * np.cos(theta) + v[1]*np.sin(theta)] -// #centre.append(np.arctan2(vecteur[0],vecteur[1])*(180/np.pi)) -// #centre.append(vecteur) -// centre.append((theta*180/np.pi) - offset) - -// #print("angle = ",centre[2]) -// return centre +const config = global.get("config") || []; + +function compute2Point(P1, P2, alpha) { + var centre = [(P2.x - P1.x) / 2 + P1.x, (P2.y - P1.y) / 2 + P1.y, 0]; + var theta = Math.atan((P2.x - P1.x), P2.y - P1.y); + centre[2] = (theta * 180) / Math.PI; + return centre; +} + +function logArrayElements(element, index, array) { + + var P1 = flow.get(element.TAG_1); + var P2 = flow.get(element.TAG_2); + var centre = compute2Point(P1, P2, element.alpha); + + var res = {}; + res.id = element.Ressource; + res.x = centre[0]; + res.y = centre[1]; + res.a = centre[2]; + res.quality = Math.min(P1.quality, P1.quality); + + msg.topic = "/AIP/RESSOURCES/" + element.Ressource; + msg.payload = res; + node.send(msg); + node.done(); +} + +config.forEach(logArrayElements); \ No newline at end of file diff --git a/data_processing/mainProcess.py b/data_processing/mainProcess.py deleted file mode 100755 index d19a2dee71199d2e6d9305417d9098b6855de752..0000000000000000000000000000000000000000 --- a/data_processing/mainProcess.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -from mqtt_client import MyMQTTClass -from computeDataFunc import * -from multiprocessing import Process -import asyncio,json -import numpy as np - - -f = open('/home/pi/aip_sac4.0/bindData.json', 'r') -listeLine = f.read().splitlines() - -config = [] - -for i in listeLine: - config.append(json.loads(i)) - -MQTT_listener = [] -ThreadList = [] - -for ressource in config: - #print(ressource) - i = 0 - MQTT_listener.append(MyMQTTClass()) - ThreadList.append(Process(target = MQTT_listener[0].run,args=(ressource["Ressource"],ressource["TAG_1"],ressource["TAG_2"],ressource["alpha"]))) - i = i + 1 - - -if __name__ == "__main__": - for i in ThreadList: - i.start() - for i in ThreadList: - i.join() \ No newline at end of file diff --git a/data_processing/mqtt_client.py b/data_processing/mqtt_client.py deleted file mode 100755 index 525b8ca96b6c6330b96b65bad993ec6780bdaa79..0000000000000000000000000000000000000000 --- a/data_processing/mqtt_client.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -from computeDataFunc import * -from paho.mqtt import client as mqtt - - -class MyMQTTClass(mqtt.Client): - - def on_connect(self, mqttc, obj, flags, rc): - #print("rc: "+str(rc)) - self.subscribe("/AIP/DWM/" + self.ID1, 0) - self.subscribe("/AIP/DWM/" + self.ID2, 1) - self.pos1 = {} - self.pos2 = {} - self.i = 0 - - # def on_connect_fail(self, mqttc, obj): - # print("Connect failed") - - def on_message(self, mqttc, obj, msg): - #print(str(msg.payload)) - pos = (json.loads(msg.payload)) - if(pos["id"] == self.ID1): - self.pos1 = pos - self.i = self.i + 1 - elif(pos["id"] == self.ID2): - self.pos2 = pos - self.i = self.i + 1 - - - # def on_publish(self, mqttc, obj, mid): - # print("mid: "+str(mid)) - - #def on_subscribe(self, mqttc, obj, mid, granted_qos): - # print("Subscribed: "+str(mid)+" "+str(granted_qos)) - - # def on_log(self, mqttc, obj, level, string): - # print(string) - - def run(self,res:str,ID1:str,ID2:str,alpha:float): - self.connect("127.0.0.1", 1883, 60) - self.ID1 = ID1 - self.ID2 = ID2 - self.ressource = res - self.alpha = alpha - - rc = 0 - while rc == 0: - rc = self.loop() - #print(len(self.data)) - if(self.pos1 != {} and self.pos2 != {} and self.i > 2): - print(self.pos1) - print(self.pos2) - c = compute2Point(self.pos1,self.pos2,self.alpha) - #print("Angle : ",c[2]) - tmp = { "seat" : 0, - "id" : self.ressource, - "x" : c[0], - "y" : c[1], - "a" : c[2], - "quality" : 100} - print(tmp) - self.publish("/AIP/RESSOURCES/" + self.ressource,json.dumps(tmp),0,True) - self.i = 0 - return rc - -if __name__ == '__main__': - mqttc = MyMQTTClass() - rc = mqttc.run("FANUC1","43A0","2CE5") - - -#print("rc: "+str(rc))