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.
Posted: 2020-03-21 10:11 PM . Last Modified: 2023-05-03 12:15 AM
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"
Posted: 2020-03-23 02:49 AM
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();
}
}
}
.
Posted: 2020-03-22 04:04 PM
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).
Posted: 2020-03-23 02:49 AM
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();
}
}
}
.
Posted: 2020-03-23 02:54 AM
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]);
Posted: 2020-03-23 03:04 PM
This worked for me. Thank you.
Create your free account or log in to subscribe to the forum - and gain access to more than 10,000+ support articles along with insights from experts and peers.