Skip to content
Snippets Groups Projects
Commit 54c3ea31 authored by jkerdreu's avatar jkerdreu
Browse files

Added is_alive, is_notify, is_xxx to Message

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/fork@1518 b32b6428-25c9-4566-ad07-03861ab6144f
parent e43ca3b1
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,6 @@ from xaal.lib.core import Engine
logger = tools.get_logger("dumper",'DEBUG')
def display(msg):
#if msg.get_action()!='alive':
msg.dump()
def main():
......@@ -38,4 +37,3 @@ def main():
if __name__ == '__main__':
main()
......@@ -77,7 +77,7 @@ class InfoDumper:
def parse_answer(self,msg):
""" message parser """
if (msg.msgtype == 'reply'):
if msg.is_reply():
if self.addr in msg.targets:
if self.target == msg.source:
if msg.action=='getAttributes':
......@@ -113,12 +113,3 @@ def search(addr):
if __name__ == '__main__':
main()
......@@ -58,8 +58,8 @@ class Scanner:
break
def parse_answer(self,msg):
if (msg.msgtype == 'notify'):
if msg.action == 'alive':
if (msg.is_notify()):
if msg.is_alive():
# hidding myself
if msg.source == self.addr:
return
......@@ -100,11 +100,3 @@ def main():
if __name__ == '__main__':
main()
......@@ -37,19 +37,20 @@ def display(msg):
targets = [reduceAddr(addr) for addr in msg.targets]
res = FORMAT % (msg.msgtype,msg.action,msg.source,msg.devtype,targets,msg.body)
if (msg.msgtype == 'request'):
if msg.is_request():
if level > 2: return
term('green')
if (msg.msgtype == 'reply'):
if msg.is_reply():
if level > 1: return
term('red')
if (msg.msgtype == 'notify'):
if msg.action == 'alive':
if msg.is_notify():
if msg.is_alive():
if level > 0: return
term('grey')
if msg.action == 'attributesChange' : term('cyan')
if msg.is_attributes_change():
term('cyan')
print(res)
......@@ -86,13 +87,3 @@ def main():
if __name__ == '__main__':
main()
......@@ -318,6 +318,30 @@ class Message(object):
if self.body: l.append(str(self.body))
return " ".join(l)
def is_request(self):
if self.msgtype == 'request':
return True
return False
def is_reply(self):
if self.msgtype == 'reply':
return True
return False
def is_notify(self):
if self.msgtype == 'notify':
return True
return False
def is_alive(self):
if self.msgtype == 'notify' and self.action == 'alive':
return True
return False
def is_attributes_change(self):
if self.msgtype == 'notify' and self.action == 'attributesChange':
return True
return False
def build_nonce(data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment