@@ -14,15 +14,15 @@ class RegisterMap:
|
|||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
map = {
|
map = {
|
||||||
# 0x41020007: {'reg': Register.DEVICE_SNR, 'fmt': '<L'}, # noqa: E501
|
# 0x41020007: {'reg': Register.DEVICE_SNR, 'fmt': '<L'}, # noqa: E501
|
||||||
0x41020018: {'reg': Register.DATA_UP_INTERVAL, 'fmt': '!B', 'ratio': 60}, # noqa: E501
|
0x41020018: {'reg': Register.DATA_UP_INTERVAL, 'fmt': '<B', 'ratio': 60}, # noqa: E501
|
||||||
0x41020019: {'reg': Register.COLLECT_INTERVAL, 'fmt': '!B', 'ratio': 1}, # noqa: E501
|
0x41020019: {'reg': Register.COLLECT_INTERVAL, 'fmt': '<B', 'ratio': 1}, # noqa: E501
|
||||||
0x4102001a: {'reg': Register.HEARTBEAT_INTERVAL, 'fmt': '!B', 'ratio': 1}, # noqa: E501
|
0x4102001a: {'reg': Register.HEARTBEAT_INTERVAL, 'fmt': '<B', 'ratio': 1}, # noqa: E501
|
||||||
0x4102001c: {'reg': Register.SIGNAL_STRENGTH, 'fmt': '!B', 'ratio': 1}, # noqa: E501
|
0x4102001c: {'reg': Register.SIGNAL_STRENGTH, 'fmt': '<B', 'ratio': 1}, # noqa: E501
|
||||||
0x4102001e: {'reg': Register.COLLECTOR_FW_VERSION, 'fmt': '!40s'}, # noqa: E501
|
0x4102001e: {'reg': Register.COLLECTOR_FW_VERSION, 'fmt': '!40s'}, # noqa: E501
|
||||||
0x4102004c: {'reg': Register.IP_ADRESS, 'fmt': '!16s'}, # noqa: E501
|
0x4102004c: {'reg': Register.IP_ADRESS, 'fmt': '!16s'}, # noqa: E501
|
||||||
0x41020064: {'reg': Register.VERSION, 'fmt': '!40s'}, # noqa: E501
|
0x41020064: {'reg': Register.VERSION, 'fmt': '!40s'}, # noqa: E501
|
||||||
|
|
||||||
0x4201001c: {'reg': Register.POWER_ON_TIME, 'fmt': '!H', 'ratio': 1}, # noqa: E501
|
0x4201001c: {'reg': Register.POWER_ON_TIME, 'fmt': '<H', 'ratio': 1}, # noqa: E501
|
||||||
0x42010020: {'reg': Register.SERIAL_NUMBER, 'fmt': '!16s'}, # noqa: E501
|
0x42010020: {'reg': Register.SERIAL_NUMBER, 'fmt': '!16s'}, # noqa: E501
|
||||||
0x420100d2: {'reg': Register.GRID_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
|
0x420100d2: {'reg': Register.GRID_VOLTAGE, 'fmt': '!H', 'ratio': 0.1}, # noqa: E501
|
||||||
0x420100d4: {'reg': Register.GRID_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
|
0x420100d4: {'reg': Register.GRID_CURRENT, 'fmt': '!H', 'ratio': 0.01}, # noqa: E501
|
||||||
@@ -56,6 +56,8 @@ class RegisterMap:
|
|||||||
0x42010126: {'reg': Register.MAX_DESIGNED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501
|
0x42010126: {'reg': Register.MAX_DESIGNED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501
|
||||||
0x42010170: {'reg': Register.NO_INPUTS, 'fmt': '!B'}, # noqa: E501
|
0x42010170: {'reg': Register.NO_INPUTS, 'fmt': '!B'}, # noqa: E501
|
||||||
|
|
||||||
|
0x4281001c: {'reg': Register.POWER_ON_TIME, 'fmt': '<H', 'ratio': 1}, # noqa: E501
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class SolarmanV5(Message):
|
|||||||
self.seq = Sequence(server_side)
|
self.seq = Sequence(server_side)
|
||||||
self.snr = 0
|
self.snr = 0
|
||||||
self.db = InfosG3P()
|
self.db = InfosG3P()
|
||||||
|
self.time_ofs = 0
|
||||||
self.switch = {
|
self.switch = {
|
||||||
|
|
||||||
0x4210: self.msg_data_ind, # real time data
|
0x4210: self.msg_data_ind, # real time data
|
||||||
@@ -352,10 +353,11 @@ class SolarmanV5(Message):
|
|||||||
total = result[1]
|
total = result[1]
|
||||||
tim = result[2]
|
tim = result[2]
|
||||||
res = result[3] # always zero
|
res = result[3] # always zero
|
||||||
logger.info(f'frame type:{ftype:02x} total:{total}s'
|
logger.info(f'frame type:{ftype:02x}'
|
||||||
f' timer:{tim:08x}s null:{res}')
|
f' timer:{tim:08x}s null:{res}')
|
||||||
dt = datetime.fromtimestamp(total)
|
if self.time_ofs:
|
||||||
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
dt = datetime.fromtimestamp(total + self.time_ofs)
|
||||||
|
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
||||||
|
|
||||||
self.__process_data(ftype)
|
self.__process_data(ftype)
|
||||||
self.__forward_msg()
|
self.__forward_msg()
|
||||||
@@ -363,27 +365,33 @@ class SolarmanV5(Message):
|
|||||||
|
|
||||||
def msg_data_ind(self):
|
def msg_data_ind(self):
|
||||||
data = self._recv_buffer
|
data = self._recv_buffer
|
||||||
result = struct.unpack_from('<BLLLLL', data, self.header_len)
|
result = struct.unpack_from('<BHLLLHL', data, self.header_len)
|
||||||
ftype = result[0] # 1 or 0x81
|
ftype = result[0] # 1 or 0x81
|
||||||
total = result[1]
|
total = result[2]
|
||||||
tim = result[2]
|
tim = result[3]
|
||||||
offset = result[3]
|
if 1 == ftype:
|
||||||
unkn = result[4]
|
self.time_ofs = result[4]
|
||||||
cnt = result[5]
|
unkn = result[5]
|
||||||
logger.info(f'ftype:{ftype:02x} total:{total}s'
|
cnt = result[6]
|
||||||
f' timer:{tim:08x}s ofs:{offset}'
|
logger.info(f'ftype:{ftype:02x} timer:{tim:08x}s'
|
||||||
f' ??: {unkn:08x} cnt:{cnt}')
|
f' ??: {unkn:04x} cnt:{cnt}')
|
||||||
dt = datetime.fromtimestamp(total)
|
if self.time_ofs:
|
||||||
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
dt = datetime.fromtimestamp(total + self.time_ofs)
|
||||||
|
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
||||||
|
|
||||||
self.__process_data(ftype & 0x7f) # mask bit 7 (0x80)
|
self.__process_data(ftype)
|
||||||
self.__forward_msg()
|
self.__forward_msg()
|
||||||
self.__send_ack_rsp(0x1210, ftype)
|
self.__send_ack_rsp(0x1210, ftype)
|
||||||
|
|
||||||
def msg_sync_start(self):
|
def msg_sync_start(self):
|
||||||
data = self._recv_buffer[self.header_len:]
|
data = self._recv_buffer[self.header_len:]
|
||||||
result = struct.unpack_from('<B', data, 0)
|
result = struct.unpack_from('<BLLL', data, 0)
|
||||||
ftype = result[0]
|
ftype = result[0]
|
||||||
|
total = result[1]
|
||||||
|
self.time_ofs = result[3]
|
||||||
|
|
||||||
|
dt = datetime.fromtimestamp(total + self.time_ofs)
|
||||||
|
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
||||||
|
|
||||||
self.__forward_msg()
|
self.__forward_msg()
|
||||||
self.__send_ack_rsp(0x1310, ftype)
|
self.__send_ack_rsp(0x1310, ftype)
|
||||||
@@ -407,8 +415,13 @@ class SolarmanV5(Message):
|
|||||||
|
|
||||||
def msg_sync_end(self):
|
def msg_sync_end(self):
|
||||||
data = self._recv_buffer[self.header_len:]
|
data = self._recv_buffer[self.header_len:]
|
||||||
result = struct.unpack_from('<B', data, 0)
|
result = struct.unpack_from('<BLLL', data, 0)
|
||||||
ftype = result[0]
|
ftype = result[0]
|
||||||
|
total = result[1]
|
||||||
|
self.time_ofs = result[3]
|
||||||
|
|
||||||
|
dt = datetime.fromtimestamp(total + self.time_ofs)
|
||||||
|
logger.info(f'ts: {dt.strftime("%Y-%m-%d %H:%M:%S")}')
|
||||||
|
|
||||||
self.__forward_msg()
|
self.__forward_msg()
|
||||||
self.__send_ack_rsp(0x1810, ftype)
|
self.__send_ack_rsp(0x1810, ftype)
|
||||||
|
|||||||
Reference in New Issue
Block a user