Sign In Help
Schneider Electric
HelpSign In
Schneider Electric Exchange
  • Home
  • Collaborate
  • Develop
  • Shop
Home Collaborate Develop Shop Log in or Register Help

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
  • Collaborate
  • Exchange Community
  • :
  • SCADA & Telemetry Solutions
  • :
  • Geo SCADA Expert Forum
  • :
  • Using the Automation Interface with C(sharp)
Community Menu
  • Forums
    • By Topic
        • EcoStruxure IT
          • EcoStruxure IT forum
        • Industrial Automation
          • Industry Automation and Control Forum
          • Alliance System Integrators Forum
          • Machine Solutions in the Digital Transformation
          • 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
          • Форум по промышленной автоматизации СНГ
        • SCADA & Telemetry Solutions
          • Geo SCADA Expert Forum
          • SCADA and Telemetry Devices Forum
        • Power Distribution IEC
          • Power Distribution and Digital
          • Power Standards & Regulations
          • Paneelbouw & Energie Distributie
          • Eldistribution & Fastighetsautomation
        • Power Distribution Softwares
          • EcoStruxure Power Design Forum
          • SEE Electrical Building+ 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 IT
        • EcoStruxure IT forum
      • Industrial Automation
        • Industry Automation and Control Forum
        • Alliance System Integrators Forum
        • Machine Solutions in the Digital Transformation
        • 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
        • Форум по промышленной автоматизации СНГ
      • SCADA & Telemetry Solutions
        • Geo SCADA Expert Forum
        • SCADA and Telemetry Devices Forum
      • Power Distribution IEC
        • Power Distribution and Digital
        • Power Standards & Regulations
        • Paneelbouw & Energie Distributie
        • Eldistribution & Fastighetsautomation
      • Power Distribution Softwares
        • EcoStruxure Power Design Forum
        • SEE Electrical Building+ 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
        • Industrial Automation
          • Industrial Edge Computing Blog
          • Industry 4.0 Blog
          • Industrie du Futur France
        • SCADA & Telemetry Solutions
          • SCADA and Telemetry Blog
        • Power Distribution IEC
          • Power Events & Webinars
          • Power Foundations Blog
        • Power Distribution NEMA
          • NEMA Power Foundations Blog
        • Power Distribution Softwares
          • EcoStruxure Power Design Blog
          • SEE Electrical Building+ Blog
        • Solutions for your Business
          • Solutions for Food & Beverage Blog
          • Solutions for Healthcare Blog
          • Solutions for Retail Blog
        • Community experts & publishers
          • Publishers Community
    • By Segment
        • Food & Beverage
          • Solutions for Food & Beverage Blog
        • Healthcare
          • Solutions for Healthcare Blog
        • Retail
          • Solutions for Retail Blog
      • Industrial Automation
        • Industrial Edge Computing Blog
        • Industry 4.0 Blog
        • Industrie du Futur France
      • SCADA & Telemetry Solutions
        • SCADA and Telemetry Blog
      • Power Distribution IEC
        • Power Events & Webinars
        • Power Foundations Blog
      • Power Distribution NEMA
        • NEMA Power Foundations Blog
      • Power Distribution Softwares
        • EcoStruxure Power Design Blog
        • SEE Electrical Building+ Blog
      • Solutions for your Business
        • Solutions for Food & Beverage Blog
        • Solutions for Healthcare Blog
        • Solutions for Retail Blog
      • Community experts & publishers
        • Publishers Community
      • Food & Beverage
        • Solutions for Food & Beverage Blog
      • Healthcare
        • Solutions for Healthcare Blog
      • Retail
        • Solutions for Retail Blog
  • 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
Join 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: 
51132members
Join Now
245263posts
Join Now

Using the Automation Interface with C(sharp)

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
‎2020-02-23 09:54 PM
0 Likes
7
1068
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-23 09:54 PM

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://tprojects.schneider-electric.com/telemetry/display/public/CS/Using+the+Automation+Interface+...

 

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,

Solved! Go to Solution.

Labels
  • SCADA
Share
Reply

Accepted Solutions
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2020-02-24 09:12 PM
0 Likes
3
1026
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 09:12 PM

Re: Using the Automation Interface with C(sharp)

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

Share
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
7 Replies 7
BevanWeiss
Sisko BevanWeiss
Sisko
‎2020-02-23 10:09 PM
0 Likes
6
1065
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-23 10:09 PM

Re: Using the Automation Interface with C(sharp)


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..
Share
Reply
sbeadle
Sisko sbeadle Sisko
Sisko
‎2020-02-24 12:51 AM
0 Likes
5
1057
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 12:51 AM

Re: Using the Automation Interface with C(sharp)

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.

 

Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2020-02-24 09:12 PM
0 Likes
3
1027
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 09:12 PM

Re: Using the Automation Interface with C(sharp)

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

Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2020-02-24 09:45 PM
0 Likes
2
1020
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 09:45 PM

Re: Using the Automation Interface with C(sharp)

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..
Share
Reply
DavidSkilbeck
Lt. Commander DavidSkilbeck
Lt. Commander
‎2020-02-24 10:19 PM
0 Likes
1
1014
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 10:19 PM

Re: Using the Automation Interface with C(sharp)

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,

Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2020-02-24 10:24 PM
0 Likes
0
1011
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 10:24 PM

Re: Using the Automation Interface with C(sharp)

'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..
Share
Reply
BevanWeiss
Sisko BevanWeiss
Sisko
‎2020-02-24 11:03 PM
0 Likes
0
1007
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-02-24 11:03 PM

Re: Using the Automation Interface with C(sharp)

@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..
Share
Reply
Top Experts
User Count
sbeadle
Sisko sbeadle Sisko
188
BevanWeiss
Sisko BevanWeiss
52
AdamWoodland
Lt. Commander AdamWoodland Lt. Commander
16
JChamberlain
Lieutenant JChamberlain Lieutenant
16
AndrewScott
Lieutenant AndrewScott
15
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
©2020, Schneider Electric