Skip to content

Commit

Permalink
fixed bug in FSM behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
javipalanca committed Jun 9, 2017
1 parent eabe807 commit a9f0bd9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 33 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

SPADE (Smart Python multi-Agent Development Environment) is a Multiagent and Organizations Platform based on the <a href="http://www.xmpp.org">XMPP/Jabber technology</a> and written in the <a href="http://www.python.org">Python</a> programming language. This technology offers by itself many features and facilities that ease the construction of MAS, such as an existing communication channel, the concepts of users (agents) and servers (platforms) and an extensible communication protocol based on XML, just like <a href="http://www.fipa.org">FIPA-ACL</a>. Many other agent platforms exist, but SPADE is the first to base its roots on the XMPP technology.

<img src="http://spade2.googlecode.com/files/spade_overview.png" height=420px/>

# User Documentation

Expand Down
14 changes: 5 additions & 9 deletions examples/fsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@ class StateFour(spade.Behaviour.OneShotBehaviour):
def _process(self):
print "This is State Four..."
self.myAgent.counter = self.myAgent.counter + 1
if self.myAgent.counter > 11:
print "Counter ", self.myAgent.counter
print "Bye Bye"
self.myAgent._kill()
else:
self._exitcode = self.myAgent.TRANSITION_DEFAULT

print "Counter ", self.myAgent.counter
print "Bye Bye"
self.myAgent._kill()

def _setup(self):
time.sleep(2)
print "AdvancedAgent starting . . ."
Expand Down Expand Up @@ -81,8 +78,7 @@ def _setup(self):
b.registerTransition(self.STATE_TWO_CODE, self.STATE_THREE_CODE, self.TRANSITION_TO_THREE)
b.registerTransition(self.STATE_THREE_CODE, self.STATE_THREE_CODE, self.TRANSITION_DEFAULT)
b.registerTransition(self.STATE_THREE_CODE, self.STATE_FOUR_CODE, self.TRANSITION_TO_FOUR)
b.registerTransition(self.STATE_FOUR_CODE, self.STATE_FOUR_CODE, self.TRANSITION_DEFAULT)


self.addBehaviour(b, None)

if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions runspade.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from xmppd.xmppd import Server

__author__ = "Gustavo Aranda <gusarba@gmail.com> and Javier Palanca <jpalanca@gmail.com>"
__version__ = "2.2"
__copyright__ = "Copyright (C) 2006-2012"
__version__ = "2.3"
__copyright__ = "Copyright (C) 2006-2017"
__license__ = "LGPL"


Expand All @@ -43,7 +43,7 @@ def print_help():

def print_version():
print "SPADE " + colors.color_yellow + __version__ + colors.color_none + " by Javier Palanca, Gustavo Aranda, Miguel Escriva and others"
print "gusarba@gmail.com - http://spade2.googlecode.com"
print "jpalanca@gmail.com - https://github.com/javipalanca/SPADE"
raise SystemExit

# Actually start the program running.
Expand Down Expand Up @@ -90,7 +90,7 @@ def main():
except:
pass

print "SPADE ", colors.color_yellow + __version__ + colors.color_none, " <gusarba@gmail.com> - http://spade2.googlecode.com"
print "SPADE ", colors.color_yellow + __version__ + colors.color_none, " <jpalanca@gmail.com> - https://github.com/javipalanca/SPADE"

try:
import psyco
Expand Down
13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/usr/bin/env python
import os
import sys
import subprocess
#from distutils.core import setup, Extension
from setuptools import setup, Extension
import glob

from runspade import __version__

#if os.name != "posix":
# import py2exe
try:
import bdist_mpkg
except:
Expand All @@ -31,16 +26,16 @@
"SPARQLWrapper",
"unittest-xml-reporting"]
if subprocess.mswindows:
deps.append( 'pywin32' )
deps.append( 'pywin32' )

setup(name='SPADE',
version=__version__,
license="LGPL",
description='Smart Python multi-Agent Development Environment',
long_description=long_description,
author='Javier Palanca, Gustavo Aranda, Miguel Escriva',
author='Javier Palanca, Gustavo Aranda, Miguel Escriva and others',
author_email='jpalanca@gmail.com',
url='http://spade2.googlecode.com',
url='https://github.com/javipalanca/SPADE',
package_dir={'spade': 'spade'},
packages=['spade','spade.mtps', 'xmpp', 'xmppd', 'xmppd.modules', 'xmppd.socker', 'tlslite', 'tlslite.utils', 'tlslite.integration'],
scripts=['runspade.py','configure.py'],#,"tlslite/scripts/tls.py", "tlslite/scripts/tlsdb.py"],
Expand All @@ -61,5 +56,3 @@
],
install_requires = deps
)


13 changes: 5 additions & 8 deletions spade/Behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,17 +776,14 @@ def _transitionTo(self, newState):
pass

def _process(self):
if (self._actualState is None):
if self._actualState is None:
self._transitionTo(self._firstStateName)
#msg = self._receive(False)
b = self._states[self._actualState]
#if msg: buede .postMessage(msg)
self._lastexitcode = b._process()
if (b.done() or b._forceKill.isSet()):
if not self._lastexitcode:
self._lastexitcode = b.exitCode()
self._transitionTo(self._transitions[b._stateName][self._lastexitcode])
self._lastexitcode = None
if not self._lastexitcode:
self._lastexitcode = b.exitCode()
self._transitionTo(self._transitions[b._stateName][self._lastexitcode])
self._lastexitcode = None

def getCurrentState(self):
return self._states[self._actualState]
Expand Down
2 changes: 1 addition & 1 deletion spade/templates/messages.pyra
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ header.pyra
</script>

<!-- Diagrams using a external service. Replaced by sequence-diagram.js-->
<!--><div class=wsd wsd_style="napkin"><pre>
<!--<div class=wsd wsd_style="napkin"><pre>
@!diagram!@
</pre></div><script type="text/javascript" src="http://www.websequencediagrams.com/service.js"></script>
-->
Expand Down

0 comments on commit a9f0bd9

Please sign in to comment.