Ejemplo n.º 1
0
def main():
    print 'Usage: Pressing just the [Enter] key will display the latest voltage readings, type ^C to exit'
    print '       Press any other key to change the voltage calibration of all the voltage readings'
    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 calibration is accurate make sure the input voltages are not varying'

    avvolts = []
    while True:
        try:

            loadconfig()
            avvolts = avv()
            #      time.sleep(60.0)
            what = raw_input(">")
            if len(what) > 0:
                realvolts = input("All Cell readings ")
                for i in range(numcells):
                    config['calibrate']['delta'][i] = round(
                        avvolts[i] - realvolts +
                        config['calibrate']['delta'][i], 3)
                print config['calibrate']['delta']
                batconfigdata = SafeConfigParser()
                batconfigdata.read('battery.cfg')
                batconfigdata.set('calibrate', 'delta',
                                  str(config['calibrate']['delta']))
                with open('battery.cfg', 'w') as batconfig:
                    batconfigdata.write(batconfig)
                batconfig.closed

        except KeyboardInterrupt:
            break
Ejemplo n.º 2
0
def main():
  print 'Usage: Pressing just the [Enter] key will display the latest voltage readings, type ^C to exit'
  print '       Type in the cell # that you want to calibrate followed by [Enter]
  print '       Then type in the mesured voltage for that cell followed by [Enter]'
  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 calibration is accurate make sure the input voltages are not varying'   
  avvolts=[]
  while True:
    try:
      loadconfig()
      avvolts=avv()
#      time.sleep(60.0)
      what = raw_input(">")
      if len(what)>0:
        realvolts = input("Cell " + what + " reading ")
        what=int(what)
        config['calibrate']['delta'][what-1] = round(avvolts[what-1]-realvolts+config['calibrate']['delta'][what-1],3)
        batconfigdata=SafeConfigParser()
        batconfigdata.read('battery.cfg')
        batconfigdata.set('calibrate','delta',str(config['calibrate']['delta']))
        with open('battery.cfg', 'w') as batconfig:
          batconfigdata.write(batconfig)
        batconfig.closed


    except KeyboardInterrupt:
      break
Ejemplo n.º 3
0
def main():
  print('Usage: Pressing just the [Enter] key will display the latest voltage readings, type ^C to exit')
  print('       Type in the cell # that you want to calibrate followed by [Enter]')
  print('       Then type in the mesured voltage for that cell followed by [Enter]')
  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 calibration is accurate make sure the input voltages are not varying')
  avvolts=[]
  while True:
    try:
      loadconfig()
      avvolts=avv()
#      time.sleep(60.0)
      what = input(">")
      if len(what)>0:
        realvolts = eval(input("Cell " + what + " reading "))
        what=int(what)
        config['calibrate']['delta'][what-1] = round(avvolts[what-1]-realvolts+config['calibrate']['delta'][what-1],3)
        batconfigdata=SafeConfigParser()
        batconfigdata.read('battery.cfg')
        batconfigdata.set('calibrate','delta',str(config['calibrate']['delta']))
        with open('battery.cfg', 'w') as batconfig:
          batconfigdata.write(batconfig)
        batconfig.closed


    except KeyboardInterrupt:
      break
Ejemplo n.º 4
0
def main():
    config.loadconfig()

    initmodel(config.config['dburi'])
    s = Session()

    while True:
        req = sys.stdin.readline()
        res = s.query(Backend).filter(
                Backend.enabled == True).order_by(func.random()).first()
        sys.stdout.write('%s\n' % (res.ipaddr if res else 'NULL'))
        sys.stdout.flush()
Ejemplo n.º 5
0
def getavi():
    istr = ""
    avi = [0.0 for i in range(numiin)]
    endlog = tail(config['files']['logfile'], 11)
    for line in range(10):
        lineargs = str(endlog[line]).split(' ')
        for iin in range(numiin):
            avi[iin] = avi[iin] + float(lineargs[1 + numcells + 2 + iin]) / 10
    for iin in range(numiin):
        istr = istr + str(round(avi[iin], 3)) + ", "
    print 'Average readings for last 100 seconds: ' + istr
    loadconfig()
    print 'gain from config file: ' + str(config['calibrate']['currentgain'])
    return avi
Ejemplo n.º 6
0
def main():
    # load config, data
    c = config.loadconfig(os.environ['config'])
    f = config.loaddata('../assets/src.csv')

    # db stuff
    connection = twitterdb.connectdb(c.database)
    conn = connection.cursor()
    twitterdb.createtable(conn, c.table)

    # create api instance
    api = config.createapi(c)

    # get  most recent tweet
    tweets = twitterapi.timelinetweets(api, c.user, c.count, today=1)

    for tweet in tweets:
        tweet.examine_tweet(f)

        # insert into db
        twitterdb.insertrow(
            conn,
            c.table,
            tweet.id,
            tweet.created_at,
            tweet.text,
            tweet.examine_flag
        )

    connection.commit()
    connection.close()
Ejemplo n.º 7
0
def deamon(soc=-1):
    """ Main loop, gets battery data, gets summary.py to do logging"""

    try:
        import summary
        logsummary = summary.Summary()
        summary = logsummary.summary
        printtime = time.strftime("%Y%m%d%H%M%S ", time.localtime())
        while int(printtime) <= int(summary['current']['timestamp']):
            print(printtime, summary['current']['timestamp'])
            print("Error: Current time before last sample time")
            time.sleep(30)
            printtime = time.strftime("%Y%m%d%H%M%S", time.localtime())
        batdata = Readings()  # initialise batdata after we have valid sys time
        alarms = Alarms(batdata)  # initialise alarms

        print(str(printtime))
        filecopy(config['files']['summaryfile'],
                 config['files']['summaryfile'] + "R" + str(int(printtime)))
        if soc > config['battery']['capacity']:
            print("Battery DOD must be less than Battery Capacity")

        else:
            if soc < 0:
                batdata.soc = summary['current']['ah'][0]
                batdata.socadj = summary['current']['dod'][0]
            else:
                batdata.soc = soc
                batdata.socadj = soc
                summary['current']['dod'][3] = 0
            summary['current']['dod'][
                3] = -100  # flag don't adjust leakage current
            prevtime = logsummary.currenttime
            prevbatvoltage = batdata.batvoltsav[numcells]
            #    logsummary.startday(summary)
            #    logsummary.starthour(summary)

            while True:
                try:
                    for i in range(config['sampling']['samplesav']):
                        #          printvoltage = ''
                        #          for i in range(numcells+1):
                        #            printvoltage = printvoltage + str(round(batdata.batvolts[i],3)).ljust(5,'0') + ' '
                        #         print (printvoltage)
                        batdata.getraw()

                        #          if batdata.batvoltsav[numcells] >= 55.2 and prevbatvoltage < 55.2:  # reset SOC counter?
                        #          print batdata.socadj/(float(summary['current']['dod'][3])*24.0)
                        if batdata.batvoltsav[numcells] < config['battery']['vreset'] \
                        and prevbatvoltage >= config['battery']['vreset'] \
                        and summary['current']['dod'][3] != 0 \
                        and -batdata.currentav[0] < config['battery']['ireset']:  # reset SOC counter?

                            if summary['current']['dod'][3] <= 0:
                                socerr = 0
                            else:
                                socerr = batdata.socadj / (
                                    float(summary['current']['dod'][3]) * 24.0)
                                socerr = max(socerr, -0.01)
                                socerr = min(socerr, 0.01)
                            config['battery']['ahloss'] = config['battery'][
                                'ahloss'] - socerr / 2
                            batconfigdata = SafeConfigParser()
                            batconfigdata.read('battery.cfg')
                            batconfigdata.set('battery', 'ahloss',
                                              str(config['battery']['ahloss']))
                            with open('battery.cfg', 'w') as batconfig:
                                batconfigdata.write(batconfig)
                            batconfig.closed

                            batdata.soc = 0.0
                            batdata.socadj = 0.0
                            summary['current']['dod'][3] = 0
                        else:
                            batdata.soc = batdata.soc + batdata.batah
                            batdata.socadj = batdata.socadj + batdata.batahadj
                        batdata.ah = batdata.ah + batdata.batah
                        batdata.inahtot = batdata.inahtot + batdata.inah
                        batdata.pwrbattot = batdata.pwrbattot + batdata.pwrbat
                        batdata.pwrintot = batdata.pwrintot + batdata.pwrin
                    prevbatvoltage = batdata.batvoltsav[numcells]
                    # check alarms
                    alarms.scanalarms(batdata)
                    # update summaries
                    logsummary.update(summary, batdata)
                    if logsummary.currenttime[4] != logsummary.prevtime[
                            4]:  # new minute
                        loadconfig()
                        logsummary.updatesection(summary, 'hour', 'current')
                        logsummary.updatesection(summary, 'alltime', 'current')
                        logsummary.updatesection(summary, 'currentday',
                                                 'current')
                        logsummary.updatesection(summary, 'monthtodate',
                                                 'current')
                        logsummary.updatesection(summary, 'yeartodate',
                                                 'current')
                        logsummary.writesummary()
                        batdata.ah = 0.0
                        batdata.ahadj = 0.0
                        batdata.inahtot = 0.0
                        batdata.pwrbattot = 0.0
                        batdata.pwrintot = 0.0
                        for i in range(batdata.numiins):
                            batdata.kWhin[i] = 0.0
                            batdata.kWhout[i] = 0.0
                        for i in range(numcells):
                            batdata.baltime[i] = 0

                    if logsummary.currenttime[3] != logsummary.prevtime[
                            3]:  # new hour
                        logsummary.starthour(summary)

                    if logsummary.currenttime[3] < logsummary.prevtime[
                            3]:  # newday
                        logsummary.startday(summary)

                    if logsummary.currenttime[1] != logsummary.prevtime[
                            1]:  # new month
                        logsummary.startmonth(summary)

                    if logsummary.currenttime[0] != logsummary.prevtime[
                            0]:  # new year
                        logsummary.startyear(summary)

                except KeyboardInterrupt:
                    sys.stdout.write('\n')
                    logsummary.close()
                    sys.exit(9)
                    break
    except Exception as err:
        log.critical(err)
        raise
Ejemplo n.º 8
0
def deamon(soc=-1):
  """ Main loop, gets battery data, gets summary.py to do logging"""
  try:
    import summary
    logsummary = summary.Summary()
    summary = logsummary.summary
    printtime = time.strftime("%Y%m%d%H%M%S ", time.localtime())
    while int(printtime) <= int(summary['current']['timestamp']):
      print(printtime,summary['current']['timestamp'])
      print ("Error: Current time before last sample time")
      time.sleep(30)
      printtime = time.strftime("%Y%m%d%H%M%S", time.localtime())
    batdata = Readings()  # initialise batdata after we have valid sys time
    alarms = Alarms(batdata,summary) # initialise alarms

    print (str(printtime))
    filecopy(config['files']['summaryfile'],config['files']['summaryfile']+"R" + str(int(printtime)))
    if soc > config['battery']['capacity']:
      print ("Battery DOD must be less than Battery Capacity")

    else:
      if soc < 0:
         batdata.soc = summary['current']['ah'][0]
         batdata.socadj = summary['current']['dod'][0]
      else:
        batdata.soc = soc
        batdata.socadj = soc
        summary['current']['dod'][3] = 0
      summary['current']['dod'][3] = -100 # flag don't adjust leakage current
      prevtime = logsummary.currenttime
      prevbatvoltage = batdata.batvoltsav[numcells]
  #    logsummary.startday(summary)
  #    logsummary.starthour(summary)


      while True:
        try:
          for i in range(config['sampling']['samplesav']):
  #          printvoltage = ''
  #          for i in range(numcells+1):
  #            printvoltage = printvoltage + str(round(batdata.batvolts[i],3)).ljust(5,'0') + ' '
  #         print (printvoltage)
            batdata.getraw()

  #          if batdata.batvoltsav[numcells] >= 55.2 and prevbatvoltage < 55.2:  # reset SOC counter?
  #          print batdata.socadj/(float(summary['current']['dod'][3])*24.0)
            if batdata.batvoltsav[numcells] < config['battery']['vreset'] \
            and prevbatvoltage >= config['battery']['vreset'] \
            and summary['current']['dod'][3] != 0 \
            and -batdata.currentav[0] < config['battery']['ireset']:  # reset SOC counter?

              if summary['current']['dod'][3] <= 0 :
                socerr=0
              else:
                socerr=batdata.socadj/(float(summary['current']['dod'][3])*24.0)
                socerr=max(socerr,-0.01)
                socerr=min(socerr,0.01)
              config['battery']['ahloss']=config['battery']['ahloss']-socerr/2
              batconfigdata=SafeConfigParser()
              batconfigdata.read('battery.cfg')
              batconfigdata.set('battery','ahloss',str(config['battery']['ahloss']))
              with open('battery.cfg', 'w') as batconfig:
                batconfigdata.write(batconfig)
              batconfig.closed

              batdata.soc = 0.0
              batdata.socadj = 0.0
              summary['current']['dod'][3] = 0
            else:
              batdata.soc = batdata.soc + batdata.batah
              batdata.socadj = batdata.socadj +batdata.batahadj
            batdata.ah = batdata.ah + batdata.batah
            batdata.inahtot = batdata.inahtot + batdata.inah
            batdata.pwrbattot = batdata.pwrbattot + batdata.pwrbat
            batdata.pwrintot = batdata.pwrintot + batdata.pwrin
          prevbatvoltage = batdata.batvoltsav[numcells]
  # check alarms
          alarms.scanalarms(batdata)
  # update summaries
          logsummary.update(summary, batdata)
          if logsummary.currenttime[4] != logsummary.prevtime[4]:  # new minute
            loadconfig()
            logsummary.updatesection(summary, 'hour', 'current')
            logsummary.updatesection(summary, 'alltime','current')
            logsummary.updatesection(summary, 'currentday','current')
            logsummary.updatesection(summary, 'monthtodate', 'current')
            logsummary.updatesection(summary, 'yeartodate', 'current')
            logsummary.writesummary()
            batdata.ah = 0.0
            batdata.ahadj = 0.0
            batdata.inahtot = 0.0
            batdata.pwrbattot = 0.0
            batdata.pwrintot = 0.0
            for i in range(batdata.numiins):
              batdata.kWhin[i] = 0.0
              batdata.kWhout[i] = 0.0
            for i in range(numcells):
              batdata.baltime[i]=0


          if logsummary.currenttime[3] != logsummary.prevtime[3]:  # new hour
            logsummary.starthour(summary)

          if logsummary.currenttime[3] < logsummary.prevtime[3]: # newday
            logsummary.startday(summary)

          if logsummary.currenttime[1] != logsummary.prevtime[1]: # new month
            logsummary.startmonth(summary)

          if logsummary.currenttime[0] != logsummary.prevtime[0]: # new year
            logsummary.startyear(summary)

        except KeyboardInterrupt:
          sys.stdout.write('\n')
          logsummary.close()
          sys.exit(9)
          break
  except Exception as err:
    log.critical(err)
    raise
Ejemplo n.º 9
0
def mainloop():
    """ Main loop, gets battery data, gets summary.py to do logging"""

    global prevbatvoltage
    summary = logsummary.summary
    for i in range(config['sampling']['samplesav']):
        #          printvoltage = ''
        #          for i in range(numcells+1):
        #            printvoltage = printvoltage + str(round(batdata.batvolts[i],3)).ljust(5,'0') + ' '
        #         print (printvoltage)
        batdata.getraw()


#          if batdata.batvoltsav[numcells] >= 55.2 and prevbatvoltage < 55.2:  # reset SOC counter?
#          print batdata.socadj/(float(summary['current']['dod'][3])*24.0)

    if batdata.batvoltsav[numcells] < config['battery']['vreset'] \
                        and prevbatvoltage >= config['battery']['vreset'] \
                        and summary['current']['dod'][3] != 0 \
                        and -batdata.currentav[-3] < config['battery']['ireset']:  # reset SOC counter?

        if summary['current']['dod'][3] <= 0:
            socerr = 0
        else:
            socerr = batdata.socadj / (float(summary['current']['dod'][3]) *
                                       24.0)
            socerr = max(socerr, -0.01)
            socerr = min(socerr, 0.01)
        config['battery']['ahloss'] = config['battery']['ahloss'] - socerr / 2
        editbatconfig('battery', 'ahloss', str(config['battery']['ahloss']))
        batdata.soc = config['battery']['socreset']
        batdata.socadj = batdata.soc
        summary['current']['dod'][3] = 0
    else:
        batdata.soc = batdata.soc + batdata.batah
        batdata.socadj = batdata.socadj + batdata.batahadj

    prevbatvoltage = batdata.batvoltsav[numcells]
    batdata.ah = batdata.ah + batdata.batah
    batdata.inahtot = batdata.inahtot + batdata.inah
    batdata.pwrbattot = batdata.pwrbattot + batdata.pwrbat
    batdata.pwrintot = batdata.pwrintot + batdata.pwrin
    # check alarms
    alarms.scanalarms(batdata)
    # update summaries
    batdata.pwravailable, batdata.minmaxdemandpwr = solaravailable(batdata)
    logsummary.update(summary, batdata)
    currenttime = str(logsummary.currenttime)
    prevtime = str(logsummary.prevtime)
    if currenttime[10:12] != prevtime[10:12]:  # new minute
        loadconfig()
        logsummary.updatesection(summary, 'hour', 'current')
        logsummary.updatesection(summary, 'alltime', 'current')
        logsummary.updatesection(summary, 'currentday', 'current')
        logsummary.updatesection(summary, 'monthtodate', 'current')
        logsummary.updatesection(summary, 'yeartodate', 'current')
        logsummary.writesummary()
        #    mqtt.publish(client,"batpwrin",str(-summary['alltime']['power'][0]))
        #    mqtt.publish(client,"batpwrout",str(summary['alltime']['power'][1]))
        #    mqtt.publish(client,"solarpwr",str(-summary['alltime']['power'][2]))
        #    print(exec("config["mqtt"]["payload"]))
        for item in config['mqtt']['payload']:
            config['mqtt']['payload'][item] = eval(
                config['mqtt']['payload'][item])
        mqtt.publish(config['mqtt']['topic'],
                     f"{config['mqtt']['payload']}".replace("'", '"'))
        #    print(f'{config["mqtt"]["payload"]}')
        #    mqtt.publish(client,"broome_st/energy",\
        #    f'{{"batpwrin":{-summary["alltime"]["power"][0]},\
        #"batpwrpwrout":{summary["alltime"]["power"][1]},\
        #"solarpwr":{-summary["alltime"]["power"][2]},\
        #"batsoc":{round(100*(1-summary["current"]["dod"][0]/config["battery"]["capacity"]),1)}\
        #}}')

        #    mqtt.publish(client,"loadpwr",str(summary['current']['power'][3]))
        batdata.ah = 0.0
        batdata.ahadj = 0.0
        batdata.inahtot = 0.0
        batdata.pwrbattot = 0.0
        batdata.pwrintot = 0.0
        for i in range(batdata.numiins):
            batdata.kWhin[i] = 0.0
            batdata.kWhout[i] = 0.0
        for i in range(numcells):
            batdata.baltime[i] = 0

    if currenttime[8:10] != prevtime[8:10]:  # new hour
        logsummary.starthour(summary)

    if currenttime[6:8] != prevtime[6:8]:  # newday
        logsummary.startday(summary)

    if currenttime[4:6] != prevtime[4:6]:  # new month
        logsummary.startmonth(summary)

    if currenttime[0:4] != prevtime[0:4]:  # new year
        logsummary.startyear(summary)
Ejemplo n.º 10
0
import httplib
httplib.responses[422] = 'Unprocessable Entity'

import bottle
app = application = bottle.app()
app.catchall = True

import version
import codec
#import http
#import model
import config
import database
#import gitlab
#import response
#import aaa
#import provider

config.loadconfig(app)
database.start(app)

# install better json plugin
bottle.uninstall(bottle.JSONPlugin)
class ExtraJSONPlugin(bottle.JSONPlugin):
	def __init__(self):
		super(ExtraJSONPlugin, self).__init__(json_dumps=codec.json_codec.encode)
bottle.install(ExtraJSONPlugin())

# roll the bones
import rest
Ejemplo n.º 11
0
def setup_request():
    config.loadconfig()
    initmodel(config.config['dburi'])
    request.db = Session()
Ejemplo n.º 12
0
'''
@author:chenghuan
@time:2018/03/22
@博客的配置项文件
'''
#ImportError: No module named 'MySQLdb'   https://www.cnblogs.com/TaleG/p/6735099.html
import pymysql
pymysql.install_as_MySQLdb()

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bootstrap import Bootstrap
from config import loadconfig
#app是Flask的实例,它接收包或者模块的名字作为参数,但一般都是传递__name__。
app = Flask(__name__)
cnf = loadconfig()
app.config.from_object(cnf)
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)

from app import views, models, url
Ejemplo n.º 13
0
import config
import twitterdb

# load dev configs
c = config.loadconfig('config.ini')
conn = config.connectdb(c.database)

# create tables
twitterdb.createdb(conn.cursor(), 'tweets')
conn.commit()
Ejemplo n.º 14
0
import time
import datetime
import random
import logging
import sys
import textwrap
from collections import deque
import itertools

import can4python as can
import RPi.GPIO as GPIO

import config
import utils

config = config.loadconfig('config.yml')

GPIO.setmode(GPIO.BCM)
joy_left = 5
joy_right = 26
joy_up = 6
joy_down = 19
GPIO.setup(joy_up, GPIO.IN, GPIO.PUD_UP)
GPIO.setup(joy_down, GPIO.IN, GPIO.PUD_UP)
GPIO.setup(joy_left, GPIO.IN, GPIO.PUD_UP)
#GPIO.setup(joy_right, GPIO.IN, GPIO.PUD_UP)

bus = can.CanBus.from_kcd_file(config['kcd'], config['canbus'])

os.environ["SDL_FBDEV"] = "/dev/fb1"
Ejemplo n.º 15
0
def mainloop():
    """ Main loop, gets battery data, gets summary.py to do logging"""

    prevbatvoltage = batdata.batvoltsav[numcells]
    for i in range(config['sampling']['samplesav']):
        #          printvoltage = ''
        #          for i in range(numcells+1):
        #            printvoltage = printvoltage + str(round(batdata.batvolts[i],3)).ljust(5,'0') + ' '
        #         print (printvoltage)
        batdata.getraw()


#          if batdata.batvoltsav[numcells] >= 55.2 and prevbatvoltage < 55.2:  # reset SOC counter?
#          print batdata.socadj/(float(summary['current']['dod'][3])*24.0)
    if batdata.batvoltsav[numcells] < config['battery']['vreset'] \
    and prevbatvoltage >= config['battery']['vreset'] \
    and summary['current']['dod'][3] != 0 \
    and -batdata.currentav[-3] < config['battery']['ireset']:  # reset SOC counter?

        if summary['current']['dod'][3] <= 0:
            socerr = 0
        else:
            socerr = batdata.socadj / (float(summary['current']['dod'][3]) *
                                       24.0)
            socerr = max(socerr, -0.01)
            socerr = min(socerr, 0.01)
        config['battery']['ahloss'] = config['battery']['ahloss'] - socerr / 2
        batconfigdata = SafeConfigParser()
        batconfigdata.read('battery.cfg')
        batconfigdata.set('battery', 'ahloss',
                          str(config['battery']['ahloss']))
        with open('battery.cfg', 'w') as batconfig:
            batconfigdata.write(batconfig)
        batconfig.closed

        batdata.soc = config['battery']['socreset']
        batdata.socadj = batdata.soc
        summary['current']['dod'][3] = 0
    else:
        batdata.soc = batdata.soc + batdata.batah
        batdata.socadj = batdata.socadj + batdata.batahadj
    batdata.ah = batdata.ah + batdata.batah
    batdata.inahtot = batdata.inahtot + batdata.inah
    batdata.pwrbattot = batdata.pwrbattot + batdata.pwrbat
    batdata.pwrintot = batdata.pwrintot + batdata.pwrin
    # check alarms
    alarms.scanalarms(batdata)
    # update summaries
    logsummary.update(summary, batdata)
    currenttime = str(logsummary.currenttime)
    prevtime = str(logsummary.prevtime)
    if currenttime[10:12] != prevtime[10:12]:  # new minute
        loadconfig()
        batdata.pwravailable, batdata.minmaxdemandpwr = solaravailable(batdata)
        logsummary.updatesection(summary, 'hour', 'current')
        logsummary.updatesection(summary, 'alltime', 'current')
        logsummary.updatesection(summary, 'currentday', 'current')
        logsummary.updatesection(summary, 'monthtodate', 'current')
        logsummary.updatesection(summary, 'yeartodate', 'current')
        logsummary.writesummary()
        batdata.ah = 0.0
        batdata.ahadj = 0.0
        batdata.inahtot = 0.0
        batdata.pwrbattot = 0.0
        batdata.pwrintot = 0.0
        for i in range(batdata.numiins):
            batdata.kWhin[i] = 0.0
            batdata.kWhout[i] = 0.0
        for i in range(numcells):
            batdata.baltime[i] = 0

    if currenttime[8:10] != prevtime[8:10]:  # new hour
        logsummary.starthour(summary)

    if currenttime[6:8] != prevtime[6:8]:  # newday
        logsummary.startday(summary)

    if currenttime[4:6] != prevtime[4:6]:  # new month
        logsummary.startmonth(summary)

    if currenttime[0:4] != prevtime[0:4]:  # new year
        logsummary.startyear(summary)