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

We Value Your Feedback!
Could you please spare a few minutes to share your thoughts on Cloud Connected vs On-Premise Services. Your feedback can help us shape the future of services.
Learn more about the survey or Click here to Launch the survey
Schneider Electric Services Innovation Team!

Using the Automation Interface with C(sharp)

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
  • Using the Automation Interface with C(sharp)
Options
  • 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
308
AndrewScott
Admiral AndrewScott
98
BevanWeiss
Spock BevanWeiss
91
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
37
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
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander

Posted: ‎2020-02-23 09:54 PM . Last Modified: ‎2023-05-03 12:16 AM

0 Likes
7
2960
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-23 09:54 PM . Last Modified: ‎2023-05-03 12:16 AM

Using the Automation Interface with C(sharp)

Hi,

I refer to the page of the below link and the comment at the bottom of the page;

 

https://community.exchange.se.com/t5/Geo-SCADA-Knowledge-Base/bg-p/geo-scada-knowledge-base

 

Anonymous says: Is reflection still need in .NET Framework version 4.x now that dynamic exists? ...

Is reflection still need in .NET Framework version 4.x now that dynamic exists?

From this line ScxV6DbClient.ScxV6Object O = S.FindObject( "New Analogue Point" );

what is S? How is it created/assigned? Mar 25th 2011

Thanks,

Labels
  • Labels:
  • SCADA
Reply
Contact Support

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

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander

Posted: ‎2020-02-24 09:12 PM

In response to sbeadle
0 Likes
3
2916
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 09:12 PM

Hi Gents, I went over to VB and the code below works for me and I can change it further to fit my requirements.

 

Imports System
Imports Microsoft.SqlServer
Imports ScxV6DbClient

Module Program
Sub Main(args As String())

Dim Svr As ScxV6DbClient.ScxV6Server
Svr = New ScxV6DbClient.ScxV6Server
Svr.Connect("XXXXXXXXX", "XXXX", "XXXXXXXX")

Dim csObj As ScxV6Object
csObj = Svr.FindObject("New Analog Point")


Dim csAgg As ScxV6Aggregate
csAgg = csObj.Aggregate("Historic")
csAgg.Enable = True
csObj.Aggregate("Historic").Enable = True

End Sub
End Module

 

Thanks,

See Answer In Context

Reply
Contact Support

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

Replies 7
BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2020-02-23 10:09 PM

0 Likes
6
2955
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-23 10:09 PM


Is reflection still need in .NET Framework version 4.x now that dynamic exists?

dynamic can dynamically 'cast' a type at runtime, and then allows for the methods / properties of this to be accessed (if they exist) at run time.  But in doing so it throws away all compile time checks related to the object.

So for the example given, it could likely be replaced with a dynamic reference.  Although I haven't tested this myself.

 

I would say that utilising static cast object and then invoking reflection only as needed is still probably my preferred way.  It provides improved 'type safety' early on, when writing the code, rather than relying on getting it right when it comes to runtime.

 

 


From this line ScxV6DbClient.ScxV6Object O = S.FindObject( "New Analogue Point" );

what is S? How is it created/assigned?


S is a reference to the ScxV6DbClient.ScxV6Server object.  It's the job of the reader to have already correctly defined this variable, and connected the connection etc etc.

 

 

Overall I would still recommend the .NET API in preference to the Automation Interface however.  It can be a little more annoying to get the initial system definition all worked out (having to manual load the Systems.xml file is annoying compared to just being able to enumerate an ScxV6System ala Automation Interface), but that becomes cookie cutter stuff after the first time, and accessing objects etc via .NET API is much nicer.


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..
Reply
Contact Support

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

sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2020-02-24 12:51 AM

In response to BevanWeiss
0 Likes
5
2947
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 12:51 AM

There is an example of using the .Net Client library here:

https://github.com/ClearSCADA/utility-examples

 

Perhaps you can share sample code for reading system names and getting valid connection parameters from the systems.xml?

 

Thanks.

 

Reply
Contact Support

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

DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander

Posted: ‎2020-02-24 09:12 PM

In response to sbeadle
0 Likes
3
2917
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 09:12 PM

Hi Gents, I went over to VB and the code below works for me and I can change it further to fit my requirements.

 

Imports System
Imports Microsoft.SqlServer
Imports ScxV6DbClient

Module Program
Sub Main(args As String())

Dim Svr As ScxV6DbClient.ScxV6Server
Svr = New ScxV6DbClient.ScxV6Server
Svr.Connect("XXXXXXXXX", "XXXX", "XXXXXXXX")

Dim csObj As ScxV6Object
csObj = Svr.FindObject("New Analog Point")


Dim csAgg As ScxV6Aggregate
csAgg = csObj.Aggregate("Historic")
csAgg.Enable = True
csObj.Aggregate("Historic").Enable = True

End Sub
End Module

 

Thanks,

Reply
Contact Support

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

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2020-02-24 09:45 PM

In response to DavidSkilbeck
0 Likes
2
2911
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 09:45 PM

Seriously?!?

You're marking your own post on Visual Basic as 'the solution' to how to use the Automation Interface with C#?

Your 'solution' didn't address your question on 'dynamic', or reflection, or what 'S' is.

 

And your VB example doesn't even deal with calling methods.

C# can trivially do all that your VB example does.  None of this is 'dynamic', or late bound invocation.

 

ScxV6Server Svr = new ScxV6DbClient.ScxV6Server();
Svr.Connect("XXXXXXXXX", "XXXX", "XXXXXXXX");

ScxV6Object csObj = Svr.FindObject("New Analog Point");

ScxV6Aggregate csAgg = csObj.Aggregate["Historic"];
csAgg.Enable = true;
csObj.Aggregate["Historic"].Enable = true;


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..
Reply
Contact Support

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

DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander

Posted: ‎2020-02-24 10:19 PM

In response to BevanWeiss
0 Likes
1
2905
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 10:19 PM

Hi Bevan,

your code locks the enable option up. So it cannot be manually changed with GeoSCADA.

The point has to be deleted.

Have you missed something.

 

Thanks,

Reply
Contact Support

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

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2020-02-24 10:24 PM

In response to DavidSkilbeck
0 Likes
0
2902
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 10:24 PM

'my' code is line for line equivalent to 'your' code, so it does everything that 'your' code does.

i.e. whilst run it sets the Historic Aggregate Enable flag (twice).


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..
Reply
Contact Support

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

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2020-02-24 11:03 PM

In response to sbeadle
0 Likes
0
2898
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • 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: ‎2020-02-24 11:03 PM

@sbeadle 

I don't have access to my cookie materials anymore, since I changed bakeries...

 

In all honesty I typically just grabbed the list of ServerNodes, and then in sequence tried to connect to them.  But the code below should be 'better' (but untested).

It would be really nice if the .NET API started to use some of the async stuff.

It would be nice if we could just await a connection once we setup the System Monitor.

If some async stuff was pushed into the .NET API, it would probably help to improve some of the performance issues I've seen with ViewX when not all nodes are available.

Really, so much of ViewX operation should be aync. 

    class Program
    {
        private static ClearScada.Client.Advanced.IServer server;
        private static EventWaitHandle waiter;


        static void Main(string[] args)
        {
            ServerSystemCollection systems;
            NetworkCredential credentials;

            using (XmlReader reader = XmlReader.Create(
                Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                    "Schneider Electric",
                    "ClearSCADA",
                    "Systems.xml")))
            {
                systems = new ServerSystemCollection(reader);
            }

            ServerSystem system = systems["TestSystem"];
            ServerSystemMonitor monitor = new ServerSystemMonitor(system);
            // obviously don't look at the password below... it's definitely secure.  Ideally this should never
            // be stored in this way, it should be parsed directly into a SecureString and stored that way forever
            credentials = new NetworkCredential("TestUser", "TestPassword");
            monitor.SetProvisionalLogOnCredentials(credentials.UserName, credentials.SecurePassword);
            monitor.PreferredNodeChanged += Monitor_PreferredNodeChanged;
            monitor.Start(false);

            waiter = new EventWaitHandle(false, EventResetMode.ManualReset);

            // we'll just go away and do some other stuff until we're told that a preferred node is available
            // we should probably do something if we get bored of waiting here...
            waiter.WaitOne(Timeout.Infinite);

            // I think we need to log on again
            server.LogOn(credentials.UserName, credentials.SecurePassword);

            // and then we can create the objects we care so much about
            server.CreateObject("CDBPoint", ObjectId.Root, "Cat");

        }

        private static void Monitor_PreferredNodeChanged(object sender, ServerNodeEventArgs e)
        {
            if(e.State.State == ServerState.Main || e.State.State == ServerState.Standby)
            {
                server = e.Node.Connect("TestApp", false);
                waiter.Set();
            }
        }
    }

 


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..
Reply
Contact Support

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

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
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