MegunoLink gets values and commands to update controls on an interface panel visualizer from specially formatted commands in serial streams. Each command must be surrounded by braces (‘{‘ and ‘}‘). Commands are decoded and dispatched by the MLP UI Message Processor component. It ignores any text that is not within braces. The MegunoLink Arduino library provides a simpler method for sending data and commands to interface panel controls.

The general format of table messages is: {UI:channel-name|command|command data}

  • The channel-name argument is optional. If present, it selects the message-channel. Channels are useful if you want several interface panels in one project, each handling a different set of commands.
  • The command argument is required. It should be one of SET, GET or CMD.
  • The value of the command data argument depends on the command.

The channel-name is a property of the MLP UI Message Processor component. To filter messages by message-channel, you need to add a MLPUIMessageProcessor in the interface panel designer and set its channel-name property.

Examples

The following are examples of messages that will be processed by the MLP UI Message Processor when sent from an Arduino or other serial source.

  • {UI|SET|TextBox.Text=So long and thanks for all the fish}: set the content of a text-box control named TextBox to So long and thanks for all the fish.
  • {UI|SET|Number.Value=42}: set the current value of a numeric up/down control named Number to 42
  • {UI|SET|CheckBox.Checked=True}: check the check-box control named CheckBox
  • {UI|GET|Number.Value}: get the current value of a control named Number
  • {UI|CMD|SendTime}: run the command named SendTime

Set Command

The SET command is used to update control properties on an Interface Panel. The general format of the command is: {UI:ChannelName|SET|ControlName.Property=NewValue} or {UI:ChannelName|SET|ControlName.Property=[Expression]}. Here NewValue or Expression is the value to assign to the control property. Expression may contain simple expressions, including referencing other controls on the Interface Panel. The ControlName is set in the Interface Panel designer (the Name property). The ChannelName is optional; it sets the message channel that the processor should handle.

The table below illustrates the properties exposed by controls supported by the Interface Panel. Not all controls have properties that can be changed using the SET command.

The control and component properties available are listed in the table below. The first table shows common properties and the second shows specific properties. Read only properties can not be changed using serial messages.

Common Interface Panel control properties.
Control Property Type Read Only Description
Common to all ForeColor String n Controls the foreground colour of the control
BackColor String n Controls the background color of the control
Visible Boolean n When set to “True” the control is visible to the user
Enabled Boolean n When set to “True” the control is enabled
Interface Panel – Specific Control Properties
Control Property Type Read Only Description
Dynamic Label Text String n The text displayed in the label.
Text box Text String n The text displayed in the control
ReadOnly Boolean n If “True” then the text box can not be edited by user
TextLength Integer y The length of text displayed in the control
Name String y The name of the control
Numeric up/down Value Decimal n The current value displayed in the control
Minimum Decimal n The minimum value allowed
Maximum Decimal n The maximum value
Name String y The name of the control
Value list SelectedIndex Integer n The index of the selected item in the list. First item is index 0. -1 if no items selected.
SelectedName String n The name associated with the selected item. Only supported for single selection lists.
Value Unsigned Integer n The value associated with the selected item. When multiple items are selected, returns the values of each selected item or’ed together.
Name String y The name of the control
Checkbox Checked Boolean n The current check state of the control
Name String y The name of the control
Radiobutton Checked Boolean n The current check state
Name String y The name of the control
Trackbar with Indicator Value Integer n The current value shown in the control
DelaySendingChanges Boolean y If “True” serial message is only sent after mouse is released.
Minimum Integer n The minimum value
Maximum Integer n The maximum value
Name String y The name of the control
Progress bar Value Integer n The current value shown by the control
Minimum Integer n The minimum value
Maximum Integer n The maximum value
Name String y The name of the control
PictureBox Visible Boolean n When “false”, the control is hidden. If true the picture box is visible.

Some Examples

Here are some examples. Note colours can be specified in text, and RGB hex values.

{UI|SET|txt.ForeColor=8855FF}
{UI|SET|txt.BackColor=Blue}
{UI|SET|txt.ForeColor=Red}
{UI|SET|txt.Enabled=False}
{UI|SET|txt.Enabled=True}
{UI|SET|txt.Visible=False}
{UI|SET|txt.Visible=True}

Get Command

Control properties can be retrieved from an Interface Panel using the GET command. The general format of the command is: {UI:ChannelName|GET|ControlName.Property|Format}. Here ControlName and PropertyName are the name of the control and property required. Format is an optional parameter that can be used to control the format of the result returned. ChannelName selects the (optional) message channel.

Property Formatting

The Format parameter in the GET command is passed to the C# ToString function. It may be used to control the formatting of the text returned. For example, the decimal value in a numeric up/down control can be returned with 3 decimal places using: {UI|GET|Number.Value|0.000}

Response Format

MegunoLink responds to a GET command with the information requested using either the bang protocol or the brace protocol. The protocol used is set using the ResponseFormat property of the MLP UI Message Processor.

Brace Protocol

The general format of the MegunoLink brace protocol response is: {UI:ChannelName|set|ControlName.Property=CurrentValue} The channel name is only included in the message return if it is set on the MLPUIMessageProcessor component.

Bang Protocol

The general format of the bang protocol response is: !ControlName.Property Value\r\n.

Cmd Commands

A command in a message library attached to the MLPUIMessageProcessor can be invoked using CMD command. The general format of the command is: {UI:ChannelName|CMD|MessageName} Here MessageName is the name of the message in the message library to be invoked. This provides a simple way to send commands to your program using your preferred message protocol.

A message library attached to an Arduino message processor

Attaching a message library to a message processor allows messages to be invoked from the Arduino using the CMD command.

For example:

  1. Add a message library named MyMessages to an interface panel
  2. Add a message processor to the interface panel
  3. In the properties for the message processor, select MyMessages for the message library
  4. In the properties for MyMessages edit the Messages collection
    1. Create a new message and name it SendTime
    2. Set the message to: The time is: [DateTime.Now]\n
  5. Send {UI|CMD|SendTime} from the Arduino
  6. MegunoLink Pro will respond with: The time is: 20/02/2014 5:26:18 p.m.

Leave a Comment

Start typing and press Enter to search