• No results found

Learning Remote Control Framework ADD-ON for LabVIEW

N/A
N/A
Protected

Academic year: 2021

Share "Learning Remote Control Framework ADD-ON for LabVIEW"

Copied!
16
0
0

Loading.... (view fulltext now)

Full text

(1)

1

Learning Remote Control

Framework – ADD-ON for

LabVIEW

TOOLS for SMART MINDS

Abstract This document introduces the RCF (Remote Control Framework) ADD-ON for LabVIEW. Purpose of this article and the documents that will follow, is introducing developers to the use of RCF to create their own remote controls to manage LabVIEW based systems. In this document the following points are covered: creating a Remote Control (RC), creating commands, adding parameters to a command, implementing LabVIEW code associated to a command.

Keywords RCF, LabVIEW, remote control, client server, OOP with LabVIEW, design pattern with LabVIEW

(2)

2

Introduction

The purpose of this document is help LabVIEW developers to integrate RCF in their own applications. RCF is a powerful ADD-ON for LabVIEW that creates a system interface of a LabVIEW based system, similar to a remote control, on different platforms such iPhone, Android phones, web browsers. LabVIEW programs play the role of servers while RCF clients act as clients. In the follow I use the term server to refer to the LabVIEW program and the term client to refer to an RCF client.

Requirements

RCF ADD-ON for LabVIEW is based on SCCT primitives. SCCT is a communication library available for different programming languages and platforms. SCCT for LabVIEW rel. 2.5.x is required.

• LabVIEW development system 2010 or higher (32 bit or 64 bit)

• SCCT (Smartphone & Cross-platform Communication Toolkit)

Refer to Resource paragraph at the end of this document to find useful link and download evaluation copies.

Overview

RCF publishes the interface of your system to clients, when they successfully connect to the server. Authentication and all communication details are managed by RCF and SCCT so you don’t have to. The interface you define for your system, is named CATALOG. A Catalog is a collection of Remote Controls devoted to different users or activities. For complex systems you can define multiple remote controls each with multiple commands, while simple systems generally have only one remote control. Every Remote Control is composed by a list of commands which extend the basic Command class, provided by RCF. A command is associated to one or many buttons of your remote control. Every command can includes some parameters that user has to fill before firing the command. Firing a command means sending to server a request with some parameters. Simplest command has no parameters. Reserved commands can be associated to a password so that only authorized users can use them. Commands (i.e. user requests) can return one or more results to user. In this case RCF is responsible to gather information and format them properly before returning them to the user. Clients are in charge to display properly results according to their definition specified at server side. Available result types are:

• Text

• Table

• Chart

• Histogram

• Piechart

• X-Y Chart

Remote Control Framework ADD-ON for LabVIEW

SCCT (Smartphone & Cross-platform Communication Toolkit)

(3)

3

The following UML diagram explains the relation between classes.

Catalog can be changed at runtime. When a catalog is update, RCF notifies to clients the new catalog, with more or less commands. Catalogs can be created programmatically with LabVIEW code or can be loaded from disk.

How RCF interacts with LabVIEW main app

Apart from basic applications without loops, generally a LabVIEW based system has one or main loops devoted to different tasks: acquiring, controlling, processing, etc. RCF interacts with them passing user requests if it cannot manages the request by itself. Command results have to be retrieved by one of the loops in the main application, for instance the acquired signal values. Interaction, i.e. data exchange among RCF and loops can be implemented in your favorite method: queues, notifiers, Global variables, etc.

Adding RCF to a LabVIEW program

The following Example illustrates how RCF is added to an existing LabVIEW program. Notice that when The main loop ends, you need to notify to RCF that its loop has to terminate otherwise LabVIEW program never stops.

Catalog Remote Control

Has (many)

Command

Is a

My first

command My second

command My third command

Parameter 1..N

LabVIEW application, with one or more loops devoted to different tasks.

RCF creates a background loop with manages users requests and all communication details.

(4)

4 RCF needs only three elements to work:

• TCP port where it has to listen to incoming connections,

• password to authenticate users

• a catalog to create remote control(s)

The above example includes stopManager.vi that stops RCF background task.

STEP 1 - Creating a simple remote control

In the following, we create a simple remote control composed by 5 commands. Follow the tutorial step by to create your own LabVIEW code or download the example at the following link:

Specifications

We create a Remote Control to manage some simple operation on server disk. Command title Command description

Get Free disk space Returns the FREE disk space in MB

Create Folder Creates a subfolder in folder where LabVIEW program is saved

Get file List Returns a table that describes files or folders available in folder where LabVIEW program is saved

First of all, we choose a title for our Remote Control and a brief description displayed on clients as RC help. Below, is shown the code to add a RC to a catalog. RC title is “Disk management”, RC layout is Remote control. RC can be displayed with different layouts by clients. Most popular layout is “Remote Control” so we use that in this example. The function build array is required because write RemoteControlList.vi

(5)

5

Creating the first command

Since RCF is based on OOP programming, you need to create specific classes for your commands. To add create a Class, choose New form LabVIEW file menu and select Class in the left side of the window:

LabVIEW asks the name of the new class, type CmdGetFreeDiskSpace, as indicated below. Take care to create a subfolder named CmdGetFreeDiskSpace into your project folder. This is necessary because multiple classes implement the same method so many Vis require the same file name.

At this point you have to link your new class with a Command class included into RCF. Right click on class name in project window and select the last menu item “Properties” as indicated below:

(6)

6

Class property window allows to edit many features of your LabVIEW class. To change its inheritance, select Inheritance form left panel and press “Change Inheritance” button in the right side

(7)

7

From left list. Select Command.lvclass and press “Inherit from selected” button.

RCF includes Command class to this purpose, use always this class to create your own commands. Close Class property window with “Ok” button and return to project window.

Right click of your class in project window and select New >> Vi for Override item. This allow to override abstract methods defined in ancestor class.

(8)

8

In New Override window, Select first row “* execute”. LabVIEW places an asterisk at the left of abstract methods that required to be implemented in concrete classes. The only method you have to override i

You can create all methods and properties you need to implement your command. Save created VI into class folder with execute.vi name. Do not override other class methods otherwise RCF won’t be able to run your command properly. RCF uses execute method in response to user requests, so remember to implement always this method.

By default, LabVIEW placed a call to ancestor method. As indicated in the following figure:

You need to substitute that code with your own LabVIEW code. For this method we place the following code, to return the free disk space to user.

(9)

9

The code returns a message with the free disk space, in MB. Every command returns a result object. RCF allows different types of result. You can find result classes and methods in RCF palette. Do not change these classes otherwise RCF clients become unstable and can crash. In this example, a TextResult object is returned to the client.

Creating the second command

Add a new class name CmdCreateFolder to your project, change its inheritance and override execute method, as done for the first command. The project window will result as follow:

This command creates a new folder with name indicated by user. This command contains a single parameter we call Folder. Parametric commands display a form created at runtime on client interface and users fill the form BEFORE send the request to RCF.

In this execute method, we use Read filedValues.vi to retrieve the field values typed by user. We know that this command has only one parameter so we take the first element of fieldValues array. Fields are always

(10)

10

returned as string values, regardless of their type. The suggested code checks is folder exists, then creates it. This command returns a TextResult object as we did for the first command.

Note: How can we create command that do not return results? If your command doesn’t need to return result, simply do not connect result indicator.

Creating the third command

Add a new class name CmdGetFileList to your project, change its inheritance and override execute method, as done for the previous commands. The project window will result as follow:

This command requires two parameters:

Folder name that indicates the subfolder to be analyzed. If this name is not specified, command uses default folder

List type A listbox with three values:

• Files only

• Folders only

• Files and Folders

(11)

11 The code of execute method is illustrated in figure below:

This execute.vi uses two subVIs to list file and folder attributes. These Vis are part of command class and saved in class folder. This command returns a table result to user. Table is fully described by a four elements cluster. Read fieldValues returns two values: the first is the folder name while the second one is the list type.

(12)

12

Composing the remote control

With the three commands created above, we compose a remote control. Use three times quickCreate.vi, to create three commands with all their parameters. Notice that:

• Commands in RC are displayed in the same order you add them in your array of command objects.

• Every command requires a title, displayed on command buttons of client interface

• Every command requires a TAG: a unique string used by RCF to identify user requests. A TAG can be any nonempty string.

(13)

13

Since commands CreateFolder and GetFileList require user input, we add fields to those commands as indicated in figure below:

Before starting the server, we add some useful details: welcome message and help URL.

Adding a welcome message

It’s important to welcome users when they successfully connect to the system. Connect a string message to welcomeMessage connector of RCF manager, as indicated in the following figure:

(14)

14

Adding a help URL

When users connect to a complex system, like automatic machine or similar, it’s important providing a detailed help of that system enriched with images and technical details: RCF allows associating a URL to every catalog. Clients display a specific “info” button linked to help URL.

To do so, connect helpURL with the proper page address, as indicated in figure below:

Some clients require prefix http:// to properly open the web page: always add http:// to help URL. When designing Execute.vi pay attention to the following points:

• Execute.vi has to be executed in short time,

• Inside an execute.vi, never requests user interaction at server side (such messagebox, alerts, etc.)

• never include never-ending loops.

Remember that multiple users can be connected at the same time and request the same command.

Debugging your application

One of the main advantages of RCF over web services, is the easiness of debugging your LabVIEW code. When you run a RCF client and request the execution of analyzed VI, you can take full advantage of LabVIEW debugging tools such probes and breakpoints.

(15)

15

Testing your RCF

Now it’s time to run your first RCF. Take note of IP address of your PC and connect your smartphone to that PC. Clients for Android and iPhone/iPad allow to save connection info on their local disk so you don’t need to type credentials every time. The following screenshots have been taken form RCF client for iOs.

(16)

16

Resources

RCF clients are available for the following platforms:

• RCF ADD-ON for LabVIEW is available for evaluation at

http://www.toolsforsmartminds.com/products/remote_control_for_labview.php

• For Android devices, visit Google Play at

https://play.google.com/store/apps/details?id=SCCT.Console

• For iPhone/iPad devices, visit Apple store at

https://itunes.apple.com/en/app/remote-control-for-labview/id595313230?mt=8&ign-mpt=uo%3D4

• For HTML5 compliant browsers, at http://www.toolsforsmartminds.com/remote_control_html5/

• For Windows based systems, a FREE RCF client is available at

http://www.toolsforsmartminds.com/products/remote_control_for_labview.php

This client has some limitation to the number of commands and parameters you can add to a remote control. This client has been created to help developers to test their LabVIEW based systems and learn how to create simple remote controls.

• SCCT is available at

http://www.toolsforsmartminds.com/products/labview_communication_library.php

• LabVIEW and related National Instruments products (such device drivers and other ADD-ONs) are available at www.ni.com

References

Related documents

The PROMs questionnaire used in the national programme, contains several elements; the EQ-5D measure, which forms the basis for all individual procedure

Utah's state-sponsored higher education took a large step forward last month when the Utah State Board of Higher Education adopted, as a working document, the

For this reason E-MAP datasets are typically analyzed using tools developed for gene expression data (e.g. the Cluster tool [11]) to group together genes with similar

If there is a dead heat for first place in one or more of the legs, the calculation of the number of dividend shares accruing to a winning customer who has forecast more than one

Tujuan penelitian adalah untuk mengetahui dan menganalisis pengaruh Current ratio, Debt to equity ratio, dan Working capital turnover terhadap Return on equity pada perusahaan

Que el propi test passi amb èxit és la validació de que les expressions regulars són correctes, que la codificació d’aquestes està ben escrita i que els

The annual review will include an update of your Enrichment Plan™ with a review of your goals, objectives and accomplishments, an update of your retirement projection, an update

Workers in the field of oral health were not taught about noma, the oral manifestations of HIV, and other severe oral diseases but rather were taught about treating dental caries