本文整理汇总了Python中neuron.Neuron.axonFire方法的典型用法代码示例。如果您正苦于以下问题:Python Neuron.axonFire方法的具体用法?Python Neuron.axonFire怎么用?Python Neuron.axonFire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuron.Neuron
的用法示例。
在下文中一共展示了Neuron.axonFire方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RaspiBot
# 需要导入模块: from neuron import Neuron [as 别名]
# 或者: from neuron.Neuron import axonFire [as 别名]
#.........这里部分代码省略.........
print "GPIO pin off\n"
pin_num = args[1]
GPIO.setup(int(pin_num), GPIO.OUT)
GPIO.output(int(pin_num), False)
self.replyMessage(user, "\nPin off: "+ pin_num +" at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()))
#This method writes to the specified GPIO pin
def command_003_write(self, user, message, args):
'''(write|w)( +(.*))?$(?i)'''
print "GPIO pin write\n"
arg_str = args[1]
aargs = arg_str.split()
pin_num = aargs[0]
state = aargs[1]
if int(state) == 1:
GPIO.output(int(pin_num), True)
self.replyMessage(user, "Pin on: "+ pin_num +" at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()))
elif int(state) == 0:
GPIO.output(int(pin_num), False)
self.replyMessage(user, "Pin off: "+ pin_num +" at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()))
#This method reads the value of the specified GPIO pin
def command_003_read(self, user, message, args):
'''(read|r)( +(.*))?$(?i)'''
print "GPIO pin read\n"
pin_num = args[1]
GPIO.setup(int(pin_num), GPIO.IN)
pin_value = GPIO.input(int(pin_num))
self.replyMessage(user, "\nPin read: "+ pin_num + " value: " + str(pin_value) + " at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()))
#This executes the shell command argument after 'shell' or 'bash'
def command_003_shell(self, user, message, args):
'''(shell|bash)( +(.*))?$(?i)'''
cmd = args[1]
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = ""
for line in p.stdout.readlines():
output += line
print line,
retval = p.wait()
self.replyMessage(user, output +" at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()))
#define some weather commands
def command_004_reportweather(self, user, message, args):
'''weather'''
#wea = Weather()
self.replyMessage(user, weatherthread.weatherreport)
#self.replyMessage(user,"sorry,I'm too lazy to check weather now...please try a url with RSS feed")
#defines RSS commands
def command_005_rss(self,user,message,args):
'''(^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*))'''
data = feedparser.parse(args[0])
for i in range(len(data.entries)):
#get the date/time
time=data.entries[i].updated
title=data.entries[i].title
summary=data.entries[i].summary
link=data.entries[i].link
self.replyMessage(user, title + " " + link)
break
#This method is to reload the Me program from start
def command_006_reload(self,user,message,args):
"""reload"""
Popen("reload", shell=True) # start reloader
exit("exit for updating all files")
#this is for trigger remote player
def command_007_play(self, user, message, args):
"""play"""
target = ("10.0.1.18",23000) # prepare target for spike
self.neuron.axonFire("play 02.mp3", target) # fire to raspberry remotely
#this is for trigger quit
def command_008_quit(self, user, message, args):
"""quit"""
sys.exit(-1)
def command_009_stopspeech(self, user, message, args):
"""stopspeech"""
target = ("",23310) # prepare target for spike
self.neuron.axonFire("stopspeech", target) # fire to raspberry remotely
#This method is the default response
def command_100_default(self, user, message, args):
'''.*?(?s)(?m)'''
data = feedparser.parse("http://news.google.com/news?hl=en&gl=us&q=neuron&um=1&ie=UTF-8&output=rss")
for i in range(len(data.entries)):
#get the date/time
time=data.entries[i].updated
title=data.entries[i].title
summary=data.entries[i].summary
link=data.entries[i].link
self.replyMessage(user, title + " " + link)
break