Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

[Imported] Accessing Automation Interface via COM object (Delphi example)

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

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: 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • [Imported] Accessing Automation Interface via COM object (Delphi example)
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
Invite a Co-worker
Send a co-worker an invite to the 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
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
95
BevanWeiss
Spock BevanWeiss
89
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Back to EcoStruxure Geo SCADA Expert Forum
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2019-11-05 02:15 PM . Last Modified: ‎2023-05-03 12:32 AM

0 Likes
0
1393
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2019-11-05 02:15 PM . Last Modified: ‎2023-05-03 12:32 AM

[Imported] Accessing Automation Interface via COM object (Delphi example)

>>Message imported from previous forum - Category:Scripts and Tips<<
User: mchartrand, originally posted: 2018-10-25 20:05:19 Id:296
This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.

_______

**_Dmytro:
Not many people realize how simple it can be to access ClearSCADA database from an outside application using the good old COM object, supported by all the old and new programming environments. No libraries (except for the built-in ones) and no third party DLLs are required. Here is my example for Object Pascal/Delphi. It renames a group, adds a value to a point's history and displays it's current value. You will need one button and one edit component on your Delphi form._**


_uses ..., ComObj
...
procedure TForm1.Button1Click(Sender: TObject);
var Svr,Obj,His: Variant;
begin
Svr:=CreateOleObject('Serck.ScxV6Server');
Svr.Connect('Main','Engineer','Password1');
Obj:=Svr.FindObject('Patients.Unknown08'); // Find that new guy occupying bed No8.
Obj.Name:='English'; // Let's call him Mr.English from now on.
Obj:=Svr.FindObject('Patients.English.Temperature');
His:=Obj.Interface.Historic; // I took his temperature at this time yesterday, while
His.LoadDataValue(0, 192, Now-1, 36.6); // the system was down.
Edit1.Text:=Obj.Interface.CurrentValueFormatted; // By the way, what is it now?
Svr.Disconnect;
end;_

**_Notes:
1. Versions: ClearSCADA 2015 R2 (Build 77.5882); Windows 7 Pro SP1 64-bit; Delphi 7.0 .
2. ComObj is a standard Object Pascal unit (supplied with all versions).
3. What is "Serck"? It is the company that originated ClearSCADA very-very long time ago. This Windows class group serves better than a monument in the middle of Newcaste, doesn't it? 🙂
4. The "Now" function returns local PC time. The "LoadDataValue" procedure interprets the input time as UTC. In this regard the example is only good for a UTC zone._**

_________________________


**_Dmytro:
Related Mysteries
An extract from the "Server Automation" online help:
(See ss1.jpg)
1. "Historic" is neither a method nor a property, it is an aggregate. However, and fortunately, for some reason it works through the Interface method. "Fortunately" because of the following.
2. The standard way of accessing an aggregate, as prescribed by the help, is by calling the Aggregate method on the object. However the call
His:=Obj.Aggregate('Historic');
results in error:
(See ss2.jpg)
3. Maybe the Aggregate method is available through the Interface method? No, it is not, either:
His:=Obj.Interface.Aggregate('Historic');
(See ss3.jpg)
4. I tried to find the Aggregate method on Database Schema. Went up and down the object tree. Is it not there; why? (Or am I blind?)
Any comments from the Support or Developers on these will be appreciated._**

![]((see attachments below) lp/08rqqryz5nxw.jpg "")
![]((see attachments below) 4r/w2o3gp55iped.jpg "")
![]((see attachments below) v8/qicjpk5e8bee.jpg "")

________________________________________

bevanweiss:
The Aggregate should be an actual object, so it's not really a method (it doesn't take arguments).

It should just be Obj.Aggregate("Historic"), and it's of type ScxV6DbClient.ScxV6Aggregate

I'm a bit rusty on Pascal, if it considers array notation to use the [] syntax, then it would be:

His := Obj.Aggregate['Historic']

______________________________

AWoodland:
Aggregate isn't a property or method in the database, hence why you can't find it in the schema and can't use it in logic for example, it is just provided by the DLL to access the aggregates.

I'll have a play and see what I use, whilst the COM automation interface is good for backwards compatability (and easier to just hack stuff together) the .NET API should be the preferred choice for anything serious.

What is "Serck"? It is the company that originated ClearSCADA very-very long time ago. This Windows class group serves better than a monument in the middle of Newcaste, doesn't it? 🙂

FWIW, the middle of Coventry, UK would be better than Newcastle, Australia as ClearSCADA was never developed at Serck Controls Australia (small bits were) 🙂

That is one of the good things about using the COM object, I still get to use 'Serck' occasionally. Same reason I still have the Serck swoosh on the window on the side of my car (that and the fact the glue is so solid I can't get the **bleep** thing off)...

_______________________________

**_Dmytro:
Exactly. That's why it looks to me as "not working for right reasons and working for wrong reasons". As per the help, the Interface method provides access to properties and methods of an object. How come it provides access to such "a funny thing" (as it appears in the "His:=Obj.Interface.Historic" assignment) as Historic. It looks more like a method access here, hence my further exploring per notes 3 and 4. And, again, as per the help (see ss1.jpg), anything accessible via the Interface method I should be able to find in the schema tree (and not as a literal reference which the name of the aggregate is)._**

____________

AWoodland:
Probably to provide consistency in data access, fwiw you can do similar in logic and also for accessing specific alarm conditions.

___________________

**_Dmytro:
You are right, and this was my understanding too. However, as noted in note 2, it doesn't work (anymore?) via COM. The message ss2.jpg simply spells out the response received from ClearSCADA AI, and has nothing to do with Delphi syntax. By the way, ScxV6DbClient.ScxV6Aggregate is a VB type. Bypassing it is done by calling Windows class Serck.ScxV6Server._**

_________________________

bevanweiss:
I think you've misquoted me 😉
I did say exactly that it is of type 'ScxV6DbClient.ScxV6Aggregate'. It's not really a 'VB type', it's just a COM Class Definition (COM type), not bound to VB, especially since it's not written in VB but C/C++ instead. For the Historic aggregate, it's actually a subtype of this, which is CHistoryBase (or CDNP3History.. depends on the associated DB object type).

It certainly still works elsewhere, none of the AI code that we use has broken in ClearSCADA 2015R2. I believe this will be a Delphi oddity. Are you able to access any Aggregates?

From the Server Automation help (ClearSCADA 2015R2)

Example
The following example written in VB.NET shows how to use the Aggregate method to retrieve the optional historic storage area of a point:

_Dim Svr as ScxV6Server
Dim Obj as ScxV6Object
Dim His as ScxV6Aggregate
' Connect to the server
Svr = new ScxV6Server
Svr.Connect "MAIN", "", ""
' Find the point in the database
Set Obj = Svr.FindObject("Group.Point")
' Use GetAggregate to get the optional historic storage
Set His = Obj.Aggregate("Historic")
If His is Nothing Then
MsgBox "Historic not defined"
Else
' Access properties and method of the His object
End If_

I'd check that your Delphi logic matches this. And that you actually have a Historic aggregate associated with the object that you're trying to use this code with. If you haven't enabled the Historic tickbox on the DB object then the aggregate reference will be Nothing ("Historic not defined")

________________________

**_Dmytro:
Adam:
And it is good it does, as the standard format doesn't work. Took me awhile to figure out this workaround 🙂
Bevan:
The above code works fine. This topic is a working example of using COM object to access CS AI. And the small print in the first post is really all the code that is required (that's the beauty of it). It is just the odd behaviour that I observed that made me post the "Mysteries" part.
The BV.NET example uses predefined types (they are probably as well not defined in VB-specific libraries, but rather in a C++-written DLL, as you clarified to me regarding the ScxV6DbClient.ScxV6Aggregate). The above Pascal example is not using any predefined types: all I needed is a few Variants. Delphi employs late binding (by the means of interface IDispatch, defined in the core unit "system.pas"). This allows me to not care what language the type library is written in, and if it exists at all ;)_**

__________________________

bevanweiss:
IDispatch is the COM late-binding mechanism. It's not Delphi specific.

Statically typing your variables as much as possible is the recommended course of action. It's not always possible, but you should strive to do this.

When using VB/C# it's also possible to just type everything as 'var', but it's really not helpful to a programmer coming after you (including yourself 'post-memory' of what your code was doing).

That the obj.Aggregate("Historic") method call did not work has me a bit surprised. It would be good if you could try this with a few of the other possible aggregates also, to confirm that it is such a Delphi issue. Maybe like the UserMethods aggregate, which exists on every object.

Or perhaps it's Delphi not liking the Aggregate method call without knowing explicitly that the object has such a method available. You might need to statically type the object reference as being to an ScxV6DbClient.ScxV6Object (which from the type library Delphi would know has an Aggregate method).

Attached file: (editor/lp/08rqqryz5nxw.jpg), SS2.jpg File size: 7025

Attached file: (editor/4r/w2o3gp55iped.jpg), SS3.jpg File size: 15186

Attached file: (editor/v8/qicjpk5e8bee.jpg), SS1.jpg File size: 72939

Attachments
Labels
  • Labels:
  • SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic
Replies 0
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of