def search_command(self, voice_command, fast_command=False): if self.conversation(voice_command): return True else: actions = Actions(self) return actions.verify_command(voice_command)
def onSelect(self,e): actions=Actions() res=actions.data_message(self.action_select.GetCurrentSelection()) if res: if res=='OpenFileDialog': path='' dlg = wx.FileDialog(self, message=_('Choose a file'), defaultDir=self.currentpath+'/sounds', defaultFile='', wildcard=_('Audio files')+' (*.mp3)|*.mp3|'+_('All files')+' (*.*)|*.*', style=wx.OPEN | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: file_path = dlg.GetPath() dlg.Destroy() self.data.SetValue(file_path) else: wx.MessageBox(res, 'Info', wx.OK | wx.ICON_INFORMATION) self.data.SetFocus()
def __init__(self, SK_): self.operators_list = [ _('was not updated in the last (sec.)'), _('was updated in the last (sec.)'), '=', '<', '<=', '>', '>=', _('contains') ] self.triggers = [] self.actions = Actions(SK) self.SK = SK_ self.SKc = [] self.cycle10 = time.time() + 0.01 self.read_Action() self.read_Calc()
import RPi.GPIO as GPIO from classes.datastream import DataStream from classes.conf import Conf from classes.language import Language from classes.actions import Actions conf=Conf() Language(conf.get('GENERAL','lang')) global sock_in global error sock_in='' error=0 a=DataStream() actions=Actions() nodata='' global runSW1on global runSW1off global runSW2on global runSW2off global runSW3on global runSW3off global runSW4on global runSW4off runSW1on=False runSW1off=False runSW2on=False runSW2off=False runSW3on=False runSW3off=False
#end thread1 # no loop conf = Conf() Language(conf.get('GENERAL', 'lang')) global triggers triggers = [] global sock_in global error sock_in = '' error = 0 a = DataStream(conf) actions = Actions(conf) nodata = '' sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) read_triggers() thread1 = threading.Thread(target=parse_nmea) if not thread1.isAlive(): thread1.start() mqtt = Mqtt(conf, a) #end no loop # loop while True:
class MySK_to_Action_Calc: def __init__(self, SK_): self.operators_list = [ _('was not updated in the last (sec.)'), _('was updated in the last (sec.)'), '=', '<', '<=', '>', '>=', _('contains') ] self.triggers = [] self.actions = Actions(SK) self.SK = SK_ self.SKc = [] self.cycle10 = time.time() + 0.01 self.read_Action() self.read_Calc() def read_Action(self): self.SK.static_list.append([]) self.SKc = self.SK.static_list[-1] data = self.SK.conf.get('ACTIONS', 'triggers') try: temp_list = eval(data) except: temp_list = [] for ii in temp_list: if ii[0] == 1: ii.append(False) # 5 state for iii in ii[4]: if iii[3] == 2: iii[2] *= 60 if iii[3] == 3: iii[2] = (iii[2] * 60) * 60 if iii[3] == 4: iii[2] = ((iii[2] * 24) * 60) * 60 if iii[3] != 0: iii.append(time.time()) # 4 last run else: iii.append('') var_list = re.findall(r'\<(.*?)\>', iii[1]) for iiii in var_list: exist = False for iiiii in self.SKc: if iiiii[0] == iiii: exist = True break if not exist: self.SKc.append( [iiii, ['', '', '', '', '', '', '', '']]) self.triggers.append(ii) if ii[1] == -1: pass else: splitlist = ii[1].split('.') magnitude = splitlist.pop() ii.append(magnitude) # 6 magnitude SKkey2 = '.'.join(splitlist) self.SKc.append([SKkey2, ['', '', '', '', '', '', '', '']]) ii[1] = self.SKc[-1] def setlist(self, listx): self.SKc.append(listx) return listx def read_Calc(self): tick = time.time() self.calcMagneticVariation = self.SK.conf.get('CALCULATE', 'mag_var') == '1' self.calcTrueHeading = self.SK.conf.get('CALCULATE', 'hdt') == '1' self.calcTrueHeading_dev = self.SK.conf.get('CALCULATE', 'hdt_dev') == '1' self.calcRateTurn = self.SK.conf.get('CALCULATE', 'rot') == '1' self.calcWindTrueWater = self.SK.conf.get('CALCULATE', 'tw_stw') == '1' self.calcWindTrueGround = self.SK.conf.get('CALCULATE', 'tw_sog') == '1' if self.calcWindTrueWater or self.calcTrueHeading or self.calcTrueHeading_dev or self.calcRateTurn or self.calcWindTrueGround or self.calcMagneticVariation: self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) if self.calcMagneticVariation: self.navigation_position_latitude = self.setlist( ['navigation.position.latitude', [0, 0, 0, 0, 0, 0, 0, 0]]) self.navigation_position_longitude = self.setlist( ['navigation.position.longitude', [0, 0, 0, 0, 0, 0, 0, 0]]) self.mag_var_rate = float( self.SK.conf.get('CALCULATE', 'mag_var_rate')) self.mag_var_rate_tick = tick self.mag_var_accuracy = float( self.SK.conf.get('CALCULATE', 'mag_var_accuracy')) if self.calcTrueHeading or self.calcTrueHeading_dev: self.navigation_headingMagnetic = self.setlist( ['navigation.headingMagnetic', [0, 0, 0, 0, 0, 0, 0, 0]]) self.navigation_magneticVariation = self.setlist( ['navigation.magneticVariation', [0, 0, 0, 0, 0, 0, 0, 0]]) self.hdt_rate = float(self.SK.conf.get('CALCULATE', 'hdt_rate')) self.hdt_rate_tick = tick self.hdt_accuracy = float( self.SK.conf.get('CALCULATE', 'hdt_accuracy')) if self.calcTrueHeading_dev: self.deviation_table = [] data = self.SK.conf.get('COMPASS', 'deviation') if not data: temp_list = [] for i in range(37): temp_list.append([i * 10, i * 10]) self.SK.conf.set('COMPASS', 'deviation', str(temp_list)) data = self.SK.conf.get('COMPASS', 'deviation') try: self.deviation_table = eval(data) except: self.deviation_table = [] if self.calcRateTurn: self.navigation_headingMagnetic = self.setlist( ['navigation.headingMagnetic', [0, 0, 0, 0, 0, 0, 0, 0]]) self.rot_rate = float(self.SK.conf.get('CALCULATE', 'rot_rate')) self.rot_rate_tick = tick self.rot_accuracy = float( self.SK.conf.get('CALCULATE', 'rot_accuracy')) self.last_heading = '' self.heading_time = '' if self.calcWindTrueWater: self.navigation_speedThroughWater = self.setlist( ['navigation.speedThroughWater', [0, 0, 0, 0]]) self.environment_wind_angleApparent = self.setlist( ['environment.wind.angleApparent', [0, 0, 0, 0]]) self.environment_wind_speedApparent = self.setlist( ['environment.wind.speedApparent', [0, 0, 0, 0]]) if self.calcWindTrueGround: self.environment_wind_angleApparent = self.setlist( ['environment.wind.angleApparent', [0, 0, 0, 0]]) self.environment_wind_speedApparent = self.setlist( ['environment.wind.speedApparent', [0, 0, 0, 0]]) self.navigation_courseOverGroundTrue = self.setlist( ['navigation.courseOverGroundTrue', [0, 0, 0, 0]]) self.navigation_speedOverGround = self.setlist( ['navigation.speedOverGround', [0, 0, 0, 0]]) self.navigation_headingMagnetic = self.setlist( ['navigation.headingMagnetic', [0, 0, 0, 0]]) def Action_set(self, item, cond): if cond: now = time.time() for i in item[4]: if item[5] == False: try: self.actions.run_action(i[0], self.getSKValues(i[1])) i[4] = now except Exception, e: print str(e) else: if i[3] == 0: pass else: if now - i[4] > i[2]: try: self.actions.run_action( i[0], self.getSKValues(i[1])) i[4] = now except Exception, e: print str(e) item[5] = True