Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mad #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified pymodel/ActionNameCoverage.py
100644 → 100755
Empty file.
Empty file modified pymodel/Analyzer.py
100644 → 100755
Empty file.
Empty file modified pymodel/AnalyzerOptions.py
100644 → 100755
Empty file.
Empty file modified pymodel/Dot.py
100644 → 100755
Empty file.
Empty file modified pymodel/FSM.py
100644 → 100755
Empty file.
Empty file modified pymodel/GraphicsOptions.py
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions pymodel/ModelProgram.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import inspect
import itertools
from pymodel.model import Model
import collections
import collections, collections.abc
import pprint

DEBUG = False
Expand Down Expand Up @@ -69,15 +69,15 @@ def make_argslist(self, a):
"""
Parameter generator: return list of all args combos for action symbol a
"""
arginfo = inspect.getargspec(a)# ArgInfo(args,varargs,keywords,locals)
arginfo = inspect.getfullargspec(a)# ArgInfo(args,varargs,keywords,locals)
if arginfo[0]:
args = arginfo[0] # usual case: fixed sequence of positional arguments
elif arginfo[1]:
args = [arginfo[1]] # special case: either no arg, or one exception arg
else:
args = () # no arguments anywhere, args must have this value
domains = [ self.module.domains[a][arg]() # evaluate state-dependent domain
if isinstance(self.module.domains[a][arg], collections.Callable)
if isinstance(self.module.domains[a][arg], collections.abc.Callable)
else self.module.domains[a][arg] # look up static domain
for arg in args if a in self.module.domains ]
combination = self.module.combinations.get(a, 'all') # default is 'all'
Expand Down Expand Up @@ -125,7 +125,7 @@ def ActionEnabled(self, a, args):
else:
# Assumes enablers[a] has only one item, always true in this version
a_enabled = self.module.enablers[a][0]
nparams = len(inspect.getargspec(a_enabled)[0])
nparams = len(inspect.getfullargspec(a_enabled)[0])
nargs = len(args)
# nparams == 0 means match any args
if nparams > 0 and nparams != nargs:
Expand Down
560 changes: 282 additions & 278 deletions pymodel/ProductModelProgram.py
100644 → 100755

Large diffs are not rendered by default.

Empty file modified pymodel/README.md
100644 → 100755
Empty file.
Empty file modified pymodel/StateCoverage.py
100644 → 100755
Empty file.
Empty file modified pymodel/TestSuite.py
100644 → 100755
Empty file.
Empty file modified pymodel/TesterOptions.py
100644 → 100755
Empty file.
Empty file modified pymodel/ViewerOptions.py
100644 → 100755
Empty file.
Empty file modified pymodel/__init__.py
100644 → 100755
Empty file.
Empty file modified pymodel/model.py
100644 → 100755
Empty file.
Empty file modified pymodel/observation_queue.py
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion pymodel/pmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
"""
PyModel Graphics - generate graphics from pymodel FSM
"""
import os.path

from pymodel import GraphicsOptions
from pymodel.Dot import dotfile
import importlib
import sys

def main():
(options, args) = GraphicsOptions.parse_args()
if not args or len(args) > 2: # args must include one FSM module
GraphicsOptions.print_help()
exit()
else:
fsm = __import__(args[0])
sys.path.append(os.path.dirname(os.path.abspath(args[0])))
fsm = importlib.import_module(args[0])
fbasename = options.output if options.output else args[0]
fname = '%s.dot' % fbasename
dotfile(fname, fsm, options.transitionLabels, options.noStateTooltip,
Expand Down
4 changes: 3 additions & 1 deletion pymodel/trun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import os
import importlib

# argv[1] is name of module containing test cases
# dir containing this module must be on PYTHONPATH
Expand All @@ -11,7 +12,8 @@
sys.exit()

try:
test = __import__(sys.argv[1])
sys.path.append(os.path.curdir)
test = importlib.import_module(sys.argv[1])
except ModuleNotFoundError:
print('\nCould not find tests file "{}".\n\n'.format(sys.argv[1]))
sys.exit()
Expand Down
Empty file modified pymodel/wsgidemo.py
100644 → 100755
Empty file.
33 changes: 33 additions & 0 deletions samples/PowerSwitch/SpeedControlFSM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# pma SpeedControl
# 3 states, 3 transitions, 1 accepting states, 0 unsafe states, 0 finished and 0 deadend states

# actions here are just labels, but must be symbols with __name__ attribute

def IncrementSpeed(): pass

# states, key of each state here is its number in graph etc. below

states = {
0 : {'SpeedControl': 0},
1 : {'SpeedControl': 1},
2 : {'SpeedControl': 2},
}

# initial state, accepting states, unsafe states, frontier states, deadend states

initial = 0
accepting = [0]
unsafe = []
frontier = []
finished = []
deadend = []
runstarts = [0]

# finite state machine, list of tuples: (current, (action, args, result), next)

graph = (
(0, (IncrementSpeed, (), None), 1),
(1, (IncrementSpeed, (), None), 2),
(2, (IncrementSpeed, (), None), 0),
)