The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Similar documents
CSIS 1624 CLASS TEST 6

CALCULATOR APPLICATION

IBSDK Quick Start Tutorial for C# 2010

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

You can call the project anything you like I will be calling this one project slide show.

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

Object oriented lab /second year / review/lecturer: yasmin maki

Quick Guide for the ServoWorks.NET API 2010/7/13

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

Form Properties Window

Chapter 13 Working with Threads

EL-USB-RT API Guide V1.0

Create your own Meme Maker in C#

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

Click on the empty form and apply the following options to the properties Windows.

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Hands-On Lab. Instrumentation and Performance -.NET. Lab version: Last updated: December 3, 2010

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Start Visual Studio, create a new project called Helicopter Game and press OK

Hands-On Lab (MBL04) Lab Manual Incorporating COM Objects into Your.NET Compact Framework 2.0 Application

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

// Precondition: None // Postcondition: The address' name has been set to the // specified value set;

Multiple processes can run in parallel on a single computer and multiple threads can run in parallel in a single process.

FDSc in ICT. Building a Program in C#

Visual Basic/C# Programming (330)

Conventions in this tutorial

Writing Your First Autodesk Revit Model Review Plug-In

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

Representing Recursive Relationships Using REP++ TreeView

Event-based Asynchronous Pattern Overview 1 Implementing the Event-based Asynchronous Pattern 5 Deciding When to Implement the Event-based

UNIT-3. Prepared by R.VINODINI 1

Creating SDK plugins

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

Chapter 12. Tool Strips, Status Strips, and Splitters

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Huw Talliss Data Structures and Variables. Variables

// Program 2 - Extra Credit // CIS // Spring // Due: 3/11/2015. // By: Andrew L. Wright. //Edited by : Ben Spalding

Visual Basic/C# Programming (330)

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

Santiago Canyon College Computer Science

In-Class Worksheet #4

NI USB-TC01 Thermocouple Measurement Device

C# winforms gridview

II. Programming Technologies

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Developing for Mobile Devices Lab (Part 1 of 2)

Tutorial 5 Completing the Inventory Application Introducing Programming

BackgroundWorker Component Overview 1 Multithreading with the BackgroundWorker Component 3 Walkthrough Running an Operation in the Background 10 How

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern

Visual Studio.NET.NET Framework. Web Services Web Forms Windows Forms. Data and XML classes. Framework Base Classes. Common Language Runtime

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

LIGHT_P_TOGGLE, LIGHT_N_TOGGLE, BATTERY_TOGGLE, ALTERNATOR_TOGGLE, AVIONICS_TOGGLE, FLOAT_RETRACT, FLOAT_EXTEND }

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

Answer on Question# Programming, C#

namespace csharp_gen277x214 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

Using Template Bookmarks for Automating Microsoft Word Reports

private void closetoolstripmenuitem_click(object sender, EventArgs e) { this.close(); }

2.3 Add GDS Google Map to Visual Studio Toolbox and create a simple map project

Visual Studio Windows Form Application #1 Basic Form Properties

Skinning Manual v1.0. Skinning Example

Savoy ActiveX Control User Guide

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

This is the start of the server code

private string sconnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString

namespace Gen837X222A1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Activating AspxCodeGen 4.0

Chapter 6 Dialogs. Creating a Dialog Style Form

Brian Kiser November Vigilant C# 2.5. Commonwealth of Kentucky Frankfort, Kentucky

emkt Browserless Coding For C#.Net and Excel

private string sconnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString

Classes in C# namespace classtest { public class myclass { public myclass() { } } }

namespace csharp_gen837x223a2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

XNA 4.0 RPG Tutorials. Part 24. Level Editor Continued

Визуал програмчлал. Багш: Ж. Шинэбаяр /Маг/

Model JI-4040 USB Multifunction Digital I/O Module - Isolated. Programmer s Interface Document

C# Threading. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

เว บแอพล เคช น. private void Back_Click(object sender, EventArgs e) { this.webbrowser2.goback(); }

Tutorial :.Net Micro Framework et.net Gadgeteer

TARGETPROCESS PLUGIN DEVELOPMENT GUIDE

Concurrent Programming

Version 1.6. MiY Product Line GateApp Development Guide

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

XNA 4.0 RPG Tutorials. Part 11b. Game Editors

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list

INCA V7.2 INCA Instrument Integration Development Kit V1.2 Tutorial

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

CHAPTER 3. Writing Windows C# Programs. Objects in C#

Using the TekScope IVI-COM Driver from C#.NET

Transcription:

This document describes how to create a simple Windows Forms Application using some Open Core Interface functions in C# with Microsoft Visual Studio Express 2013. 1 Preconditions The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at: www.boschrexroth.com/oce The COM-DLL of the Open Core Interface SDK must be registered at the Windows Registry. Therefore you need to have administration privileges. Open the installation directory of the MLPI-SDK in your File-Explorer and move into the folder 01VRS / mlpi4com / bin. Execute the batch-file register.bat as administrator. A message window will report the successful registration. Page 1 of 20

2 Creating a Visual Studio Project Open Visual Studio and create a new Visual C# Project and choose Windows Forms Application. Page 2 of 20

Visual Studio will create a new Visual Studio solution with a default form. Now you have to add a reference to the Open Core Interface DLL. Therefore open the Reference Manager by choosing PROJECT / Add Reference The Open Core Interface Library will appear under its name Rexroth MotionLogicProgrammingInterface 1.0 Type Library. Mark this library. Page 3 of 20

After pressing OK you will find the library commlpilib in your project references. Hint: The abbreviation MLPI means Motion Logic Programming Interface and is the name of the implementation of an Open Core Interface at a MLC / XLC control unit. Page 4 of 20

3 Adding some UI Controls Add three Textboxes and Labels for: IP-Address, User-Name and Password and two Buttons for Connect and Disconnect. Add a Textbox and a Label for displaying the MLC Status message. Page 5 of 20

4 Adding C# Code for the UI Controls Open the source code of the default form ( Form1.cs ). Add the namespace commlpilib by adding the following line of code: using commlpilib; Declare a MLPI-Connection-Variable called mymlc: public MlpiConnection mymlc; Create a new MLPI-Connection by using its constructor: mymlc = new MlpiConnection( ); Page 6 of 20

Now we have to add some callback functions for the Connect and Disconnect buttons. Therefore double-click on the Button Connect and Visual Studio will automatically add a callback-function which looks like this: private void buttonname_click(object sender, EventArgs e) A text string will be used to handle IP-Adress, User-Name and Password for the connect-method of the MLPI-Connection-Object. Therefore we read the values from the UI controls ( Textboxes ). Page 7 of 20

Now we have to call the MLPI-method Connect by using a try-catch exception handler: Page 8 of 20

Page 9 of 20

The status message of the MLC Control is being read by calling the MLPImethod MLPIConnection.System.GetDisplayedDiagnosis( ). Write the returned text string into the UI text box. Page 10 of 20

Used C# Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; // Add Open Core Interface Library using commlpilib; namespace VS2013_WindowsFormsApplication_Demo public partial class Form1 : Form // declare a public MLPI connection variable public MlpiConnection mymlc; public Form1() InitializeComponent(); // create new MLPI connection instance mymlc = new MlpiConnection(); private void buttonconnect_click(object sender, EventArgs e) string strconnectionarguments, stripaddress, strusername, strpassword; stripaddress = textboxip.text; strusername = textboxuser.text; strpassword = textboxpassword.text; strconnectionarguments = stripaddress + " user=" + strusername + " password=" + strpassword; try mymlc.connect(strconnectionarguments); catch(systemexception ex) System.Console.WriteLine("Exception: " + ex.message); if (mymlc.isconnected == true) textboxstatusdisplay.text = mymlc.system.getdisplayeddiagnosis().text; else textboxstatusdisplay.text = "Connection couldn t be established"; Page 11 of 20

5 Access to symbol variables Add UI controls for selecting, reading and writing a symbol variable. We will use a ComboBox to show all available symbol variables. 5.1 Filling the ComboBox To read the list of all accessible symbol variables we use the MLPI Method MlpiConnection.Logic.Applications[ ].GetSymbolOfApplications( ). This method returns an array of strings which contains all symbolic variable names. This list will be copied to a ComboBox. Page 12 of 20

5.2 Reading variable values Add a callback method of the button. Values of symbol variables can be read by using the method MlpiConnection.Logic.ReadVariableBySymbolAsString( ). 5.3 Writing variable values Add a callback method of the button. Values of symbol variables can be written by using the method MlpiConnection.Logic.WriteVariableBySymbolAsString( ). Page 13 of 20

5.4 Testing the application To test this symbol variables access a Logic Application must run on the MLC / XLC control and the data access has to be enabled in the IndraWorks symbol configuration. In case of questions please have a look at the IndraWorks Online help and look for symbol configuration. After a successful connection the combo box will show all available symbol variables: The chosen variable will be read or written by pressing the related button. Page 14 of 20

Page 15 of 20

Example C# Code: // **************************************************************************** // C# DEMO Program for Open Core Interface of MLC / XLC // // This example shows how to connect to a MLC / XLC system by using the // Open Core Interface. Implemented functions are: // Connect and disconnect to MLC/XLC, read diagnosis text from MLC, // read list of available symbol variables, read and write symbol variables, // read/write access to MLC or Motion Axis Parameters (e. g. A 0 0100), // read/write access to axis interface in motion lib. // It does not show how to implemented cyclical parameter reading with an // asynchronous background thread. // **************************************************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; // Add Open Core Interface Library namespace using commlpilib; namespace VS2013_WindowsFormsApplication_Demo public partial class MainForm : Form const string strversion = "v0.1"; // Declare a public MLPI connection variable public MlpiConnection mymlc; public MainForm() InitializeComponent(); // Show app version labelversion.text = strversion; // Create new MLPI connection instance mymlc = new MlpiConnection(); private void buttonconnect_click(object sender, EventArgs e) string strconnectionarguments, stripaddress, strusername, strpassword; stripaddress = textboxip.text; strusername = textboxuser.text; strpassword = textboxpassword.text; strconnectionarguments = stripaddress + " user=" + strusername + " password=" + strpassword; // Clear the symbol variable combo box comboboxsymbolvar.items.clear(); try // Try to connect to MLC / XLC mymlc.connect(strconnectionarguments); catch(systemexception ex) System.Console.WriteLine("Exception: " + ex.message); Page 16 of 20

if (mymlc.isconnected == true) // Read MLC / XLC display diagnosis message textboxstatusdisplay.text = mymlc.system.getdisplayeddiagnosis().text; else textboxstatusdisplay.text = "Connection couldn t be established"; // Read name of MLCs PLC Application (Logic) string strnameofapplication = mymlc.logic.getnameofapplication(0); // Read complete list of symbol variable names string[] symbollist = (string[])mymlc.logic.applications[strnameofapplication].getsymbolsofapplication(); // Check if the list isn t empty if (symbollist!= null) foreach (string symbol in symbollist) // Write each symbol variable name into the ComboBox comboboxsymbolvar.items.add(symbol); private void buttonread_click(object sender, EventArgs e) // Read symbol variable value and put it into UI control if (comboboxsymbolvar.text!= "") textboxactualvalue.text = mymlc.logic.readvariablebysymbolasstring(comboboxsymbolvar.text); // Example how to read an axis parameter value directly // textboxactualvalue.text = mymlc.parameter.readdataasstring("a015:a 0 0100"); // Example how to read data from MLCs axis interface // textboxactualvalue.text = ( mymlc.motion.axes[15].getactualposition() ).ToString(); private void buttonwrite_click(object sender, EventArgs e) if (comboboxsymbolvar.text!= "") // Write symbol variable value mymlc.logic.writevariablebysymbolasstring(comboboxsymbolvar.text, textboxnewvalue.text); // Read the written value back into UI control textboxactualvalue.text = mymlc.logic.readvariablebysymbolasstring(comboboxsymbolvar.text); // Example how to write a value directly to an axis parameter (position limit) // mymlc.parameter.writedata(textboxnewvalue.text, "A015:A 0 0030"); // Example how to write directly to an axis interface element // double newvalue = Convert.ToDouble( textboxnewvalue.text ); // mymlc.motion.axes[15].setpositionlimitpos( newvalue ); private void buttondisconnect_click(object sender, EventArgs e) if (mymlc.isconnected == true) Page 17 of 20

mymlc.disconnect(); // Disconnect MLPI Connection textboxstatusdisplay.text = "No Connection!"; Page 18 of 20

6 Using of asynchronous background threads for cyclic polling of values To read a variable value cyclically it is necessary to use a background thread to avoid blocking the main application. An example could look like the following code: 6.1 Creating a background thread using System.Threading; // Create BackgroundWorker Thread, assign and start methods BackgroundWorker bgworkerpollstatus = new BackgroundWorker(); bgworkerpollstatus.dowork += new DoWorkEventHandler(bgWorkerPollStatus_DoWork); bgworkerpollstatus.runworkercompleted += new RunWorkerCompletedEventHandler(bgWorker_WorkCompleted); bgworkerpollstatus.progresschanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged); // Activate ProgressChanged Event Handler bgworkerpollstatus.workerreportsprogress = true; // Start polling... bgworkerpollstatus.dowork will be cyclically called bgworkerpollstatus.runworkerasync(); brunning = true; 6.2 Handler for cyclic DoWork-Event // ******************************************************************** // Asynchronous BackgroundWorker Thread for polling of status info **** // ******************************************************************** public void bgworkerpollstatus_dowork(object sender, DoWorkEventArgs e) int idummy; do if (mymlc.isconnected == true) try // Read diagnosis and variables, return values back to calling thread strdisplaytext = mymlc.system.getdisplayeddiagnosis().text; strplcvariable1 = mymlc.logic.readvariablebysymbol(strsymbolvar1name).tostring(); catch // Exception Handling ausführen ; (sender as BackgroundWorker).ReportProgress(iDummy); // triggers _ProgressChanged Thread.Sleep(100); // wait 100 milliseconds while (brunning == true); Page 19 of 20

6.3 Handler for ProgressChanged-Event // ******************************************************************** // *** CHANGED Callback for asynchronous Background Thread ************ // ******************************************************************** private void bgworker_progresschanged(object sender, ProgressChangedEventArgs e) // This code will be called each time when method.reportprogress( ) of // bgworkerpollstatus_dowork is called textboxdisplay.text = strdisplaytext; textboxplcvar1.text = strplcvariable1; textboxplcvar2.text = strplcvariable2; // Update Textbox UI Controls 6.4 Handler for WorkCompleted-Event // ******************************************************************** // *** COMPLETED Callback for asynchronous Background Thread ********** // ******************************************************************** private void bgworker_workcompleted(object sender, RunWorkerCompletedEventArgs e) // This code will be called once when bgworkerpollstatus_dowork will be exited textboxdisplay.text = strdisplaytext; // update Textbox UI Control Page 20 of 20