Forum Replies Created
-
AuthorPosts
-
KevinVt
ParticipantHello Mikhail,
Below 2 messages are got from MQTT Server, these topics are same, and type are different.
——————————————————————————–
Message1:
Topic=【report/allpoints】 msg=【{“saleid”:”10100001″,”gateid”:”10100001001″,”type”:”report”,”time”:”2023-06-01 13:10:00″,”sequence”:”22″,”source”:”da”,”meter”:[{“id”:”1″,”status”:”1″,”name”:”VrtDev1″,”values”:{“Pf”:”0.287000″,”Uab”:”391.900024″,”Ubc”:”392.300018″,”Uca”:”391.799988″,”Ia”:”0.400000″,”Ib”:”0.000000″,”Ic”:”0.400000″,”P”:”0.000000″,”Q”:”-0.160000″,”S”:”0.160000″,”EPI”:”2257.599854″,”EPE”:”10.800000″,”EQL”:”93.199997″,”EPIJ”:”0.000000″,”EPIF”:”0.000000″,”EPIP”:”0.000000″,”EPIG”:”0.000000″,”MDMINUTE”:”0.000000″,”MDHOUR”:”0.000000″,”MDDAY”:”0.000000″,”MDMONTH”:”0.000000″,”MD”:”0.000000″,”UaTHD”:”2.210000″,”UbTHD”:”2.510000″,”UcTHD”:”2.780000″,”IaTHD”:”0.000000″,”IbTHD”:”0.000000″,”IcTHD”:”0.000000″,”VUB”:”0.220000″,”CUB”:”100.000000″,”Pa”:”0.000000″,”Pb”:”0.000000″,”Pc”:”0.040000″,”IL”:”0.000000″,”EQC”:”980.000000″}}]}】 qos level= 【AtMostOnce】
Message2:
Topic=【report/allpoints】 msg=【{“saleid”:”10100001″,”gateid”:”10100001001″,”type”:”heart_beat”,”operation”:”notify”,”time”:”2023-06-01 13:10:07″}】 qos Level=【AtMostOnce】I wrote below js code to filter the message,
—————-js code ————————let data = JSON.parse(payload);
if (data.type == “report”) {
// set values
setValue(0, new Date(data.time).getTime());
setValue(1, data.sequence);setValue(2, data.meter[0].values.Pf);
setValue(3, data.meter[0].values.Uab);
setValue(4, data.meter[0].values.Ubc);
setValue(5, data.meter[0].values.Uca);}
else
{
log(“Ignore HearBeat Data…”);
}
————————————————It can print the log “Ignore HearBeat Data…” when got message with type “heart_beat”, and at same time, all channels value were set to null.
I hope to get the channel value when got message with type of “report” and keep channel value unchange when got meesage with type “heart_beat”.
Hope you can understand what I said.
Thanks a lot.
KevinVt
ParticipantDear Mikhail,
I got the solution of this question, default value of Timeout and Delay in RTU device are 0, it’s OK when set Timeout to 1000 and Delay to 200.
Thanks.
KevinVt
ParticipantGot it, Thanks a lot!
KevinVt
ParticipantHello Mikhail
Thanks a lot for your answers, another question, for some data can not convert to double, such as name, how to get their value ?KevinVt
ParticipantHello Mikhail,
I had setup MQTT Client in v6, and I can get data from MQTT broker, but I confused 2 questions, could you please help to check?
1, all the data I got is double, can I get data in other format? for example, the sequence number is int.
Current Data
| # | Code | Name | Value | Channel |
| 1 | .saleid | MqttReport.saleid | 10,100,001.000 | |
| 2 | .gateid | MqttReport.gateid | 10,100,001,001.000 | |
| 3 | .time | MqttReport.time | — | |
| 4 | .sequence | MqttReport.sequence | 100.000 | |2, when use setValue(1,data.time) in js file for MqttReport.time, had error: “Error : Input string was
not in a correct format.”
I had try different format of timestamp, all got errors. How can I get correct time value?Thanks a lot!
-
AuthorPosts