Skip to content
Snippets Groups Projects
Commit 9c7c4686 authored by Server (Shared Users)'s avatar Server (Shared Users)
Browse files

aa

parent 3ef67ca3
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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 """
......
......@@ -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):
"""
......
......@@ -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})
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment