iots.py 2.25 KB
Newer Older
Michele's avatar
Michele committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright (c) 2015 Michele Volpato
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

21
22
23
24
import os,sys,inspect
# Include project dir in path
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
25
sys.path.append(parentdir)
26
27
print(parentdir)
from systems.implementations import InputOutputLTS
28
29


Michele's avatar
Michele committed
30
31
inputs = set([1,2])
outputs = set(['a','b'])
32
33
34
35
36
37
38
39
40
quiescence = 'delta'

I3 = InputOutputLTS(2, inputs, outputs, quiescence)

I3.addTransition(1,1,0)
I3.addTransition(1,2,0)
I3.addTransition(0,1,0)
I3.addTransition(0,2,1)

Michele's avatar
Michele committed
41
42
inputs = set([1,'c'])
outputs = set(['a','b'])
43
44
45
46
47
48
49
quiescence = 'delta'

I4 = InputOutputLTS(3, inputs, outputs, quiescence)
I4.isInputEnabled()
I4.move(2)
I3.isInputEnabled()

50

Michele's avatar
Michele committed
51
52
inputs = set(['a','b'])
outputs = set(['x','y'])
53
quiescence = 'delta'
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
I1=InputOutputLTS(8, inputs, outputs, quiescence)
I1.addTransition(0,'a',1)
I1.addTransition(0,'a',2)
I1.addTransition(0,'b',0)
I1.addTransition(1,'a',0)
I1.addTransition(1,'b',3)
I1.addTransition(2,'a',0)
I1.addTransition(2,'b',3)
I1.addTransition(2,'x',4)
I1.addTransition(3,'a',0)
I1.addTransition(3,'x',4)
I1.addTransition(3,'b',3)
I1.addTransition(4,'y',2)
I1.addTransition(4,'b',4)
I1.addTransition(4,'a',0)

I1.move('a')
72
73
print(I1.currentState())
I1.isInputEnabled()