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


import sys
import time
import serial
import binascii
import glob
import logger
from threading import Thread
from config import config
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


#!/usr/bin/python
numcells = config['battery']['numcells']
log = logger.logging.getLogger(__name__)
log.setLevel(logger.logging.DEBUG)
log.addHandler(logger.errfile)
initrawdat ={'DataValid':False,'BInI':0.0,'BOutI':0.0,'BV':0.0,'PVI':0.0,'PVW':0,'ACW':0.0,'ChgStat':b'00'}



class Rawdat():
  """class for obtaining data from and controlling indidvdual PIP inverters.
  When class is instantiated the SN of the PIP is used to tie the instance of
  the class to the particular machine"""

  def __init__(self,sn,InterfacesInUse):
    self.rawdat = dict.copy(initrawdat)
    self.reply ='' # placeholder for reply from sendcmd
    self.pipdown=0.0
    self.sn=sn
    self.timeslaveon=0  # time slave inverter was turned on
    try:
      self.findpip(InterfacesInUse)
    except IOError as err:
      self.pipdown=time.time() # flag pip is down

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


# Path: pip.py
import sys
import time
import serial
import binascii
import glob
import logger
from threading import Thread
from config import config

# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


#!/usr/bin/python
numcells = config['battery']['numcells']
log = logger.logging.getLogger(__name__)
log.setLevel(logger.logging.DEBUG)
log.addHandler(logger.errfile)
initrawdat ={'DataValid':False,'BInI':0.0,'BOutI':0.0,'BV':0.0,'PVI':0.0,'PVW':0,'ACW':0.0,'ChgStat':b'00'}



class Rawdat():
  """class for obtaining data from and controlling indidvdual PIP inverters.
  When class is instantiated the SN of the PIP is used to tie the instance of
  the class to the particular machine"""

  def __init__(self,sn,InterfacesInUse):
    self.rawdat = dict.copy(initrawdat)
    self.reply ='' # placeholder for reply from sendcmd
    self.pipdown=0.0
    self.sn=sn
    self.timeslaveon=0  # time slave inverter was turned on
    try:
      self.findpip(InterfacesInUse)
    except IOError as err:
      self.pipdown=time.time() # flag pip is down

      log.error(err)