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


import numpy as np
import sys
import time
import serial
import glob
import logger
from copy import deepcopy
from config import config
               'Temp':[-50.0,-50.0,-50.0,-50.0,-50.0,-50.0,-50.0,-50.0]}


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,interfacesinuse):
    self.rawdat = deepcopy(initrawdat)
    self.reply ='' # placeholder for reply from sendcmd
    self.pylondown=0.0
    try:
      self.findpylon()
    except serial.serialutil.SerialException as err:
      self.pylondown=time.time() # flag pylontech is down
      log.error(err)


    self.floatv=48.0
    self.bulkv=48.0
    self.rechargev=48.0
    self.lowv=44.0
#    self.command=b''  # last command sent to pylontech
    self.time=0.0

  def findpylon(self):
    """Scan ports to find pylon port"""

    self.pylonport=""

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


# Path: pylon.py
import numpy as np
import sys
import time
import serial
import glob
import logger
from copy import deepcopy
from config import config

               'Temp':[-50.0,-50.0,-50.0,-50.0,-50.0,-50.0,-50.0,-50.0]}


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,interfacesinuse):
    self.rawdat = deepcopy(initrawdat)
    self.reply ='' # placeholder for reply from sendcmd
    self.pylondown=0.0
    try:
      self.findpylon()
    except serial.serialutil.SerialException as err:
      self.pylondown=time.time() # flag pylontech is down
      log.error(err)


    self.floatv=48.0
    self.bulkv=48.0
    self.rechargev=48.0
    self.lowv=44.0
#    self.command=b''  # last command sent to pylontech
    self.time=0.0

  def findpylon(self):
    """Scan ports to find pylon port"""

    self.pylonport=""

    for dev in glob.glob(config['Ports']['pylonport']):