当前位置: 首页>>代码示例>>Python>>正文


Python Machine.__init__方法代码示例

本文整理汇总了Python中transitions.Machine.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.__init__方法的具体用法?Python Machine.__init__怎么用?Python Machine.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在transitions.Machine的用法示例。


在下文中一共展示了Machine.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self):
        # Define the different states of the state machine
        states = ['secure', 'takeoff', 'follow', 'take_picture', \
                  'land', 'reacquisition', 'emergency']

        # Define the transitions between states
        # FORMAT: ['trigger_event', 'source_state', 'destination_state']
        transitions = [
            ['takeoff_command', 'secure', 'takeoff'],
            ['takeoff_alt_reached', 'takeoff', 'follow'],
            ['picture_command', 'follow', 'take_picture'],
            ['picture_taken', 'take_picture', 'land'],
            ['land_alt_reached', 'land', 'secure'],
            ['emergency_condition', ['takeoff', 'follow', 'take_picture', 'land'], 'emergency'],
            ['takeoff_tag_lost', 'takeoff', 'reacquisition'],
            ['follow_tag_lost', 'follow', 'reacquisition'],
            ['land_tag_lost', 'land', 'reacquisition'],
            ['take_picture_tag_lost', 'take_picture', 'reacquisition'],
            ['takeoff_tag_found', 'reacquisition', 'takeoff'],
            ['follow_tag_found', 'reacquisition', 'follow'],
            ['land_tag_found', 'reacquisition', 'land'],
            ['take_picture_tag_found', 'reacquisition', 'take_picture'],
            ['timed_out', 'reacquisition', 'emergency'],
            ['reset', 'emergency', 'secure']
        ]

        Machine.__init__(self, states=states, transitions=transitions, \
                         initial='secure')
开发者ID:CSULAQuadcopter,项目名称:eagle_one_test,代码行数:30,代码来源:StateMachine.py

示例2: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self, manifold):
        self.manifold = manifold
        self.gui = None

        # Record controller states
        states = [
            State(name='disconnected',  on_enter=['unbusyUI', 'updateUI']),
            State(name='connected',     on_enter=['unbusyUI', 'updateUI']),
            State(name='confirmed',     on_enter=['unbusyUI', 'updateUI']),
            State(name='ready',         on_enter=['unbusyUI', 'updateUI', 'prepRecording']),
            State(name='started',       on_enter=['unbusyUI', 'updateUI', 'startRecording']),
            State(name='paused',        on_enter=['unbusyUI', 'updateUI', 'pauseRecording'])
        ]

        # Record controller state transition definition
        transitions = [
            {'trigger': 'connect',    'source': 'disconnected', 'dest': 'connected'    , 'prepare': ['busyUI', 'connectToServers', 'pingServers'], 'conditions': 'connection_confirmed'},
            {'trigger': 'disconnect', 'source': 'connected',    'dest': 'disconnected' , 'prepare': ['busyUI'] },
            {'trigger': 'disconnect', 'source': 'paused',       'dest': 'disconnected' , 'prepare': ['busyUI'] },
            {'trigger': 'new',        'source': 'connected',    'dest': 'ready'        , 'prepare': ['busyUI'] },
            {'trigger': 'new',        'source': 'paused',       'dest': 'ready'        , 'prepare': ['busyUI'] },
            {'trigger': 'start',      'source': 'ready',        'dest': 'started'      , 'prepare': ['busyUI'] },
            {'trigger': 'pause',      'source': 'started',      'dest': 'paused'       , 'prepare': ['busyUI'] },
        ]

        # Record machine
        Machine.__init__(self,
                         states=states,
                         transitions=transitions,
                         initial='disconnected')
开发者ID:jonnew,项目名称:stupidctrl,代码行数:32,代码来源:recordsm.py

示例3: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self):
        states = ['wait',
                  'in_trial',
                  'post_trial',
                  'done']
        
        transitions = [
            {'source': 'wait',
             'trigger': 'step',
             'conditions': 'check_for_space',
             'after': 'remove_text',
             'dest': 'in_trial'},

            {'source': 'in_trial',
             'trigger': 'step',
             'prepare': ['update_target_pos', 'update_target_color_and_count'],
             'conditions': 'samples_exhausted',
             'after': ['draw_time_on_target', 'start_countdown'],
             'dest': 'post_trial'},
            
            {'source': 'post_trial',
             'trigger': 'step',
             'conditions': 'time_elapsed',
             'dest': 'done'}
        ]
        Machine.__init__(self, states=states,
                         transitions=transitions, initial='wait')
开发者ID:aforren1,项目名称:isotrack,代码行数:29,代码来源:state_dec.py

示例4: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
 def __init__(self):
     self.states = [
         {'name': 'Begin'},         #
         {'name': 'End'},           #
         {'name': 'ChoosePage'},    #
         {'name': 'FirstPage'},     #
         {'name': 'SecondPage'},    #
         {'name': 'Error'}          #
     ]
     self.transitions = [
         {'trigger': 'step', 'source': 'Begin',      'dest': 'ChoosePage'},
         {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'FirstPage',  'conditions': ['verify', 'answerIsOne'], 'after': 'to_ChoosePage'},
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'Error',  'after': 'err'},
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'FirstPage',  'conditions': 'verify', 'after': 'to_ChoosePage'},
         {'trigger': 'step', 'source': 'FirstPage',  'dest': 'ChoosePage'},
         # {'trigger': 'step', 'source': 'FirstPage',  'dest': 'Error',  'after': 'err'},
         {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'SecondPage', 'conditions': ['verify', 'answerIsTwo'], 'after': 'to_ChoosePage'},
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'SecondPage', 'conditions': 'verify', 'after': 'to_ChoosePage'},
         {'trigger': 'step', 'source': 'SecondPage', 'dest': 'ChoosePage'},
         {'trigger': 'step', 'source': 'SecondPage', 'dest': 'Error',  'after': 'err'},
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'End',        'conditions': ['verify', 'answerIsThree']},
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'End',        'conditions': 'verify'}
         # {'trigger': 'step', 'source': 'ChoosePage', 'dest': 'End'},
         {'trigger': 'step', 'source': '*', 'dest': 'End'}
     ]
     Machine.__init__(self, states=self.states, transitions=self.transitions,
                      initial='Begin', send_event=True)
     self.pageNumber = None
     self.answer = None
开发者ID:niimailtah,项目名称:Euphoria,代码行数:31,代码来源:rule.py

示例5: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self):


        states=['chitchat',
                'requestingRide', 'offeringRide',
                'sendingLocation','sendingDestination',
                'waiting',
                'matchFound','nomatchFound',
                'completed']
            
        transitions = [
            { 'trigger': 'abort', 'source': '*', 'dest': 'chitchat'},
            { 'trigger': 'wantRide', 'source': 'chitchat', 'dest': 'requestingRide'},
            { 'trigger': 'offerRide', 'source': 'chitchat', 'dest': 'offeringRide'},
            { 'trigger': 'hasToSendLocation', 'source': 'requestingRide', 'dest': 'sendingLocation'},
            { 'trigger': 'hasToSendLocation', 'source': 'offeringRide', 'dest': 'sendingLocation' },
            { 'trigger': 'hasToSendDestination', 'source': 'sendingLocation', 'dest': 'sendingDestination' },
            { 'trigger': 'gotPosition', 'source': 'sendingDestination', 'dest': 'waiting'},
            { 'trigger': 'OK', 'source': 'waiting', 'dest': 'matchFound' },
            { 'trigger': 'sorry', 'source': 'waiting', 'dest': 'nomatchFound' },
            { 'trigger': 'done', 'source': 'matchFound', 'dest': 'completed' },
            { 'trigger': 'done', 'source': 'nomatchFound', 'dest': 'completed' },
            { 'trigger': 'end', 'source': 'completed', 'dest': 'chitchat' },
            ]
        Machine.__init__(self, states=states, transitions=transitions,auto_transitions=False,initial='chitchat')
开发者ID:anbasile,项目名称:pmu,代码行数:27,代码来源:fsm.py

示例6: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self):
        state = ['Up', 'Failed', 'Maintenance', 'Blocked']
        Machine.__init__(self, states = state, initial='Up')
        self.add_transition('start', 'Up', 'Up', after = "startJob")
        self.add_transition('fail', 'Up', 'Failed', after = 'startFail')
        self.add_transition('repair', 'Failed', 'Up', after = 'rep')
        self.add_transition('maint', 'Up', 'Maintenance', after='startmaint')
        self.add_transition('maintcpl', 'Maintenance', 'Up')
        self.add_transition('interrep', 'Failed', 'Maintenance', after='startmaint')
        self.add_transition('block', 'Up', 'Blocked')
        self.add_transition('unblock', 'Blocked', 'Up')
        self.queue = SortedSet(key = lambda job: job.arrivalTime)
        self.numServers = 1
        self.busyServers = 0
        self.prevState = None
        Server._ids +=1
        self.serviceTimeDistribution = None
        self.name = "Server {}".format(Server._ids)
        self.In = None
        self.Out = None
        self.scheduler = None
        self.activejob = None
        self.interuptjob = None

        #debugging
        self.jobsarrived = 0
        self.jobsprocessed = 0
        self.numfailures = 0
        self.nummaint = 0
        self.onzin = 0
开发者ID:allardneijmeijer,项目名称:Master-Thesis,代码行数:32,代码来源:mm1sfm.py

示例7: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
 def __init__(self):
     self.states = [
         {'name': 'Begin'},         #
         {'name': 'End'},           #
         {'name': 'Error'}          #
     ]
     self.transitions = [
         {'trigger': 'step', 'source': 'Begin',      'dest': 'End'}
     ]
     Machine.__init__(self, states=self.states, transitions=self.transitions,
                      initial='Begin', send_event=True)
     self.answer = None
开发者ID:niimailtah,项目名称:Euphoria,代码行数:14,代码来源:exchange.py

示例8: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
 def __init__(self, tracker, blob):
     Machine.__init__(self, states=BlobTracker.States, initial='hypothesis')
     self.blob = None
     self.age = 1
     self.tracker = tracker
     self.kalman = cv2.KalmanFilter(4, 2, 0)
     self.setup_kalman(blob.centroid)
     self._ocr = PlateDetector.Instance()
     r = lambda: random.randint(0,255)
     self.color = (r(),r(),r())
     self.id = BlobTracker.id
     BlobTracker.id += 1
     self.code = None
     self.best_image = None
     self._addblob(blob)
开发者ID:MirichST,项目名称:patchcap,代码行数:17,代码来源:track.py

示例9: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Machine.__init__(self, *args, **kwargs)

        if len(self.states) < 2:
            raise ValueError('OrderedStateMachine must be defined at constuction time')

        def add_transition(_from,_to):
            self.add_transition('%s_to_%s' % (_from,_to), _from, _to)

        #auto define transitions between states
        state_names = self.states.keys()
        for states in pairwise(state_names):
            add_transition(*states)
        #add a transition from the last to the initial state
        add_transition(state_names[-1], self._initial)
        #add a transition from the last to the first non-initial state
        add_transition(state_names[-1],[s for s in state_names if s != self._initial][0])
开发者ID:peterpolidoro,项目名称:flymad,代码行数:19,代码来源:dorothea.py

示例10: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self, service, maxqueue, mtbf, mttr, mInt, mTime, stoch):
        super().__init__()

        # initialize state machine
        state = ['Up', 'Failed', 'Maintenance', 'Blocked']
        Machine.__init__(self, states=state, initial='Up')
        self.add_transition('start', 'Up', 'Up', after='start_job')
        self.add_transition('fail', 'Up', 'Failed', after='start_fail')
        self.add_transition('repair', 'Failed', 'Up', after='rep')
        self.add_transition('maintain', 'Up', 'Maintenance', after='start_maint')
        self.add_transition('maintcpl', 'Maintenance', 'Up', after='stop_maint')
        self.add_transition('interrep', 'Failed', 'Maintenance', after='start_maint')
        self.add_transition('block', 'Up', 'Blocked')
        self.add_transition('unblock', 'Blocked', 'Up')

        # initialize all kind of variables
        self.queue = Queue(maxqueue)
        self.numServers = 1
        self.busyServers = 0
        self.mtbf = mtbf
        self.mttr = mttr
        self.maintInt = mInt
        self.maintTime = mTime
        self.serviceTimeDistribution = service
        self.blocked = False
        Server.stochastic = stoch

        Server._ids += 1
        self.name = 'Server {}'.format(Server._ids)
        self.In, self.Out, self.scheduler, self.activejob, self.interuptjob = None, None, None, None, None
        self.blocked = False

        # logging variables
        self.jobsarrived = 0
        self.jobsprocessed = 0
        self.jobsprocessed = 0
        self.numfailures = 0
        self.numMaint = 0
        self.ctime = []
        self.logging = []
        self.idletime = 0
        self.previdle = 0
        self.startidle = 0
开发者ID:allardneijmeijer,项目名称:Master-Thesis,代码行数:45,代码来源:simulator.py

示例11: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
 def __init__(self):
     self.states = [
         {'name': 'Begin'},             #
         {'name': 'Node1'},             # after VizirMessage before CaravanProfit
         {'name': 'Node2'},             # after CaravanProfit before Crisis/Exchange
         {'name': 'Node3'},             # after Crisis/Exchange before CaravanSupply
         {'name': 'Node4'},             # after CaravanSupply before CaravanRob
         {'name': 'Node5'},             # after CaravanRob before Metropolitan
         {'name': 'Node6'},             # after Metropolitan before War
         {'name': 'Node7'},             # after War before VizirCatch
         {'name': 'Node8'},             # after VizirCatch before Inheritance
         {'name': 'Node9'},             # after Inheritance before ...
         {'name': 'End'},               #
         {'name': 'Intro'},             #
         {'name': 'MainMenu'},          #
         {'name': 'Rules'},             #
         {'name': 'NewGame'},           #
         {'name': 'StartTurn'},         #
         {'name': 'PrintState'},        #
         {'name': 'VizirMessage'},      #
         {'name': 'CaravanProfit'},     #
         {'name': 'Crisis'},            #
         {'name': 'Exchange'},          #
         {'name': 'CaravanSupply'},     #
         {'name': 'CaravanRob'},        #
         {'name': 'Metropolitan'},      #
         {'name': 'War'},               #
         {'name': 'VizirCatch'},        #
         {'name': 'Inheritance'},       #
         {'name': 'ChildBirthDay'},     #
         {'name': 'Marriage'},          #
         {'name': 'WifeDead'},          #
         {'name': 'WifeIn'},            #
         {'name': 'Sickness'},          #
         {'name': 'GiveGrain'},         #
         {'name': 'MakeTurn'},          #
         {'name': 'NextYear'},          #
         {'name': 'NYParty'},           #
         {'name': 'EndTurn'},           #
         {'name': 'EndGame'}            #
     ]
     self.transitions = [
         {'trigger': 'step', 'source': 'Begin', 'dest': 'Intro'},
         {'trigger': 'step', 'source': 'Intro', 'dest': 'MainMenu'},
         {'trigger': 'step', 'source': 'MainMenu', 'dest': 'Rules', 'conditions': 'answerIsTwo'},
         {'trigger': 'step', 'source': 'Rules', 'dest': 'MainMenu'},
         {'trigger': 'step', 'source': 'MainMenu', 'dest': 'End', 'conditions': 'answerIsThree'},
         {'trigger': 'step', 'source': 'MainMenu', 'dest': 'NewGame', 'conditions': 'answerIsOne'},
         {'trigger': 'step', 'source': 'NewGame', 'dest': 'PrintState'},
         {'trigger': 'step', 'source': 'PrintState', 'dest': 'VizirMessage', 'unless': 'isFirstYear'},
         {'trigger': 'step', 'source': 'PrintState', 'dest': 'Node1'},
         {'trigger': 'step', 'source': 'VizirMessage', 'dest': 'Node1'},
         {'trigger': 'step', 'source': 'Node1', 'dest': 'CaravanProfit', 'conditions': 'is5YearCaravan'},
         {'trigger': 'step', 'source': 'Node1', 'dest': 'Node2'},
         {'trigger': 'step', 'source': 'CaravanProfit', 'dest': 'Node2', 'before': 'update_random'},
         {'trigger': 'step', 'source': 'Node2', 'dest': 'Crisis', 'conditions': 'isCrisis'},
         {'trigger': 'step', 'source': 'Crisis', 'dest': 'Node3'},
         {'trigger': 'step', 'source': 'Node2', 'dest': 'Exchange', 'unless': 'isCrisis'},
         {'trigger': 'step', 'source': 'Exchange', 'dest': 'Node3'},
         {'trigger': 'step', 'source': 'Node3', 'dest': 'CaravanSupply', 'conditions': 'is0YearCaravan'},
         {'trigger': 'step', 'source': 'Node3', 'dest': 'Node4'},
         {'trigger': 'step', 'source': 'CaravanSupply', 'dest': 'Node4'},
         {'trigger': 'step', 'source': 'Node4', 'dest': 'CaravanRob', 'unless': 'is0YearCaravan'},
         {'trigger': 'step', 'source': 'Node4', 'dest': 'Node5'},
         {'trigger': 'step', 'source': 'CaravanRob', 'dest': 'Node5'},
         {'trigger': 'step', 'source': 'Node5', 'dest': 'Metropolitan', 'conditions': 'isReceiveMetropolitan'},
         {'trigger': 'step', 'source': 'Node5', 'dest': 'Node6'},
         {'trigger': 'step', 'source': 'Metropolitan', 'dest': 'Node6'},
         {'trigger': 'step', 'source': 'Node6', 'dest': 'War', 'conditions': 'isReasonWar'},
         {'trigger': 'step', 'source': 'Node6', 'dest': 'Node7'},
         {'trigger': 'step', 'source': 'War', 'dest': 'Node7'},
         {'trigger': 'step', 'source': 'Node7', 'dest': 'VizirCatch'},
         {'trigger': 'step', 'source': 'Node7', 'dest': 'Node8'},
         {'trigger': 'step', 'source': 'VizirCatch', 'dest': 'Node8'},
         {'trigger': 'step', 'source': 'Node8', 'dest': 'Inheritance'},
         {'trigger': 'step', 'source': 'Node8', 'dest': 'Node9'},
         {'trigger': 'step', 'source': 'Inheritance', 'dest': 'Node9'},
         {'trigger': 'step', 'source': 'Node9', 'dest': 'End'}
     ]
     Machine.__init__(self, states=self.states, transitions=self.transitions,
                      initial='Begin', send_event=True, before_state_change='update_random')
     random.seed()
     self.random_number = None
     self.answer = 0
     self.current_year = 1
开发者ID:niimailtah,项目名称:Euphoria,代码行数:87,代码来源:euphoria.py

示例12: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self, states, initial='A'):

        self.state = None

        Machine.__init__(self, states=states, initial=initial)
开发者ID:jaquinonesg,项目名称:SMA_exp,代码行数:7,代码来源:utils.py

示例13: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self, opts):
        self.cimc = opts['cimc_ip']
        self.cimc_username = opts['cimc_username']
        self.cimc_password = opts['cimc_password']
        self.apic_password = opts['apic_admin_password']
        if opts['verbose'] == "True":
            self.verbose = True
        else:
            self.verbose = False
        if opts['quiet'] == 'True':
            self.quiet = True
        else:
            self.quiet = False
        if opts['simulator'] == True:
            self.simulator = True
        else:
            self.simulator = False
        self.fabric_name = opts['fabric_name']
        self.num_controllers = opts['number_of_controllers']
        self.controller_id = opts['controller_number']
        self.controller_name = opts['controller_name']
        self.tep_address_pool = opts['tep_address_pool']
        self.infra_vlan_id = opts['infra_vlan_id']
        self.bd_mc_address_pool = opts['bd_mc_addresses']
        self.oob_ip_addr = opts['oob_ip_address']
        self.oob_def_gw = opts['oob_default_gateway']
        self.int_speed = opts['int_speed']
        self.strong_passwd = opts['strong_passwords']
        # Used to execute commands in CIMC
        self.cimc_client = None
        # Used to do things on the APIC, has to go through CIMC first of course
        self.apic_client = None
        self.cimc_interact = None
        self.provided_fabric_name = False
        self.states = [
            # Start and initialization states
            {'name': 'start'},
            {'name': 'connect_cimc', 'on_enter': 'on_enter_connect_cimc'},
            # CIMC related states
            {'name': 'check_sol', 'on_enter': 'on_enter_check_sol'},
            {'name': 'configure_sol', 'on_enter': 'on_enter_configure_sol'},
            {'name': 'disconnect_cimc', 'on_enter': 'on_enter_disconnect_cimc'},
            {'name': 'cycle_host', 'on_enter': 'on_enter_cycle_host'},
            # APIC specific initialization states
            {'name': 'connect_apic', 'on_enter': 'on_enter_connect_apic'},
            {'name': 'logout_apic', 'on_enter': 'on_enter_logout_apic'},
            {'name': 'login_apic', 'on_enter': 'on_enter_login_apic'},
            {'name': 'password_login_apic', 'on_enter': 'on_enter_password_login_apic'},
            {'name': 'eraseconfig', 'on_enter': 'on_enter_eraseconfig'},
            # Setup script related states
            {'name': 'press_any_key', 'on_enter': 'on_enter_press_any_key'},
            {'name': 'provide_fabric_name', 'on_enter': 'on_enter_provide_fabric_name'},
            {'name': 'provide_number_ctrlrs', 'on_enter': 'on_enter_provide_number_ctrlrs'},
            {'name': 'provide_ctrlr_id', 'on_enter': 'on_enter_provide_ctrlr_id'},
            {'name': 'provide_ctrlr_name', 'on_enter': 'on_enter_provide_ctrlr_name'},
            {'name': 'provide_tep_addr_pool', 'on_enter': 'on_enter_provide_tep_addr_pool'},
            {'name': 'provide_infra_vlan_id', 'on_enter': 'on_enter_provide_infra_vlan_id'},
            {'name': 'provide_bd_mc_addr_pool', 'on_enter': 'on_enter_provide_bd_mc_addr_pool'},
            {'name': 'provide_oob_address', 'on_enter': 'on_enter_provide_oob_address'},
            {'name': 'provide_oob_def_gw', 'on_enter': 'on_enter_provide_oob_def_gw'},
            {'name': 'provide_int_speed', 'on_enter': 'on_enter_provide_int_speed'},
            {'name': 'provide_strong_passwd', 'on_enter': 'on_enter_provide_strong_passwd'},
            {'name': 'provide_admin_passwd', 'on_enter': 'on_enter_provide_admin_passwd'},
            {'name': 'provide_modify_config', 'on_enter': 'on_enter_provide_modify_config'},
        ]
        Machine.__init__(self, states=self.states, initial='start')

        self.add_transition(trigger='start', source='start', dest='connect_cimc')

        self.add_transition(trigger='cimc_prompt_detected',
                            source='connect_cimc',
                            dest='check_sol')

        self.add_transition(trigger='sol_not_configured',
                            source='check_sol',
                            dest='configure_sol')

        self.add_transition(trigger='sol_config_committed',
                            source='configure_sol',
                            dest='check_sol')

        self.add_transition(trigger='cycle_host',
                            source='connect_apic',
                            dest='cycle_host')

        # We can enter the connect_apic state from multiple sources, this states
        # entry callback will need to be smarter than the average bear.
        self.add_transition(trigger='connect_to_apic',
                            source=['check_sol', 'logout_apic'],
                            dest='connect_apic')

        self.add_transition(trigger='apic_prompt_detected',
                            source='connect_apic',
                            dest='logout_apic')

        self.add_transition(trigger='apic_login_detected',
                            source=['connect_apic', 'logout_apic', 'password_login_apic',
                                    'cycle_host'],
                            dest='login_apic')

#.........这里部分代码省略.........
开发者ID:alvarojarrin,项目名称:wiper,代码行数:103,代码来源:wiper.py

示例14: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
    def __init__(self):
        self.FirstWAKE = True
        self.log = logging.getLogger('L.Machine')
        self.zoowrap = ZooWrap()
        self.novawrap = NovaWrap()
        self.mona = MonaWrap()
        states = [{
            'name': 'booting'
            }, {
            'name': 'normal',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'overload',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'overload_avoid',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'underload',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'underload_avoid',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'sleeping',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'wakeup',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }, {
            'name': 'confirmed',
            'on_enter': 'on_enter_state',
            'on_exit': 'on_exit_state'
            }
        ]
        self.states_aux = {
            'normal': {
                'res_mood': 'HIGH', 'thr': None},
            'overload': {
                'res_mood': 'NO', 'thr': None},
            'overload_avoid': {
                'res_mood': 'NO', 'thr': None},
            'underload': {
                'res_mood': 'NO', 'thr': None},
            'underload_avoid': {
                'res_mood': 'MID', 'thr': None},
            'sleeping': {
                'res_mood': 'SLEEP', 'thr': None},
            'wakeup': {
                'res_mood': 'NO', 'thr': None},
            'confirmed': {
                'res_mood': 'NO', 'thr': None}
        }
        transitions = [
            {'trigger': 'boot',
             'source': 'booting', 'dest': 'wakeup'},
            {'trigger': 'overload',
             'source': 'normal', 'dest': 'overload'},
            {'trigger': 'avoid',
             'source': 'overload', 'dest': 'overload_avoid'},
            {'trigger': 'retry',
             'source': 'overload_avoid', 'dest': 'overload'},
            {'trigger': 'underload',
             'source': 'normal', 'dest': 'underload'},
            {'trigger': 'avoid',
             'source': 'underload', 'dest': 'underload_avoid'},
            {'trigger': 'retry',
             'source': 'underload_avoid', 'dest': 'underload'},
            {'trigger': 'sleep',
             'source': 'underload', 'dest': 'sleeping'},
            {'trigger': 'wake',
             'source': 'sleeping', 'dest': 'wakeup'},
            {'trigger': 'chillout',
             'source': 'wakeup', 'dest': 'normal'},
            {'trigger': 'chillout',
             'source': 'sleeping', 'dest': 'normal'},
            {'trigger': 'confirm',
             'source': 'normal', 'dest': 'confirmed'},
            {'trigger': 'confirm',
             'source': 'underload_avoid', 'dest': 'confirmed'},
            {'trigger': 'chillout',
             'source': 'confirmed', 'dest': 'normal'},
            {'trigger': 'chillout',
             'source': 'overload_avoid', 'dest': 'normal'},
            {'trigger': 'chillout',
             'source': 'underload_avoid', 'dest': 'normal'},
            {'trigger': 'chillout',
             'source': 'overload', 'dest': 'normal'},
            {'trigger': 'chillout',
             'source': 'underload', 'dest': 'normal'}
        ]
        Machine.__init__(self,
                         states=states, transitions=transitions,
#.........这里部分代码省略.........
开发者ID:M425,项目名称:Monacos,代码行数:103,代码来源:state_machine.py

示例15: __init__

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import __init__ [as 别名]
 def __init__(self):
   dealerButton = random.randint(1, 4)
   self.transit = False
   Machine.__init__(self, states=self.states, transitions=self.transitions, initial=self.states[0])
开发者ID:danricho,项目名称:OzWeb500,代码行数:6,代码来源:OzWeb500Server.py


注:本文中的transitions.Machine.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。