diff --git a/app/docu/proxy_2.yuml b/app/docu/proxy_2.yuml index 5138428..6c50022 100644 --- a/app/docu/proxy_2.yuml +++ b/app/docu/proxy_2.yuml @@ -5,10 +5,10 @@ [note: Example of instantiation for a GEN3 inverter!{bg:cornsilk}] [<>||__iter__()] -[InverterG3|addr;remote:StreamPtr;local:StreamPtr|create_remote();;close()] -[InverterG3]++->[local:StreamPtr] -[InverterG3]++->[remote:StreamPtr] - +[InverterBase|addr;remote:StreamPtr;local:StreamPtr|create_remote();;close()] +[InverterBase]^[InverterG3] +[InverterBase]++->[local:StreamPtr] +[InverterBase]++->[remote:StreamPtr] [<>||set_node_id();get_conn_no();;tx_add();tx_flush();tx_get();tx_peek();tx_log();tx_clear();tx_len();;fwd_add();fwd_log();rx_get();rx_peek();rx_log();rx_clear();rx_len();rx_set_cb();;prot_set_timeout_cb()] [AsyncIfcImpl|fwd_fifo:ByteFifo;tx_fifo:ByteFifo;rx_fifo:ByteFifo;conn_no:Count;node_id;timeout_cb] [AsyncStream|reader;writer;addr;r_addr;l_addr|;loop;disc();close();healthy();;__async_read();__async_write();__async_forward()] diff --git a/app/docu/proxy_3.svg b/app/docu/proxy_3.svg index aadb6fe..d429bed 100644 --- a/app/docu/proxy_3.svg +++ b/app/docu/proxy_3.svg @@ -4,366 +4,379 @@ - + G - + A0 - - - -Example of -instantiation for a -GEN3PLUS inverter! + + + +Example of +instantiation for a +GEN3PLUS inverter! A1 - -<<AbstractIterMeta>> - - -__iter__() - - - -A14 - -<<ProtocolIfc>> - -_registry - -close() - - - -A1->A14 - - - - - -A2 - -InverterG3P - -addr -forward_at_cmd_resp -remote:StreamPtr -local:StreamPtr - -create_remote() -close() - - - -A3 - -local:StreamPtr - - - -A2->A3 - - - - - - -A4 - -remote:StreamPtr - - - -A2->A4 - - - - - - -A8 - -AsyncStreamServer - -create_remote - -<async>server_loop() -<async>_async_forward() -<async>publish_outstanding_mqtt() -close() - - - -A3->A8 - - - - - - -A9 - -AsyncStreamClient - - -<async>client_loop() -<async>_async_forward()) - - - -A4->A9 - - -0..1 - - - -A5 - -<<AsyncIfc>> - - -set_node_id() -get_conn_no() -tx_add() -tx_flush() -tx_get() -tx_peek() -tx_log() -tx_clear() -tx_len() -fwd_add() -fwd_log() -rx_get() -rx_peek() -rx_log() -rx_clear() -rx_len() -rx_set_cb() -prot_set_timeout_cb() - - - -A6 - -AsyncIfcImpl - -fwd_fifo:ByteFifo -tx_fifo:ByteFifo -rx_fifo:ByteFifo -conn_no:Count -node_id -timeout_cb - - - -A5->A6 - - - - - -A7 - -AsyncStream - -reader -writer -addr -r_addr -l_addr - -<async>loop -disc() -close() -healthy() -__async_read() -__async_write() -__async_forward() - - - -A6->A7 - - - - - -A7->A8 - - - - - -A7->A9 - - - - - -A10 - -SolarmanV5 - -conn_no -addr -inverter:InverterG3P -control -serial -snr -db:InfosG3P -switch - -msg_unknown() -healthy() -close() - - - -A10->A3 - - - - - - -A10->A4 - - -0..1 - - - -A12 - -InfosG3P - -client_mode:bool - -ha_confs() -parse() -calc() -build() - - - -A10->A12 - - - - - -A11 - -Infos - -stat -new_stat_data -info_dev - -static_init() -dev_value() -inc_counter() -dec_counter() -ha_proxy_conf -ha_conf -ha_remove -update_db -set_db_def_value -get_db_value -ignore_this_device - - - -A11->A12 - - - - - -A13 - -Message - -server_side:bool -mb:Modbus -ifc:AsyncIfc -node_id -header_valid:bool -header_len -data_len -unique_id -sug_area:str -new_data:dict -state:State -shutdown_started:bool -modbus_elms -mb_timer:Timer -mb_timeout -mb_first_timeout -modbus_polling:bool - -_set_mqtt_timestamp() -_timeout() -_send_modbus_cmd() -<async> end_modbus_cmd() -close() -inc_counter() -dec_counter() - - - -A13->A5 - - -use - - - -A13->A10 - - - - - -A14->A13 - - + +<<AbstractIterMeta>> + + +__iter__() A15 - -Modbus - -que -snd_handler -rsp_handler -timeout -max_retires -last_xxx -err -retry_cnt -req_pend -tim - -build_msg() -recv_req() -recv_resp() -close() + +<<ProtocolIfc>> + +_registry + +close() - + + +A1->A15 + + + + + +A2 + +InverterBase + +addr +remote:StreamPtr +local:StreamPtr + +create_remote() +close() + + + +A3 + +InverterG3P + +forward_at_cmd_resp + + + +A2->A3 + + + + + +A4 + +local:StreamPtr + + + +A2->A4 + + + + + + +A5 + +remote:StreamPtr + + + +A2->A5 + + + + + + +A9 + +AsyncStreamServer + +create_remote + +<async>server_loop() +<async>_async_forward() +<async>publish_outstanding_mqtt() +close() + + + +A4->A9 + + + + + + +A10 + +AsyncStreamClient + + +<async>client_loop() +<async>_async_forward()) + + + +A5->A10 + + +0..1 + + + +A6 + +<<AsyncIfc>> + + +set_node_id() +get_conn_no() +tx_add() +tx_flush() +tx_get() +tx_peek() +tx_log() +tx_clear() +tx_len() +fwd_add() +fwd_log() +rx_get() +rx_peek() +rx_log() +rx_clear() +rx_len() +rx_set_cb() +prot_set_timeout_cb() + + + +A7 + +AsyncIfcImpl + +fwd_fifo:ByteFifo +tx_fifo:ByteFifo +rx_fifo:ByteFifo +conn_no:Count +node_id +timeout_cb + + + +A6->A7 + + + + + +A8 + +AsyncStream + +reader +writer +addr +r_addr +l_addr + +<async>loop +disc() +close() +healthy() +__async_read() +__async_write() +__async_forward() + + + +A7->A8 + + + + + +A8->A9 + + + + + +A8->A10 + + + + + +A11 + +SolarmanV5 + +conn_no +addr +inverter:InverterG3P +control +serial +snr +db:InfosG3P +switch + +msg_unknown() +healthy() +close() + + + +A11->A4 + + + + + + +A11->A5 + + +0..1 + + + +A13 + +InfosG3P + +client_mode:bool + +ha_confs() +parse() +calc() +build() + + + +A11->A13 + + + + + +A12 + +Infos + +stat +new_stat_data +info_dev + +static_init() +dev_value() +inc_counter() +dec_counter() +ha_proxy_conf +ha_conf +ha_remove +update_db +set_db_def_value +get_db_value +ignore_this_device + + + +A12->A13 + + + + + +A14 + +Message + +server_side:bool +mb:Modbus +ifc:AsyncIfc +node_id +header_valid:bool +header_len +data_len +unique_id +sug_area:str +new_data:dict +state:State +shutdown_started:bool +modbus_elms +mb_timer:Timer +mb_timeout +mb_first_timeout +modbus_polling:bool + +_set_mqtt_timestamp() +_timeout() +_send_modbus_cmd() +<async> end_modbus_cmd() +close() +inc_counter() +dec_counter() + + + +A14->A6 + + +use + + -A15->A13 - - -has -0..1 +A14->A11 + + + + + +A15->A14 + + + + + +A16 + +Modbus + +que +snd_handler +rsp_handler +timeout +max_retires +last_xxx +err +retry_cnt +req_pend +tim + +build_msg() +recv_req() +recv_resp() +close() + + + +A16->A14 + + +has +0..1 diff --git a/app/docu/proxy_3.yuml b/app/docu/proxy_3.yuml index 4602240..18bcec1 100644 --- a/app/docu/proxy_3.yuml +++ b/app/docu/proxy_3.yuml @@ -5,9 +5,10 @@ [note: Example of instantiation for a GEN3PLUS inverter!{bg:cornsilk}] [<>||__iter__()] -[InverterG3P|addr;forward_at_cmd_resp;remote:StreamPtr;local:StreamPtr|create_remote();;close()] -[InverterG3P]++->[local:StreamPtr] -[InverterG3P]++->[remote:StreamPtr] +[InverterBase|addr;remote:StreamPtr;local:StreamPtr|create_remote();;close()] +[InverterBase]^[InverterG3P|forward_at_cmd_resp;] +[InverterBase]++->[local:StreamPtr] +[InverterBase]++->[remote:StreamPtr] [<>||set_node_id();get_conn_no();;tx_add();tx_flush();tx_get();tx_peek();tx_log();tx_clear();tx_len();;fwd_add();fwd_log();rx_get();rx_peek();rx_log();rx_clear();rx_len();rx_set_cb();;prot_set_timeout_cb()] [AsyncIfcImpl|fwd_fifo:ByteFifo;tx_fifo:ByteFifo;rx_fifo:ByteFifo;conn_no:Count;node_id;timeout_cb] diff --git a/app/src/gen3plus/infos_g3p.py b/app/src/gen3plus/infos_g3p.py index fd2c97c..4cbe08c 100644 --- a/app/src/gen3plus/infos_g3p.py +++ b/app/src/gen3plus/infos_g3p.py @@ -193,18 +193,11 @@ class RegisterSel: class InfosG3P(Infos): - __slots__ = ('client_mode') + __slots__ = ('client_mode', ) def __init__(self, client_mode: bool): super().__init__() self.client_mode = client_mode - # shared value between both inverter connections - '''Flag if response for the last at command must be send to the cloud. - - False: send result only to the MQTT broker, cause the AT+ command - came from there - True: send response packet to the cloud, cause the AT+ command - came from the cloud''' self.set_db_def_value(Register.MANUFACTURER, 'TSUN') self.set_db_def_value(Register.EQUIPMENT_MODEL, 'TSOL-MSxx00') self.set_db_def_value(Register.CHIP_TYPE, 'IGEN TECH') diff --git a/app/src/gen3plus/inverter_g3p.py b/app/src/gen3plus/inverter_g3p.py index 2461d46..6a3f55d 100644 --- a/app/src/gen3plus/inverter_g3p.py +++ b/app/src/gen3plus/inverter_g3p.py @@ -8,8 +8,16 @@ from gen3plus.solarman_emu import SolarmanEmu class InverterG3P(InverterBase): def __init__(self, reader: StreamReader, writer: StreamWriter, client_mode: bool = False): - remote_prot = None + # shared value between both inverter connections self.forward_at_cmd_resp = False + '''Flag if response for the last at command must be send to the cloud. + + False: send result only to the MQTT broker, cause the AT+ command + came from there + True: send response packet to the cloud, cause the AT+ command + came from the cloud''' + + remote_prot = None if client_mode: remote_prot = SolarmanEmu super().__init__(reader, writer, 'solarman',