Is it possible to call the ClearSCADA Time Average function from a .NET application using the client library? Any example code will be much appreciated.
Thanks a lot.
Solved! Go to Solution.
Yes, it's possible.
From the .NET API you can InvokeMethods, you just need to know the name of the Method that you want to call, and what aggregate it is on, and what arguments to provide to it.
Pretty much all of these can be found in the DB Schema.
So I would start there.
If you're on your local GeoSCADA Expert server you can probably just go here:
https://localhost/schema/CHistoryBase
And that should show you the methods available. You can see 'ProcessedValue' which will return 'a single processed historic value', which sounds like what a Time Average would be.
Then if you look at the argument for it, it wants:
It will return a variant representing the processed value.
Here's some sample code to do that - comments do some of the explaining:
// Retrieve the last day's data
DateTime startTime = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1));
DateTime endTime = DateTime.UtcNow;
// Retrieve an average of the last day's values - Processed Data
// Historic Aggregate code 3 = average of values. Search help for "Animations for Historic Data" for codes.
object[] pParams = new object[4] { startTime, endTime, 3, "" };
object value = (object)myPoint.InvokeMethod("Historic.ProcessedValue", pParams);
Console.WriteLine("Processed Average Value: " + value.ToString());
Yes, it's possible.
From the .NET API you can InvokeMethods, you just need to know the name of the Method that you want to call, and what aggregate it is on, and what arguments to provide to it.
Pretty much all of these can be found in the DB Schema.
So I would start there.
If you're on your local GeoSCADA Expert server you can probably just go here:
https://localhost/schema/CHistoryBase
And that should show you the methods available. You can see 'ProcessedValue' which will return 'a single processed historic value', which sounds like what a Time Average would be.
Then if you look at the argument for it, it wants:
It will return a variant representing the processed value.
Here's some sample code to do that - comments do some of the explaining:
// Retrieve the last day's data
DateTime startTime = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1));
DateTime endTime = DateTime.UtcNow;
// Retrieve an average of the last day's values - Processed Data
// Historic Aggregate code 3 = average of values. Search help for "Animations for Historic Data" for codes.
object[] pParams = new object[4] { startTime, endTime, 3, "" };
object value = (object)myPoint.InvokeMethod("Historic.ProcessedValue", pParams);
Console.WriteLine("Processed Average Value: " + value.ToString());
Time Average = 30
StdDev = 5
Thanks a lot for your help!
Discuss challenges in energy and automation with 30,000+ experts and peers.
Find answers in 10,000+ support articles to help solve your product and business challenges.
Find peer based solutions to your questions. Provide answers for fellow community members!