Skip to content
Snippets Groups Projects
Commit 3b5feab4 authored by Ramin Yaghoubzadeh's avatar Ramin Yaghoubzadeh
Browse files

Removed second parameter from IU _modify_links() - it was not used anymore after refactoring.

Fixed ipaacaspam.py test. Improved .gitignore
parent 4579f9cd
No related branches found
No related tags found
No related merge requests found
...@@ -10,3 +10,7 @@ java/.classpath ...@@ -10,3 +10,7 @@ java/.classpath
.project .project
.classpath .classpath
**/.*.swp **/.*.swp
.*.sw[a-z]
*.un~
Session.vim
...@@ -210,23 +210,23 @@ class IUInterface(object): #{{{ ...@@ -210,23 +210,23 @@ class IUInterface(object): #{{{
'''Attempt to add links if the conditions are met '''Attempt to add links if the conditions are met
and send an update message. Then call the local setter.''' and send an update message. Then call the local setter.'''
if not hasattr(targets, '__iter__'): targets=[targets] if not hasattr(targets, '__iter__'): targets=[targets]
self._modify_links(links=self, is_delta=True, new_links={type:targets}, links_to_remove={}, writer_name=writer_name) self._modify_links(is_delta=True, new_links={type:targets}, links_to_remove={}, writer_name=writer_name)
self._add_and_remove_links( add={type:targets}, remove={} ) self._add_and_remove_links( add={type:targets}, remove={} )
def remove_links(self, type, targets, writer_name=None): def remove_links(self, type, targets, writer_name=None):
'''Attempt to remove links if the conditions are met '''Attempt to remove links if the conditions are met
and send an update message. Then call the local setter.''' and send an update message. Then call the local setter.'''
if not hasattr(targets, '__iter__'): targets=[targets] if not hasattr(targets, '__iter__'): targets=[targets]
self._modify_links(links=self, is_delta=True, new_links={}, links_to_remove={type:targets}, writer_name=writer_name) self._modify_links(is_delta=True, new_links={}, links_to_remove={type:targets}, writer_name=writer_name)
self._add_and_remove_links( add={}, remove={type:targets} ) self._add_and_remove_links( add={}, remove={type:targets} )
def modify_links(self, add, remove, writer_name=None): def modify_links(self, add, remove, writer_name=None):
'''Attempt to modify links if the conditions are met '''Attempt to modify links if the conditions are met
and send an update message. Then call the local setter.''' and send an update message. Then call the local setter.'''
self._modify_links(links=self, is_delta=True, new_links=add, links_to_remove=remove, writer_name=writer_name) self._modify_links(is_delta=True, new_links=add, links_to_remove=remove, writer_name=writer_name)
self._add_and_remove_links( add=add, remove=remove ) self._add_and_remove_links( add=add, remove=remove )
def set_links(self, links, writer_name=None): def set_links(self, links, writer_name=None):
'''Attempt to set (replace) links if the conditions are met '''Attempt to set (replace) links if the conditions are met
and send an update message. Then call the local setter.''' and send an update message. Then call the local setter.'''
self._modify_links(links=self, is_delta=False, new_links=links, links_to_remove={}, writer_name=writer_name) self._modify_links(is_delta=False, new_links=links, links_to_remove={}, writer_name=writer_name)
self._replace_links( links=links ) self._replace_links( links=links )
def get_links(self, type): def get_links(self, type):
return set(self._links[type]) return set(self._links[type])
...@@ -300,7 +300,7 @@ class IU(IUInterface):#{{{ ...@@ -300,7 +300,7 @@ class IU(IUInterface):#{{{
self.revision_lock = threading.RLock() self.revision_lock = threading.RLock()
self._payload = Payload(iu=self) self._payload = Payload(iu=self)
def _modify_links(self, links, is_delta=False, new_links={}, links_to_remove={}, writer_name=None): def _modify_links(self, is_delta=False, new_links={}, links_to_remove={}, writer_name=None):
if self.committed: if self.committed:
raise IUCommittedError(self) raise IUCommittedError(self)
with self.revision_lock: with self.revision_lock:
...@@ -412,7 +412,7 @@ class RemotePushIU(IUInterface):#{{{ ...@@ -412,7 +412,7 @@ class RemotePushIU(IUInterface):#{{{
self._payload = Payload(iu=self, new_payload=payload, omit_init_update_message=True) self._payload = Payload(iu=self, new_payload=payload, omit_init_update_message=True)
self._links = links self._links = links
def _modify_links(self, links, is_delta=False, new_links={}, links_to_remove={}, writer_name=None): def _modify_links(self, is_delta=False, new_links={}, links_to_remove={}, writer_name=None):
"""Modify the links: add or remove item from this payload remotely and send update.""" """Modify the links: add or remove item from this payload remotely and send update."""
if self.committed: if self.committed:
raise IUCommittedError(self) raise IUCommittedError(self)
......
...@@ -66,6 +66,7 @@ class Sender(object): ...@@ -66,6 +66,7 @@ class Sender(object):
def __init__(self, send_frequency): def __init__(self, send_frequency):
self.ob = ipaaca.OutputBuffer('PowerOut') self.ob = ipaaca.OutputBuffer('PowerOut')
self.iu = ipaaca.IU('spam') self.iu = ipaaca.IU('spam')
self.data_prefix='A'*1024;
self.iu.payload = {'data':'0'} self.iu.payload = {'data':'0'}
self.ob.add(self.iu) self.ob.add(self.iu)
self.counter = 0 self.counter = 0
...@@ -79,6 +80,17 @@ class Sender(object): ...@@ -79,6 +80,17 @@ class Sender(object):
time.sleep(self.delay) time.sleep(self.delay)
self.counter += 1 self.counter += 1
self.iu.payload['data'] = str(self.counter) self.iu.payload['data'] = str(self.counter)
#self.iu.payload = {
# 'data':self.data_prefix,
# 'data2':self.data_prefix,
# 'data3':self.data_prefix,
# 'data4':self.data_prefix,
# 'data5':self.data_prefix,
# 'data6':self.data_prefix,
# 'data7':self.data_prefix,
# 'data8':self.data_prefix,
# 'data9':self.data_prefix,
# }
if self.counter == 1000: if self.counter == 1000:
print "Sent 1k updates at", int(1000.0/(time.time()-last_time)),"Hz" print "Sent 1k updates at", int(1000.0/(time.time()-last_time)),"Hz"
last_time = time.time() last_time = time.time()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment