Sign In Help
Schneider Electric
HelpLogin / Register

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.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel

Invitation Sent

Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
  • Home
  • Communities
  • :
  • SCADA & Telemetry Solutions
  • :
  • Geo SCADA Expert Forum
  • :
  • Re: Using automation interface with C# to load history
Community Menu
  • Forums
    • By Topic
        • EcoStruxure Building
          • Field Devices Forum
        • EcoStruxure Power & Grid
          • Metering & Power Quality
        • EcoStruxure IT
          • EcoStruxure IT forum
        • Industrial Automation
          • Industry Automation and Control Forum
          • Alliance System Integrators Forum
          • Machine Automation Forum
          • EcoStruxure Automation Expert / IEC 61499 Forum
          • Industrial Edge Computing Forum
          • Level and Pressure Instrumentation Forum
          • Modicon User Group
          • PLC Club Indonesia
          • SEE Automation Club Forum
          • Fabrika ve Makina Otomasyonu Çözümleri
          • Форум по промышленной автоматизации СНГ
          • Motorabgangstechnik & Antriebstechnik Forum
        • SCADA & Telemetry Solutions
          • Geo SCADA Expert Forum
          • SCADA and Telemetry Devices Forum
        • Power Distribution IEC
          • Power Distribution and Digital
          • Power Standards & Regulations
          • Solutions for Motor Management
          • Paneelbouw & Energie Distributie
          • Eldistribution & Fastighetsautomation
          • Elektrik Tasarım Dağıtım ve Uygulama Çözümleri
        • Power Distribution NEMA
          • US Utility Forum
        • Power Distribution Softwares
          • EcoStruxure Power Design Forum
          • LayoutFAST User Group Forum
        • Wireless Information Network Solutions
          • Instrument Area Network
          • Remote Monitoring
          • Tank Level Monitoring
          • Remote Data Collection
        • Solutions for your Business
          • Solutions for Food & Beverage Forum
          • Solutions for Healthcare Forum
    • By Segment
        • Food & Beverage
          • Solutions for Food & Beverage Forum
        • Healthcare
          • Solutions for Healthcare Forum
      • EcoStruxure Building
        • Field Devices Forum
      • EcoStruxure Power & Grid
        • Metering & Power Quality
      • EcoStruxure IT
        • EcoStruxure IT forum
      • Industrial Automation
        • Industry Automation and Control Forum
        • Alliance System Integrators Forum
        • Machine Automation Forum
        • EcoStruxure Automation Expert / IEC 61499 Forum
        • Industrial Edge Computing Forum
        • Level and Pressure Instrumentation Forum
        • Modicon User Group
        • PLC Club Indonesia
        • SEE Automation Club Forum
        • Fabrika ve Makina Otomasyonu Çözümleri
        • Форум по промышленной автоматизации СНГ
        • Motorabgangstechnik & Antriebstechnik Forum
      • SCADA & Telemetry Solutions
        • Geo SCADA Expert Forum
        • SCADA and Telemetry Devices Forum
      • Power Distribution IEC
        • Power Distribution and Digital
        • Power Standards & Regulations
        • Solutions for Motor Management
        • Paneelbouw & Energie Distributie
        • Eldistribution & Fastighetsautomation
        • Elektrik Tasarım Dağıtım ve Uygulama Çözümleri
      • Power Distribution NEMA
        • US Utility Forum
      • Power Distribution Softwares
        • EcoStruxure Power Design Forum
        • LayoutFAST User Group Forum
      • Wireless Information Network Solutions
        • Instrument Area Network
        • Remote Monitoring
        • Tank Level Monitoring
        • Remote Data Collection
      • Solutions for your Business
        • Solutions for Food & Beverage Forum
        • Solutions for Healthcare Forum
      • Food & Beverage
        • Solutions for Food & Beverage Forum
      • Healthcare
        • Solutions for Healthcare Forum
  • Blogs
    • By Topic
        • EcoStruxure Power & Grid
          • Backstage Access Resources
        • Industrial Automation
          • Industry 4.0 Blog
          • Industrie du Futur France
        • SCADA & Telemetry Solutions
          • SCADA and Telemetry Blog
        • Power Distribution IEC
          • Power Events & Webinars
          • Power Foundations Blog
          • UK&I Residential and Commercial Electrical Distribution
        • Power Distribution NEMA
          • NEMA Power Foundations Blog
        • Power Distribution Softwares
          • EcoStruxure Power Design Blog
        • Solutions for your Business
          • Solutions for Food & Beverage Blog
          • Solutions for Healthcare Blog
          • Solutions for Retail Blog
          • Solutions for eMobility
          • Digital Hospital Solutions – UK&I
        • Knowledge Center
          • Industrial Automation How-to videos
          • Digital E-books
          • Success Stories Corner
        • Community experts & publishers
          • Publishers Community
    • By Segment
        • Food & Beverage
          • Solutions for Food & Beverage Blog
        • Healthcare
          • Solutions for Healthcare Blog
        • Retail
          • Solutions for Retail Blog
        • Retail
          • Solutions for eMobility
        • Retail
          • Digital Hospital Solutions – UK&I
      • EcoStruxure Power & Grid
        • Backstage Access Resources
      • Industrial Automation
        • Industry 4.0 Blog
        • Industrie du Futur France
      • SCADA & Telemetry Solutions
        • SCADA and Telemetry Blog
      • Power Distribution IEC
        • Power Events & Webinars
        • Power Foundations Blog
        • UK&I Residential and Commercial Electrical Distribution
      • Power Distribution NEMA
        • NEMA Power Foundations Blog
      • Power Distribution Softwares
        • EcoStruxure Power Design Blog
      • Solutions for your Business
        • Solutions for Food & Beverage Blog
        • Solutions for Healthcare Blog
        • Solutions for Retail Blog
        • Solutions for eMobility
        • Digital Hospital Solutions – UK&I
      • Knowledge Center
        • Industrial Automation How-to videos
        • Digital E-books
        • Success Stories Corner
      • Community experts & publishers
        • Publishers Community
      • Food & Beverage
        • Solutions for Food & Beverage Blog
      • Healthcare
        • Solutions for Healthcare Blog
      • Retail
        • Solutions for Retail Blog
      • Retail
        • Solutions for eMobility
      • Retail
        • Digital Hospital Solutions – UK&I
  • Ideas
        • Industrial Automation
          • Modicon Ideas & new features
        • SCADA & Telemetry Solutions
          • Geo SCADA Expert Ideas
          • SCADA and Telemetry Devices Ideas
  • Knowledge Center
    • Building Automation Knowledge Base
    • Industrial Automation Knowledge Base
    • Industrial Automation How-to videos
    • SCADA & Telemetry Solutions Knowledge Base
    • Digital E-books
    • Success Stories Corner
    • Power Talks
  • Events & Webinars
    • Innovation Talks
    • Innovation Summit
    • Let's Exchange Series
    • Technology Partners
  • Support
    • Ask Exchange
    • Leaderboard
    • Our Community Guidelines
    • Community User Guide
    • How-To & Best Practices
    • More
Register Now
How can we help?
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
53119members
248546posts

Using automation interface with C# to load history

Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Solved Go to Solution
Back to Geo SCADA Expert Forum
Solved
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-23 04:16 PM
0 Likes
13
689
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-23 04:16 PM

Using automation interface with C# to load history

Hi, I am trying to load history values to a tag. I refer to the last section of the below

 

https://tprojects.schneider-electric.com/telemetry/display/public/CS/Using+the+Automation+Interface+...

 

 

// 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 } );

 

 

I have changed the code to below

 

ScxV6Server S = new ScxV6Server();
S.Connect("Local", "admin", "admin");
// Get object
ScxV6DbClient.ScxV6Object O = S.FindObject("System.Xxxxx.HistoryAnalogPoint");
// 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[] { sampleGS[i], sampleStartDateTime[i], 192 });

 

When the code gets to the line - ScxV6Server S = new ScxV6Server();

the following error occurs (Class not registered).

 

System.Runtime.InteropServices.COMException
HResult=0x80040154
Message=Retrieving the COM class factory for component with CLSID {EEAD2002-0777-11D2-AF05-0000E82E7A14} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
Source=DNP3FT
StackTrace:
at InsertHistoryCOMAPI.Program.Main(String[] args) in C:\Users\Administrator\source\repos\\Program.cs:line 186

 

Thanks,

Labels
  • SCADA
Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply

Accepted Solutions
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-24 06:13 PM
0 Likes
5
585
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 06:13 PM

Re: Using automation interface with C# to load history

It's CHistoryBase which has the aggregate.

 

Why are you doing the GetType()?

 

Why not just obtain the Historic aggregate on the object that you want to load the historic data for, and then call InvokeMethod on that aggregate, and pass in the required items...

 

i.e.

aggr.InvokeMethod("LoadDataValue", new object[] {reason, quality, timestamp, value});

or

aggr.InvokeMethod("LoadDataValues", new object[] {valueArray, timestampArray, qualityArray, reasonArray});

or

aggr.InvokeMethod("LoadDataValuesEx", new object[] {valueArray, timestampArray, qualityArray, statusArray, stateArray, reasonArray, msStateArray, putAsideArray} );

 

My offline code example actually shows a version without the new object[] {...}..., and instead just directly passing the arguments after the methodName.  It doesn't match the .NET API help method definition... but it's obviously worked for me at some time.  I haven't fired up Visual Studio to check out the InvokeMethod signature.. maybe it does accept a variable number of arguments.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..

See Answer In Context

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
13 Replies 13
AdamWoodland
Commander AdamWoodland Commander
Commander
‎2021-02-23 05:42 PM
0 Likes
12
684
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-23 05:42 PM

Re: Using automation interface with C# to load history

Try

 

new Serck.ScxV6Server()

 

If that doesn't work you may need to regsvr32 DBClient.dll (in the x86 ClearSCADA installation folder), the installer should do that but maybe something went wonky somewhere.

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-23 06:50 PM
0 Likes
11
681
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-23 06:50 PM

Re: Using automation interface with C# to load history

Hi, I added the Serk, it still had an  error.

However, I removed the Serk and after that all errors cleared.

I am now able to run the code further.

 

@AdamWoodland 

I find it unclear at the moment, what is the format it is looking for as regards to Values, Times, Qualities.

Historic.GetType().InvokeMember( "LoadDataValues", System.Reflection.BindingFlags.InvokeMethod, null, Historic, new object[] { Values, Times, Qualities } );

Should it be more { Value, Time, Quality }? Value = 4.45, Time = 2021/02/24 12:30:22:55, Quality = 192?
If I can get it to write one value to the history of a point it would be a start.

Thanks,

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-24 03:00 AM
0 Likes
10
634
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 03:00 AM

Re: Using automation interface with C# to load history

What does the schema say the arguments to LoadDataValues should be?


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
AdamWoodland
Commander AdamWoodland Commander
Commander
‎2021-02-24 12:41 PM
0 Likes
9
617
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 12:41 PM

Re: Using automation interface with C# to load history

Also see https://tprojects.schneider-electric.com/telemetry/display/public/CS/Importing+History+Using+LoadDat...

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-24 12:44 PM
0 Likes
8
615
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 12:44 PM

Re: Using automation interface with C# to load history

Thanks Adam, I hadn't found that.

Thanks,

 

Hi, I notice the later article indicates four parameters

 LoadDataValue( Value{Variant},
                Timestamp{Time},
                Quality{Long},
                Reason{Byte} )

where the first indicates three

{ Values, Times, Qualities }

which should it be?

 

So I have tried

 

{ sampleGS[i], sampleStartDateTime[i], sampleQuality[i], sampleReason[i] }

 


which when written to the console looks like
4.0218887,2020,07,22,16,11,38,010,192,8 this may not be correct format?


This throws an error

 

 

System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=System.Private.CoreLib
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at InsertHistoryCOMAPI.Program.Main(String[] args) in C:\Users\Administrator\source\repos\Xxxxx\Program.cs:line 200

Inner Exception 1:
ArgumentException: Value does not fall within the expected range.

 

 

Thanks,

Tags (1)
  • Tags:
  • scada
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-24 03:02 PM
0 Likes
7
597
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 03:02 PM

Re: Using automation interface with C# to load history

If using C# recommendations are:

 

LoadDataValues requires ARRAYS, not single values

LoadDataValue requires single values, not arrays

 

You should use DateTimeOffset as DateTime inputs to functions, and expect DateTimeOffset as return values.

You shouldn't explicitly "box" 'Value' (variant) datatypes, you can use the native intrinsic type just fine.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-24 04:16 PM
0 Likes
6
591
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 04:16 PM

Re: Using automation interface with C# to load history

Hi Bevan,

where in the schema were you referring to above please.

 

ok, I will try LoadDataValue.
Can any body give correct variable type and values that I can place into the line below, that they know works, so that I can at least see it work please.

Historic.GetType().InvokeMember("LoadDataValue", System.Reflection.BindingFlags.InvokeMethod, null, Historic, new object[] { sampleValueTest, sampleStartDateTimeTest, sampleQualityTest });

 

sampleValueTest

 

sampleStartDateTimeTest

sampleQualityTest

 

Thanks,

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-24 06:13 PM
0 Likes
5
586
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-24 06:13 PM

Re: Using automation interface with C# to load history

It's CHistoryBase which has the aggregate.

 

Why are you doing the GetType()?

 

Why not just obtain the Historic aggregate on the object that you want to load the historic data for, and then call InvokeMethod on that aggregate, and pass in the required items...

 

i.e.

aggr.InvokeMethod("LoadDataValue", new object[] {reason, quality, timestamp, value});

or

aggr.InvokeMethod("LoadDataValues", new object[] {valueArray, timestampArray, qualityArray, reasonArray});

or

aggr.InvokeMethod("LoadDataValuesEx", new object[] {valueArray, timestampArray, qualityArray, statusArray, stateArray, reasonArray, msStateArray, putAsideArray} );

 

My offline code example actually shows a version without the new object[] {...}..., and instead just directly passing the arguments after the methodName.  It doesn't match the .NET API help method definition... but it's obviously worked for me at some time.  I haven't fired up Visual Studio to check out the InvokeMethod signature.. maybe it does accept a variable number of arguments.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..

See Answer In Context

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-25 02:42 PM
0 Likes
4
539
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-25 02:42 PM

Re: Using automation interface with C# to load history

Hi, I was attempting to follow the 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 } );

 

 

I thought this would allow for data to be loaded into the history of the point.

Thanks,

 

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-25 05:34 PM
0 Likes
3
532
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-25 05:34 PM

Re: Using automation interface with C# to load history

Here's something from @sbeadle , it's where I'd start from... 

https://github.com/GeoSCADA/Utilities-and-Examples/blob/main/InsertHistoricData/Program.cs

 

His LoadDataValue example

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

 

Although I prefer the inline definition of the new object[] {} (as my previous example used)

 

He's got another example here:

https://github.com/GeoSCADA/Utilities-and-Examples/blob/main/SetInternalPoint/Program.cs

where he uses InvokeMethod on the base object (i.e. PointObj from the above example) but has a longer qualifier on the method name ("Historic.RawValues" in this version... but that would be "Historic.LoadDataValue" if you wanted to invoke the LoadDataValue method instead).

 

The tproject concept has quite a lot of jumping backwards through hoops, which seems unnecessary.

Perhaps back when it was created the Aggregates collection didn't exist.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-25 05:52 PM
0 Likes
2
530
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-25 05:52 PM

Re: Using automation interface with C# to load history

Hi, I went back through some older code I had and came across this.

I just changed the date and this worked.
Apart from having to change the date to a more recent one of course.

 

 

 

 

DBObject TestPoint;
                Aggregate HistAgg;

                //Object[] argsTo;
                DateTime dt;
                Object[] argsTo = new Object[4];

                using (Connection conn = new Connection("ClearSCADA"))
                {

                    // Connect to local server
                    SecureString passwd = new SecureString();
                    string strPassword = "admin";
                    foreach (char c in strPassword)
                        passwd.AppendChar(c);
                    passwd.MakeReadOnly();
                    conn.Connect("localhost");
                    conn.LogOn("admin", passwd);
                    



                    //string pointValue = dict["Test2"];
                    // Get the point
                    TestPoint = conn.GetObject("System.Dashboard.Engineering Dashboard.Work Orders.Points.HistoryAnalogPoint");
                    // If Historic is enabled for the point, insert historic data
                    if (TestPoint.Aggregates.TryGetValue("Historic", out HistAgg) == true)
                    {

                        argsTo[0] = "4"; // Reason
                                         //argsTo[0] = column1[0]; 
                                         //argsTo[1] = "1"; // Quality
                        argsTo[1] = "192"; // Quality
                                           //argsTo[1] = column3[0]; // Quality
                        dt = new DateTime(2020, 3, 02, 11, 55, 52);
                        argsTo[2] = new System.DateTimeOffset(dt);
                        //argsTo[2] = column2[0]; //DateTime
                        //argsTo[3] = "88";
                        ////argsTo[3] = column4[0]; //Value
                        argsTo[3] = 4.45; //Value

                        HistAgg.InvokeMethod("LoadDataValue", argsTo);
                        
                    }
                    conn.LogOff();
                    conn.Disconnect();

 

 

Thanks, 

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2021-02-25 10:28 PM
0 Likes
1
517
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-25 10:28 PM

Re: Using automation interface with C# to load history

Hi, these are the settings for my Geo SCADA.

ErrorMessageCSV4Import.png

 

This a sample of the data I want to import
4.0218887,2020,07,22,16,11,38,010,192,8
3.1718216,2020,07,22,16,11,53,010,192,8

This is what I am getting in Geo SCADA

 

 

If I use the below it wont import historic values

dt = new DateTime(2020, 2, 26, 11, 55, 52);

If I change the 2020 to 2021 it imports.

Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2021-02-26 12:47 AM
0 Likes
0
506
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2021-02-26 12:47 AM

Re: Using automation interface with C# to load history

Assuming that you were running your code at close to 5pm on the 26th February 2021... and you have a historic configuration set to keep data for 52 weeks... then 52*7 = 364 days... so the 26th February 2020 is NOT within your configured historic retention window.

In fact you're two days out, since last year was a leap year..

 

You should go back through the help files for the settings in the Server Configuration pane, really see what it says for each of the fields, and think about how that will relate to what you are trying to do.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (6)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Share
Reply
Top Experts
User Count
sbeadle
Sisko sbeadle Sisko
188
BevanWeiss
Sisko BevanWeiss
56
AndrewScott
Lt. Commander AndrewScott
18
AdamWoodland
Commander AdamWoodland Commander
17
JChamberlain
Lt. Commander JChamberlain Lt. Commander
16
geoffpatton
Lt. Commander geoffpatton
10
See More Top Experts
Find a Service Provider
Find a certified partner to help you address your integration, installation, maintenance and project needs.
View all Providers
Support

Have a question? Please contact us with details, and we will respond.

Contact Us
FAQ

Look through existing questions to find popular answers.

Learn More
About

Want to know more about Exchange and its possibilities?

Learn More

Full access is just steps away!

Join Exchange for FREE and get unlimited access to our global community of experts.

Connect with Peers & Experts

Discuss challenges in energy and automation with 30,000+ experts and peers.

Get Support in Our Knowledge Base

Find answers in 10,000+ support articles to help solve your product and business challenges.

Ask Questions. Give Solutions

Find peer based solutions to your questions. Provide answers for fellow community members!

Register today for FREE

Register Now

Already have an account?Log in

About Us FAQ Terms & Conditions Privacy Notice Change your cookie settings
©2021, Schneider Electric