def addrow(dicttemp, temp=True): global IOdata global IOdatatemp if temp: IOdatatemp.append(dicttemp) return True else: IOdata.append(dicttemp) filestoragemod.savefiledata(HWDATAFILENAME,IOdata) return True
def replacerow(element,dicttemp): searchfield="name" searchvalue=element for line in data: if line[searchfield]==searchvalue: for row in line: line[row]=dicttemp[row] filestoragemod.savefiledata(DATAFILENAME,data) return True return False
def deleterow(element, temp=True): global IOdata global IOdatatemp searchfield=HW_INFO_NAME searchvalue=element if temp: for line in IOdatatemp: if searchfield in line: if line[searchfield]==searchvalue: IOdatatemp.remove(line) return True return False else: for line in IOdata: if searchfield in line: if line[searchfield]==searchvalue: IOdata.remove(line) filestoragemod.savefiledata(HWDATAFILENAME,IOdata) return True return False
def savecalibartion(): filestoragemod.savefiledata(HWDATAFILENAME,IOdata)
def IOdatafromtemp(): global IOdata IOdata=copy.deepcopy(IOdatatemp) filestoragemod.savefiledata(HWDATAFILENAME,IOdata)
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) # filestoragemod.deletefile(filename) def consitencycheck():
def saveWTsetting(): filestoragemod.savefiledata(WTDATAFILENAME,WTdata)
def savedata(filedata): filestoragemod.savefiledata(DATAFILENAME,filedata)
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)
def saveWTsetting(): filestoragemod.savefiledata(WTDATAFILENAME, WTdata)
global WTDATAFILENAME WTDATAFILENAME = "wtdata.txt" global DEFWTDATAFILENAME DEFWTDATAFILENAME = "default/defwtdata.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--------//////////////////////////////////////////////////////////////////////////////////// # filestoragemod.readfiledata(filename,filedata) # filestoragemod.savefiledata(filename,filedata) # filestoragemod.appendfiledata(filename,filedata) # filestoragemod.savechange(filename,searchfield,searchvalue,fieldtochange,newvalue) # filestoragemod.deletefile(filename) def consitencycheck():
def savesetting(): filestoragemod.savefiledata(DATAFILENAME, data)
# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- ////////////////////////////////////////// DATAFILENAME = "addata.txt" DEFDATAFILENAME = "default/defaddata.txt" global data data = [] tempelementdict = {} # 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--------//////////////////////////////////////////////////////////////////////////////////// # filestoragemod.readfiledata(filename,filedata) # filestoragemod.savefiledata(filename,filedata) # filestoragemod.appendfiledata(filename,filedata) # filestoragemod.savechange(filename,searchfield,searchvalue,fieldtochange,newvalue) # filestoragemod.deletefile(filename) def replaceschemanameandsave(replacedict): filename = DATAFILENAME
def saveFTsetting(): filestoragemod.savefiledata(FTDATAFILENAME, FTdata)
def restoredefault(): filestoragemod.deletefile(DATAFILENAME) filedata=[{'name':'clock', 'timezone':'UTC'}] filestoragemod.savefiledata(DATAFILENAME,filedata)
def restoredefault(): filestoragemod.deletefile(DATAFILENAME) filedata=[{'name':'login', 'username':'******','password':'******' }] filestoragemod.savefiledata(DATAFILENAME,filedata)
def saveFTsetting(): filestoragemod.savefiledata(FTDATAFILENAME,FTdata)
global WTDATAFILENAME WTDATAFILENAME="automationdata.txt" global DEFWTDATAFILENAME DEFWTDATAFILENAME="default/defautomationdata.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--------//////////////////////////////////////////////////////////////////////////////////// # filestoragemod.readfiledata(filename,filedata) # filestoragemod.savefiledata(filename,filedata) # filestoragemod.appendfiledata(filename,filedata) # filestoragemod.savechange(filename,searchfield,searchvalue,fieldtochange,newvalue)
def restoredefault(): filestoragemod.deletefile(DATAFILENAME) filedata=[{"name": "IPsetting", "LocalIPaddress": "192.168.1.172", "LocalPORT": "5172", "LocalAPSSID" : "Hydrosys4", "APtime" : "180"}] filestoragemod.savefiledata(DATAFILENAME,filedata)
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 # {"resolution": "320x240", "fps": "20", "time": "10:30", "name": "default"} # once the setting is saved, several lines will be produced with name="camera" and "camname" = video1 , video2 , etc # {"resolution": "320x240", "fps": "20", "time": "10:30", "name": "camera", "camname" : "video1"}
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"} Stepper_Status={} Stepper_Status["default"]={'position':"0"}
def savesetting(): filestoragemod.savefiledata(DATAFILENAME,data)
def restoredefault(): filestoragemod.deletefile(DATAFILENAME) filedata=[{'name':'email', 'address':'','password':'' }] filestoragemod.savefiledata(DATAFILENAME,filedata)