DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT and RabbitMQ support

Solved!
Go to solution

Hi Group,

 

In review of the DIAdem help, found that there was a object for MQTT.   (Message Queue Telemetry Transport Protocol) for my 2018 DIAdem version.

This appear like this will allow DIAdem to communicate with RabbitMQ.    Is this possible, and are their any examples of this.

 

Paul

 

0 Kudos
Message 1 of 3
(2,445 Views)
Solution
Accepted by topic author Pesmith8

Dear Paul,

 

Have you seen this documentation?

 

Object: MQTT
http://zone.ni.com/reference/en-XX/help/370858P-01/diamisc/objects/mqtt_objects_mqtt/

Message 2 of 3
(2,419 Views)

Additional details:

 

This is a note for the user Community about the nice MQTT BiDirectional Messaging system

 

The help in DIAdem could use some improvement.  Below is a script that will work with a Local install of Mosquito Broker.  

In order to help with understanding how the MQTT works, I would suggest strongly that the youtube link be viewed at 

https://www.youtube.com/watch?v=VSwu-ZYiTxg     It gives a good background for the MQTT system.

 

The script below will both post and read topics from the MQTT Mosquito broker.

 

'----------------------------------------------------------------------------

'-- VBS script file

'-- Created on 05/25/2019 20:08:51

'-- Author:

'-- Comment:

'-------------------------------------------------------------------------------

Option Explicit  'Forces the explicit declaration of all the variables in a script.

Dim MQTT

 

Sub SFD_WriteChannel(ChannelNumberP, ParamP, DataP, ErrorP)

  Call MQTT.WriteString(ParamP, DataP)

End Sub

 

Sub SFD_Init(DeviceParam1V, DeviceParam2V, ErrorP)

  Set MQTT  = CreateMQTT(DeviceParam1V)

  MQTT.Connect

End Sub

 

dim sError

dim sTemp : sTemp = ""

call SFD_Init("127.0.0.1", "test01", sError)

 

call MQTT.Subscribe("test01")

'call SFD_WriteChannel("127.0.0.1", "test01", "Message0333", sError)  ' Worked ! to post to topic on Broker

 

dim smsg : smsg = ""

 

MQTT.Subscribe("test01")

dim i

for i = 0 to 1000

  sTemp = ""

  sTemp = MQTT.ReadString("test01")  ' this works but also every time it reads msg the same message appears even if it is old.

  ' would then need to put in a date/time for message. so that know that have already received it, so that can only look for new ones.

  ' also does not have any memory of past msgs Must then monitor the topic to make sure that receive all the messages.  For use for Datavisor packages.

  ' would want to have a fairly fast monitoring system for listening to this topic. 

  ' Maybe would want this to be a python program using paho,where would listen to topic, and then put into a log file as it comes in. Then can parse this as needed.

  ' would

  

  If isEmpty(sTemp) Then

    sTemp = ""

  end if

 

  logfilewrite i & " " &sTemp   

  pause 0.5

 

'call SFD_ReadChannel("127.0.0.1", "test01", smsg, sError) 

 

next

 

Sub SFD_ReadChannel(ChannelNumberP, ParamP, DataP, ErrorP)

  Dim sTemp

  Set MQTT  = CreateMQTT(ChannelNumberP)

  sTemp = MQTT.ReadString(ParamP)

 

  If isEmpty(sTemp) Then

   DataP = NoValue

  Else

    If sTemp <> "" Then

      DataP = CDbl(sTemp)

    Else

      DataP = NoValue

    End If

  End If

End Sub

 

0 Kudos
Message 3 of 3
(2,181 Views)