Setting up a Communication Stream

Communications in qdex use common communication protocols and  associated parameters, often TCP/IP. In this way, all that is required to send and receive data is the IP address of the computer or device. Communications in qdex require two key blocks:

1) A client block to specify the communication protocol and reference address of the stream.

2) A simulation block to send and receive data over that stream. Inside the simulation, the signal and probe blocks are used to send/receive different types of data.

Client Block

The client block is used to define the communication stream. It requires a name and a reference address to work. The URI must specify the protocol, the address, and the port number. You can also write scripts that are triggered when one of the following events occur: 

  1. onConnected - occurs when connection to stream is made..
  2. onDisconnected - occurs when disconnection from stream is made.
  3. onReceive - occurs when data is received from stream.

Note that the client block maintains a persistent connection, which means that it automatically reconnects whenever the connection is lost. To stop this persistent connection the simulation that is referencing the client block must be stopped.


This example uses a client block, that when connected and disconnected, updates the text of a button and notifies you when data is received.

<client name="myClient" uri="tcpip://">
  <!--Updating button text.-->
    myButton.Text = "Disconnect"
  <!--Updating button text.-->
    myButton.Text = "Connect"
  <!--Notifying user when data is recieved.-->
    notify(" Data Received")

Simulation Block

The simulation is used to send and receive data over a stream. A connection with the client will not be established until the simulation has been started and connection will be maitained until simulation stops.

<simulation name="mySim" period="0.01">
      <!--Recieving data, outputting to plot-->
      <signal ref ="mySection.myClient"/>
      <probe ref="mySection.myPlot" />
  <!--Sending value from qdex slider-->
     <signal ref ="mySection.mySlider"/>
     <probe ref ="mySection.myClient"/>