ocervinka / plccoms-mqtt-bridge

Bi-directional communication bridge between Teco's PLCComS and MQTT broker
5 stars 0 forks source link

Vícenásobné zasílání SET: pro MQTT zprávy směrem na PLCComS #17

Open AcMetelka opened 4 months ago

AcMetelka commented 4 months ago

Ahoj, nevím, co dělám špatně, nebo jestli se mi nějak zle zkompilovala aplikace v dockeru, ale: Při přidání var-mappingů do yaml.conf se každá hodnota z MQTT posílá na PLCComS server tolikrát, kolik je namapovaných proměnných. Nemyslím, že mi to dělalo před časem, když jsem už aplikaci používal, ale to jsem vyčítal data z PLC a neposílal téměř žádná směrem MQTT > PLC, tak jsem to možná jen nezjistil.

Příklad konfigurace:

plccoms:
  host: 10.0.0.106 # kubectl --context j5005 port-forward svc/plccoms 5010:5010
  port: 5010

mqtt:
  scheme: tcp
  host: 10.0.0.106 # kubectl --context j5005 port-forward svc/mosquitto 1883:1883
  port: 1883
  username: metelka
  #password: 12345
  clientId: plccoms-mqtt-bridge

var-blacklist:
  - "STATE_.+"
  - ".+_ON"
  - ".+_OFF"
  - ".+_TRIG"

  - "SYSTEM_24HOUR_OBSERVAITON_.+"
  - "SYSTEM_AG.+"
  - "USERBITS"
  - "__.+"

var-mapping:
  - var: "FVECURRENT"
    state-topic: "plc-fve/bms-b/totalcurrent"
    cmd-topic: "plc-fve/bms-b/totalcurrent/set"
  - var: "FVEVOLTAGE"
    state-topic: "plc-fve/bms-b/totalpower"
    cmd-topic: "plc-fve/bms-b/totalpower/set"

Log z dockeru, je vidět, že každou hodnotu obdrženou z MQTT pošle dvakrát na PLCComS. Kdybych měl proměnných 10, tak pošle každou 10x.

2024-07-18T00:09:54.717Z INFO   o.p.PlcMqttBridge [MQTT Call: plccoms-mqtt-bridge] MQTT->PLC: plc-fve/bms-b/totalcurrent/set,-3.63 -> FVECURRENT,-3.63
2024-07-18T00:09:54.719Z INFO   o.p.PlcMqttBridge [MQTT Call: plccoms-mqtt-bridge] MQTT->PLC: plc-fve/bms-b/totalcurrent/set,-3.63 -> FVECURRENT,-3.63
2024-07-18T00:09:54.724Z INFO   o.p.PlcMqttBridge [MQTT Call: plccoms-mqtt-bridge] MQTT->PLC: plc-fve/bms-b/totalpower/set,-188.32 -> FVEVOLTAGE,-188.32
2024-07-18T00:09:54.726Z INFO   o.p.PlcMqttBridge [MQTT Call: plccoms-mqtt-bridge] MQTT->PLC: plc-fve/bms-b/totalpower/set,-188.32 -> FVEVOLTAGE,-188.32
2024-07-18T00:09:55.067Z INFO   o.p.PlcMqttBridge [TelnetClient] PLC->MQTT: FVECURRENT,-3.630000 -> plc-fve/bms-b/totalcurrent,-3.630000
2024-07-18T00:09:55.072Z INFO   o.p.PlcMqttBridge [TelnetClient] PLC->MQTT: FVEVOLTAGE,-188.320007 -> plc-fve/bms-b/totalpower,-188.320007

Toto je log z PLCComS, kde je vidět, že pošle každou proměnnou vícekrát:

2024-07-18 02:02:20.053498 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a252 [0xec 0x51 0x68 0xc0] - addr: 00009810 size: 04 bit: 0 FVECURRENT
2024-07-18 02:02:20.053631 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efe2 [0x52 0xb8 0x4e 0xc0] - addr: 00009810 size: 04 bit: 0 FVECURRENT
2024-07-18 02:02:20.053728 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a24e [0x3d 0x4a 0x3c 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 02:02:20.053790 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efde [0xec 0x91 0x27 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 02:02:20.054139 PLCComS->SendNetComm():: 10.0.0.106 6 10 [RX: 0 / TX: 56] omsg = DIFF:FVECURRENT,-3.630000
DIFF:FVEVOLTAGE,-188.289993
2024-07-18 02:02:24.950252 PLCComS->DoReqCommObject():: 10.0.0.106 6 2 [RX: 88 / TX: 0] imsg = SET:FVECURRENT,-3.63
SET:FVECURRENT,-3.63
SET:FVEVOLTAGE,-188.32
SET:FVEVOLTAGE,-188.32
2024-07-18 02:02:25.093426 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a24e [0xec 0x51 0x3c 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 02:02:25.093574 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efde [0x3d 0x4a 0x3c 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 02:02:25.093971 PLCComS->SendNetComm():: 10.0.0.106 6 10 [RX: 0 / TX: 29] omsg = DIFF:FVEVOLTAGE,-188.320007
2024-07-18 02:02:29.881499 PLCComS->DoReqCommObject():: 10.0.0.106 6 2 [RX: 88 / TX: 0] imsg = SET:FVECURRENT,-3.03
SET:FVECURRENT,-3.03
SET:FVEVOLTAGE,-157.20
SET:FVEVOLTAGE,-157.20
2024-07-18 02:02:29.909793 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a252 [0x85 0xeb 0x41 0xc0] - addr: 00009810 size: 04 bit: 0 FVECURRENT
2024-07-18 02:02:29.909924 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efe2 [0xec 0x51 0x68 0xc0] - addr: 00009810 size: 04 bit: 0 FVECURRENT
2024-07-18 02:02:29.910020 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a24e [0x33 0x33 0x1d 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 02:02:29.910083 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efde [0xec 0x51 0x3c 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE

Ještě další příklad, kde se posílalo všech 12 definovaných proměnných a bylo jedno, jestli byly definovány s maskováním části za poslední tečkou, která se liší, nebo jsem je po jedné rozepsal do conf.yaml.

  - var: "FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE"
    state-topic: "plc-fve/bms-b/mincellvoltage"
    cmd-topic: "plc-fve/bms-b/mincellvoltage/set"

  - var: "FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE"
    state-topic: "plc-fve/bms-b/maxcellvoltage"
    cmd-topic: "plc-fve/bms-b/maxcellvoltage/set"

  - var: "FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR"
    state-topic: "plc-fve/bms-b/minvoltagecellnr"
    cmd-topic: "plc-fve/bms-b/minvoltagecellnr/set"

   ..... nebo .....

  #- var: "FVEJKBMSDATA.MQTTDATA.(.*)"
  #  state-topic: "plc-fve/bms-b/{1}"
  #  cmd-topic: "plc-fve/bms-b/{1}/set"
  #  log-level: debug
2024-07-18 01:59:24.817179 PLCComS->DoReqCommObject():: 10.0.0.106 6 2 [RX: 6612 / TX: 0] imsg = SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXCELLVOLTAGE,3.246
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MAXVOLTAGECELLNR,8
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.MINVOLTAGECELLNR,13
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.AVERAGECELLVOLTAGE,3.240
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.09
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEVOLTAGE,-471.13
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.CHARGINGPOWER,0.00
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.13
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAINING,23
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
SET:FVEJKBMSDATA.MQTTDATA.CAPACITYREMAININGDERIVED,70.1
2024-07-18 01:59:25.245968 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a323 [0xbc 0x74 0x93 0x3c] - addr: 00010019 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE
2024-07-18 01:59:25.246132 PLCComS->DiffCommObject():: ptr_old: 0x7fac00f0b3 [0x96 0x43 0x8b 0x3c] - addr: 00010019 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE
2024-07-18 01:59:25.246237 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a33b [0xa4 0x90 0xeb 0x43] - addr: 00010043 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER
2024-07-18 01:59:25.246299 PLCComS->DiffCommObject():: ptr_old: 0x7fac00f0cb [0x00 0x20 0xe6 0x43] - addr: 00010043 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER
2024-07-18 01:59:25.246382 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a319 [0x8d 0x97 0x4e 0x40] - addr: 00010009 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE
2024-07-18 01:59:25.246441 PLCComS->DiffCommObject():: ptr_old: 0x7fac00f0a9 [0xf0 0xa7 0x4e 0x40] - addr: 00010009 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE
2024-07-18 01:59:25.246516 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a32f [0xa4 0x70 0x11 0xc1] - addr: 00010031 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.TOTALCURRENT
2024-07-18 01:59:25.246575 PLCComS->DiffCommObject():: ptr_old: 0x7fac00f0bf [0x7b 0x14 0x0e 0xc1] - addr: 00010031 size: 04 bit: 0 FVEJKBMSDATA.MQTTDATA.TOTALCURRENT
2024-07-18 01:59:25.246653 PLCComS->DiffCommObject():: ptr_new: 0x7fac00a24e [0xa4 0x90 0xeb 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 01:59:25.246773 PLCComS->DiffCommObject():: ptr_old: 0x7fac00efde [0x00 0x20 0xe6 0xc3] - addr: 00009806 size: 04 bit: 0 FVEVOLTAGE
2024-07-18 01:59:25.247171 PLCComS->SendNetComm():: 10.0.0.106 6 10 [RX: 0 / TX: 242] omsg = DIFF:FVEJKBMSDATA.MQTTDATA.DELTACELLVOLTAGE,0.018000
DIFF:FVEJKBMSDATA.MQTTDATA.DISCHARGINGPOWER,471.130005
DIFF:FVEJKBMSDATA.MQTTDATA.MINCELLVOLTAGE,3.228000
DIFF:FVEJKBMSDATA.MQTTDATA.TOTALCURRENT,-9.090000
DIFF:FVEVOLTAGE,-471.130005
AcMetelka commented 4 months ago

OK něco jsem pošolichal, odstranil negativní důsledek, ale nehledal až tak příčinu, na to nemám znalost a čas zjišťovat. S pomocí AI 😄 jsem vygeneroval proměnnou myLastVarMapping , na základě které se eviduje poslední na PLCComS odesílaná hodnota a v případě opakování té samé se odeslání vynechá. Tak nějak to funguje. 😄

    private Collection<PlccomsVar> onList(Collection<PlccomsVar> listedVars) {
        int blacklistedCount = 0;
        Map<String, Integer> blacklistedCountByPattern = new HashMap<>();
        List<String> unmappedVars = new ArrayList<>();
    AtomicReference<String> myLastVarMapping = new AtomicReference<>("");

.....

        try {
            mqttClient.subscribe(varMappingsByTopic.keySet(), (topic, message) -> {
                VarMapping varMapping = varMappingsByTopic.get(topic);
                String inputValue = new String(message.getPayload());

        if (!varMapping.destination.equals(myLastVarMapping.get())) {
                    String convertedValue = varMapping.config.cmdFunction.apply(inputValue);
                    LOGGER.log(varMapping.config.logLevel, "MQTT->PLC: {},{} -> {},{}",
                            topic, inputValue, varMapping.destination, convertedValue);
                    plccomsClient.setVar(varMapping.destination, convertedValue);
        }
        myLastVarMapping.set(varMapping.destination);
            });
        } catch (MqttException e) {
            LOGGER.error("Failed to subscribe to topic(s)", e);
        }
ocervinka commented 3 months ago

Ahoj,

To je divne. Jsi si jisty, ze neni pricina uz MQTT zdroj? Pripojil bych testovaciho MQTT clienta a zkontroloval to.

18 prida logovani vsech mapovanych MQTT topiku na PLC promenne. Tim se vylouci chyba mapovani.

Pri startu, kdy se mapovani generuje, by to melo logovat napr:

Mapping from command topics: plc-fve/bms-b/totalcurrent/set->FVECURRENT, plc-fve/bms-b/totalpower/set->FVEVOLTAGE

ale netestoval jsem to.

Jinak, ja prevod z MQTT na PLC se pouzival a zadny problem jsem neregistroval. Zapsani stejne hodnoty nekolikrat je ale mozne prehlednout, protoze realny vysledek je vetsinou stejny.