Forum Home › Forums › Communicating with Devices › How to use a c# script to process input XML/MQTT message
Tagged: input processing, mqtt, sctript
- This topic has 19 replies, 3 voices, and was last updated 1 year, 9 months ago by
Mikhail.
-
AuthorPosts
-
September 1, 2023 at 10:31 am #13278
reha
ParticipantHi,
Im trying to understand.. how to introduce/install a custom (mine) c# to Rapid Scada server? how can I call that script? purpose is the process xml formatted MQTT message to extract certain data field. Will be so happy, if you can share a link/sample or guide/tutorial. many thanks in advance, rehaSeptember 5, 2023 at 9:11 am #13295Mikhail
ModeratorHi,
1. Add your scripts into the Scripts (v6) or Formulas (v5) table.
2. Write a DLL in C# using the examples from GitHub.
3. The MQTT driver support JavaScript.Please specify your question.
September 12, 2023 at 10:20 pm #13348reha
ParticipantHi Michael,
thank you so much for the guidance.. The thing that I wish to achieve..
Environment: I use MQTT to collect the sensor data. currently 2 sensors.. Temp & Hum
Issue: the received MQTT message is in JSON formatted and contains 2 values (temperature & humidity)
Target: process the MQTT message to extract values and assign to sensorsI thought, I can use scripts to process that MQTT message and pass to individual sensors.. But I really dont know “where & how to” start..
by the way, is there any documentation that I can have a look to understand scripts and the way it works. many thanks in advance, reha
September 13, 2023 at 8:43 am #13353Mikhail
ModeratorSeptember 13, 2023 at 8:45 am #13354Mikhail
ModeratorYou need to create a communication line in Communicator. Then choose MQTT Client as communication channel type. Then create a device under the line, open its properties and specify subscriptions.
September 13, 2023 at 8:46 am #13355Mikhail
Moderatoris there any documentation that I can have a look to understand scripts and the way it works
Currently, only the forum. The docs should be created, of course.
September 13, 2023 at 9:53 am #13359reha
ParticipantHi Michael
thank you so much for the detailed explain. As now, my app working properly via MQTT, when MQTT message contains only 1 data value (nothing else) . Now it is the phase to include complex MQTT messages as you mentioned above. To respond your request, current confighere is my working application: http://78.189.224.253:10008/ (default credentials)
comm line definitions
line definitions
device settings
mQTT topic (just single, simple value as now)September 13, 2023 at 10:15 am #13360reha
ParticipantNow, I will try to receive more complicated MQTT message in XML format and extract these value , then pass each value as single/simple value to channel.. many thanks for the guidance and helps.
September 14, 2023 at 10:49 am #13370Mikhail
ModeratorHi,
If you need to use JS to extract values from JSON, set JavaScript enabled = Yes (in device properties). Create a js file, put it in the Communicator configuration. Specify the file name in the JavaScript file name property.September 14, 2023 at 10:50 am #13371Mikhail
ModeratorAlso you need to specify subitems.
September 14, 2023 at 10:51 am #13372Mikhail
ModeratorNovember 3, 2023 at 8:13 am #13583joii
ParticipantHello,Mikhail
Can I take a look at how to manipulate and assign attributes in JavaScript,
And how to display the collected real-time data of JSON on the viewNovember 3, 2023 at 10:45 am #13585Mikhail
ModeratorHello,
Please check this post.
Values extracted from JSON are tags of Communicator. They bound to channels and displayed in a common way.November 3, 2023 at 10:47 am #13586Mikhail
ModeratorI suggest, first, to configure MQTT driver for reading simple numeric values. When it’s done, try using JSON. If you provide screenshots of the configuration and result, I can help more detailed.
November 3, 2023 at 11:01 am #13589Mikhail
ModeratorScreenshots may be useful
https://ibb.co/9Wqwy4g
https://ibb.co/qBP3pXP
https://ibb.co/VMMTv2m -
AuthorPosts
- You must be logged in to reply to this topic.