Use Native Libraries. Introduction

Similar documents
Introduction to the DLL for the USB Interface Board K8061

How to read/write text file

Limnor Studio User s Guide

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

Use Plug-ins. Use Plug-ins 2012

Symphony G2 FDK API Manual for C# FDK API Manual for C# June ITS Company

Deploying Haystack Applications

Type Conversion. and. Statements

Limnor Studio Getting Started

ComponentSpace SAML v2.0 Installation Guide

Chapter 1 Getting Started

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

Limnor Studio User s Guide

Contents Introduction

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

Project Compiler. CS031 TA Help Session November 28, 2011

Project types supported by Limnor Studio

Kansas TRCC. Kansas ecitation Validation Engine Design

Run Time Environment

Software Development Kit. Quick Start Guide

Web Forms ASP.NET. 2/12/2018 EC512 - Prof. Skinner 1

This section provides an overview of developing with the BillQuick Software Development Kit.

Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)

Introduction to Programming Using Java (98-388)

Limnor Studio User s Guide

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science And Engineering

.NET Wrapper SDK Descriptor

EL-USB-RT API Guide V1.0

Programming Tips for Plugins

Activating AspxCodeGen 4.0

Use JavaScript Files

SPARK. Native Device Interface (NDI)

Programming in Visual Basic with Microsoft Visual Studio 2010

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

Call DLL from Limnor Applications

Authoring Installations for Microsoft s.net Framework

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

Develop Your Own Function and Function Block

Cookbook for using SQL Server DTS 2000 with.net

PROGRAMMING WITH THE MICROSOFT.NET FRAMEWORK USING MICROSOFT VISUAL STUDIO 2005 Course No. MS4995A 5 Day PREREQUISITES COURSE OUTLINE

COPYRIGHTED MATERIAL. Part I The C# Ecosystem. ChapTEr 1: The C# Environment. ChapTEr 2: Writing a First Program

Java 1.5 in a Nutshell

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Algorithms & Data Structures

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Table of Contents Preface Bare Necessities... 17

04 Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio. Ben Riga

Getting started 7. Storing values 21. Creating variables 22 Reading input 24 Employing arrays 26 Casting data types 28 Fixing constants 30 Summary 32

Login Manager ASPX Sample

Lab 2.1: Fixing a C++ program

OnBase ver Thick Client Installation Instructions. Install Microsoft SQL Server 2012 Native Client

B.E /B.TECH DEGREE EXAMINATIONS,

Gathering and Modifying Real-Time Software Data in a Visual Studio Environment Mark Rogers November 6, 2008

Advanced Java Concepts Unit 2: Linked Lists.

Adding Contracts to C#

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

Introduction to Microsoft.NET Framework Programming using VS 2005 (C#)

TrueTime PiccSIM integration

Application Architecture Using Generics C#.Net 2.0

Moving to Visual Studio 2005

DAD Lab. 1 Introduc7on to C#

Pointers, Arrays and Parameters

Module Overview. Monday, January 30, :55 AM

Function Overloading

Learning to Program in Visual Basic 2005 Table of Contents

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

SDK Programmers Guide

Introduction To C#.NET

C# Language. CSE 409 Advanced Internet Technology

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413

Argumentative Development Notes

C#: framework overview and in-the-small features

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

MagTek Common Message Structure (MTCMS) Programmer s Reference Manual (Microsoft.NET/Java/Applet)

We assume that the user has basic knowledge of C# and is able to create a new C# project.

Exam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80

Level 3 Computing Year 2 Lecturer: Phil Smith

Windows 8. Rainer Stropek. System Architecture. System Architecture re of Windows Store Apps. Saves the day. software architects gmbh

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

What s New RobotStudio

Ocean Wizards and Developers Tools in Visual Studio

Chapter 3 Function Overloading

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

Page 1. Agenda. Programming Languages. C Compilation Process

Java classes cannot extend multiple superclasses (unlike Python) but classes can implement multiple interfaces.

Module 2: Introduction to a Managed Execution Environment

Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, Vol. 2. pp Virtuoso Virtuality

Computers, Variables and Types. Engineering 1D04, Teaching Session 2

4. C++ functions. 1. Library Function 2. User-defined Function

CS2141 Software Development using C/C++ C++ Basics

Using Mini-Circuits' PTE (Portable Test Equipment) with LabVIEW Frequently Asked Questions (FAQs)

Module 14: Attributes

Expressions and Casting

Microsoft Visual C++.Net Step By Step (Step By Step (Microsoft)) By Julian Templeman, Andy Olsen READ ONLINE

Appendix G: Writing Managed C++ Code for the.net Framework

Getting started with C++ (Part 2)

C++ Support Classes (Data and Variables)

Transcription:

Use Native Libraries Contents Introduction... 1 Native DLL Location... 1 Get Library Function Declarations... 1 Generate Wrapper DLL... 2 Use the Wrapper DLL.... 3 32-Bit Libraries... 9 Test... 11 Sample C# file... 12 Introduction Most hardware manufacturers provide SDK for their hardware in native libraries, written in C language, Assembly language, or other unmanaged languages, that is, libraries not for Microsoft.Net Framework. Some manufacturers do not include libraries for.net Framework in their SDK. In such cases, we need to create a.net Framework wrapper so that such native libraries can be used in Limnor Studio. We use K8055 Interface Board as an example to show how it is done. Native DLL Location The native DLL must be copied to {System32} folder or {SysWOW64} folder, as the manufacturers stated in their SDK. Typically it is c:\windows\system32, or c:\windows\syswow64. Get Library Function Declarations We need to get function declarations expressed in C# language. Some manufacturers provide C# function declarations. If a manufacturer does not provide C# function declarations then we need to convert from other languages provided by the manufacturer. Such conversion usually is straight forward. Suppose we download the K8055 SDK from http://www.velleman.eu/distributor/support/downloads/?code=k8055.

The SDK contains a file K8055_DLL_manual.pdf. This file lists C# function declarations for the SDK: Copy all the C# declarations from this file into a text file and change the file extension from.txt to.cs. Add a class name for it. K8055D and K8055DClass are two names we arbitrarily chosen for this sample. The whole file will be included at the end of this document. We may also call K8055DClass a wrapper class. Generate Wrapper DLL In Limnor Studio, choose menu Tools Source Compiler.

Select the cs file we created previously: Remember where the new DLL file will be generated because later we will need to use the DLL file. Click the Compile button. The DLL file is generated. Use the Wrapper DLL. We create a Windows Application project to use the K8055 SDK.

Select Windows Application : A new Windows Application project is created. It has one Form named Form1. The way to use the wrapper DLL is to create actions using the functions contained in the DLL. To make it easier, we may add the wrapper class to Form1 as shown below. Right-click a root node, choose Add Utility : Click Load File :

Select the wrapper DLL we generated: Select the wrapper class in the wrapper DLL:

The wrapper class appears in the Object Explorer. All its functions are listed under it. To use a function, right-click it and choose Create action : Let s show an example of executing the interface board action. We add a button and a label to the form. When the user clicks the button, we want to execute SearchDevices and display the result of this action to the label. Let s create an action to execute SearchDevices. To find the SearchDevices methods, expand Static methods of the K8055DClass:

Scroll down and find SearchDevices. Right-click SearchDevices; choose Create action : A dialogue box appears showing the properties of the action. According to the SDK manual, SearchDevices will return an integer as the result. We may set the action s AssignTo property to the label so that the action result will be displayed in the label: We need to assign the action result to the Text property of the label. So, expand the Inherited properties node of the label: Scroll down to find and select the Text property:

This action execute the SearchDevices action and displays the result in the label: The action can be found under the SearchDevices node and Actions node: To execute this action when the user clicks the button, we need to assign this action to the Click event of the button. Right-click the button; choose Assign Action ; choose Click event:

Choose the action we just created and click Next : The action is assigned to the Click event of the button. We can see that the action appears under the Click event: 32-Bit Libraries If the native DLL is of 32-bit then your project must be compiled for 32-bit. For Limnor Studio 5, select the project in the Solution Explorer; set the TargetPlatform to X86:

For Limnor Studio VS, choose menu Project {Project Name} Properties :

Set the Platform Target to x86: For more information, see http://www.limnor.com/studio_x86.html Test We may test the application: The form appears: Click the button. The SearchDevices function of the interface board executes. 0 appears in the label indicating that the computer does not have a K8055 interface board:

Sample C# file Below is the C# file we used for generating the wrapper DLL. All function declarations are copied from the SDK manual K8055 interface Board. namespace K8055D { using System.Runtime.InteropServices; public sealed class K8055DClass { public static extern int OpenDevice(int CardAddress); public static extern void CloseDevice(); public static extern int ReadAnalogChannel(int Channel); public static extern void ReadAllAnalog(ref int Data1, ref int Data2); public static extern void OutputAnalogChannel(int Channel, int Data); public static extern void OutputAllAnalog(int Data1, int Data2); public static extern void ClearAnalogChannel(int Channel); public static extern void SetAllAnalog(); public static extern void ClearAllAnalog(); public static extern void SetAnalogChannel(int Channel); public static extern void WriteAllDigital(int Data); public static extern void ClearDigitalChannel(int Channel); public static extern void ClearAllDigital(); public static extern void SetDigitalChannel(int Channel); public static extern void SetAllDigital();

public static extern bool ReadDigitalChannel(int Channel); public static extern int ReadAllDigital(); public static extern int ReadCounter(int CounterNr); public static extern void ResetCounter(int CounterNr); public static extern void SetCounterDebounceTime(int CounterNr, int DebounceTime); public static extern int Version(); public static extern int SearchDevices(); public static extern int SetCurrentDevice(int lngcardaddress); } }