Beispiel #1
0
 def __init__(self,parent=None):   
     QtGui.QWidget.__init__(self, parent)
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)        
     
     self.timer = QtCore.QTimer(self)
     self.setWindowTitle("%s V%s" % (self.progName , self.progVer))
     self.connect(self.ui.startButton,QtCore.SIGNAL("clicked()"),self.startSending)
     self.connect(self.ui.stopButton,QtCore.SIGNAL("clicked()"),self.stopSending)
     self.connect(self.ui.saveButton,QtCore.SIGNAL("clicked()"),self.saveSettings)        
     self.connect(self.ui.lockBox, QtCore.SIGNAL("stateChanged(int)"),self.lockFields)
             
     self.readConfigFile(self.cfgFile)
Beispiel #2
0
class meteoScan(QtGui.QMainWindow):

    progName = "Meteo Scan"
    progVer = "0.7"
    logFile = "meteoScanLog.log"
    cfgFile = "meteoScanConfig.cfg"

    configValues = {}
    conn = ""


    def __init__(self,parent=None):   
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)        
        
        self.timer = QtCore.QTimer(self)
        self.setWindowTitle("%s V%s" % (self.progName , self.progVer))
        self.connect(self.ui.startButton,QtCore.SIGNAL("clicked()"),self.startSending)
        self.connect(self.ui.stopButton,QtCore.SIGNAL("clicked()"),self.stopSending)
        self.connect(self.ui.saveButton,QtCore.SIGNAL("clicked()"),self.saveSettings)        
        self.connect(self.ui.lockBox, QtCore.SIGNAL("stateChanged(int)"),self.lockFields)
                
        self.readConfigFile(self.cfgFile)
                          

    def sendData(self):
        try:
            data = {    "date": "\"" + str(datetime.now().date().isoformat()) + "\"",
                        "time": "\"" + str(datetime.now().time().isoformat().split(".")[0]) + "\"",
                        "AmbientT": str(cloud.AmbientT),
                		"ClarityIIVersion": "\"" + str(cloud.ClarityIIVersion) + "\"" ,
                        "CloudCondition": str(cloud.CloudCondition) ,
                        "CloudyThreshT": str(cloud.CloudyThreshT) ,
                        "DayCondition": str(cloud.DayCondition) ,
                        "DayLightV": str(cloud.DayLightV) ,
                        "DayThreshV": str(cloud.DayThreshV) ,
                        "DewPointT": str(cloud.DewPointT) ,
                        "Fahrenheit": str(int(cloud.Fahrenheit == "True")),
                        "FirmwareVersion": str(cloud.FirmwareVersion),
                        "HeaterPercent": str(cloud.HeaterPercent) ,
                        "HumidityPercent": str(cloud.HumidityPercent),
                        "Mph": str(int(cloud.Mph == "True" )) ,
                        "RainCondition": str(cloud.RainCondition),
                        "RainF": str(int(cloud.RainF == "True" )),
                        "RainThreshV": str(cloud.RainThreshV),
                        "RelSkyT": str(cloud.RelSkyT),
                        "RoofCloseRequested": str(int(cloud.RoofCloseRequested == "True" )),
                        "SecondsSinceGoodData": str(cloud.SecondsSinceGoodData),
                        "SensorT": str(cloud.SensorT),
                        "VCloudyThreshT": str(cloud.VCloudyThreshT),
                        "VDayThreshV": str(cloud.VDayThreshV),
                        "VWindyThreshSpeed": str(cloud.VWindyThreshSpeed),
                        "WetF": str(int(cloud.WetF == "True" )),
                        "WetThreshV": str(cloud.WetThreshV),
                        "Wind": str(cloud.Wind),
                        "WindCondition": str(cloud.WindCondition),
                        "WindUnits": str(cloud.WindUnits),
                        "WindyThreshSpeed": str(cloud.WindyThreshSpeed),
                	}
        except:
            self.logManager("Errore ClarityII.CloudSensorII ","both")
            self.stopSending()
            return False            
                    	                            
        cursor = self.conn.cursor()       
        sqlCmd = "INSERT INTO meteo_data (%s) VALUES(%s) " % (",".join(data.keys()),",".join(data.values()))

        try:
          cursor.execute(sqlCmd)
        except (MySQLdb.OperationalError, MySQLdb.ProgrammingError), error:
            self.logManager("%d %s" % (error.args[0],error.args[1]),"both")
            self.stopSending()
            return False
        
        self.logManager(",".join(data.values()),"log")