Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
84649members
353989posts

Getting historic data via .NET client API

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

Solved
Dean_Mercer
Cadet
0 Likes
4
1828

Getting historic data via .NET client API

Has anyone here tried getting historic data out of ClearSCADA using the .NET client API?

 

I've tried calling "historicAggregate.InvokeMethod("RawValuesRange", args)" and  "historicAggregate.InvokeMethod("RawValues", args)", but both are returning the exception "ClearScada.Client.MethodException: 'Failed to execute method 'Historic.RawValuesRange': Not implemented"

 


Accepted Solutions
sbeadle
Janeway Janeway
Janeway
0 Likes
2
1814

Re: Getting historic ata via .NET client API

Here's an example. Other ways of declaring and using parameters are possible. This uses an array declaration to receive the results.

 

Jesse - using ODBC will be similar performance, maybe a shade slower as the query has to be interpreted. You'd also need a connection string/details in addition to what your code might be doing elsewhere.

 

There's also an SQL interface in the C# library, so to use the client object functions as well as sql statements in the same connection is possible. If someone asks a separate question about that I may post an example!

 

using System;
using ClearScada.Client;            // This requires a Reference from the project to this dll
using System.Security;

namespace InsertHistoricData
{
	class Program
	{
		static void Main()
		{
			string user = "s";
			string pass = "s";

			ClearScada.Client.Simple.Connection connection;
			var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);
			connection = new ClearScada.Client.Simple.Connection("Utility");
			connection.Connect(node);
			var spassword = new System.Security.SecureString();
			foreach (var c in pass)  spassword.AppendChar(c); 
			connection.LogOn(user, spassword);
			ClearScada.Client.Simple.DBObject PointObj = connection.GetObject("Test General.Test His Insert and Load.New Analog Point");
			DateTime now = DateTime.UtcNow;

			Object[] p1 = new Object[4];
			p1[0] = 1;
			p1[1] = 192;
			p1[2] = now;
			p1[3] = 1;
			PointObj.Aggregates["Historic"].InvokeMethod("LoadDataValue", p1);


			Object[] p2 = new Object[5];
			p2[0] = now.AddSeconds(-1);
			p2[1] = now.AddSeconds(1);
			p2[2] = 0;
			p2[3] = true;
			p2[4] = "All";
			object r = PointObj.Aggregates["Historic"].InvokeMethod("RawValue", p2);
			Console.WriteLine(r);

			Object[] p3 = new Object[6];
			p3[0] = now.AddSeconds(-1);
			p3[1] = now.AddSeconds(1);
			p3[2] = 0;
			p3[3] = 1;
			p3[4] = true;
			p3[5] = "All";
			object [] k = (object [])PointObj.Aggregates["Historic"].InvokeMethod("RawValues", p3);

			Console.WriteLine(k[0]);

			Console.ReadKey();
		}
	}
}

 

See Answer In Context

4 Replies 4
JChamberlain
Schneider Alumni (Retired)
Schneider Alumni (Retired)
0 Likes
3
1822

Re: Getting historic ata via .NET client API

I've not done it and couldn't find an example, but I did find a suggestion that it might be easier to to via ODBC (System.Data.Odbc.OdbcConnection).

sbeadle
Janeway Janeway
Janeway
0 Likes
2
1815

Re: Getting historic ata via .NET client API

Here's an example. Other ways of declaring and using parameters are possible. This uses an array declaration to receive the results.

 

Jesse - using ODBC will be similar performance, maybe a shade slower as the query has to be interpreted. You'd also need a connection string/details in addition to what your code might be doing elsewhere.

 

There's also an SQL interface in the C# library, so to use the client object functions as well as sql statements in the same connection is possible. If someone asks a separate question about that I may post an example!

 

using System;
using ClearScada.Client;            // This requires a Reference from the project to this dll
using System.Security;

namespace InsertHistoricData
{
	class Program
	{
		static void Main()
		{
			string user = "s";
			string pass = "s";

			ClearScada.Client.Simple.Connection connection;
			var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);
			connection = new ClearScada.Client.Simple.Connection("Utility");
			connection.Connect(node);
			var spassword = new System.Security.SecureString();
			foreach (var c in pass)  spassword.AppendChar(c); 
			connection.LogOn(user, spassword);
			ClearScada.Client.Simple.DBObject PointObj = connection.GetObject("Test General.Test His Insert and Load.New Analog Point");
			DateTime now = DateTime.UtcNow;

			Object[] p1 = new Object[4];
			p1[0] = 1;
			p1[1] = 192;
			p1[2] = now;
			p1[3] = 1;
			PointObj.Aggregates["Historic"].InvokeMethod("LoadDataValue", p1);


			Object[] p2 = new Object[5];
			p2[0] = now.AddSeconds(-1);
			p2[1] = now.AddSeconds(1);
			p2[2] = 0;
			p2[3] = true;
			p2[4] = "All";
			object r = PointObj.Aggregates["Historic"].InvokeMethod("RawValue", p2);
			Console.WriteLine(r);

			Object[] p3 = new Object[6];
			p3[0] = now.AddSeconds(-1);
			p3[1] = now.AddSeconds(1);
			p3[2] = 0;
			p3[3] = 1;
			p3[4] = true;
			p3[5] = "All";
			object [] k = (object [])PointObj.Aggregates["Historic"].InvokeMethod("RawValues", p3);

			Console.WriteLine(k[0]);

			Console.ReadKey();
		}
	}
}

 

sbeadle
Janeway Janeway
Janeway
0 Likes
1
1812

Re: Getting historic ata via .NET client API

And to use the ...Range methods, you need a time offset string:

			Object[] p4 = new Object[6];
			p4[0] = now.AddSeconds(-1);
			p4[1] = "2S";
			p4[2] = 0;
			p4[3] = 1;
			p4[4] = true;
			p4[5] = "All";
			object[] q = (object[])PointObj.Aggregates["Historic"].InvokeMethod("RawValuesRange", p4);

			Console.WriteLine(q[0]);
Dean_Mercer
Cadet
0 Likes
0
1805

Re: Getting historic ata via .NET client API

This worked for me. Thank you.