rename class Inverter into Proxy

This commit is contained in:
Stefan Allius
2024-10-04 23:37:05 +02:00
parent 3a94afb48d
commit 00e9a4534d
14 changed files with 300 additions and 232 deletions

View File

@@ -4,193 +4,257 @@
<!-- Generated by graphviz version 2.40.1 (20161225.0304) <!-- Generated by graphviz version 2.40.1 (20161225.0304)
--> -->
<!-- Title: G Pages: 1 --> <!-- Title: G Pages: 1 -->
<svg width="463pt" height="882pt" <svg width="626pt" height="966pt"
viewBox="0.00 0.00 463.35 882.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> viewBox="0.00 0.00 625.50 966.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 878)"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 962)">
<title>G</title> <title>G</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-878 459.348,-878 459.348,4 -4,4"/> <polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-962 621.5,-962 621.5,4 -4,4"/>
<!-- A0 --> <!-- A0 -->
<g id="node1" class="node"> <g id="node1" class="node">
<title>A0</title> <title>A0</title>
<polygon fill="#fff8dc" stroke="#000000" points="108.5444,-850 .1516,-850 .1516,-814 114.5444,-814 114.5444,-844 108.5444,-850"/> <polygon fill="#fff8dc" stroke="#000000" points="191.6964,-934 83.3036,-934 83.3036,-898 197.6964,-898 197.6964,-928 191.6964,-934"/>
<polyline fill="none" stroke="#000000" points="108.5444,-850 108.5444,-844 "/> <polyline fill="none" stroke="#000000" points="191.6964,-934 191.6964,-928 "/>
<polyline fill="none" stroke="#000000" points="114.5444,-844 108.5444,-844 "/> <polyline fill="none" stroke="#000000" points="197.6964,-928 191.6964,-928 "/>
<text text-anchor="middle" x="57.348" y="-835" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">You can stick notes</text> <text text-anchor="middle" x="140.5" y="-919" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">You can stick notes</text>
<text text-anchor="middle" x="57.348" y="-823" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">on diagrams too!</text> <text text-anchor="middle" x="140.5" y="-907" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">on diagrams too!</text>
</g> </g>
<!-- A1 --> <!-- A1 -->
<g id="node2" class="node"> <g id="node2" class="node">
<title>A1</title> <title>A1</title>
<polygon fill="none" stroke="#000000" points="133.348,-842 133.348,-874 204.348,-874 204.348,-842 133.348,-842"/> <polygon fill="none" stroke="#000000" points="215.5,-926 215.5,-958 331.5,-958 331.5,-926 215.5,-926"/>
<text text-anchor="start" x="143.293" y="-855" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">IterRegistry</text> <text text-anchor="start" x="225.149" y="-939" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;AbstractIterMeta&gt;&gt;</text>
<polygon fill="none" stroke="#000000" points="133.348,-822 133.348,-842 204.348,-842 204.348,-822 133.348,-822"/> <polygon fill="none" stroke="#000000" points="215.5,-906 215.5,-926 331.5,-926 331.5,-906 215.5,-906"/>
<polygon fill="none" stroke="#000000" points="133.348,-790 133.348,-822 204.348,-822 204.348,-790 133.348,-790"/> <polygon fill="none" stroke="#000000" points="215.5,-874 215.5,-906 331.5,-906 331.5,-874 215.5,-874"/>
<text text-anchor="start" x="150.787" y="-803" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__iter__</text> <text text-anchor="start" x="255.439" y="-887" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__iter__</text>
</g>
<!-- A3 -->
<g id="node4" class="node">
<title>A3</title>
<polygon fill="none" stroke="#000000" points="20.348,-708 20.348,-740 316.348,-740 316.348,-708 20.348,-708"/>
<text text-anchor="start" x="151.4015" y="-721" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Inverter</text>
<polygon fill="none" stroke="#000000" points="20.348,-592 20.348,-708 316.348,-708 316.348,-592 20.348,-592"/>
<text text-anchor="start" x="144.452" y="-689" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.db_stat</text>
<text text-anchor="start" x="137.7885" y="-677" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.entity_prfx</text>
<text text-anchor="start" x="128.6235" y="-665" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.discovery_prfx</text>
<text text-anchor="start" x="128.0595" y="-653" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_node_id</text>
<text text-anchor="start" x="124.1705" y="-641" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.proxy_unique_id</text>
<text text-anchor="start" x="140.0135" y="-629" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">cls.mqtt:Mqtt</text>
<text text-anchor="start" x="137.7835" y="-605" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text>
<polygon fill="none" stroke="#000000" points="20.348,-560 20.348,-592 316.348,-592 316.348,-560 20.348,-560"/>
<text text-anchor="start" x="30.266" y="-573" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote(inv_prot, conn_class)async_publ_mqtt()</text>
</g>
<!-- A1&#45;&gt;A3 -->
<g id="edge5" class="edge">
<title>A1&#45;&gt;A3</title>
<path fill="none" stroke="#000000" d="M168.348,-779.6728C168.348,-767.2695 168.348,-753.6887 168.348,-740.1336"/>
<polygon fill="none" stroke="#000000" points="164.8481,-779.7881 168.348,-789.7881 171.8481,-779.7881 164.8481,-779.7881"/>
</g>
<!-- A2 -->
<g id="node3" class="node">
<title>A2</title>
<polygon fill="none" stroke="#000000" points="27.348,-466 27.348,-510 149.348,-510 149.348,-466 27.348,-466"/>
<text text-anchor="start" x="78.625" y="-491" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Mqtt</text>
<text text-anchor="start" x="55.8295" y="-479" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;Singleton&gt;&gt;</text>
<polygon fill="none" stroke="#000000" points="27.348,-410 27.348,-466 149.348,-466 149.348,-410 27.348,-410"/>
<text text-anchor="start" x="45.8355" y="-447" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;ha_restarts</text>
<text text-anchor="start" x="53.6145" y="-435" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__client</text>
<text text-anchor="start" x="37.2215" y="-423" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__cb_MqttIsUp</text>
<polygon fill="none" stroke="#000000" points="27.348,-366 27.348,-410 149.348,-410 149.348,-366 27.348,-366"/>
<text text-anchor="start" x="50.284" y="-391" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;publish()</text>
<text text-anchor="start" x="54.4525" y="-379" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;close()</text>
</g>
<!-- A3&#45;&gt;A2 -->
<g id="edge4" class="edge">
<title>A3&#45;&gt;A2</title>
<path fill="none" stroke="#000000" d="M130.0325,-548.4638C126.3726,-538.7653 122.694,-529.0169 119.1193,-519.544"/>
<polygon fill="#000000" stroke="#000000" points="130.068,-548.5583 135.9288,-552.7596 134.3048,-559.7855 128.444,-555.5841 130.068,-548.5583"/>
<polygon fill="#000000" stroke="#000000" points="115.5839,-510.1751 123.3248,-517.9424 117.3492,-514.8532 119.1145,-519.5312 119.1145,-519.5312 119.1145,-519.5312 117.3492,-514.8532 114.9043,-521.12 115.5839,-510.1751 115.5839,-510.1751"/>
</g> </g>
<!-- A4 --> <!-- A4 -->
<g id="node5" class="node"> <g id="node5" class="node">
<title>A4</title> <title>A4</title>
<polygon fill="none" stroke="#000000" points="168.348,-460 168.348,-492 329.348,-492 329.348,-460 168.348,-460"/> <polygon fill="none" stroke="#000000" points="178.5,-726 178.5,-758 369.5,-758 369.5,-726 178.5,-726"/>
<text text-anchor="start" x="220.508" y="-473" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterBase</text> <text text-anchor="start" x="240.0965" y="-739" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;InverterIfc&gt;&gt;</text>
<polygon fill="none" stroke="#000000" points="168.348,-440 168.348,-460 329.348,-460 329.348,-440 168.348,-440"/> <polygon fill="none" stroke="#000000" points="178.5,-706 178.5,-726 369.5,-726 369.5,-706 178.5,-706"/>
<polygon fill="none" stroke="#000000" points="168.348,-384 168.348,-440 329.348,-440 329.348,-384 168.348,-384"/> <polygon fill="none" stroke="#000000" points="178.5,-650 178.5,-706 369.5,-706 369.5,-650 178.5,-650"/>
<text text-anchor="start" x="178.274" y="-421" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;disc(shutdown_started)</text> <text text-anchor="start" x="240.522" y="-687" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">healthy()&#45;&gt;bool</text>
<text text-anchor="start" x="178.5535" y="-409" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;async_create_remote()</text> <text text-anchor="start" x="188.2835" y="-675" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;disc(shutdown_started=False)</text>
<text text-anchor="start" x="229.402" y="-397" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">healthy()</text> <text text-anchor="start" x="219.544" y="-663" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;create_remote()</text>
</g> </g>
<!-- A3&#45;&gt;A4 --> <!-- A1&#45;&gt;A4 -->
<g id="edge1" class="edge"> <g id="edge1" class="edge">
<title>A3&#45;&gt;A4</title> <title>A1&#45;&gt;A4</title>
<path fill="none" stroke="#000000" d="M205.9667,-550.3105C213.5193,-530.2961 221.1855,-509.9807 227.8831,-492.2319"/> <path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M273.5,-863.7744C273.5,-831.6663 273.5,-790.6041 273.5,-758.1476"/>
<polygon fill="none" stroke="#000000" points="202.6472,-549.1938 202.3912,-559.7855 209.1964,-551.6652 202.6472,-549.1938"/> <polygon fill="none" stroke="#000000" points="270.0001,-863.8621 273.5,-873.8622 277.0001,-863.8622 270.0001,-863.8621"/>
</g>
<!-- A2 -->
<g id="node3" class="node">
<title>A2</title>
<polygon fill="none" stroke="#000000" points="441.5,-454 441.5,-498 563.5,-498 563.5,-454 441.5,-454"/>
<text text-anchor="start" x="492.777" y="-479" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Mqtt</text>
<text text-anchor="start" x="469.9815" y="-467" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;Singleton&gt;&gt;</text>
<polygon fill="none" stroke="#000000" points="441.5,-398 441.5,-454 563.5,-454 563.5,-398 441.5,-398"/>
<text text-anchor="start" x="459.9875" y="-435" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;ha_restarts</text>
<text text-anchor="start" x="467.7665" y="-423" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__client</text>
<text text-anchor="start" x="451.3735" y="-411" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;static&gt;__cb_MqttIsUp</text>
<polygon fill="none" stroke="#000000" points="441.5,-354 441.5,-398 563.5,-398 563.5,-354 441.5,-354"/>
<text text-anchor="start" x="464.436" y="-379" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;publish()</text>
<text text-anchor="start" x="468.6045" y="-367" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;close()</text>
</g>
<!-- A3 -->
<g id="node4" class="node">
<title>A3</title>
<polygon fill="none" stroke="#000000" points="387.5,-792 387.5,-824 617.5,-824 617.5,-792 387.5,-792"/>
<text text-anchor="start" x="489.7215" y="-805" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Proxy</text>
<polygon fill="none" stroke="#000000" points="387.5,-676 387.5,-792 617.5,-792 617.5,-676 387.5,-676"/>
<text text-anchor="start" x="474.1545" y="-773" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;db_stat</text>
<text text-anchor="start" x="467.491" y="-761" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;entity_prfx</text>
<text text-anchor="start" x="458.326" y="-749" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;discovery_prfx</text>
<text text-anchor="start" x="457.762" y="-737" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;proxy_node_id</text>
<text text-anchor="start" x="453.873" y="-725" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;proxy_unique_id</text>
<text text-anchor="start" x="469.716" y="-713" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;cls&gt;mqtt:Mqtt</text>
<text text-anchor="start" x="471.9355" y="-689" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text>
<polygon fill="none" stroke="#000000" points="387.5,-584 387.5,-676 617.5,-676 617.5,-584 387.5,-584"/>
<text text-anchor="start" x="478.6145" y="-657" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">class_init()</text>
<text text-anchor="start" x="473.334" y="-645" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">class_close()</text>
<text text-anchor="start" x="444.984" y="-621" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;_cb_mqtt_is_up()</text>
<text text-anchor="start" x="397.197" y="-609" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;_register_proxy_stat_home_assistant()</text>
<text text-anchor="start" x="406.084" y="-597" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;_async_publ_mqtt_proxy_stat(key)</text>
</g>
<!-- A3&#45;&gt;A2 -->
<g id="edge9" class="edge">
<title>A3&#45;&gt;A2</title>
<path fill="none" stroke="#000000" d="M502.5,-571.373C502.5,-549.9571 502.5,-528.339 502.5,-508.5579"/>
<polygon fill="#000000" stroke="#000000" points="502.5001,-571.682 506.5,-577.6821 502.5,-583.682 498.5,-577.682 502.5001,-571.682"/>
<polygon fill="#000000" stroke="#000000" points="502.5,-498.392 507.0001,-508.3919 502.5,-503.392 502.5001,-508.392 502.5001,-508.392 502.5001,-508.392 502.5,-503.392 498.0001,-508.392 502.5,-498.392 502.5,-498.392"/>
</g> </g>
<!-- A5 --> <!-- A5 -->
<g id="node6" class="node"> <g id="node6" class="node">
<title>A5</title> <title>A5</title>
<polygon fill="none" stroke="#000000" points="187.348,-284 187.348,-316 309.348,-316 309.348,-284 187.348,-284"/> <polygon fill="none" stroke="#000000" points="205.5,-502 205.5,-534 396.5,-534 396.5,-502 205.5,-502"/>
<text text-anchor="start" x="224.7325" y="-297" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3</text> <text text-anchor="start" x="272.66" y="-515" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterBase</text>
<polygon fill="none" stroke="#000000" points="187.348,-228 187.348,-284 309.348,-284 309.348,-228 187.348,-228"/> <polygon fill="none" stroke="#000000" points="205.5,-386 205.5,-502 396.5,-502 396.5,-386 205.5,-386"/>
<text text-anchor="start" x="238.345" y="-265" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text> <text text-anchor="start" x="281.8335" y="-483" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">_registry</text>
<text text-anchor="start" x="208.901" y="-253" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text> <text text-anchor="start" x="270.4355" y="-471" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">__ha_restarts</text>
<text text-anchor="start" x="214.18" y="-241" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text> <text text-anchor="start" x="290.997" y="-447" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text>
<polygon fill="none" stroke="#000000" points="187.348,-172 187.348,-228 309.348,-228 309.348,-172 187.348,-172"/> <text text-anchor="start" x="274.0505" y="-435" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">config_id:str</text>
<text text-anchor="start" x="196.9515" y="-209" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text> <text text-anchor="start" x="247.3785" y="-423" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">prot_class:MessageProt</text>
<text text-anchor="start" x="233.3505" y="-185" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text> <text text-anchor="start" x="261.553" y="-411" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text>
<text text-anchor="start" x="266.832" y="-399" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text>
<polygon fill="none" stroke="#000000" points="205.5,-318 205.5,-386 396.5,-386 396.5,-318 205.5,-318"/>
<text text-anchor="start" x="267.522" y="-367" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">healthy()&#45;&gt;bool</text>
<text text-anchor="start" x="215.2835" y="-355" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;disc(shutdown_started=False)</text>
<text text-anchor="start" x="246.544" y="-343" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;create_remote()</text>
<text text-anchor="start" x="240.984" y="-331" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;async_publ_mqtt()</text>
</g>
<!-- A3&#45;&gt;A5 -->
<g id="edge7" class="edge">
<title>A3&#45;&gt;A5</title>
<path fill="none" stroke="#000000" d="M409.1791,-575.5683C399.1409,-561.7533 389.0008,-547.7982 379.1588,-534.2532"/>
<polygon fill="none" stroke="#000000" points="406.3649,-577.6495 415.0747,-583.682 412.0279,-573.5347 406.3649,-577.6495"/>
</g> </g>
<!-- A4&#45;&gt;A5 --> <!-- A4&#45;&gt;A5 -->
<g id="edge2" class="edge"> <g id="edge2" class="edge">
<title>A4&#45;&gt;A5</title> <title>A4&#45;&gt;A5</title>
<path fill="none" stroke="#000000" d="M248.348,-373.9068C248.348,-355.4405 248.348,-335.1691 248.348,-316.2449"/> <path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M279.7719,-639.4228C282.8086,-608.1559 286.5373,-569.7639 289.991,-534.2034"/>
<polygon fill="none" stroke="#000000" points="244.8481,-373.9601 248.348,-383.9602 251.8481,-373.9602 244.8481,-373.9601"/> <polygon fill="none" stroke="#000000" points="276.2531,-639.4473 278.77,-649.7389 283.2203,-640.1241 276.2531,-639.4473"/>
</g> </g>
<!-- A6 --> <!-- A6 -->
<g id="node7" class="node"> <g id="node7" class="node">
<title>A6</title> <title>A6</title>
<polygon fill="none" stroke="#000000" points="333.348,-284 333.348,-316 455.348,-316 455.348,-284 333.348,-284"/> <polygon fill="none" stroke="#000000" points="356.5,-236 356.5,-268 468.5,-268 468.5,-236 356.5,-236"/>
<text text-anchor="start" x="367.398" y="-297" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3P</text> <text text-anchor="start" x="389.9995" y="-249" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">StreamPtr</text>
<polygon fill="none" stroke="#000000" points="333.348,-228 333.348,-284 455.348,-284 455.348,-228 333.348,-228"/> <polygon fill="none" stroke="#000000" points="356.5,-216 356.5,-236 468.5,-236 468.5,-216 356.5,-216"/>
<text text-anchor="start" x="384.345" y="-265" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text> <polygon fill="none" stroke="#000000" points="356.5,-172 356.5,-216 468.5,-216 468.5,-172 356.5,-172"/>
<text text-anchor="start" x="354.901" y="-253" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text> <text text-anchor="start" x="366.3825" y="-197" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">stream:MessageProt</text>
<text text-anchor="start" x="360.18" y="-241" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text> <text text-anchor="start" x="387.2185" y="-185" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ifc:AsyncIfc</text>
<polygon fill="none" stroke="#000000" points="333.348,-172 333.348,-228 455.348,-228 455.348,-172 333.348,-172"/>
<text text-anchor="start" x="342.9515" y="-209" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text>
<text text-anchor="start" x="379.3505" y="-185" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g> </g>
<!-- A4&#45;&gt;A6 --> <!-- A5&#45;&gt;A6 -->
<g id="edge3" class="edge"> <g id="edge8" class="edge">
<title>A4&#45;&gt;A6</title> <title>A5&#45;&gt;A6</title>
<path fill="none" stroke="#000000" d="M295.0446,-375.9511C309.349,-356.9439 325.2087,-335.87 339.9781,-316.2449"/> <path fill="none" stroke="#000000" d="M359.288,-317.872C366.9377,-303.802 374.5179,-289.86 381.4556,-277.0995"/>
<polygon fill="none" stroke="#000000" points="292.2338,-373.8654 289.0171,-383.9602 297.8269,-378.0747 292.2338,-373.8654"/> <polygon fill="#000000" stroke="#000000" points="386.3856,-268.0318 385.5625,-278.9667 383.9973,-272.4245 381.609,-276.8173 381.609,-276.8173 381.609,-276.8173 383.9973,-272.4245 377.6556,-274.6678 386.3856,-268.0318 386.3856,-268.0318"/>
<text text-anchor="middle" x="385.1534" y="-284.9938" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">2</text>
</g> </g>
<!-- A7 --> <!-- A7 -->
<g id="node8" class="node"> <g id="node8" class="node">
<title>A7</title> <title>A7</title>
<polygon fill="none" stroke="#000000" points="362.9901,-36 273.7059,-36 273.7059,0 362.9901,0 362.9901,-36"/> <polygon fill="none" stroke="#000000" points="338.2314,-238 262.7686,-238 262.7686,-202 338.2314,-202 338.2314,-238"/>
<text text-anchor="middle" x="318.348" y="-15" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;AsyncIfc&gt;&gt;</text> <text text-anchor="middle" x="300.5" y="-217" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3</text>
</g> </g>
<!-- A5&#45;&gt;A7 --> <!-- A5&#45;&gt;A7 -->
<g id="edge7" class="edge"> <g id="edge5" class="edge">
<title>A5&#45;&gt;A7</title> <title>A5&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M240.5289,-171.6857C240.2064,-143.9437 243.216,-112.5864 254.348,-86 261.2443,-69.5295 274.0532,-54.6444 286.4105,-43.0292"/> <path fill="none" stroke="#000000" d="M300.5,-307.7729C300.5,-280.5002 300.5,-254.684 300.5,-238.2013"/>
<polygon fill="#000000" stroke="#000000" points="293.9894,-36.2348 289.5473,-46.2607 290.2664,-39.5724 286.5434,-42.91 286.5434,-42.91 286.5434,-42.91 290.2664,-39.5724 283.5396,-39.5594 293.9894,-36.2348 293.9894,-36.2348"/> <polygon fill="none" stroke="#000000" points="297.0001,-307.872 300.5,-317.872 304.0001,-307.872 297.0001,-307.872"/>
<text text-anchor="middle" x="286.135" y="-51.6279" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1..2</text>
</g>
<!-- A8 -->
<g id="node9" class="node">
<title>A8</title>
<polygon fill="none" stroke="#000000" points="373.6053,-122 263.0907,-122 263.0907,-86 373.6053,-86 373.6053,-122"/>
<text text-anchor="middle" x="318.348" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;MessageProt&gt;&gt;</text>
</g>
<!-- A5&#45;&gt;A8 -->
<g id="edge6" class="edge">
<title>A5&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M284.3733,-171.9495C291.5966,-157.5029 298.7616,-143.1729 304.6363,-131.4235"/>
<polygon fill="#000000" stroke="#000000" points="309.2405,-122.215 308.7932,-133.1718 307.0044,-126.6872 304.7683,-131.1593 304.7683,-131.1593 304.7683,-131.1593 307.0044,-126.6872 300.7434,-129.1468 309.2405,-122.215 309.2405,-122.215"/>
<text text-anchor="middle" x="308.6942" y="-139.2076" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1..2</text>
</g>
<!-- A6&#45;&gt;A7 -->
<g id="edge9" class="edge">
<title>A6&#45;&gt;A7</title>
<path fill="none" stroke="#000000" d="M398.9275,-171.9166C398.1587,-144.0552 394.0617,-112.5537 382.348,-86 375.087,-69.5402 362.0955,-54.573 349.7057,-42.8973"/>
<polygon fill="#000000" stroke="#000000" points="342.1257,-36.0689 352.5675,-39.4186 345.8407,-39.4154 349.5556,-42.762 349.5556,-42.762 349.5556,-42.762 345.8407,-39.4154 346.5437,-46.1054 342.1257,-36.0689 342.1257,-36.0689"/>
<text text-anchor="middle" x="361.2504" y="-38.921" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1..2</text>
</g>
<!-- A6&#45;&gt;A8 -->
<g id="edge8" class="edge">
<title>A6&#45;&gt;A8</title>
<path fill="none" stroke="#000000" d="M355.2349,-171.9495C347.314,-157.3584 339.4577,-142.8863 333.0441,-131.0718"/>
<polygon fill="#000000" stroke="#000000" points="328.2362,-122.215 336.962,-128.8567 330.6217,-126.6093 333.0071,-131.0036 333.0071,-131.0036 333.0071,-131.0036 330.6217,-126.6093 329.0523,-133.1505 328.2362,-122.215 328.2362,-122.215"/>
<text text-anchor="middle" x="344.3124" y="-131.1127" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1..2</text>
</g>
<!-- A8&#45;&gt;A7 -->
<g id="edge10" class="edge">
<title>A8&#45;&gt;A7</title>
<path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M318.348,-85.7616C318.348,-74.3597 318.348,-59.4342 318.348,-46.494"/>
<polygon fill="#000000" stroke="#000000" points="318.348,-36.2121 322.8481,-46.2121 318.348,-41.2121 318.3481,-46.2121 318.3481,-46.2121 318.3481,-46.2121 318.348,-41.2121 313.8481,-46.2121 318.348,-36.2121 318.348,-36.2121"/>
<text text-anchor="middle" x="309.8956" y="-64.6355" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">use</text>
</g> </g>
<!-- A9 --> <!-- A9 -->
<g id="node10" class="node"> <g id="node10" class="node">
<title>A9</title> <title>A9</title>
<polygon fill="none" stroke="#000000" points="347.348,-466 347.348,-498 454.348,-498 454.348,-466 347.348,-466"/> <polygon fill="none" stroke="#000000" points="94.4001,-238 12.5999,-238 12.5999,-202 94.4001,-202 94.4001,-238"/>
<text text-anchor="start" x="371.1175" y="-479" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ModbusConn</text> <text text-anchor="middle" x="53.5" y="-217" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">InverterG3P</text>
<polygon fill="none" stroke="#000000" points="347.348,-398 347.348,-466 454.348,-466 454.348,-398 347.348,-398"/>
<text text-anchor="start" x="391.3995" y="-447" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">host</text>
<text text-anchor="start" x="392.235" y="-435" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">port</text>
<text text-anchor="start" x="390.845" y="-423" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text>
<text text-anchor="start" x="357.231" y="-411" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">stream:InverterG3P</text>
<polygon fill="none" stroke="#000000" points="347.348,-378 347.348,-398 454.348,-398 454.348,-378 347.348,-378"/>
</g> </g>
<!-- A9&#45;&gt;A6 --> <!-- A5&#45;&gt;A9 -->
<g id="edge6" class="edge">
<title>A5&#45;&gt;A9</title>
<path fill="none" stroke="#000000" d="M196.7667,-346.4637C165.8973,-321.9347 132.3582,-294.4156 102.5,-268 91.7971,-258.5312 80.3616,-247.3925 71.232,-238.23"/>
<polygon fill="none" stroke="#000000" points="194.962,-349.4991 204.9739,-352.965 199.3086,-344.0121 194.962,-349.4991"/>
</g>
<!-- A11 -->
<g id="node12" class="node">
<title>A11</title>
<polygon fill="none" stroke="#000000" points="456.1421,-36 366.8579,-36 366.8579,0 456.1421,0 456.1421,-36"/>
<text text-anchor="middle" x="411.5" y="-15" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;AsyncIfc&gt;&gt;</text>
</g>
<!-- A6&#45;&gt;A11 -->
<g id="edge11" class="edge"> <g id="edge11" class="edge">
<title>A9&#45;&gt;A6</title> <title>A6&#45;&gt;A11</title>
<path fill="none" stroke="#000000" d="M398.4907,-377.9458C397.9843,-361.5736 397.4269,-343.5504 396.8896,-326.177"/> <path fill="none" stroke="#000000" d="M396.5836,-171.9861C390.0675,-146.4721 384.9947,-114.5619 389.5,-86 391.6448,-72.403 396.0621,-57.8206 400.3796,-45.6603"/>
<polygon fill="#000000" stroke="#000000" points="396.576,-316.0403 401.3831,-325.8963 396.7307,-321.0379 396.8853,-326.0355 396.8853,-326.0355 396.8853,-326.0355 396.7307,-321.0379 392.3874,-326.1746 396.576,-316.0403 396.576,-316.0403"/> <polygon fill="#000000" stroke="#000000" points="403.9307,-36.0902 404.6707,-47.0311 402.1913,-40.7779 400.4518,-45.4656 400.4518,-45.4656 400.4518,-45.4656 402.1913,-40.7779 396.2329,-43.9001 403.9307,-36.0902 403.9307,-36.0902"/>
<text text-anchor="middle" x="405.5847" y="-330.8965" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text> <text text-anchor="middle" x="405.5493" y="-53.0246" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text>
<text text-anchor="middle" x="389.482" y="-357.0896" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text> </g>
<!-- A12 -->
<g id="node13" class="node">
<title>A12</title>
<polygon fill="none" stroke="#000000" points="508.7573,-122 398.2427,-122 398.2427,-86 508.7573,-86 508.7573,-122"/>
<text text-anchor="middle" x="453.5" y="-101" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;&lt;MessageProt&gt;&gt;</text>
</g>
<!-- A6&#45;&gt;A12 -->
<g id="edge10" class="edge">
<title>A6&#45;&gt;A12</title>
<path fill="none" stroke="#000000" d="M429.5315,-171.8133C434.3787,-158.0994 439.4923,-143.6315 443.7456,-131.5978"/>
<polygon fill="#000000" stroke="#000000" points="447.0913,-122.132 448.0016,-133.06 445.425,-126.8462 443.7588,-131.5604 443.7588,-131.5604 443.7588,-131.5604 445.425,-126.8462 439.516,-130.0607 447.0913,-122.132 447.0913,-122.132"/>
<text text-anchor="middle" x="449.0201" y="-139.0387" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text>
</g>
<!-- A8 -->
<g id="node9" class="node">
<title>A8</title>
<polygon fill="#fff8dc" stroke="#000000" points="586.906,-248 486.094,-248 486.094,-192 592.906,-192 592.906,-242 586.906,-248"/>
<polyline fill="none" stroke="#000000" points="586.906,-248 586.906,-242 "/>
<polyline fill="none" stroke="#000000" points="592.906,-242 586.906,-242 "/>
<text text-anchor="middle" x="539.5" y="-235" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Creates an GEN3</text>
<text text-anchor="middle" x="539.5" y="-223" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inverter instance</text>
<text text-anchor="middle" x="539.5" y="-211" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">with</text>
<text text-anchor="middle" x="539.5" y="-199" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">prot_class:Talent</text>
</g>
<!-- A7&#45;&gt;A8 -->
<g id="edge3" class="edge">
<title>A7&#45;&gt;A8</title>
<path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M308.5491,-238.3283C317.4345,-256.0056 333.5793,-281.6949 356.5,-293 401.1429,-315.019 422.6447,-312.368 468.5,-293 490.1607,-283.8511 508.4784,-264.5049 521.0802,-248.0264"/>
</g>
<!-- A10 -->
<g id="node11" class="node">
<title>A10</title>
<polygon fill="#fff8dc" stroke="#000000" points="239.022,-248 111.978,-248 111.978,-192 245.022,-192 245.022,-242 239.022,-248"/>
<polyline fill="none" stroke="#000000" points="239.022,-248 239.022,-242 "/>
<polyline fill="none" stroke="#000000" points="245.022,-242 239.022,-242 "/>
<text text-anchor="middle" x="178.5" y="-235" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">Creates an GEN3PLUS</text>
<text text-anchor="middle" x="178.5" y="-223" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">inverter instance</text>
<text text-anchor="middle" x="178.5" y="-211" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">with</text>
<text text-anchor="middle" x="178.5" y="-199" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">prot_class:SolarmanV5</text>
</g>
<!-- A9&#45;&gt;A10 -->
<g id="edge4" class="edge">
<title>A9&#45;&gt;A10</title>
<path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M94.5156,-220C100.3114,-220 106.1072,-220 111.903,-220"/>
</g>
<!-- A12&#45;&gt;A11 -->
<g id="edge12" class="edge">
<title>A12&#45;&gt;A11</title>
<path fill="none" stroke="#000000" stroke-dasharray="5,2" d="M444.5929,-85.7616C438.8574,-74.0176 431.2964,-58.5355 424.8496,-45.3349"/>
<polygon fill="#000000" stroke="#000000" points="420.3943,-36.2121 428.8262,-43.223 422.5885,-40.7049 424.7827,-45.1978 424.7827,-45.1978 424.7827,-45.1978 422.5885,-40.7049 420.7391,-47.1726 420.3943,-36.2121 420.3943,-36.2121"/>
<text text-anchor="middle" x="429.0435" y="-70.1832" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">use</text>
</g>
<!-- A13 -->
<g id="node14" class="node">
<title>A13</title>
<polygon fill="none" stroke="#000000" points=".5,-454 .5,-486 107.5,-486 107.5,-454 .5,-454"/>
<text text-anchor="start" x="24.2695" y="-467" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ModbusConn</text>
<polygon fill="none" stroke="#000000" points=".5,-386 .5,-454 107.5,-454 107.5,-386 .5,-386"/>
<text text-anchor="start" x="44.5515" y="-435" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">host</text>
<text text-anchor="start" x="45.387" y="-423" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">port</text>
<text text-anchor="start" x="43.997" y="-411" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">addr</text>
<text text-anchor="start" x="10.383" y="-399" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">stream:InverterG3P</text>
<polygon fill="none" stroke="#000000" points=".5,-366 .5,-386 107.5,-386 107.5,-366 .5,-366"/>
</g>
<!-- A13&#45;&gt;A9 -->
<g id="edge13" class="edge">
<title>A13&#45;&gt;A9</title>
<path fill="none" stroke="#000000" d="M53.5,-365.8625C53.5,-327.1513 53.5,-278.6088 53.5,-248.4442"/>
<polygon fill="#000000" stroke="#000000" points="53.5,-238.2147 58.0001,-248.2147 53.5,-243.2147 53.5001,-248.2147 53.5001,-248.2147 53.5001,-248.2147 53.5,-243.2147 49.0001,-248.2148 53.5,-238.2147 53.5,-238.2147"/>
<text text-anchor="middle" x="61.9524" y="-253.3409" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">1</text>
<text text-anchor="middle" x="45.0476" y="-344.7363" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">has</text>
</g>
<!-- A14 -->
<g id="node15" class="node">
<title>A14</title>
<polygon fill="none" stroke="#000000" points="93.7333,-722 13.2667,-722 13.2667,-686 93.7333,-686 93.7333,-722"/>
<text text-anchor="middle" x="53.5" y="-701" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">ModbusTcp</text>
</g>
<!-- A14&#45;&gt;A13 -->
<g id="edge14" class="edge">
<title>A14&#45;&gt;A13</title>
<path fill="none" stroke="#000000" d="M53.5,-685.7596C53.5,-647.9991 53.5,-559.5189 53.5,-496.3277"/>
<polygon fill="#000000" stroke="#000000" points="53.5,-486.0223 58.0001,-496.0223 53.5,-491.0223 53.5001,-496.0223 53.5001,-496.0223 53.5001,-496.0223 53.5,-491.0223 49.0001,-496.0224 53.5,-486.0223 53.5,-486.0223"/>
<text text-anchor="middle" x="61.9524" y="-501.1485" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">*</text>
<text text-anchor="middle" x="45.0476" y="-664.6335" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">creates</text>
</g> </g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -3,29 +3,34 @@
// {generate:true} // {generate:true}
[note: You can stick notes on diagrams too!{bg:cornsilk}] [note: You can stick notes on diagrams too!{bg:cornsilk}]
[IterRegistry||__iter__] [<<AbstractIterMeta>>||__iter__]
[Mqtt;<<Singleton>>|<static>ha_restarts;<static>__client;<static>__cb_MqttIsUp|<async>publish();<async>close()] [Mqtt;<<Singleton>>|<static>ha_restarts;<static>__client;<static>__cb_MqttIsUp|<async>publish();<async>close()]
[Inverter|cls.db_stat;cls.entity_prfx;cls.discovery_prfx;cls.proxy_node_id;cls.proxy_unique_id;cls.mqtt:Mqtt;;__ha_restarts|async_create_remote(inv_prot, conn_class)async_publ_mqtt()] [Proxy|<cls>db_stat;<cls>entity_prfx;<cls>discovery_prfx;<cls>proxy_node_id;<cls>proxy_unique_id;<cls>mqtt:Mqtt;;__ha_restarts|class_init();class_close();;<async>_cb_mqtt_is_up();<async>_register_proxy_stat_home_assistant();<async>_async_publ_mqtt_proxy_stat(key)]
[InverterBase||<async>disc(shutdown_started);<async>async_create_remote();healthy()]
[Inverter]^[InverterBase]
[InverterBase]^[InverterG3|addr;remote:StreamPtr;local:StreamPtr|async_create_remote();;close()]
[InverterBase]^[InverterG3P|addr;remote:StreamPtr;local:StreamPtr|async_create_remote();;close()]
[Inverter]++->[Mqtt;<<Singleton>>]
[IterRegistry]^[Inverter|server_side:bool;header_valid:bool;header_len:unsigned;data_len:unsigned;unique_id;node_id;sug_area;_recv_buffer:bytearray;_send_buffer:bytearray;_forward_buffer:bytearray;db:Infos;new_data:list;state|_read():void<abstract>;close():void;inc_counter():void;dec_counter():void] [<<InverterIfc>>||healthy()->bool;<async>disc(shutdown_started=False);<async>create_remote();]
[<<AbstractIterMeta>>]^-.-[<<InverterIfc>>]
[InverterBase|_registry;__ha_restarts;;addr;config_id:str;prot_class:MessageProt;remote:StreamPtr;local:StreamPtr;|healthy()->bool;<async>disc(shutdown_started=False);<async>create_remote();<async>async_publ_mqtt()]
[StreamPtr||stream:MessageProt;ifc:AsyncIfc]
[<<InverterIfc>>]^-.-[InverterBase]
[InverterG3]-[note: Creates an GEN3 inverter instance with prot_class:Talent{bg:cornsilk}]
[InverterG3P]-[note: Creates an GEN3PLUS inverter instance with prot_class:SolarmanV5{bg:cornsilk}]
[InverterBase]^[InverterG3]
[InverterBase]^[InverterG3P]
[Proxy]^[InverterBase]
[InverterBase]-2>[StreamPtr]
[Proxy]++->[Mqtt;<<Singleton>>]
[<<AsyncIfc>>] [<<AsyncIfc>>]
[InverterG3]-1..2>[<<MessageProt>>] [StreamPtr]-1>[<<MessageProt>>]
[InverterG3]-1..2>[<<AsyncIfc>>] [StreamPtr]-1>[<<AsyncIfc>>]
[InverterG3P]-1..2>[<<MessageProt>>]
[InverterG3P]-1..2>[<<AsyncIfc>>]
[<<MessageProt>>]use-.->[<<AsyncIfc>>] [<<MessageProt>>]use-.->[<<AsyncIfc>>]
[ModbusConn|host;port;addr;stream:InverterG3P;|]has-1>[InverterG3P] [ModbusConn|host;port;addr;stream:InverterG3P;|]has-1>[InverterG3P]
[ModbusTcp]creates-*>[ModbusConn]

View File

@@ -54,7 +54,7 @@
<text text-anchor="start" x="329.901" y="-553" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text> <text text-anchor="start" x="329.901" y="-553" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text>
<text text-anchor="start" x="335.18" y="-541" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text> <text text-anchor="start" x="335.18" y="-541" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text>
<polygon fill="none" stroke="#000000" points="308.348,-472 308.348,-528 430.348,-528 430.348,-472 308.348,-472"/> <polygon fill="none" stroke="#000000" points="308.348,-472 308.348,-528 430.348,-528 430.348,-472 308.348,-472"/>
<text text-anchor="start" x="317.9515" y="-509" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text> <text text-anchor="start" x="317.9515" y="-509" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">create_remote()</text>
<text text-anchor="start" x="354.3505" y="-485" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text> <text text-anchor="start" x="354.3505" y="-485" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g> </g>
<!-- A7 --> <!-- A7 -->
@@ -63,7 +63,7 @@
<polygon fill="none" stroke="#000000" points="12.348,-100 12.348,-132 190.348,-132 190.348,-100 12.348,-100"/> <polygon fill="none" stroke="#000000" points="12.348,-100 12.348,-132 190.348,-132 190.348,-100 12.348,-100"/>
<text text-anchor="start" x="56.8995" y="-113" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">AsyncStreamServer</text> <text text-anchor="start" x="56.8995" y="-113" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">AsyncStreamServer</text>
<polygon fill="none" stroke="#000000" points="12.348,-68 12.348,-100 190.348,-100 190.348,-68 12.348,-68"/> <polygon fill="none" stroke="#000000" points="12.348,-68 12.348,-100 190.348,-100 190.348,-68 12.348,-68"/>
<text text-anchor="start" x="53.2805" y="-81" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote</text> <text text-anchor="start" x="53.2805" y="-81" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">create_remote</text>
<polygon fill="none" stroke="#000000" points="12.348,0 12.348,-68 190.348,-68 190.348,0 12.348,0"/> <polygon fill="none" stroke="#000000" points="12.348,0 12.348,-68 190.348,-68 190.348,0 12.348,0"/>
<text text-anchor="start" x="53.0055" y="-49" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;server_loop()</text> <text text-anchor="start" x="53.0055" y="-49" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;server_loop()</text>
<text text-anchor="start" x="43.8365" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;_async_forward()</text> <text text-anchor="start" x="43.8365" y="-37" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">&lt;async&gt;_async_forward()</text>
@@ -105,7 +105,7 @@
<text text-anchor="start" x="21.901" y="-311" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text> <text text-anchor="start" x="21.901" y="-311" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">remote:StreamPtr</text>
<text text-anchor="start" x="27.18" y="-299" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text> <text text-anchor="start" x="27.18" y="-299" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">local:StreamPtr</text>
<polygon fill="none" stroke="#000000" points=".348,-230 .348,-286 122.348,-286 122.348,-230 .348,-230"/> <polygon fill="none" stroke="#000000" points=".348,-230 .348,-286 122.348,-286 122.348,-230 .348,-230"/>
<text text-anchor="start" x="9.9515" y="-267" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">async_create_remote()</text> <text text-anchor="start" x="9.9515" y="-267" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">create_remote()</text>
<text text-anchor="start" x="46.3505" y="-243" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text> <text text-anchor="start" x="46.3505" y="-243" font-family="Helvetica,sans-Serif" font-size="10.00" fill="#000000">close()</text>
</g> </g>
<!-- A3&#45;&gt;A7 --> <!-- A3&#45;&gt;A7 -->

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -5,13 +5,13 @@
[note: You can stick notes on diagrams too!{bg:cornsilk}] [note: You can stick notes on diagrams too!{bg:cornsilk}]
[IterRegistry||__iter__] [IterRegistry||__iter__]
[InverterG3|addr;remote:StreamPtr;local:StreamPtr|async_create_remote();;close()] [InverterG3|addr;remote:StreamPtr;local:StreamPtr|create_remote();;close()]
[InverterG3P|addr;remote:StreamPtr;local:StreamPtr|async_create_remote();;close()] [InverterG3P|addr;remote:StreamPtr;local:StreamPtr|create_remote();;close()]
[<<AsyncIfc>>||set_node_id();get_conn_no();;tx_add();tx_flush();tx_get();tx_peek();tx_log();tx_clear();tx_len();;fwd_add();fwd_flush();fwd_log();fwd_clear();rx_get();rx_peek();rx_log();rx_clear();rx_len();rx_set_cb();;prot_set_timeout_cb()] [<<AsyncIfc>>||set_node_id();get_conn_no();;tx_add();tx_flush();tx_get();tx_peek();tx_log();tx_clear();tx_len();;fwd_add();fwd_flush();fwd_log();fwd_clear();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] [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|;<async>loop;disc();close();healthy();;__async_read();__async_write();__async_forward()] [AsyncStream|reader;writer;addr;r_addr;l_addr|;<async>loop;disc();close();healthy();;__async_read();__async_write();__async_forward()]
[AsyncStreamServer|async_create_remote|<async>server_loop();<async>_async_forward();<async>publish_outstanding_mqtt();close()] [AsyncStreamServer|create_remote|<async>server_loop();<async>_async_forward();<async>publish_outstanding_mqtt();close()]
[AsyncStreamClient||<async>client_loop();<async>_async_forward())] [AsyncStreamClient||<async>client_loop();<async>_async_forward())]
[<<AsyncIfc>>]^-.-[AsyncIfcImpl] [<<AsyncIfc>>]^-.-[AsyncIfcImpl]
[AsyncIfcImpl]^[AsyncStream] [AsyncIfcImpl]^[AsyncStream]

View File

@@ -7,12 +7,12 @@ from typing import Self
from itertools import count from itertools import count
if __name__ == "app.src.async_stream": if __name__ == "app.src.async_stream":
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.byte_fifo import ByteFifo from app.src.byte_fifo import ByteFifo
from app.src.async_ifc import AsyncIfc from app.src.async_ifc import AsyncIfc
from app.src.infos import Infos from app.src.infos import Infos
else: # pragma: no cover else: # pragma: no cover
from inverter import Inverter from proxy import Proxy
from byte_fifo import ByteFifo from byte_fifo import ByteFifo
from async_ifc import AsyncIfc from async_ifc import AsyncIfc
from infos import Infos from infos import Infos
@@ -240,7 +240,7 @@ class AsyncStream(AsyncIfcImpl):
await self._writer.wait_closed() await self._writer.wait_closed()
def close(self) -> None: def close(self) -> None:
logging.info(f'AsyncStream.close1() l{self.l_addr} | r{self.r_addr}') logging.debug(f'AsyncStream.close() l{self.l_addr} | r{self.r_addr}')
"""close handler for a no waiting disconnect """close handler for a no waiting disconnect
hint: must be called before releasing the connection instance hint: must be called before releasing the connection instance
@@ -249,7 +249,6 @@ class AsyncStream(AsyncIfcImpl):
self._reader.feed_eof() # abort awaited read self._reader.feed_eof() # abort awaited read
if self._writer.is_closing(): if self._writer.is_closing():
return return
logger.info(f'AsyncStream.close2() l{self.l_addr} | r{self.r_addr}')
self._writer.close() self._writer.close()
def healthy(self) -> bool: def healthy(self) -> bool:
@@ -325,15 +324,15 @@ class AsyncStream(AsyncIfcImpl):
class AsyncStreamServer(AsyncStream): class AsyncStreamServer(AsyncStream):
def __init__(self, reader: StreamReader, writer: StreamWriter, def __init__(self, reader: StreamReader, writer: StreamWriter,
async_publ_mqtt, async_create_remote, async_publ_mqtt, create_remote,
rstream: "StreamPtr") -> None: rstream: "StreamPtr") -> None:
AsyncStream.__init__(self, reader, writer, rstream) AsyncStream.__init__(self, reader, writer, rstream)
self.async_create_remote = async_create_remote self.create_remote = create_remote
self.async_publ_mqtt = async_publ_mqtt self.async_publ_mqtt = async_publ_mqtt
def close(self) -> None: def close(self) -> None:
logging.info('AsyncStreamServer.close()') logging.debug('AsyncStreamServer.close()')
self.async_create_remote = None self.create_remote = None
self.async_publ_mqtt = None self.async_publ_mqtt = None
super().close() super().close()
@@ -342,7 +341,7 @@ class AsyncStreamServer(AsyncStream):
logger.info(f'[{self.node_id}:{self.conn_no}] ' logger.info(f'[{self.node_id}:{self.conn_no}] '
f'Accept connection from {self.r_addr}') f'Accept connection from {self.r_addr}')
Infos.inc_counter('Inverter_Cnt') Infos.inc_counter('Inverter_Cnt')
await self.publish_outstanding_mqtt() await self.publish_outstanding_mqtugt()
await self.loop() await self.loop()
Infos.dec_counter('Inverter_Cnt') Infos.dec_counter('Inverter_Cnt')
await self.publish_outstanding_mqtt() await self.publish_outstanding_mqtt()
@@ -360,7 +359,7 @@ class AsyncStreamServer(AsyncStream):
async def _async_forward(self) -> None: async def _async_forward(self) -> None:
"""forward handler transmits data over the remote connection""" """forward handler transmits data over the remote connection"""
if not self.remote.stream: if not self.remote.stream:
await self.async_create_remote() await self.create_remote()
if self.remote.stream and \ if self.remote.stream and \
self.remote.ifc.init_new_client_conn_cb(): self.remote.ifc.init_new_client_conn_cb():
await self.remote.ifc._AsyncStream__async_write() await self.remote.ifc._AsyncStream__async_write()
@@ -375,7 +374,7 @@ class AsyncStreamServer(AsyncStream):
'''Publish all outstanding MQTT topics''' '''Publish all outstanding MQTT topics'''
try: try:
await self.async_publ_mqtt() await self.async_publ_mqtt()
await Inverter._async_publ_mqtt_proxy_stat('proxy') await Proxy._async_publ_mqtt_proxy_stat('proxy')
except Exception: except Exception:
pass pass
@@ -387,7 +386,7 @@ class AsyncStreamClient(AsyncStream):
self.close_cb = close_cb self.close_cb = close_cb
def close(self) -> None: def close(self) -> None:
logging.info('AsyncStreamClient.close()') logging.debug('AsyncStreamClient.close()')
self.close_cb = None self.close_cb = None
super().close() super().close()

View File

@@ -9,7 +9,7 @@ from asyncio import StreamReader, StreamWriter
if __name__ == "app.src.inverter_base": if __name__ == "app.src.inverter_base":
from app.src.iter_registry import AbstractIterMeta from app.src.iter_registry import AbstractIterMeta
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.async_stream import StreamPtr from app.src.async_stream import StreamPtr
from app.src.async_stream import AsyncStreamClient from app.src.async_stream import AsyncStreamClient
from app.src.async_stream import AsyncStreamServer from app.src.async_stream import AsyncStreamServer
@@ -17,7 +17,7 @@ if __name__ == "app.src.inverter_base":
from app.src.infos import Infos from app.src.infos import Infos
else: # pragma: no cover else: # pragma: no cover
from iter_registry import AbstractIterMeta from iter_registry import AbstractIterMeta
from inverter import Inverter from proxy import Proxy
from async_stream import StreamPtr from async_stream import StreamPtr
from async_stream import AsyncStreamClient from async_stream import AsyncStreamClient
from async_stream import AsyncStreamServer from async_stream import AsyncStreamServer
@@ -28,6 +28,7 @@ logger_mqtt = logging.getLogger('mqtt')
class InverterIfc(metaclass=AbstractIterMeta): class InverterIfc(metaclass=AbstractIterMeta):
_registry = []
@abstractmethod @abstractmethod
def __init__(self, reader: StreamReader, writer: StreamWriter, def __init__(self, reader: StreamReader, writer: StreamWriter,
@@ -52,17 +53,16 @@ class InverterIfc(metaclass=AbstractIterMeta):
pass # pragma: no cover pass # pragma: no cover
@abstractmethod @abstractmethod
async def async_create_remote(self) -> None: async def create_remote(self) -> None:
pass # pragma: no cover pass # pragma: no cover
class InverterBase(InverterIfc, Inverter): class InverterBase(InverterIfc, Proxy):
_registry = []
def __init__(self, reader: StreamReader, writer: StreamWriter, def __init__(self, reader: StreamReader, writer: StreamWriter,
config_id: str, prot_class, config_id: str, prot_class,
client_mode: bool = False): client_mode: bool = False):
Inverter.__init__(self) Proxy.__init__(self)
self._registry.append(weakref.ref(self)) self._registry.append(weakref.ref(self))
self.addr = writer.get_extra_info('peername') self.addr = writer.get_extra_info('peername')
self.config_id = config_id self.config_id = config_id
@@ -71,7 +71,7 @@ class InverterBase(InverterIfc, Inverter):
self.remote = StreamPtr(None) self.remote = StreamPtr(None)
ifc = AsyncStreamServer(reader, writer, ifc = AsyncStreamServer(reader, writer,
self.async_publ_mqtt, self.async_publ_mqtt,
self.async_create_remote, self.create_remote,
self.remote) self.remote)
self.local = StreamPtr( self.local = StreamPtr(
@@ -113,7 +113,7 @@ class InverterBase(InverterIfc, Inverter):
await self.local.ifc.disc() await self.local.ifc.disc()
def healthy(self) -> bool: def healthy(self) -> bool:
logging.debug('Inverter healthy()') logging.debug('InverterBase healthy()')
if self.local.ifc and not self.local.ifc.healthy(): if self.local.ifc and not self.local.ifc.healthy():
return False return False
@@ -121,7 +121,7 @@ class InverterBase(InverterIfc, Inverter):
return False return False
return True return True
async def async_create_remote(self) -> None: async def create_remote(self) -> None:
'''Establish a client connection to the TSUN cloud''' '''Establish a client connection to the TSUN cloud'''
tsun = Config.get(self.config_id) tsun = Config.get(self.config_id)
@@ -179,7 +179,7 @@ class InverterBase(InverterIfc, Inverter):
for key in stream.new_data: for key in stream.new_data:
await self.__async_publ_mqtt_packet(stream, key) await self.__async_publ_mqtt_packet(stream, key)
for key in Infos.new_stat_data: for key in Infos.new_stat_data:
await Inverter._async_publ_mqtt_proxy_stat(key) await Proxy._async_publ_mqtt_proxy_stat(key)
except MqttCodeError as error: except MqttCodeError as error:
logging.error(f'Mqtt except: {error}') logging.error(f'Mqtt except: {error}')

View File

@@ -13,6 +13,5 @@ class AbstractIterMeta(ABCMeta):
def __iter__(cls): def __iter__(cls):
for ref in cls._registry: for ref in cls._registry:
obj = ref() obj = ref()
print(f'obj: {obj}')
if obj is not None: if obj is not None:
yield obj yield obj

View File

@@ -2,7 +2,7 @@ import asyncio
import logging import logging
import json import json
if __name__ == "app.src.inverter": if __name__ == "app.src.proxy":
from app.src.config import Config from app.src.config import Config
from app.src.mqtt import Mqtt from app.src.mqtt import Mqtt
from app.src.infos import Infos from app.src.infos import Infos
@@ -14,8 +14,8 @@ else: # pragma: no cover
logger_mqtt = logging.getLogger('mqtt') logger_mqtt = logging.getLogger('mqtt')
class Inverter(): class Proxy():
'''class Inverter is a baseclass '''class Proxy is a baseclass
The class has some class method for managing common resources like a The class has some class method for managing common resources like a
connection to the MQTT broker or proxy error counter which are common connection to the MQTT broker or proxy error counter which are common
@@ -34,12 +34,12 @@ class Inverter():
destroyed destroyed
methods: methods:
async_create_remote(): Establish a client connection to the TSUN cloud create_remote(): Establish a client connection to the TSUN cloud
async_publ_mqtt(): Publish data to MQTT broker async_publ_mqtt(): Publish data to MQTT broker
''' '''
@classmethod @classmethod
def class_init(cls) -> None: def class_init(cls) -> None:
logging.debug('Inverter.class_init') logging.debug('Proxy.class_init')
# initialize the proxy statistics # initialize the proxy statistics
Infos.static_init() Infos.static_init()
cls.db_stat = Infos() cls.db_stat = Infos()
@@ -61,7 +61,7 @@ class Inverter():
# reset at midnight when you restart the proxy just before # reset at midnight when you restart the proxy just before
# midnight! # midnight!
inverters = Config.get('inverters') inverters = Config.get('inverters')
# logger.debug(f'Inverters: {inverters}') # logger.debug(f'Proxys: {inverters}')
for inv in inverters.values(): for inv in inverters.values():
if (type(inv) is dict): if (type(inv) is dict):
node_id = inv['node_id'] node_id = inv['node_id']
@@ -100,7 +100,7 @@ class Inverter():
@classmethod @classmethod
def class_close(cls, loop) -> None: # pragma: no cover def class_close(cls, loop) -> None: # pragma: no cover
logging.debug('Inverter.class_close') logging.debug('Proxy.class_close')
logging.info('Close MQTT Task') logging.info('Close MQTT Task')
loop.run_until_complete(cls.mqtt.close()) loop.run_until_complete(cls.mqtt.close())
cls.mqtt = None cls.mqtt = None

View File

@@ -5,7 +5,7 @@ import os
from asyncio import StreamReader, StreamWriter from asyncio import StreamReader, StreamWriter
from aiohttp import web from aiohttp import web
from logging import config # noqa F401 from logging import config # noqa F401
from inverter import Inverter from proxy import Proxy
from inverter_base import InverterIfc from inverter_base import InverterIfc
from gen3.inverter_g3 import InverterG3 from gen3.inverter_g3 import InverterG3
from gen3plus.inverter_g3p import InverterG3P from gen3plus.inverter_g3p import InverterG3P
@@ -87,7 +87,7 @@ async def handle_shutdown(web_task):
# #
# first, disc all open TCP connections gracefully # first, disc all open TCP connections gracefully
# #
async for inverter in InverterIfc: for inverter in InverterIfc:
await inverter.disc(True) await inverter.disc(True)
logging.info('Proxy disconnecting done') logging.info('Proxy disconnecting done')
@@ -152,7 +152,7 @@ if __name__ == "__main__":
ConfigErr = Config.class_init() ConfigErr = Config.class_init()
if ConfigErr is not None: if ConfigErr is not None:
logging.info(f'ConfigErr: {ConfigErr}') logging.info(f'ConfigErr: {ConfigErr}')
Inverter.class_init() Proxy.class_init()
Schedule.start() Schedule.start()
ModbusTcp(loop) ModbusTcp(loop)
@@ -185,7 +185,7 @@ if __name__ == "__main__":
pass pass
finally: finally:
logging.info("Event loop is stopped") logging.info("Event loop is stopped")
Inverter.class_close(loop) Proxy.class_close(loop)
logging.debug('Close event loop') logging.debug('Close event loop')
loop.close() loop.close()
logging.info(f'Finally, exit Server "{serv_name}"') logging.info(f'Finally, exit Server "{serv_name}"')

View File

@@ -7,7 +7,7 @@ from mock import patch
from enum import Enum from enum import Enum
from app.src.infos import Infos from app.src.infos import Infos
from app.src.config import Config from app.src.config import Config
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.inverter_base import InverterBase from app.src.inverter_base import InverterBase
from app.src.singleton import Singleton from app.src.singleton import Singleton
from app.src.gen3.inverter_g3 import InverterG3 from app.src.gen3.inverter_g3 import InverterG3
@@ -126,14 +126,14 @@ async def test_remote_conn(config_conn, patch_open_connection):
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
with InverterG3(FakeReader(), FakeWriter()) as inverter: with InverterG3(FakeReader(), FakeWriter()) as inverter:
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream assert inverter.remote.stream
del inverter del inverter
cnt = 0 cnt = 0
for inv in InverterBase: for inv in InverterBase:
print(f'Inverter refs:{gc.get_referrers(inv)}') print(f'InverterBase refs:{gc.get_referrers(inv)}')
cnt += 1 cnt += 1
assert cnt == 0 assert cnt == 0
@@ -147,12 +147,12 @@ async def test_remote_except(config_conn, patch_open_connection):
test = TestType.RD_TEST_TIMEOUT test = TestType.RD_TEST_TIMEOUT
with InverterG3(FakeReader(), FakeWriter()) as inverter: with InverterG3(FakeReader(), FakeWriter()) as inverter:
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream==None assert inverter.remote.stream==None
test = TestType.RD_TEST_EXCEPT test = TestType.RD_TEST_EXCEPT
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream==None assert inverter.remote.stream==None
del inverter del inverter
@@ -169,7 +169,7 @@ async def test_mqtt_publish(config_conn, patch_open_connection):
_ = patch_open_connection _ = patch_open_connection
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3(FakeReader(), FakeWriter()) as inverter: with InverterG3(FakeReader(), FakeWriter()) as inverter:
stream = inverter.local.stream stream = inverter.local.stream
@@ -197,7 +197,7 @@ async def test_mqtt_err(config_conn, patch_open_connection, patch_mqtt_err):
_ = patch_mqtt_err _ = patch_mqtt_err
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3(FakeReader(), FakeWriter()) as inverter: with InverterG3(FakeReader(), FakeWriter()) as inverter:
stream = inverter.local.stream stream = inverter.local.stream
@@ -214,7 +214,7 @@ async def test_mqtt_except(config_conn, patch_open_connection, patch_mqtt_except
_ = patch_mqtt_except _ = patch_mqtt_except
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3(FakeReader(), FakeWriter()) as inverter: with InverterG3(FakeReader(), FakeWriter()) as inverter:
stream = inverter.local.stream stream = inverter.local.stream

View File

@@ -6,7 +6,7 @@ from mock import patch
from enum import Enum from enum import Enum
from app.src.infos import Infos from app.src.infos import Infos
from app.src.config import Config from app.src.config import Config
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.inverter_base import InverterBase from app.src.inverter_base import InverterBase
from app.src.singleton import Singleton from app.src.singleton import Singleton
from app.src.gen3plus.inverter_g3p import InverterG3P from app.src.gen3plus.inverter_g3p import InverterG3P
@@ -110,7 +110,7 @@ async def test_remote_conn(config_conn, patch_open_connection):
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter: with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter:
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream assert inverter.remote.stream
@@ -124,12 +124,12 @@ async def test_remote_except(config_conn, patch_open_connection):
test = TestType.RD_TEST_TIMEOUT test = TestType.RD_TEST_TIMEOUT
with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter: with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter:
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream==None assert inverter.remote.stream==None
test = TestType.RD_TEST_EXCEPT test = TestType.RD_TEST_EXCEPT
await inverter.async_create_remote() await inverter.create_remote()
await asyncio.sleep(0) await asyncio.sleep(0)
assert inverter.remote.stream==None assert inverter.remote.stream==None
@@ -139,7 +139,7 @@ async def test_mqtt_publish(config_conn, patch_open_connection):
_ = patch_open_connection _ = patch_open_connection
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter: with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter:
stream = inverter.local.stream stream = inverter.local.stream
@@ -167,7 +167,7 @@ async def test_mqtt_err(config_conn, patch_open_connection, patch_mqtt_err):
_ = patch_mqtt_err _ = patch_mqtt_err
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter: with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter:
stream = inverter.local.stream stream = inverter.local.stream
@@ -184,7 +184,7 @@ async def test_mqtt_except(config_conn, patch_open_connection, patch_mqtt_except
_ = patch_mqtt_except _ = patch_mqtt_except
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter: with InverterG3P(FakeReader(), FakeWriter(), client_mode=False) as inverter:
stream = inverter.local.stream stream = inverter.local.stream

View File

@@ -10,7 +10,7 @@ from app.src.config import Config
from app.src.infos import Infos from app.src.infos import Infos
from app.src.mqtt import Mqtt from app.src.mqtt import Mqtt
from app.src.messages import Message, State from app.src.messages import Message, State
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.modbus_tcp import ModbusConn, ModbusTcp from app.src.modbus_tcp import ModbusConn, ModbusTcp
@@ -175,7 +175,7 @@ async def test_modbus_cnf1(config_conn, patch_open):
_ = patch_open _ = patch_open
global test global test
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
test = TestType.RD_TEST_TIMEOUT test = TestType.RD_TEST_TIMEOUT
assert Infos.stat['proxy']['Inverter_Cnt'] == 0 assert Infos.stat['proxy']['Inverter_Cnt'] == 0
@@ -196,7 +196,7 @@ async def test_modbus_cnf2(config_conn, patch_no_mqtt, patch_open):
_ = patch_no_mqtt _ = patch_no_mqtt
global test global test
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
test = TestType.RD_TEST_0_BYTES test = TestType.RD_TEST_0_BYTES
assert Infos.stat['proxy']['Inverter_Cnt'] == 0 assert Infos.stat['proxy']['Inverter_Cnt'] == 0
@@ -222,7 +222,7 @@ async def test_modbus_cnf3(config_conn, patch_no_mqtt, patch_open):
_ = patch_no_mqtt _ = patch_no_mqtt
global test global test
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
test = TestType.RD_TEST_0_BYTES test = TestType.RD_TEST_0_BYTES
assert Infos.stat['proxy']['Inverter_Cnt'] == 0 assert Infos.stat['proxy']['Inverter_Cnt'] == 0
@@ -255,7 +255,7 @@ async def test_mqtt_err(config_conn, patch_mqtt_err, patch_open):
_ = patch_mqtt_err _ = patch_mqtt_err
global test global test
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
test = TestType.RD_TEST_0_BYTES test = TestType.RD_TEST_0_BYTES
assert Infos.stat['proxy']['Inverter_Cnt'] == 0 assert Infos.stat['proxy']['Inverter_Cnt'] == 0
@@ -288,7 +288,7 @@ async def test_mqtt_except(config_conn, patch_mqtt_except, patch_open):
_ = patch_mqtt_except _ = patch_mqtt_except
global test global test
assert asyncio.get_running_loop() assert asyncio.get_running_loop()
Inverter.class_init() Proxy.class_init()
test = TestType.RD_TEST_0_BYTES test = TestType.RD_TEST_0_BYTES
assert Infos.stat['proxy']['Inverter_Cnt'] == 0 assert Infos.stat['proxy']['Inverter_Cnt'] == 0

View File

@@ -6,7 +6,7 @@ import logging
from mock import patch, Mock from mock import patch, Mock
from app.src.singleton import Singleton from app.src.singleton import Singleton
from app.src.inverter import Inverter from app.src.proxy import Proxy
from app.src.mqtt import Mqtt from app.src.mqtt import Mqtt
from app.src.gen3plus.solarman_v5 import SolarmanV5 from app.src.gen3plus.solarman_v5 import SolarmanV5
from app.src.config import Config from app.src.config import Config
@@ -63,13 +63,13 @@ def config_conn(test_hostname, test_port):
async def test_inverter_cb(config_conn): async def test_inverter_cb(config_conn):
_ = config_conn _ = config_conn
with patch.object(Inverter, '_cb_mqtt_is_up', wraps=Inverter._cb_mqtt_is_up) as spy: with patch.object(Proxy, '_cb_mqtt_is_up', wraps=Proxy._cb_mqtt_is_up) as spy:
print('call Inverter.class_init') print('call Proxy.class_init')
Inverter.class_init() Proxy.class_init()
assert 'homeassistant/' == Inverter.discovery_prfx assert 'homeassistant/' == Proxy.discovery_prfx
assert 'tsun/' == Inverter.entity_prfx assert 'tsun/' == Proxy.entity_prfx
assert 'test_1/' == Inverter.proxy_node_id assert 'test_1/' == Proxy.proxy_node_id
await Inverter._cb_mqtt_is_up() await Proxy._cb_mqtt_is_up()
spy.assert_called_once() spy.assert_called_once()
@pytest.mark.asyncio @pytest.mark.asyncio
@@ -77,8 +77,8 @@ async def test_mqtt_is_up(config_conn):
_ = config_conn _ = config_conn
with patch.object(Mqtt, 'publish') as spy: with patch.object(Mqtt, 'publish') as spy:
Inverter.class_init() Proxy.class_init()
await Inverter._cb_mqtt_is_up() await Proxy._cb_mqtt_is_up()
spy.assert_called() spy.assert_called()
@pytest.mark.asyncio @pytest.mark.asyncio
@@ -86,6 +86,6 @@ async def test_mqtt_proxy_statt_invalid(config_conn):
_ = config_conn _ = config_conn
with patch.object(Mqtt, 'publish') as spy: with patch.object(Mqtt, 'publish') as spy:
Inverter.class_init() Proxy.class_init()
await Inverter._async_publ_mqtt_proxy_stat('InValId_kEy') await Proxy._async_publ_mqtt_proxy_stat('InValId_kEy')
spy.assert_not_called() spy.assert_not_called()

View File

@@ -682,6 +682,7 @@ def config_tsun_inv1():
Config.act_config = {'solarman':{'enabled': True},'inverters':{'Y170000000000001':{'monitor_sn': 2070233889, 'node_id':'inv1', 'modbus_polling': True, 'suggested_area':'roof', 'sensor_list': 688}}} Config.act_config = {'solarman':{'enabled': True},'inverters':{'Y170000000000001':{'monitor_sn': 2070233889, 'node_id':'inv1', 'modbus_polling': True, 'suggested_area':'roof', 'sensor_list': 688}}}
def test_read_message(device_ind_msg): def test_read_message(device_ind_msg):
Config.act_config = {'solarman':{'enabled': True}}
m = MemoryStream(device_ind_msg, (0,)) m = MemoryStream(device_ind_msg, (0,))
m.read() # read complete msg, and dispatch msg m.read() # read complete msg, and dispatch msg
assert not m.header_valid # must be invalid, since msg was handled and buffer flushed assert not m.header_valid # must be invalid, since msg was handled and buffer flushed