diff --git a/Server_CoAP/CoAPthon3/coapserver.py b/Server_CoAP/CoAPthon3/coapserver.py index 1a9470dfd114af8f7a0832b137d762e8937eb184..a93974be8da438db68e58d98b6ff64c1ff556257 100644 --- a/Server_CoAP/CoAPthon3/coapserver.py +++ b/Server_CoAP/CoAPthon3/coapserver.py @@ -36,6 +36,7 @@ class CoAPServer(CoAP): while True: cursor = self.usersCollection.find() for c in cursor: + print(c['uuid']) positionCalculationThread = threading.Thread(target = self.positionCalculation, args=([c['uuid']])) positionCalculationThread.start() time.sleep(3.1) @@ -45,8 +46,9 @@ class CoAPServer(CoAP): print("existing updateUserLocation") def positionCalculation(self, useruuid): + print(useruuid) currentTime = time.time() - trackingCursor = self.trackingCollection.find({'$and':[{'useruuid':{'$eq' : useruuid}}, + trackingCursor = self.trackingCollection.find({'$and':[{'useruuid': useruuid}, {'updateTime':{'$gt' : currentTime - 3}}]}) #trackingCursor = self.trackingCollection.find({'$and':[{'useruuid':{'$eq' : useruuid}}]}) userLocationData =[] @@ -70,8 +72,11 @@ class CoAPServer(CoAP): flag = 0 userLocationData = sorted(userLocationData, key=lambda k: k['distance'], reverse = False) + for u in userLocationData: + print(userLocationData) if len(userLocationData) < 3: + print("userLoicationData < 3") return nodeList = [] @@ -86,6 +91,7 @@ class CoAPServer(CoAP): x, y = triangulationInst.doTriangulation() if x == None: + print("no solution") return dd = datetime.datetime.now() diff --git a/Server_CoAP/CoAPthon3/coapthon/layers/messagelayer.py b/Server_CoAP/CoAPthon3/coapthon/layers/messagelayer.py index f4cba329754613c2205f3875d0cf0d5cab3d2821..7d22055a2ff525b6299d4f27f608075a2d8b4b66 100644 --- a/Server_CoAP/CoAPthon3/coapthon/layers/messagelayer.py +++ b/Server_CoAP/CoAPthon3/coapthon/layers/messagelayer.py @@ -9,7 +9,7 @@ from coapthon.transaction import Transaction __author__ = 'Giacomo Tanganelli' logger = logging.getLogger(__name__) - +logger.propagate = False def str_append_hash(*args): """ Convert each argument to a lower case string, appended, then hash """ diff --git a/Server_CoAP/CoAPthon3/coapthon/server/coap.py b/Server_CoAP/CoAPthon3/coapthon/server/coap.py index 99d2757377eef3e60e25a87ca2f1fe460607d169..2c08d554996080997c5437dbacddd1ab42d931d7 100644 --- a/Server_CoAP/CoAPthon3/coapthon/server/coap.py +++ b/Server_CoAP/CoAPthon3/coapthon/server/coap.py @@ -28,7 +28,7 @@ if not os.path.isfile("logging.conf"): logger = logging.getLogger(__name__) logging.config.fileConfig("logging.conf", disable_existing_loggers=False) - +logger.propagate = False class CoAP(object): """ diff --git a/Server_CoAP/CoAPthon3/exampleresources.py b/Server_CoAP/CoAPthon3/exampleresources.py index 4c44314c3c49265c46ef9faadf3a1dcc7a8bbd1f..2987a8934fc10d918de18e68051d4f13c9fe200a 100644 --- a/Server_CoAP/CoAPthon3/exampleresources.py +++ b/Server_CoAP/CoAPthon3/exampleresources.py @@ -42,7 +42,7 @@ class RpNodeInfoResource(Resource): return self, response def postRpNodeInfoInDB(self, info): - info = info['myMAC'] + info = info['rpMAC'] self.collection.delete_many({ 'rpMAC' : info }) rpuuid = "52528282"+str(uuid.uuid4())[8:] rpuuid = rpuuid.replace("-","") @@ -89,15 +89,16 @@ class RpNodeInfoResource(Resource): if tempdoc[0]['x'] == 0 and tempdoc[0]['y'] == 0: vertexA = tempdoc[0] vertexB = tempdoc[0] + #print("kkkkkkkkkkkkkkk", graphColletion.find({'v1': vertexB['rpuuid'], 'v2': info}) ) dis = { - 'a': graphColletion.find({'v1': vertexB[0][rpuuid], 'v2': info})[0]['distance'], - 'b': graphColletion.find({'v1': vertexA[0][rpuuid], 'v2': info})[0]['distance'], - 'c': vertexB[0]['x'] + 'a': graphColletion.find({'v1': vertexB['rpuuid'], 'v2': info})[0]['distance'], + 'b': graphColletion.find({'v1': vertexA['rpuuid'], 'v2': info})[0]['distance'], + 'c': vertexB['x'] } cosA = (math.pow(dis['b'], 2) + math.pow(dis['c'], 2) - math.pow(dis['a'], 2)) / (2 * dis['b'] * dis['c']) sinA = math.sqrt((1 - math.pow(cosA,2))) - x = b * cosA - y = b * sinA + x = dis['b'] * cosA + y = dis['b'] * sinA self.collection.update({'rpuuid' : info}, {'$set':{'x': x, 'y': y}}, False) else: graphD = graphColletion.find({'v2' : info}) diff --git a/Server_Vue_Express/backend/routes/api.js b/Server_Vue_Express/backend/routes/api.js index 368cb6422b40653f81aec8b6616ff37154a0f602..bcff263330df83e0d72a7753cd6db481f93ebc48 100644 --- a/Server_Vue_Express/backend/routes/api.js +++ b/Server_Vue_Express/backend/routes/api.js @@ -24,11 +24,11 @@ console.log("aaaa") /* POST CreateNewUser page. */ router.post('/CreateNewUser', function(req, res, next) { var uuid = uuidv1() - + console.log(uuid.toString().replace(/-/gi, "")) var user = new User({ name: req.body.name, aID: req.body.aID, - uuid:uuid + uuid: uuid.toString().replace(/-/gi, "") }); user.save(function(err, user){ if(err) return console.error(err);