GXDN: Gurux Developer Network
Gurux GXDevice component
In this walkthrough, you learn how to use Gurux GXDevice components (GXDevice) in the Visual Studio .NET environment using the C# language. GXDeviceSample demonstrates how GXDevice is used in .NET.
Adding GXDevice support to the project
  1. Start Visual Studio .NET
  2. Open the project where you want to add the GXDevice support, or create a new one
  3. Open Toolbox
  4. Select Customize Toolbox


In the opened dialog, select COM Components tab. Select GXDevice and click OK to finish.


Using components with .NET
To use the GXDevice component, you can either drag the component to the form, or create the component dynamically.


Creating component dynamically
To create component in run time, select Add Reference option in Project menu. The dialog shows available components, of which you choose the components to use. In this case select GXDevice components, and click OK to finish. Following example shows how to create a GXDevice component.

using GuruxDeviceLib;
//Create new GXDevice
GuruxDeviceLib.GXDevice axGXDevice1 = new GXDeviceClass();

Selecting Device and the Media
First select used device and media.

// Select new Device
axGXDevice1.SelectDevice("GXSNMPSample", "GuruxDevice");
// Select and configure new Media
axGXDevice1.GXClient.SelectMedia("SNMP");
IGXMedia media = (IGXMedia)axGXDevice1.GXClient.GetCurrentMedia();
media.Properties();
// Assign new media settings
axGXDevice1.GXClient.AssignMedia(media);

Reading values
After Device and Media are selected, establish the connection. Then read and display the values. When done, close the connection.

axGXDevice1.OpenDevice();
axGXDevice1.ReadValues();
foreach (GXProperty prop in axGXDevice1.Properties)
{
    MessageBox.Show(prop.GetValue(GX_VARTYPE.GX_VT_STR).ToString()); 
}
axGXDevice1.Close();

Using the components from development environment

Using from .NET | Using from Visual Basic | Using from C++ | Note on parameter types