Ejemplo n.º 1
0
def consitencycheck():
	
	# this routine align the fertilizer table elements with the Hardware available elements "name" labelled with usedfor "fertilizing"
	
	elementlist=getelementlist()
	recordkey="element"
	elementlistfile=[]
	for ln in FTdata:
		if recordkey in ln:
			elementlistfile.append(ln[recordkey])

	tabletoadd=[]
	for tablename1 in elementlist:
		found=False
		for tablename2 in elementlistfile:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoadd.append(tablename1)
			
	tabletoremove=[]
	for tablename1 in elementlistfile:
		found=False
		for tablename2 in elementlist:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoremove.append(tablename1)

	#print " ---------------------------------------------------------------------<----------------<-----------______________"
	#print "to add ", tabletoadd
	#print "to remove " , tabletoremove
	#print "FTdata ", FTdata
	
	# get the dictionary line with an element as reference (from default file)
	defdata=[]
	filestoragemod.readfiledata(DEFFTDATAFILENAME,defdata)
	for ln in defdata:
		if recordkey in ln:
			referenceln=dict(ln)
			break
			
			
	for tablename in tabletoadd:
		# add copying from element:"1"
		#print "adding table ", tablename
		ln=dict(referenceln)
		ln[recordkey]=tablename
		FTdata.append(ln)



		
	for tablename in tabletoremove:
		for ln in FTdata:
			if recordkey in ln:
				if ln[recordkey]==tablename:
					FTdata.remove(ln)
					
	saveFTsetting()
Ejemplo n.º 2
0
def consitencycheck():
	
	# this routine align the fertilizer table elements with the Hardware available elements "name" labelled with usedfor "fertilizing"
	
	elementlist=getelementlist()
	recordkey="element"
	elementlistfile=[]
	for ln in FTdata:
		if recordkey in ln:
			elementlistfile.append(ln[recordkey])

	tabletoadd=[]
	for tablename1 in elementlist:
		found=False
		for tablename2 in elementlistfile:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoadd.append(tablename1)
			
	tabletoremove=[]
	for tablename1 in elementlistfile:
		found=False
		for tablename2 in elementlist:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoremove.append(tablename1)

	#print " ---------------------------------------------------------------------<----------------<-----------______________"
	#print "to add ", tabletoadd
	#print "to remove " , tabletoremove
	#print "FTdata ", FTdata
	
	# get the dictionary line with an element as reference (from default file)
	defdata=[]
	filestoragemod.readfiledata(DEFFTDATAFILENAME,defdata)
	for ln in defdata:
		if recordkey in ln:
			referenceln=dict(ln)
			break
			
			
	for tablename in tabletoadd:
		# add copying from element:"1"
		#print "adding table ", tablename
		ln=dict(referenceln)
		ln[recordkey]=tablename
		FTdata.append(ln)



		
	for tablename in tabletoremove:
		for ln in FTdata:
			if recordkey in ln:
				if ln[recordkey]==tablename:
					FTdata.remove(ln)
					
	saveFTsetting()
Ejemplo n.º 3
0
def consistencycheck():

    # this routine align the watering table elements with the Hardware available elements "name" labelled with usedfor "watering"
    # in case the element name from Hardwareconfig do not match with the element name of the row, the row is thene deleted
    # if elenemt name in hardware config is not found in the file, then a row is added with default parameters.
    elementlist = getelementlist()
    recordkey = "element"
    elementlistfile = []
    for ln in WTdata:
        if recordkey in ln:
            elementlistfile.append(ln[recordkey])

    tabletoadd = []
    for tablename1 in elementlist:
        found = False
        for tablename2 in elementlistfile:
            if tablename1 == tablename2:
                found = True
        if not (found):
            tabletoadd.append(tablename1)

    tabletoremove = []
    for tablename1 in elementlistfile:
        found = False
        for tablename2 in elementlist:
            if tablename1 == tablename2:
                found = True
        if not (found):
            tabletoremove.append(tablename1)

    #print " ---------------------------------------------------------------------<----------------<-----------______________"
    #print "to add ", tabletoadd
    #print "to remove " , tabletoremove
    #print "WTdata ", WTdata

    # get the dictionary line with an element as reference (from default file)
    defWTdata = []
    filestoragemod.readfiledata(DEFWTDATAFILENAME, defWTdata)
    for ln in defWTdata:
        if recordkey in ln:
            referenceln = dict(ln)
            break
    # copy the previous taken line and change the element parameter
    for tablename in tabletoadd:
        # add copying from element:"1"
        #print "adding table ", tablename
        ln = dict(referenceln)
        ln[recordkey] = tablename
        WTdata.append(ln)

    # remove the dictionalry line that are not consistent with element list
    for tablename in tabletoremove:
        for ln in WTdata:
            if recordkey in ln:
                if ln[recordkey] == tablename:
                    WTdata.remove(ln)

    saveWTsetting()
Ejemplo n.º 4
0
def consistencycheck():
	
	# this routine align the watering table elements with the Hardware available elements "name" labelled with usedfor "watering"
	# in case the element name from Hardwareconfig do not match with the element name of the row, the row is thene deleted
	# if elenemt name in hardware config is not found in the file, then a row is added with default parameters.
	elementlist=getelementlist()
	recordkey="element"
	elementlistfile=[]
	for ln in WTdata:
		if recordkey in ln:
			elementlistfile.append(ln[recordkey])

	tabletoadd=[]
	for tablename1 in elementlist:
		found=False
		for tablename2 in elementlistfile:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoadd.append(tablename1)
			
	tabletoremove=[]
	for tablename1 in elementlistfile:
		found=False
		for tablename2 in elementlist:
			if tablename1==tablename2 :
				found=True
		if not(found) :
			tabletoremove.append(tablename1)

	#print " ---------------------------------------------------------------------<----------------<-----------______________"
	#print "to add ", tabletoadd
	#print "to remove " , tabletoremove
	#print "WTdata ", WTdata
	
	# get the dictionary line with an element as reference (from default file)
	defWTdata=[]
	filestoragemod.readfiledata(DEFWTDATAFILENAME,defWTdata)
	for ln in defWTdata:
		if recordkey in ln:
			referenceln=dict(ln)
			break
	# copy the previous taken line and change the element parameter
	for tablename in tabletoadd: 
		# add copying from element:"1"
		#print "adding table ", tablename
		ln=dict(referenceln)
		ln[recordkey]=tablename
		WTdata.append(ln)

	# remove the dictionalry line that are not consistent with element list
	for tablename in tabletoremove:
		for ln in WTdata:
			if recordkey in ln:
				if ln[recordkey]==tablename:
					WTdata.remove(ln)
					
	saveWTsetting()
def storevariable(storeid, element, variable, value):
    filedata = []  # list of dictionaries
    readok = filestoragemod.readfiledata(DATAFILENAME, filedata)
    # even if readok  is not True, the below procedure creates a new file
    #search for the storeid and elemet
    storeidfound = False

    for thedict in filedata:
        if "storeid" in thedict:
            if thedict["storeid"] == storeid:
                storeidfound = True
                #search for elemet
                if element in thedict:
                    thedict[element][variable] = value
                else:
                    #create element
                    dicttemp = {}
                    dicttemp[variable] = value
                    thedict[element] = dicttemp

    if not storeidfound:
        # add another row to the dictionary
        dicttemp = {}
        dicttemp["storeid"] = storeid
        dicttemp[element] = {}
        dicttemp[element][variable] = value
        filedata.append(dicttemp)

    filestoragemod.savefiledata(DATAFILENAME, filedata)

    return True
Ejemplo n.º 6
0
def replaceschemanameandsave(replacedict):
    filename = DATAFILENAME
    filedata = []
    filestoragemod.readfiledata(filename, filedata)
    # questo il possibile dizionario: { 'name':'', 'm':0.0, 'q':0.0, 'lastupdate':'' } #variabile tipo dizionario
    for old in replacedict.keys():
        new = replacedict[old]
        if old != new:
            line = filedata[0]
            for key in line.keys():
                if line[key] == old:
                    line[key] = new
                    print(key, "  ", line[key])

            for i in range(3, len(filedata)):
                line = filedata[i]
                if line["name"] == old:
                    line["name"] = new
                    print(old, "  ", new)

    filestoragemod.savefiledata(filename, filedata)
    global data
    data = filedata
    return True
def readstoredvariable(storeid, element, variable):
    filedata = []  # list of dictionaries
    readok = filestoragemod.readfiledata(DATAFILENAME, filedata)
    # even if readok  is not True, the below procedure creates a new file
    #search for the storeid and elemet
    isok = False
    value = ""
    for thedict in filedata:
        if "storeid" in thedict:
            if thedict["storeid"] == storeid:
                #search for elemet
                if element in thedict:
                    if variable in thedict[element]:
                        value = thedict[element][variable]
                        isok = True

    return isok, value
Ejemplo n.º 8
0


# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////


global FTDATAFILENAME
FTDATAFILENAME="ftdata.txt"
global DEFFTDATAFILENAME
DEFFTDATAFILENAME="default/defftdata.txt"

global FTdata
FTdata=[]

# read FTdata -----
if not filestoragemod.readfiledata(FTDATAFILENAME,FTdata): #read  setting file
	#read from default file
	filestoragemod.readfiledata(DEFFTDATAFILENAME,FTdata)
	print "Fertilizer writing default calibration data"
	filestoragemod.savefiledata(FTDATAFILENAME,FTdata)
	
# end read IOdata -----



# ///////////////// --- END GLOBAL VARIABLES ------



#-- start filestorage utility--------////////////////////////////////////////////////////////////////////////////////////	
Ejemplo n.º 9
0
HWdataKEYWORDS[HW_CTRL_LOGIC] = ["pos", "neg"]
HWdataKEYWORDS[HW_CTRL_MAILADDR] = []
HWdataKEYWORDS[HW_CTRL_MAILTITLE] = []
HWdataKEYWORDS[HW_FUNC_USEDFOR] = USAGELIST  #used for
HWdataKEYWORDS[HW_FUNC_SCHEDTYPE] = ["oneshot", "periodic"]  #scheduling type
HWdataKEYWORDS[HW_FUNC_TIME] = []  #time in format hh:mm:ss

HWdataKEYWORDS[HW_CTRL_FREQ] = []
HWdataKEYWORDS[HW_CTRL_MIN] = []
HWdataKEYWORDS[HW_CTRL_MAX] = []

# ///////////////// -- Hawrware data structure Setting --  ///////////////////////////////

IOdata = []
# read IOdata -----
if not filestoragemod.readfiledata(HWDATAFILENAME,
                                   IOdata):  #read calibration file
    print "warning hwdata file not found -------------------------------------------------------"
    #read from default file
    filestoragemod.readfiledata(DEFHWDATAFILENAME, IOdata)
    print "writing default calibration data"
    filestoragemod.savefiledata(HWDATAFILENAME, IOdata)
# end read IOdata -----
IOdatatemp = copy.deepcopy(IOdata)
IOdatarow = {}

# ///////////////// --- END GLOBAL VARIABLES ------

#-- start filestorage utility--------////////////////////////////////////////////////////////////////////////////////////

# filestoragemod.readfiledata(filename,filedata)
# filestoragemod.savefiledata(filename,filedata)
Ejemplo n.º 10
0
def restoredefault():
	global FTdata
	filestoragemod.deletefile(FTDATAFILENAME)
	filestoragemod.readfiledata(DEFFTDATAFILENAME,FTdata)
	consitencycheck()
Ejemplo n.º 11
0
def replacewordandsave(oldword,
                       newword):  # used when names are changed in start.py
    global WTdata
    filestoragemod.replacewordandsave(WTDATAFILENAME, oldword, newword)
    filestoragemod.readfiledata(WTDATAFILENAME, WTdata)
Ejemplo n.º 12
0
# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////


global WTDATAFILENAME
WTDATAFILENAME="interruptdata.txt"
global DEFWTDATAFILENAME
DEFWTDATAFILENAME="default/definterruptdata.txt"

global WTdata
WTdata=[]



# read WTdata -----
if not filestoragemod.readfiledata(WTDATAFILENAME,WTdata): #read watering setting file
	#read from default file
	filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
	print("Watering writing default calibration data")
	filestoragemod.savefiledata(WTDATAFILENAME,WTdata)
	
# end read IOdata -----



# ///////////////// --- END GLOBAL VARIABLES ------



#-- start filestorage utility--------////////////////////////////////////////////////////////////////////////////////////	
Ejemplo n.º 13
0
def restoredefault():
	global WTdata
	filestoragemod.deletefile(WTDATAFILENAME)
	filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
	#print "WT data -----------------------------------> ",  WTdata
	consistencycheck()
Ejemplo n.º 14
0
def restoredefault():
	global WTdata
	filestoragemod.deletefile(WTDATAFILENAME)
	filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
	#print "WT data -----------------------------------> ",  WTdata
	consitencycheck()
Ejemplo n.º 15
0
def restoredefault():
	filestoragemod.deletefile(DATAFILENAME)
	filestoragemod.readfiledata(DEFDATAFILENAME,data)
	savesetting()
Ejemplo n.º 16
0
def readdata(filedata):
	filestoragemod.readfiledata(DATAFILENAME,filedata)
Ejemplo n.º 17
0
def restoredefault():
    filestoragemod.deletefile(HWDATAFILENAME)
    filestoragemod.readfiledata(DEFHWDATAFILENAME, IOdata)
    savecalibartion()
Ejemplo n.º 18
0
HWdataKEYWORDS[HW_CTRL_MAILADDR]=[]
HWdataKEYWORDS[HW_CTRL_MAILTITLE]=[]
HWdataKEYWORDS[HW_FUNC_USEDFOR]=USAGELIST #used for
HWdataKEYWORDS[HW_FUNC_SCHEDTYPE]=["oneshot", "periodic"] #scheduling type
HWdataKEYWORDS[HW_FUNC_TIME]=[] #time in format hh:mm:ss

HWdataKEYWORDS[HW_CTRL_FREQ]=[]
HWdataKEYWORDS[HW_CTRL_MIN]=[]
HWdataKEYWORDS[HW_CTRL_MAX]=[]


# ///////////////// -- Hawrware data structure Setting --  ///////////////////////////////

IOdata=[]
# read IOdata -----
if not filestoragemod.readfiledata(HWDATAFILENAME,IOdata): #read calibration file
	print "warning hwdata file not found -------------------------------------------------------"
	#read from default file
	filestoragemod.readfiledata(DEFHWDATAFILENAME,IOdata)
	print "writing default calibration data"
	filestoragemod.savefiledata(HWDATAFILENAME,IOdata)
# end read IOdata -----
IOdatatemp=copy.deepcopy(IOdata)
IOdatarow={}

# ///////////////// --- END GLOBAL VARIABLES ------


# ///////////////// -- STATUS VARIABLES UTILITY --  ///////////////////////////////
Servo_Status={}
Servo_Status["default"]={'duty':"3"}
Ejemplo n.º 19
0
def replacewordandsave(oldword,newword):  # used when names are changed in start.py
	global WTdata
	filestoragemod.replacewordandsave(WTDATAFILENAME,oldword,newword)
	filestoragemod.readfiledata(WTDATAFILENAME,WTdata)
Ejemplo n.º 20
0
def restoredefault():
	filestoragemod.deletefile(HWDATAFILENAME)
	filestoragemod.readfiledata(DEFHWDATAFILENAME,IOdata)
	savecalibartion()
Ejemplo n.º 21
0
def readfromfile():
    global FTdata
    filestoragemod.readfiledata(FTDATAFILENAME, FTdata)
Ejemplo n.º 22
0
def readdata(filedata):
    filestoragemod.readfiledata(DATAFILENAME, filedata)
Ejemplo n.º 23
0
def replacewordandsave(oldword,newword):
	global WTdata
	filestoragemod.replacewordandsave(WTDATAFILENAME,oldword,newword)
	filestoragemod.readfiledata(WTDATAFILENAME,WTdata)
Ejemplo n.º 24
0
import time
import filestoragemod
import hardwaremod



# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////


global DATAFILENAME
DATAFILENAME="logincred.txt"


# if file does not exist create file
data=[]
if not filestoragemod.readfiledata(DATAFILENAME,data): #read  setting file
	filedata=[{'name':'login', 'username':'******','password':'******' }]
	filestoragemod.savefiledata(DATAFILENAME,filedata)


	
def restoredefault():
	filestoragemod.deletefile(DATAFILENAME)
	filedata=[{'name':'login', 'username':'******','password':'******' }]
	filestoragemod.savefiledata(DATAFILENAME,filedata)


	
def savedata(filedata):
	filestoragemod.savefiledata(DATAFILENAME,filedata)
Ejemplo n.º 25
0
# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////




DATAFILENAME="camdata.txt"
DEFDATAFILENAME="default/defcamdata.txt"
CAMERAPARAMETERS=["camname","resolution","position","servo","time","active","vflip"]


global data
data=[]

# read data -----
if not filestoragemod.readfiledata(DATAFILENAME,data): #read watering setting file
	#read from default file
	filestoragemod.readfiledata(DEFDATAFILENAME,data)
	print "Watering writing default calibration data"
	filestoragemod.savefiledata(DATAFILENAME,data)
# end read data -----



# ///////////////// --- END GLOBAL VARIABLES ------



#-- start filestorage utility--------////////////////////////////////////////////////////////////////////////////////////	

# one row is called "default" and include the default data before setting
Ejemplo n.º 26
0
import time
import filestoragemod
import hardwaremod

# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////

global FTDATAFILENAME
FTDATAFILENAME = "ftdata.txt"
global DEFFTDATAFILENAME
DEFFTDATAFILENAME = "default/defftdata.txt"

global FTdata
FTdata = []

# read FTdata -----
if not filestoragemod.readfiledata(FTDATAFILENAME,
                                   FTdata):  #read  setting file
    #read from default file
    filestoragemod.readfiledata(DEFFTDATAFILENAME, FTdata)
    print "Fertilizer writing default calibration data"
    filestoragemod.savefiledata(FTDATAFILENAME, FTdata)

# end read IOdata -----

# ///////////////// --- END GLOBAL VARIABLES ------

#-- start filestorage utility--------////////////////////////////////////////////////////////////////////////////////////

# filestoragemod.readfiledata(filename,filedata)
# filestoragemod.savefiledata(filename,filedata)
# filestoragemod.appendfiledata(filename,filedata)
# filestoragemod.savechange(filename,searchfield,searchvalue,fieldtochange,newvalue)
Ejemplo n.º 27
0
import os.path
import sys
import string
from datetime import datetime, date, timedelta
import time
import filestoragemod
import hardwaremod

# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////

global DATAFILENAME
DATAFILENAME = "logincred.txt"

# if file does not exist create file
data = []
if not filestoragemod.readfiledata(DATAFILENAME, data):  #read  setting file
    filedata = [{'name': 'login', 'username': '******', 'password': '******'}]
    filestoragemod.savefiledata(DATAFILENAME, filedata)


def restoredefault():
    filestoragemod.deletefile(DATAFILENAME)
    filedata = [{'name': 'login', 'username': '******', 'password': '******'}]
    filestoragemod.savefiledata(DATAFILENAME, filedata)


def savedata(filedata):
    filestoragemod.savefiledata(DATAFILENAME, filedata)


def getusername():
Ejemplo n.º 28
0
def restoredefault():
    global FTdata
    filestoragemod.deletefile(FTDATAFILENAME)
    filestoragemod.readfiledata(DEFFTDATAFILENAME, FTdata)
    consitencycheck()
Ejemplo n.º 29
0
def replacewordandsave(oldword,newword):
	global WTdata
	filestoragemod.replacewordandsave(WTDATAFILENAME,oldword,newword)
	filestoragemod.readfiledata(WTDATAFILENAME,WTdata)
Ejemplo n.º 30
0
def restoredefault():
    filestoragemod.deletefile(DATAFILENAME)
    filestoragemod.readfiledata(DEFDATAFILENAME, data)
    savesetting()
Ejemplo n.º 31
0
def readfromfile():
	global WTdata
	filestoragemod.readfiledata(WTDATAFILENAME,WTdata)
Ejemplo n.º 32
0
def replacewordandsave(oldword, newword):
    filestoragemod.replacewordandsave(FTDATAFILENAME, oldword, newword)
    filestoragemod.readfiledata(FTDATAFILENAME, FTdata)