From c5943428e915c7e486d2811d52c9d2701ea90aca Mon Sep 17 00:00:00 2001 From: Fabian Date: Sun, 18 Feb 2024 16:51:51 +0400 Subject: [PATCH] fix: name 'logger' is not defined --- Dockerfile | 5 +++-- bmslib/models/__init__.py | 3 ++- bmslib/models/jikong.py | 2 +- bmslib/sampling.py | 2 +- tools/bit_finder.py | 8 ++++---- tools/impedance/data.py | 2 +- tools/impedance/imp.py | 3 ++- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index f59aff2..b3586a6 100755 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,9 @@ WORKDIR /app # RUN apk add --no-cache python3 bluez py-pip git RUN apk add python3 -RUN apk add bluez #< 5.66-r4" - # https://pkgs.alpinelinux.org/packages?name=bluez&branch=v3.16&repo=&arch=aarch64&maintainer= +RUN apk add bluez +#RUN apk add bluez < 5.66-r4" +# https://pkgs.alpinelinux.org/packages?name=bluez&branch=v3.16&repo=&arch=aarch64&maintainer= RUN apk add py-pip RUN apk add git # py3-pip diff --git a/bmslib/models/__init__.py b/bmslib/models/__init__.py index fb7e509..62975f3 100644 --- a/bmslib/models/__init__.py +++ b/bmslib/models/__init__.py @@ -1,6 +1,7 @@ -from enum import IntEnum, auto +from bmslib.util import get_logger +logger = get_logger() def get_bms_model_class(name): diff --git a/bmslib/models/jikong.py b/bmslib/models/jikong.py index 2cbb128..d0dc15d 100644 --- a/bmslib/models/jikong.py +++ b/bmslib/models/jikong.py @@ -254,7 +254,7 @@ async def fetch(self, wait=True) -> BmsSample: return self._decode_sample(buf, t_buf) async def subscribe(self, callback: Callable[[BmsSample], None]): - self._callbacks[0x02].append(lambda buf: callback(self._decode_sample(buf))) + self._callbacks[0x02].append(lambda buf: callback(self._decode_sample(buf, t_buf=time.time()))) async def fetch_voltages(self): """ diff --git a/bmslib/sampling.py b/bmslib/sampling.py index f21513d..b618759 100644 --- a/bmslib/sampling.py +++ b/bmslib/sampling.py @@ -451,7 +451,7 @@ def __init__(self): self._last: Optional[BmsSample] = None def __iadd__(self, s: BmsSample): - self._power += s._power + self._power += s.power self._current += s.current self._voltage += s.voltage self._num += 1 diff --git a/tools/bit_finder.py b/tools/bit_finder.py index 25f6340..3c3e375 100644 --- a/tools/bit_finder.py +++ b/tools/bit_finder.py @@ -16,10 +16,10 @@ #bytearray(b'\x01\x12\x00\x00u0\x03\xe8'), #bytearray(b'\x01\x12\x00\x00u0\x03\xe8'), - [ D2 03 04 00 00 00 00 18 FE ], - D203 0400 0000 0018 FE - D203 0400 0000 0018 FE - D203 0400 0000 0018 FE + #[ D2 03 04 00 00 00 00 18 FE ], + #D203 0400 0000 0018 FE + #D203 0400 0000 0018 FE + #D203 0400 0000 0018 FE """ diff --git a/tools/impedance/data.py b/tools/impedance/data.py index ef1625b..061edd9 100644 --- a/tools/impedance/data.py +++ b/tools/impedance/data.py @@ -87,4 +87,4 @@ def fetch_batmon_ha_sensors(tr, alias, num_cells, freq='1s'): if __name__ == "__main__": - fetch_batmon_ha_sensors(("2022-01-05", "2022-02-05"), 'daly_bms') + fetch_batmon_ha_sensors(("2022-01-05", "2022-02-05"), 'daly_bms', num_cells=8) diff --git a/tools/impedance/imp.py b/tools/impedance/imp.py index 769bdc2..1676e4d 100644 --- a/tools/impedance/imp.py +++ b/tools/impedance/imp.py @@ -1,11 +1,12 @@ import json -import math import matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd +from bmslib.pwmath import EWM + if False: # read from csv files df = pd.read_csv('mppt_scan_I.csv') I = pd.Series(df.A.values, index=pd.DatetimeIndex(df.time.values))