from fsa_fsa_weaved_classes import FSAState
from fsaclasses import FSAModel, Transition, Event, State, After, AtomValue

class SampleFSA_A(FSAModel):
    def __init__(self):
        x = State("x")
        y = State("y")
        z = State("z", final=True)
        
        x2y = Transition("x2y", x, y)
        y2z = Transition("y2z", y, z)
        
        x2y.trigger = After(AtomValue(2.0))
        y2z.trigger = Event("e2")
        
        self.states = [
                       x,
                       y,
                       z
                       ]
        
        self.initialState = x
        
        self.transitions = [
                            x2y,
                            y2z
                            ]

class SampleFSA_B(FSAModel):
    def __init__(self):
        x = State("x")
        y = State("y")
        z = State("z")
        
        x2y = Transition("x2y", x, y)
        z2y = Transition("z2y", z, y)
        
        x2y.trigger = Event("e1")
        z2y.trigger = After(AtomValue(2.0))
        
        self.states = [
                       x,
                       y,
                       z
                       ]
        
        self.initialState = x
        
        self.transitions = [
                            x2y,
                            z2y
                            ]


class TopLevelFSA(FSAModel):
    def __init__(self):
        a = FSAState("a", SampleFSA_A())
        b = FSAState("b", SampleFSA_B())
        c = State("c", final=True)
        
        a2b = Transition("a2b", a, b)
        b2c = Transition("b2c", b, c)
        
        a2b.trigger = Event("e2")
        b2c.trigger = After(AtomValue(10.0))
        
        self.states = [
                       a,
                       b,
                       c
                       ]
        
        self.initialState = a
        
        self.transitions = [
                            a2b,
                            b2c
                            ]