def Run(self, portNumber, host=None): try: print("Switch Controller running...") while 1: # Receive UDP Params udpRawAction = self.udpService.ListenToPortOnce( portNumber, host) print(udpRawAction) actionName = udpRawAction.split('#')[0] switchName = udpRawAction.split('#')[1] functionName = GetActionName(actionName) gpioNumber = GetGpioPort(switchName) if (functionName is not None and gpioNumber is not None): gpioNumber = int(gpioNumber) if not isinstance( gpioNumber, list) else gpioNumber # Execute Action actions = Actions() getattr(actions, functionName)(gpioNumber) print functionName except (KeyboardInterrupt, SystemExit): raise except: traceback.print_exc() finally: GPIO.cleanup()
def Main(): try: lastColor = 'green' distanceActions = DistanceActions(trigger, echo) servoActions = Actions() while True: distance = distanceActions.TakeDistance() print(distance) if(distance <= minDistance): GPIO.output(ledRojo, GPIO.HIGH) GPIO.output(ledAmarillo, GPIO.LOW) GPIO.output(ledVerde, GPIO.LOW) if(lastColor != 'red'): servoActions.Deg0(servo) lastColor = 'red' else: if(distance >= minDistance and distance <= midDistance): GPIO.output(ledRojo, GPIO.LOW) GPIO.output(ledAmarillo, GPIO.HIGH) GPIO.output(ledVerde, GPIO.LOW) if(lastColor != 'yellow'): servoActions.Deg90(servo) lastColor = 'yellow' else: GPIO.output(ledRojo, GPIO.LOW) GPIO.output(ledAmarillo, GPIO.LOW) GPIO.output(ledVerde, GPIO.HIGH) if(lastColor != 'green'): servoActions.Deg180(servo) lastColor = 'green' time.sleep(0.3) except (KeyboardInterrupt, SystemExit): raise finally: GPIO.cleanup()
async def on_message(message): CLANBATTLE_DAMAGELOG_CHANNEL = [] CLANBATTLE_DAMAGELOG_CHANNEL.append(os.getenv("CLANBATTLE_DAMAGELOG_CHANNEL1", "")) CLANBATTLE_DAMAGELOG_CHANNEL.append(os.getenv("CLANBATTLE_DAMAGELOG_CHANNEL2", "")) CLANBATTLE_DAMAGELOG_CHANNEL.append(os.getenv("CLANBATTLE_DAMAGELOG_CHANNEL3", "")) CLANBATTLE_DAMAGELOG_CHANNEL.append(os.getenv("CLANBATTLE_DAMAGELOG_CHANNEL4", "")) CLANBATTLE_DAMAGELOG_CHANNEL.append(os.getenv("CLANBATTLE_DAMAGELOG_CHANNEL5", "")) # botへのメンションのときの動作(主に管理者用) if str(client.user.id) in message.content: mact = ManageActions.ManageActions() mact.check_and_action(message) else: # 送り主がBotだった場合はスルー if client.user != message.author: # # 発言の内容をDBに格納 # # text = remove_emoji(message.content) # # if text != '': # pridb = PriDb.PriDb() # pridb.insert_talk( # message.server.id, # message.author.id, # text, # message.timestamp.strftime("%Y/%m/%d %H:%M:%S") # ) # # act = Actions.Actions() res_type, res = act.check_and_response(message) # for i in client.get_all_emojis(): # print (i) if res_type == 'file': await client.send_file(message.channel, res) if res_type == 'text': await message.channel.send(res) if res_type == 'damage_memo': m = await message.channel.send(res) await m.add_reaction(emoji.emojize(':bikini:')) act.insert_damage_memo(m) if res_type == 'edit': cb = ClanBattle.ClanBattle() m_id = cb.get_damage_memo_message_id(message.channel.id) await message.delete() current_boss_num = CLANBATTLE_DAMAGELOG_CHANNEL.index(str(message.channel.id)) edit_message = await client.get_channel(int(CLANBATTLE_DAMAGELOG_CHANNEL[current_boss_num])).fetch_message(m_id) await edit_message.edit(content=res, suppress=True) if res_type == 'emoji': for e in res: await client.add_reaction(message, e)
def setGUIActions(self): actions = Actions.Actions(parent=self) self.inputsPane.updateOutputsList.connect( actions.updateOutputsListAction) self.outputsPane.filePathCheckbox.stateChanged.connect( actions.updateFullPath) self.outputsPane.outputLocationTextbox.textChanged.connect( actions.updatePathLocation) self.processButton.released.connect(actions.getFileList) actions.updateStatusbar("Welcome to ChromecastConverter 1.0")
def __init__(self, work_size=1800): self.work_size = work_size self.stepper_x = ed.EasyDriver(pin_step=40, pin_dir=38, delay=STOP_DELAY) # up self.stepper_y = ed.EasyDriver(pin_step=33, pin_dir=31, delay=STOP_DELAY) # down self.stepper_x.dir(CW) self.stepper_y.dir(CW) self.laser = lc.LaserCtrl(pin_pwm=12) self.laser_close() self.actions = ac.Actions() self.pos = [0, 0]
async def on_message(message): # botへのメンションのときの動作(主に管理者用) if str(client.user.id) in message.content: mact = ManageActions.ManageActions() mact.check_and_action(message) else: # 送り主がBotだった場合はスルー if client.user != message.author: # # 発言の内容をDBに格納 # # text = remove_emoji(message.content) # # if text != '': # pridb = PriDb.PriDb() # pridb.insert_talk( # message.server.id, # message.author.id, # text, # message.timestamp.strftime("%Y/%m/%d %H:%M:%S") # ) # # act = Actions.Actions() res_type, res = act.check_and_response(message) # for i in client.get_all_emojis(): # print (i) if res_type == 'file': file_image = discord.File(res) await message.channel.send(file=file_image) if res_type == 'text': await message.channel.send(res)
from Word import * from Actions import * if __name__ == '__main__': actions = Actions() #actions.train() #actions.check_all(False) actions.check_one()