# Path: config.py
# def editbatconfig(section,item,itemvalue):
# def loadconfig():


import sys
import time
from os import rename
from shutil import copy as filecopy
from copy import deepcopy
from ast import literal_eval
from configparser import SafeConfigParser
from config import config, loadconfig
  except IOError:
    pass
  iin=literal_eval(summaryfile.get('current','ioutmax'))
  iprint = ''
  for i in range(numiin):
    iprint = iprint + str(i+1) + '=' + str(iin[i]).ljust(5,'0') + ', '
  print('Readings from summary: ' + iprint)

  
def main():
  print('Usage: At > prompt enter current input channel number to change then [Enter] key')
  print('       Pressing just the [Enter] key will display the latest current readings, type ^C to exit')
  print()
  print('       Make sure the Battery Monitoring software is running otherwise the summary file will not be current')
  print('       This program uses the data from the log file generated by the Battery Monitoring software')
  print('       Make sure that the Battery Monitoring software is logging to a real file and not /dev/null')
  print('       This program averages the data from the log file for the last 100 seconds.')
  print('       To make sure that the calibartion is accurate make sure the current on the input being calibrated is not varying')   
  while True:
    try:
#      time.sleep(60.0)
      geti()
      what = input(">")
      if len(what)>0:
        avi=getavi()
        reali = eval(input("Input " + what + " multimeter reading "))
        if reali == 0:
          print("Input Error: Zero not valid current input")
        else:
          what=int(what)

# Path: config.py
# def editbatconfig(section,item,itemvalue):
# def loadconfig():


# Path: caligain.py
import sys
import time
from os import rename
from shutil import copy as filecopy
from copy import deepcopy
from ast import literal_eval
from configparser import SafeConfigParser
from config import config, loadconfig

  except IOError:
    pass
  iin=literal_eval(summaryfile.get('current','ioutmax'))
  iprint = ''
  for i in range(numiin):
    iprint = iprint + str(i+1) + '=' + str(iin[i]).ljust(5,'0') + ', '
  print('Readings from summary: ' + iprint)

  
def main():
  print('Usage: At > prompt enter current input channel number to change then [Enter] key')
  print('       Pressing just the [Enter] key will display the latest current readings, type ^C to exit')
  print()
  print('       Make sure the Battery Monitoring software is running otherwise the summary file will not be current')
  print('       This program uses the data from the log file generated by the Battery Monitoring software')
  print('       Make sure that the Battery Monitoring software is logging to a real file and not /dev/null')
  print('       This program averages the data from the log file for the last 100 seconds.')
  print('       To make sure that the calibartion is accurate make sure the current on the input being calibrated is not varying')   
  while True:
    try:
#      time.sleep(60.0)
      geti()
      what = input(">")
      if len(what)>0:
        avi=getavi()
        reali = eval(input("Input " + what + " multimeter reading "))
        if reali == 0:
          print("Input Error: Zero not valid current input")
        else:
          what=int(what)

          config['calibrate']['currentgain'][what-1] = config['calibrate']['currentgain'][what-1]*reali/avi[what-1]