本文整理匯總了Python中statemachine.StateMachine.process方法的典型用法代碼示例。如果您正苦於以下問題:Python StateMachine.process方法的具體用法?Python StateMachine.process怎麽用?Python StateMachine.process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類statemachine.StateMachine
的用法示例。
在下文中一共展示了StateMachine.process方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: import
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import process [as 別名]
from globalvars import (SOCKET_ADDR, STOPPED, FORWARD, FAST_FORWARD, REVERSE)
from statemachine import StateMachine
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(SOCKET_ADDR)
print "Socket bound, waiting for data"
sm = StateMachine()
state = sm.state
try:
while True:
data, addr = sock.recvfrom(4)
floatval = float(data.split("\n")[0])
print sm.process(floatval)
new_state = sm.state
if state == STOPPED and new_state == FORWARD:
spotify.play()
elif state != STOPPED and new_state == STOPPED:
spotify.pause()
elif state != REVERSE and new_state == REVERSE:
spotify.prev()
elif state != FAST_FORWARD and new_state == FAST_FORWARD:
spotify.next()
state = new_state
except:
logging.exception("recv loop %s", data)
finally:
sock.close()
示例2: len
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import process [as 別名]
last_time = time.time()
number_string = ""
try:
while pygame.event.poll().type != KEYDOWN and len(number_string) < 10:
data, addr = sock.recvfrom(4)
cur_time = time.time()
time_delta = cur_time - last_time
last_time = cur_time
multiplier = time_delta / seconds_per_sample
floatval = float(data.split("\n")[0])
sm.process(floatval)
spinner.update(floatval * degrees_per_sample * multiplier)
if abs(360.0 - spinner.rotation) < .01:
dialed_number = detect_number(spinner.min_rotation)
if dialed_number is not None:
number_string += str(dialed_number)
if len(number_string) == 1:
sys.stdout.write("(%d" % dialed_number)
elif len(number_string) == 2:
sys.stdout.write(str(dialed_number))
elif len(number_string) == 3:
sys.stdout.write("%d) " % dialed_number)
elif len(number_string) <= 6:
sys.stdout.write(str(dialed_number))
示例3: StateMachine
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import process [as 別名]
if __name__ == "__main__":
m = StateMachine()
m.add_state("start_state",start_transitions)
m.add_state("province_state",province_transitions)
m.add_state("city_state",city_transitions)
m.add_state("region_state",region_transitions)
m.add_state("state_state",state_transitions)
m.add_state("town_state",town_transitions,end_state=1)
m.add_state("street_state",street_transitions,end_state = 1)
m.add_state("doorplate_state",None,end_state = 1)
m.set_start("start_state")
#m.process("浙江杭州市西湖區城區文三路黃龍國際G座18層")
#m.process("浙江省杭州市西湖區城區文三路黃龍國際G座18層")
#m.process("北京市北三環東路8號靜安中心大廈")
#m.process("黑龍江省哈爾濱市呼蘭區南京路美蘭家園5棟2單元303")
#m.process("廣東省深圳市羅湖區金稻田路1228號理想新城9棟A單元301室")
#m.process("新疆維吾爾自治區昌吉回族自治州昌吉市昌吉市建國西路甜蜜家園9-1-301")
#m.process("北京市北京市大興區黃村鎮海子角海悅公館41號樓4單元602")
#m.process("陝西省寶雞市千陽縣南關路糧食小區")
#m.process("黑龍江省雞西市虎林市黑龍江省虎林市公安南街276號")
#m.process("遼寧省大連市金州區站前街道生輝第一城物業")
#m.process("安徽省蕪湖市無為縣高溝鎮龍庵街道")
#m.process("廣東省深圳市南山區科興科學園A3單元12樓")
#m.process("湖北省黃岡市浠水縣散花鎮塗墩村七組")
for x in open("sample_address.txt"):
m.process(x.strip("\n"))