def openCurrentFolderDialog(self): folder = QFileDialog.getExistingDirectory(self, "Select Directory") tmpdata = dict() tmpdata["path"] = os.path.normpath(folder) tmpdata["outputDirectory"] = self.out_le.text() settings.settingsClass().save(tmpdata) self.initialize()
def openSettingsDialog(self): self.dial = settingsDialog.settingsDialogClass(self) if self.dial.exec_(): print('SETTINGS OK') data = self.dial.getTableData() settings.settingsClass().save(data) self.updateList()
def openSettingDialog(self): """открывает диалог настроек""" self.dial = settingsDialog.settingDialogClass(self) if self.dial.exec_(): print ('SETTINGS OK') # отладочная информация data = self.dial.getTableData() settings.settingsClass().save(data) self.updateList()
def selectOutputDirectory(self): folder = QFileDialog.getExistingDirectory(self, "Select Directory") tmpdata = dict() tmpdata["outputDirectory"] = os.path.normpath(folder) tmpdata["path"] = self.iconvert_lb.text() settings.settingsClass().save(tmpdata) self.out_le.setText(os.path.normpath(folder)) self.initialize()
def initialize(self): data = settings.settingsClass().load() if data.get('path'): self.iconvert_lb.setText('%s' % data['path']) self.out_le.setText(data['outputDirectory']) else: tmpdata = dict() tmpdata["path"] = os.path.dirname(__file__) tmpdata["outputDirectory"] = self.out_le.text() settings.settingsClass().save(tmpdata) self.iconvert_lb.setText('Current path is not selected') self.out_le.setText('Output folder is not selected...')
def main(): mySettings = settingsClass() #mySettings.resetSettings() outpin = mySettings.settings['pwmPin'] pwmLow = mySettings.settings['pwmLow'] pwmMid = mySettings.settings['pwmMid'] pwmHigh = mySettings.settings['pwmHigh'] gpio.setmode(gpio.BCM) gpio.setup(outpin, gpio.OUT) myPwm = gpio.PWM(outpin, mySettings.settings['pwmFrequency']) myPwm.start(pwmMid) sleep(5) while True: #myPwm.ChangeDutyCycle(1) myPwm.ChangeDutyCycle(pwmLow) # Low sleep(0.25) myPwm.ChangeDutyCycle(pwmMid) # mid pwm sleep(0.25) myPwm.ChangeDutyCycle(pwmHigh) # High sleep(0.25) myPwm.ChangeDutyCycle(pwmMid) # mid pwm sleep(0.25)
def createProject(data): template = json.load(open(templateEditor.templateFile)) path = settings.settingsClass().load()['path'] if os.path.exists(path): pName = checkLegalCharacters(data['name']) pPath = os.path.join(path, pName) if mkFolder(pPath): buildFolders(pPath, template) makeProjectFile(pPath, data)
def createProject(data): template = json.load(open(templateEditor.templateFile)) path = settings.settingsClass().load()['path'] if os.path.exists(path): pName = checkLegalCharacters(data['name']) pPath = os.path.join(path, pName) if mkFolder(pPath): buildFolders(pPath, template) makeProjectFile(pPath, data)
def createProject(data): # возвращает templete который создали в editor template = json.load(open(templateEditor.templateFile)) # путь к проектам path = settings.settingsClass().load()['path'] if os.path.exists(path): pName = checkLegalCharacters(data['name']) pPath = os.path.join(path, pName) if mkFolder(pPath): buildFolders(pPath, template) makeProjectFile(pPath, data)
def updateProjectList(self): self.clear() data = settings.settingsClass().load() path = data.get('path') if path: if os.path.exists(path): for f in os.listdir(path): fullPath = os.path.join(path, f) if self.isProject(fullPath): item = self.addProject(f) item.setData(32, fullPath) return True else: return False
def __init__(self): self.mySettings = settingsClass() self.pumpOn = False self.hoseOn = 0 self.irrigationOn = False self.displayBrightness = 0.5 self.outpin = 0 self.pwmMid = 0 self.pwmHigh = 0 self.myPwm = gpio self.initHardware()
def updateProjectList(self): self.clear() data = settings.settingsClass().load() path = data.get('path') if path: if os.path.exists(path): for f in os.listdir(path): fullPath = os.path.join(path, f ) if self.isProject(fullPath): item = self.addProject(f) item.setData(32, fullPath) return True else: return False
def updateProjectList(self): """ обновляет список проектов""" self.clear() data = settings.settingsClass().load() path = data.get('path') if path: if os.path.exists(path): for f in os.listdir(path): fullPath = os.path.join(path, f) if self.isProject(fullPath): item = self.addProject(f) item.setData( 32, fullPath ) # занесение информации о пути расположения проекта return True else: return False
def main(): mySensorState = sensorState() mySettings = settingsClass() sql = "SELECT * FROM public.\"sunrisesetLatestDetail\";" cur.execute(sql) rows = cur.fetchall() if len(rows) > 0: row = rows[0] sunrise = row[2] sunset = row[3] irrigationPeriod = mySettings.settings["pumpduration"] isTimeToIrrigate = 0 nowStartTime = datetime.now() nowStartInt = (nowStartTime.hour * 60) + nowStartTime.minute nowSunriseStart = (sunrise.hour * 60) + sunrise.minute nowSunriseEnd = (sunrise.hour * 60) + sunrise.minute + irrigationPeriod nowSunsetStart = (sunset.hour * 60) + sunset.minute nowSunsetEnd = (sunset.hour * 60) + sunset.minute + irrigationPeriod if nowSunriseStart <= nowStartInt <= nowSunriseEnd: isTimeToIrrigate = 1 else: isTimeToIrrigate = 0 mySensorState.setSensorID('10000002') mySensorState.setSensorType('sun-rise') mySensorState.setSensorValue(isTimeToIrrigate) mySensorState.setSatus() if nowSunsetStart <= nowStartInt <= nowSunsetEnd: isTimeToIrrigate = 1 else: isTimeToIrrigate = 0 mySensorState.setSensorID('10000003') mySensorState.setSensorType('sun-set') mySensorState.setSensorValue(isTimeToIrrigate) mySensorState.setSatus()
def main(): mySettings = settingsClass() # get settings from db mySunrise = sunRiseSet() # Get sunrise and sunset from DB mySunrise.getSunriseset() myWeather = weather() myWeather.getWeather() #inkyphat.set_border(inkyphat.WHITE) if (myWeather.wind_dir in ('South')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_s.png") elif (myWeather.wind_dir in ('SW', 'SSW')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_sw.png") elif (myWeather.wind_dir in ('SE', 'SSE')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_se.png") elif (myWeather.wind_dir in ('North', 'NNW', 'NNE')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_n.png") elif (myWeather.wind_dir in ('West', 'WSW', 'WNW')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_w.png") elif (myWeather.wind_dir in ('East', 'ESE', 'ENE')): inkyphat.set_image("/home/pi/code/watertanks/resources/compass_e.png") else: #if (myWeather.wind_dir in ('S', 'SE', 'SW', 'NE', 'N', 'NW', 'W', 'S')): imgFile = "/home/pi/code/watertanks/resources/compass_{0}.png".replace( '{0}', myWeather.wind_dir.lower()) inkyphat.set_image(imgFile) printTitle("Tank") printText(1, "Sunrise:", mySunrise.sunrise.isoformat()[0:8], '') printText(2, "Sunset:", mySunrise.sunset.isoformat()[0:8], '') printText(3, "Water:", mySettings.settings["pumpduration"], 'min') temp_c = str(myWeather.temp_c) windchill_c = str(myWeather.windchill_c) printText(4, "Temp:", temp_c + 'c w/c ' + windchill_c, 'c') printText(5, "Weather:", myWeather.weather, '') wind_mph = str(myWeather.wind_mph) wind_gust_mph = str(myWeather.wind_gust_mph) printText(6, "Wind:", myWeather.wind_dir + " spd: " + wind_mph + 'g: ' + wind_gust_mph, '') inkyphat.show() # And show it!
def initHardware(self): if automationhat.is_automation_hat(): # init local automation hat automationhat.light.power.write(1) mySettings = settingsClass() # get settings from db #mySettings.resetSettings() # setup pwm self.outpin = mySettings.settings['pwmPin'] #pwmLow = mySettings.settings['pwmLow'] # Not used as this would reverse the pump self.pwmMid = mySettings.settings['pwmMid'] self.pwmHigh = mySettings.settings['pwmHigh'] self.hoseOn = self.pwmMid # Start pwm gpio.setmode(gpio.BCM) gpio.setup(self.outpin, gpio.OUT) self.myPwm = gpio.PWM(self.outpin, mySettings.settings['pwmFrequency']) self.myPwm.start(self.pwmMid) # pump init
def fillTable(self): data = settings.settingsClass().load() for key, value in data.items(): self.addParm(key, value)
def openSettingsDialog(self): self.dial = settingsDialog.settingsDialogClass(self) if self.dial.exec_(): data = self.dial.getTableData() settings.settingsClass().save(data) self.updateList()
def __init__(self, parent=None): super(ratConvertClass, self).__init__() self.setupUi(self) self.setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint) ############################ #VARIBLES self.messages = [ 'Waiting for data...', 'Ready!!!!', 'Set IConvert path', 'same as source...', 'Out folder error!!!' ] # iconsPath = os.path.join(os.path.dirname(__file__),'icons') self.icons = { 'title': QIcon(':/rat_icon.png'), 'image': QIcon(':/image.png'), 'trash': QIcon(':/trash.png'), 'minus': QIcon(':/minus.png'), 'folder': QIcon(':/folder.png'), } self.outFormats = formats.formats #['rat','exr'] #Window self.setWindowTitle('RAT Converter v1.0') self.setWindowIcon(self.icons['title']) self.statusBar.showMessage(self.messages[0]) #Buttons self.browseFiles_btn.setText('') self.browseFiles_btn.setIcon(self.icons['image']) self.browseFolder_btn.setText('') self.browseFolder_btn.setIcon(self.icons['folder']) self.remove_btn.setText('') self.remove_btn.setIcon(self.icons['trash']) self.show_btn.setText('') self.show_btn.setIcon(self.icons['minus']) self.multi_cb.setVisible(0) self.stop_btn.setEnabled(False) self.RAT_btn.setEnabled(False) #FORMATS for f in self.outFormats: self.format_cb.addItem(f.upper()) #settings self.confir_file_name = 'ratConvertSettings' self.defaultExt = 'exr,hdr,tif,png,jpg' self.settings = settings.settingsClass(self.confir_file_name) self.fileList = [] self.targetDir = None #Source line edit self.sourceList_lw.setParent(None) self.sourceList_lw = sourceListWidget.sourceListClass(self) self.source_ly.addWidget(self.sourceList_lw) #Target Line edit self.target_le.setParent(None) self.target_le = targetLineEdit.targetLineEdit(self) self.target_le.setDefFolder() self.newtarget_ly.addWidget(self.target_le) ############################## CONNECT self.delExt_btn.clicked.connect(self.delExt) self.newExt_le.returnPressed.connect(self.addExt) self.RAT_btn.clicked.connect(self.start) self.browsIconvert_btn.clicked.connect(self.setIconvertPath) self.browseTarget_btn.clicked.connect(self.getTargetDir) self.remove_btn.clicked.connect(self.removeItem) self.show_btn.clicked.connect(self.updateList) self.stop_btn.clicked.connect(self.stopProcess) self.help_btn.clicked.connect(self.showHelp) self.target_le.editingFinished.connect(self.target_le.editFinish) @self.browseFiles_btn.clicked.connect def checkAllClick(): self.getSourceFiles(True) @self.browseFolder_btn.clicked.connect def checkAllClick(): self.getSourceFiles(False) @self.checkAll_btn.clicked.connect def checkAllClick(): self.checkAll(True) @self.unckeckAll_btn.clicked.connect def uncheckAllClick(): self.checkAll(False) ############################### START self.center() self.fillList() self.setIconvert()
def main(): # i2c bus = smbus.SMBus(1) # send works on bus 1 DEVICE_ADDRESS = 0x14 DEVICE_REG_MODE1 = 0x00 bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x01) #bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high #displayBrightness = 0.5 state = -2 # Startup state myWeather = weather() myLedControl = ledcontrol() # init remote led control if automationhat.is_automation_hat(): # init local automation hat automationhat.light.power.write(1) automationhat.light.comms.write(1) #time.sleep(0.05) # sleep to give the system time to set the LEDs mySettings = settingsClass() # get settings from db #mySettings.resetSettings() # setup pwm #outpin = mySettings.settings['pwmPin'] #pwmLow = mySettings.settings['pwmLow'] #pwmMid = mySettings.settings['pwmMid'] #pwmHigh = mySettings.settings['pwmHigh'] # Start pwm #gpio.setmode(gpio.BCM) #gpio.setup(outpin, gpio.OUT) #myPwm = gpio.PWM(outpin, mySettings.settings['pwmFrequency']) #myPwm.start(pwmMid) # pump init # Set sunrise sunset vars dayRollover = -1 # get new sunrise sunset times only once! mySunrise = sunRiseSet() # Get sunrise and sunset from DB # Config the display #scrollphathd.set_brightness(0.5) automationhat.light.comms.write(0) myTimeNow = datetime.datetime.now() currTime = myTimeNow.hour + myTimeNow.minute lastTime = currTime currHour = -1 lastHour = -2 while True: myTimeNow = datetime.datetime.now() currTime = myTimeNow.hour + myTimeNow.minute currHour = myTimeNow.hour # Update the time string for the display every minute if (currTime != lastTime and state == -1): lastTime = currTime #scrollphathd.clear() #scrollphathd.write_string(getStatusText(str(mySunrise.sunrise), str(mySunrise.sunset)) , x=0, y=0, font=font5x7, brightness=0.5) # Update the weather trend (last 24 hours) every hour if (currHour != lastHour): lastHour = currHour myWeather.getWeather() myWeather.getRecentTrend() # get new sunrise and sunset times rollTime = myTimeNow.hour + myTimeNow.minute if (rollTime == 0 and dayRollover == -1): mySunrise = sunRiseSet() dayRollover = 0 elif (rollTime == 0 and dayRollover == 0): dayRollover = 0 else: dayRollover = -1 numStartTime = (myTimeNow.hour * 3600) + (myTimeNow.minute * 60) + myTimeNow.second # i2c read #time.sleep(1) i2cRead = bus.read_byte_data(DEVICE_ADDRESS, 0) # complex if conditions so I pulled them into variables ifWeatherTrend = ((myWeather.isTrend('Rain') or myWeather.isTrend('Snow')) and state != 5) ifSunrise = ((numStartTime >= mySunrise.numSunriseSeconds and numStartTime <= (mySunrise.numSunriseSeconds + (mySettings.settings["pumpduration"] * 60))) and state != 1) ifSunset = ((numStartTime >= mySunrise.numSunsetSeconds and numStartTime <= (mySunrise.numSunsetSeconds + (mySettings.settings["pumpduration"] * 60))) and state != 4) ifIrrigationButton = (i2cRead == 12 and state != 3) ifHose = (i2cRead == 10 and state != 2) #ifIrrigationAndHose = (automationhat.input.one.read() == True and automationhat.input.two.read() == True) ifBauFromSunrise = (not(numStartTime >= mySunrise.numSunriseSeconds and numStartTime <= (mySunrise.numSunriseSeconds + (mySettings.settings["pumpduration"] * 60))) and state == 1) ifBauFromSunset = (not(numStartTime >= mySunrise.numSunsetSeconds and numStartTime <= (mySunrise.numSunsetSeconds + (mySettings.settings["pumpduration"] * 60))) and state == 4) ifBauFromIrrigationButton = (automationhat.input.two.read() == False and state == 3) ifBauFromStartup = ((automationhat.input.one.read() == False and state == 2) or state == -2) if (ifWeatherTrend == True and (ifHose == False and state != 2)): state = 5 # Sunrise state automationhat.light.comms.write(1) # Comm light on to show activity. automationhat.output.one.write(0) # irrigation solenoid on automationhat.output.two.write(0) # hose solenoid off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (automationhat.input.one.read() == True and automationhat.input.two.read() == True): #Fail automationhat.light.comms.write(1) # Comm light on to show activity. automationhat.output.one.write(0) # irrigation solenoid on automationhat.output.two.write(0) # hose solenoid off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifSunrise): # sunrise irrigation requested state = 1 # Sunrise state automationhat.light.comms.write(1) # Comm light on to show activity. #scrollphathd.clear() #scrollphathd.write_string(' irrigation on: ' + str(mySettings.settings["pumpduration"]) + ' mins', x=0, y=0, font=font5x7, brightness = displayBrightness) # action the water solenoid and pump automationhat.output.one.write(1) # irrigation solenoid on automationhat.output.two.write(0) # hose solenoid off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifSunset): # sunrise irrigation requested state = 4 # Sunset state automationhat.light.comms.write(1) # Comm light on to show activity. #scrollphathd.clear() #scrollphathd.write_string(' irrigation on: ' + str(mySettings.settings["pumpduration"]) + ' mins', x=0, y=0, font=font5x7, brightness = displayBrightness) # action the water solenoid and pump automationhat.output.one.write(1) # irrigation solenoid on automationhat.output.two.write(0) # hose solenoid off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifIrrigationButton): # sunrise irrigation requested state = 3 # Sunrise state automationhat.light.comms.write(1) # Comm light on to show activity. #scrollphathd.clear() #scrollphathd.write_string(' irrigation on: ' + str(mySettings.settings["pumpduration"]) + ' mins', x=0, y=0, font=font5x7, brightness = displayBrightness) automationhat.output.one.write(1) # irrigation solenoid on automationhat.output.two.write(0) # hose solenoid off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifHose): # hose requested on state = 2 # Hose state automationhat.light.comms.write(1) # Comm light on to show activity. #scrollphathd.clear() #scrollphathd.write_string(' hose On', x=0, y=0, font=font5x7, brightness = displayBrightness) # action the water solenoid and pump automationhat.output.two.write(0) # irrigation solenoid off automationhat.output.two.write(1) # hose solenoid on bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x02) # pwm high myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(1) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifBauFromSunrise or ifBauFromSunset or ifBauFromStartup or ifBauFromIrrigationButton): # BAU state state = -1 automationhat.light.comms.write(1) # Comm light on to show activity. #scrollphathd.clear() #scrollphathd.write_string(getStatusText(str(mySunrise.sunrise), str(mySunrise.sunset)) , x=0, y=0, font=font5x7, brightness = displayBrightness) # action the water solenoid and pump automationhat.output.one.write(0) # irrigation led off automationhat.output.two.write(0) # hose led off bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG_MODE1, 0x01) # pwm mid myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display automationhat.light.comms.write(0) # Comm light off to show activity.
def main(): gpio.setmode(gpio.BCM) gpio.setup([irrigationPin, hosePin, powerPin], gpio.OUT) gpio.output([irrigationPin, hosePin], gpio.LOW) gpio.output([powerPin], gpio.HIGH) #mqMessage = "" state = -2 # Startup state myWeather = weather() myLedControl = ledcontrol() # init remote led control mySensor = sensorComm() #myMqSensor = mqSensor() #myMqControl = mqControl() mySettings = settingsClass() # get settings from db #mySettings.resetSettings() #automationhat.is_automation_hat() #if automationhat.is_automation_hat(): # init local automation hat #automationhat.light.power.write(1) #automationhat.light.comms.write(1) # setup pwm #pwmLow = mySettings.settings['pwmLow'] pwmMid = mySettings.settings['pwmMid'] pwmHigh = mySettings.settings['pwmHigh'] # Start pwm # serial comm to the Arduino to set/get sensor data. mySensor.pumpPWM = pwmMid mySensor.setValues() #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) mySensor.refresh() #mqMessage = mySensor.refresh() #myMqSensor.sendMQ(mqMessage) # Set sunrise sunset vars dayRollover = -1 # get new sunrise sunset times only once! mySunrise = sunRiseSet() # Get sunrise and sunset from DB # Config the display #scrollphathd.set_brightness(0.5) myTimeNow = datetime.datetime.now() currTime = myTimeNow.hour + myTimeNow.minute lastTime = currTime currHour = -1 lastHour = -2 myWeather.getWeather() #automationhat.light.comms.write(0) while True: myTimeNow = datetime.datetime.now() currTime = myTimeNow.hour + myTimeNow.minute currHour = myTimeNow.hour # Update the time string for the display every minute if (currTime != lastTime and state == -1): lastTime = currTime # Update the weather trend (last 24 hours) every hour if (currHour != lastHour): lastHour = currHour myWeather.getWeather() myWeather.getRecentTrend() # get new sunrise and sunset times rollTime = myTimeNow.hour + myTimeNow.minute if (rollTime == 0 and dayRollover == -1): mySunrise = sunRiseSet() dayRollover = 0 elif (rollTime == 0 and dayRollover == 0): dayRollover = 0 else: dayRollover = -1 numStartTime = (myTimeNow.hour * 3600) + (myTimeNow.minute * 60) + myTimeNow.second #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.refresh() #mqMessage = mySensor.refresh() #myMqSensor.sendMQ(mqMessage) #automationhat.light.comms.write(0) # Comm light on to show activity. # complex if conditions so I pulled them into variables ifWeatherTrend = ((myWeather.isTrend('Rain') or myWeather.isTrend('Snow')) and state != 5) ifSunrise = ((numStartTime >= mySunrise.numSunriseSeconds and numStartTime <= (mySunrise.numSunriseSeconds + (mySettings.settings["pumpduration"] * 60))) and state != 1) ifSunset = ((numStartTime >= mySunrise.numSunsetSeconds and numStartTime <= (mySunrise.numSunsetSeconds + (mySettings.settings["pumpduration"] * 60))) and state != 4) ifIrrigationButton = (str(mySensor.settings['irrigationButton']) =='1'); ifHose = (str(mySensor.settings['hoseButton']) =='1') ; ifBauFromSunrise = (not(numStartTime >= mySunrise.numSunriseSeconds and numStartTime <= (mySunrise.numSunriseSeconds + (mySettings.settings["pumpduration"] * 60))) and state == 1) ifBauFromSunset = (not(numStartTime >= mySunrise.numSunsetSeconds and numStartTime <= (mySunrise.numSunsetSeconds + (mySettings.settings["pumpduration"] * 60))) and state == 4) ifBauFromIrrigationButton = (ifIrrigationButton == False and state == 3) ifBauFromHoseButton = (ifHose == False and state == 2) ifBauFromStartup = ((ifIrrigationButton or ifHose) and state == -2) if (ifWeatherTrend == True and (ifHose == False and state != 2)): state = 5 # Weather is rain or snow #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 0 mySensor.pumpPWM = pwmMid mySensor.setValues() gpio.output([irrigationPin, hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifIrrigationButton and ifHose): #Fail #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 0 mySensor.pumpPWM = pwmHigh mySensor.setValues() gpio.output([irrigationPin, hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifSunrise): # sunrise irrigation requested state = 1 # Sunrise state #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 1 mySensor.pumpPWM = pwmHigh mySensor.setValues() gpio.output([irrigationPin], gpio.HIGH) gpio.output([hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifSunset): # sunrise irrigation requested state = 4 # Sunset state #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 1 mySensor.pumpPWM = pwmHigh mySensor.setValues() gpio.output([irrigationPin], gpio.HIGH) gpio.output([hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifIrrigationButton and state != 3): # sunrise irrigation requested state = 3 # Sunrise state #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 1 mySensor.pumpPWM = pwmHigh mySensor.setValues() gpio.output([irrigationPin], gpio.HIGH) gpio.output([hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(1) # update remote display myLedControl.setHoseGreen(0) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifHose and state != 2): # hose requested on state = 2 # Hose state #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 1 mySensor.irrigation = 0 mySensor.pumpPWM = pwmHigh mySensor.setValues() gpio.output([irrigationPin], gpio.LOW) gpio.output([hosePin], gpio.HIGH) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(1) # update remote display #automationhat.light.comms.write(0) # Comm light off to show activity. elif (ifBauFromSunrise or ifBauFromSunset or ifBauFromStartup or ifBauFromIrrigationButton or ifBauFromHoseButton): # BAU state state = -1 #automationhat.light.comms.write(1) # Comm light on to show activity. mySensor.hose = 0 mySensor.irrigation = 0 mySensor.pumpPWM = pwmMid mySensor.setValues() gpio.output([irrigationPin, hosePin], gpio.LOW) #mqMessage = mySensor.setValues() #myMqControl.sendMQ(mqMessage) myLedControl.setIrrigationGreen(0) # update remote display myLedControl.setHoseGreen(0) # update remote display
def __init__(self, parent=None): super(ratConvertClass, self).__init__() self.setupUi(self) self.setWindowFlags( Qt.Window|Qt.WindowStaysOnTopHint ) ############################ #VARIBLES self.messages = ['Waiting for data...', 'Ready!!!!', 'Set IConvert path', 'same as source...', 'Out folder error!!!'] # iconsPath = os.path.join(os.path.dirname(__file__),'icons') self.icons = {'title':QIcon(':/rat_icon.png'), 'image':QIcon(':/image.png'), 'trash':QIcon(':/trash.png'), 'minus':QIcon(':/minus.png'), 'folder':QIcon(':/folder.png'), } self.outFormats = formats.formats#['rat','exr'] #Window self.setWindowTitle('RAT Converter v1.0') self.setWindowIcon(self.icons['title']) self.statusBar.showMessage(self.messages[0]) #Buttons self.browseFiles_btn.setText('') self.browseFiles_btn.setIcon(self.icons['image']) self.browseFolder_btn.setText('') self.browseFolder_btn.setIcon(self.icons['folder']) self.remove_btn.setText('') self.remove_btn.setIcon(self.icons['trash']) self.show_btn.setText('') self.show_btn.setIcon(self.icons['minus']) self.multi_cb.setVisible(0) self.stop_btn.setEnabled(False) self.RAT_btn.setEnabled(False) #FORMATS for f in self.outFormats: self.format_cb.addItem(f.upper()) #settings self.confir_file_name = 'ratConvertSettings' self.defaultExt = 'exr,hdr,tif,png,jpg' self.settings = settings.settingsClass(self.confir_file_name) self.fileList = [] self.targetDir = None #Source line edit self.sourceList_lw.setParent(None) self.sourceList_lw = sourceListWidget.sourceListClass(self) self.source_ly.addWidget(self.sourceList_lw) #Target Line edit self.target_le.setParent(None) self.target_le = targetLineEdit.targetLineEdit(self) self.target_le.setDefFolder() self.newtarget_ly.addWidget(self.target_le) ############################## CONNECT self.delExt_btn.clicked.connect(self.delExt) self.newExt_le.returnPressed.connect(self.addExt) self.RAT_btn.clicked.connect(self.start) self.browsIconvert_btn.clicked.connect(self.setIconvertPath) self.browseTarget_btn.clicked.connect(self.getTargetDir) self.remove_btn.clicked.connect(self.removeItem) self.show_btn.clicked.connect(self.updateList) self.stop_btn.clicked.connect(self.stopProcess) self.help_btn.clicked.connect(self.showHelp) self.target_le.editingFinished.connect(self.target_le.editFinish) @self.browseFiles_btn.clicked.connect def checkAllClick(): self.getSourceFiles(True) @self.browseFolder_btn.clicked.connect def checkAllClick(): self.getSourceFiles(False) @self.checkAll_btn.clicked.connect def checkAllClick(): self.checkAll(True) @self.unckeckAll_btn.clicked.connect def uncheckAllClick(): self.checkAll(False) ############################### START self.center() self.fillList() self.setIconvert()
def fillTable(self): data = settings.settingsClass().load() for key, value in data.items(): self.addParm(key, value)