• # en changeant la destination des ecritures

    Posté par . En réponse au message Faire 2 bases de données. Évalué à 2.

    actuellement tu as

    #now let's insert the result into rrdtool database
    fileRrdTool = "/home/www/Graph/data_DHT22.rrd"
    #let's fill the command line with the
    #Current time (Right now), temperature and humidity
    rdata = "N" + validateRRD(temperature) + validateRRD(humidity)
    subprocess.Popen(["/usr/bin/rrdtool","update",fileRrdTool,rdata])

    qui indique que le fichier sera data_DHT22.rrd
    que les rdata seront "N"TemperatureHumidité
    pour ensuite l'ecrire dans le fichier.

    en reecrivant le code ainsi, ca doit le faire

    #now let's insert the result into rrdtool database
    fileRrdTEMP = "/home/www/Graph/data_DHT22.rrd"
    fileRrdHUM = "/home/www/Graph/data_DHT22Y.rrd"
    #let's fill the command line with the
    #Current time (Right now), temperature and humidity
    rdata-temp = "N" + validateRRD(temperature)
    rdata-hum = "N" + validateRRD(humidity)
    subprocess.Popen(["/usr/bin/rrdtool","update",fileRrdTEMP,rdata-temp])
    subprocess.Popen(["/usr/bin/rrdtool","update",fileRrdHUM,rdata-hum])

    et probablement, plus bas, adapter, dans la fonction rrdExport pour gerer cela

     texte += "DEF:{}={}:{}:AVERAGE ".format('a',fileRrdTool,'th_dht22')
     texte += "XPORT:{}:""{}"" ".format('a','th_dht22')
     texte += "DEF:{}={}:{}:AVERAGE ".format('b',fileRrdTool,'hm_dht22')
     texte += "XPORT:{}:""{}"" ".format('b','hm_dht22')

    qui devient

     texte += "DEF:{}={}:{}:AVERAGE ".format('a',fileRrdTEMP,'th_dht22')
     texte += "XPORT:{}:""{}"" ".format('a','th_dht22')
     texte += "DEF:{}={}:{}:AVERAGE ".format('b',fileRrdHUM,'hm_dht22')
     texte += "XPORT:{}:""{}"" ".format('b','hm_dht22')