#print("runtime")
    #print("reading input")
    # Read again, once inside each loop so we terminate if the 
    # variable name is changed

    inputsreadenabled = pilib.sqlitedatumquery(pilib.controldatabase, 'select inputsreadenabled from systemstatus')

    # Set last run time
    pilib.sqlitequery(pilib.controldatabase, 'update systemstatus set lastinputspoll=\'' + pilib.gettimestring() + '\'')
    pilib.sqlitequery(pilib.controldatabase, 'update systemstatus set inputsreadstatus=\'1\'')

    # Read and record everything as specified in controldatabase
    # Update database of inputs with read data

    reply = updateio.updateiodata(pilib.controldatabase)

    result = pilib.readonedbrow(pilib.controldatabase, 'systemstatus', 0)
    systemsdict = result[0]
    #print("here is the systems dict")
    #print(systemsdict)
    readtime = systemsdict['inputsreadfreq']

    plotpoints = 20
    logpoints = 100

    ################################################### 
    # Update controlvalues in channels

    channels = pilib.readalldbrows(pilib.controldatabase, 'channels')
    for channel in channels:
 def updateio(self):
     from updateio import updateiodata
     from pilib import controldatabase
     updateiodata(controldatabase)