Client compatible with older versin
This commit is contained in:
parent
d95709b9a1
commit
aab0df7438
3 changed files with 13 additions and 4 deletions
|
@ -276,7 +276,7 @@ class Hugvey(object):
|
|||
|
||||
def __init__(self, id = None):
|
||||
self.id = self.getId() if id is None else id
|
||||
logger.debug(f'Hugvey {self.id}')
|
||||
logger.debug('Hugvey {}'.format(self.id))
|
||||
|
||||
def getId(self) -> int:
|
||||
"""Get Hugvey ID from hostname"""
|
||||
|
|
|
@ -12,7 +12,7 @@ def getTopic(hugvey_id):
|
|||
|
||||
|
||||
def zmqSend(socket, hugvey_id, msg):
|
||||
log = mainLogger.getChild(f"{hugvey_id}").getChild("communication")
|
||||
log = mainLogger.getChild("{}".format(hugvey_id)).getChild("communication")
|
||||
log.debug("SEND: {}".format(msg))
|
||||
msgData = json.dumps(msg)
|
||||
topic = getTopic(hugvey_id)
|
||||
|
@ -22,7 +22,7 @@ def zmqSend(socket, hugvey_id, msg):
|
|||
async def zmqReceive(socket):
|
||||
topic, msg = await socket.recv_multipart()
|
||||
hugvey_id = topic.decode()[2:]
|
||||
mainLogger.getChild(f"{hugvey_id}").getChild("communication").debug(
|
||||
mainLogger.getChild("{}".format(hugvey_id)).getChild("communication").debug(
|
||||
"Received 0mq messages for Hugvey #{} containing {}".format(hugvey_id, msg.decode())
|
||||
)
|
||||
return int(hugvey_id), json.loads(msg.decode())
|
||||
|
|
|
@ -1503,6 +1503,7 @@ class Graph {
|
|||
}
|
||||
|
||||
calculateDistancesFromStart() {
|
||||
console.time('calculateDistancesFromStart');
|
||||
let starts = this.messages.filter( m => m.hasOwnProperty('start') && m['start'] == true);
|
||||
if (starts.length < 1) {
|
||||
console.error("No start set");
|
||||
|
@ -1589,23 +1590,30 @@ class Graph {
|
|||
}
|
||||
|
||||
let yPos = 0;
|
||||
console.time('step1');
|
||||
for(let startMsg of starts) {
|
||||
console.time('start: '+startMsg['@id']);
|
||||
if(distances[startMsg['@id']] === null) {
|
||||
distances[startMsg['@id']] = [0, yPos];
|
||||
}
|
||||
yPos = traverseMsg(startMsg['@id'], 1 , true, yPos);
|
||||
yPos += 1;
|
||||
console.timeEnd('start: '+startMsg['@id']);
|
||||
}
|
||||
|
||||
console.timeEnd('step1');
|
||||
console.time('step2');
|
||||
// now we have the formal tree, lets try to polish the rest:
|
||||
for(let msgId in distances) {
|
||||
console.time('polish: '+ msgId);
|
||||
if(distances[msgId] === null) {
|
||||
continue;
|
||||
}
|
||||
// let's see if there are parent nodes that are not in the distances array
|
||||
// traverse up and see whether we encounter anything new
|
||||
traverseMsg(msgId, distances[msgId][0] -1, false, distances[msgId][1])
|
||||
console.timeEnd('polish: '+ msgId);
|
||||
}
|
||||
console.timeEnd('step2');
|
||||
|
||||
// let additionalsDepth = 0;
|
||||
//// now the secondary strands:
|
||||
|
@ -1618,6 +1626,7 @@ class Graph {
|
|||
// traverseMsg(msgId, additionalsDepth+1, true);
|
||||
//
|
||||
// }
|
||||
console.timeEnd("calculateDistancesFromStart");
|
||||
return distances;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue