Geo SCADA Expert

This site's content is being moved
View the Geo SCADA Expert content in Schneider Electric Exchange
Please bear with us as we tidy and improve the pages. We welcome comments on the Geo SCADA Expert Forum

Using the automation interface with C# is very similar to using it within VB, apart from the obvious syntax differences between the two languages.

We do recommend you use the .Net Client interface though. If you look in the Start Menu folder for ClearSCADA, you'll notice a "Client API" shortcut. This link will take you to the documentation for the automation interface. You should start in the ClearScada.Client.Simple Namespace. The key classes to use are "Connection" and "DBObject".

However, to use the automation interface:

  1. When C# is running, select Project - Add Reference
  2. Select the COM tab
  3. Scroll down until you find the "Scx V6 Automation Interface" entry
  4. Select OK. You will see the entry added to the References section in the solution explorer (by default on the right hand side of the screen).
  5. Use the following code to connect to the server and create an internal analog point.
string sSystem = "MAIN";
string sUid = "Eng";
string sPwd= "";

// Define the server object and create a new instance of it
ScxV6DbClient.ScxV6Server objServer = new ScxV6DbClient.ScxV6Server();

// Connect to the server
objServer.Connect(sSystem, sUid, sPwd);

// Define the object and create a new internal analog point
ScxV6DbClient.ScxV6Object obj = objServer.CreateObject("CPointAlgManual", "$Root");

Note: You can download the free Visual C# 2005 Express Edition (along with other languages) from the Microsoft website. This can be used for commercial software development (see http://msdn.microsoft.com/en-gb/express/aa718399.aspx point 4).

Accessing properties/methods directly

Using Obj.Interface.CurrentValue for example, like you would from VB won't work from C#. This is because "Interface" is a vanilla IDispatch so you need to use late binding.

In VB.Net the compiler will do the plumbing for you automatically. In C# you currently need to use reflection manually, as shown in the example below.

// Get object
ScxV6DbClient.ScxV6Object O = S.FindObject( "New Analogue Point" );

// The line below doesn't work because Interface is declared in the IDL as a vanilla IDispatch, instead we need to use late-binding via Reflection
// O.Interface.LoadDataValues( Values, Times, Qualities );

// Instead, use reflection:
// Get the Historic aggregate
object Historic = O.Interface.GetType().InvokeMember( "Historic", System.Reflection.BindingFlags.GetProperty, null,O.Interface,null );

// Invoke the LoadDataValues method
if ( Historic != null )
  Historic.GetType().InvokeMember( "LoadDataValues", System.Reflection.BindingFlags.InvokeMethod, null, Historic, new object[] { Values, Times, Qualities } );