# ex: set ro:
# DO NOT EDIT.
# generated by smc (http://smc.sourceforge.net/)
# from file : AppClass.sm

import statemap


class AppClassState(statemap.State):

    def Entry(self, fsm):
        pass

    def Exit(self, fsm):
        pass

    def EOS(self, fsm):
        self.Default(fsm)

    def One(self, fsm):
        self.Default(fsm)

    def Unknown(self, fsm):
        self.Default(fsm)

    def Zero(self, fsm):
        self.Default(fsm)

    def Default(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write('TRANSITION   : Default\n')
        msg = "\n\tState: %s\n\tTransition: %s" % (
            fsm.getState().getName(), fsm.getTransition())
        raise statemap.TransitionUndefinedException(msg)

class Map1_Default(AppClassState):

    def Unknown(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Default\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Default.Unknown()\n")

        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("EXIT TRANSITION : Map1.Default.Unknown()\n")

        fsm.setState(Map1.Error)
        fsm.getState().Entry(fsm)


class Map1_Start(Map1_Default):

    def EOS(self, fsm):
        ctxt = fsm.getOwner()
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Start\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Start.EOS()\n")

        fsm.clearState()
        try:
            ctxt.Acceptable()
        finally:
            if fsm.getDebugFlag() == True:
                fsm.getDebugStream().write("EXIT TRANSITION : Map1.Start.EOS()\n")

            fsm.setState(Map1.OK)
            fsm.getState().Entry(fsm)


    def One(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Start\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Start.One()\n")

        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("EXIT TRANSITION : Map1.Start.One()\n")

        fsm.setState(Map1.Ones)
        fsm.getState().Entry(fsm)


    def Zero(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Start\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Start.Zero()\n")

        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("EXIT TRANSITION : Map1.Start.Zero()\n")

        fsm.setState(Map1.Zeros)
        fsm.getState().Entry(fsm)


class Map1_Zeros(Map1_Default):

    def EOS(self, fsm):
        ctxt = fsm.getOwner()
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Zeros\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Zeros.EOS()\n")

        fsm.clearState()
        try:
            ctxt.Acceptable()
        finally:
            if fsm.getDebugFlag() == True:
                fsm.getDebugStream().write("EXIT TRANSITION : Map1.Zeros.EOS()\n")

            fsm.setState(Map1.OK)
            fsm.getState().Entry(fsm)


    def One(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Zeros\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Zeros.One()\n")

        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("EXIT TRANSITION : Map1.Zeros.One()\n")

        fsm.setState(Map1.Ones)
        fsm.getState().Entry(fsm)


    def Zero(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Zeros\n")



class Map1_Ones(Map1_Default):

    def EOS(self, fsm):
        ctxt = fsm.getOwner()
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Ones\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Ones.EOS()\n")

        fsm.clearState()
        try:
            ctxt.Acceptable()
        finally:
            if fsm.getDebugFlag() == True:
                fsm.getDebugStream().write("EXIT TRANSITION : Map1.Ones.EOS()\n")

            fsm.setState(Map1.OK)
            fsm.getState().Entry(fsm)


    def One(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Ones\n")



    def Zero(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Ones\n")

        fsm.getState().Exit(fsm)
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Ones.Zero()\n")

        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("EXIT TRANSITION : Map1.Ones.Zero()\n")

        fsm.setState(Map1.Error)
        fsm.getState().Entry(fsm)


class Map1_OK(Map1_Default):
    pass

class Map1_Error(Map1_Default):

    def EOS(self, fsm):
        ctxt = fsm.getOwner()
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Error\n")

        endState = fsm.getState()
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("ENTER TRANSITION: Map1.Error.EOS()\n")

        fsm.clearState()
        try:
            ctxt.Unacceptable()
        finally:
            if fsm.getDebugFlag() == True:
                fsm.getDebugStream().write("EXIT TRANSITION : Map1.Error.EOS()\n")

            fsm.setState(endState)


    def One(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Error\n")



    def Unknown(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Error\n")



    def Zero(self, fsm):
        if fsm.getDebugFlag() == True:
            fsm.getDebugStream().write("LEAVING STATE   : Map1.Error\n")



class Map1(object):

    Start = Map1_Start('Map1.Start', 0)
    Zeros = Map1_Zeros('Map1.Zeros', 1)
    Ones = Map1_Ones('Map1.Ones', 2)
    OK = Map1_OK('Map1.OK', 3)
    Error = Map1_Error('Map1.Error', 4)
    Default = Map1_Default('Map1.Default', -1)

class AppClass_sm(statemap.FSMContext):

    def __init__(self, owner):
        statemap.FSMContext.__init__(self, Map1.Start)
        self._owner = owner

    def __getattr__(self, attrib):
        def trans_sm(*arglist):
            self._transition = attrib
            getattr(self.getState(), attrib)(self, *arglist)
            self._transition = None
        return trans_sm

    def enterStartState(self):
        self._state.Entry(self)

    def getOwner(self):
        return self._owner

# Local variables:
#  buffer-read-only: t
# End:
