本文整理汇总了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"))