def doExternalUpdate(): attempt = 0 if state.getState('lastSuccess') == 1: maxAttempt = 3 else: maxAttempt = 1 while attempt < maxAttempt: try: soc = soc_external.DownloadSoC() except: soc = 0 raise if soc > 0: saveSoc(soc, 0) state.setState('lastSuccess', 1) break else: attempt += 1 state.setState('lastSuccess', 0) if attempt < maxAttempt: soclogging.logDebug(2, "Retrying in 60 Seconds...") time.sleep(60) return
def ackTimerTrigger(): try: now = int(time.time()) state.setState('lastRun', now) except: raise return
def saveSoc(soc, manual): try: f = open(parameters.getParameter('currentSocFile'), 'w') f.write(str(int(soc))) f.close() except: raise try: if parameters.getParameter('abrpEnable') == 1: abrp.pushABRP(soc) except: pass if manual == 0: try: f = open(parameters.getParameter('meterFile'), 'r') meter = float(f.read()) f.close() except: meter = 0 try: state.setState('lastSoc', soc) state.setState('lastMeter', meter) state.setState('unplug', 0) state.setState('charged', 0) except: raise return