Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
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.
Send Invite Cancel
84650members
353993posts

.NET API to query ClearSCADA View

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

Solved
Kan
Ensign
Ensign
0 Likes
3
1629

.NET API to query ClearSCADA View

Hello! I need to replicate some logic in ClearSCADA code in .NET. The scada code selects values from a View and does some processing.


Does anyone know what API calls can query the View and get its data? Thanks a lot.


Accepted Solutions
sbeadle
Janeway Janeway
Janeway
0 Likes
2
1623

Re: .NET API to query ClearSCADA View

What do you mean by a View - a SQL query?

 

An SQL query can be made on the .Net API using the Advanced connection type.

 

// Non-working code as an example:
                var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);

                AdvConnection = node.Connect("mytest", false); // New type argument
                using (var spassword = new System.Security.SecureString())
                {
                    foreach (var c in password)
                    {
                        spassword.AppendChar(c);
                    }

                    AdvConnection.LogOn(user, spassword);
                }
// Fix indenting!
			Int32 result = 0;
                        String sql = "select id from cgroup"
			// Find the database reference of the thing
			ClearScada.Client.Advanced.IQuery serverQuery = AdvConnection.PrepareQuery(sql, new ClearScada.Client.Advanced.QueryParseParameters());
			ClearScada.Client.Advanced.QueryResult queryResult = serverQuery.ExecuteSync(new ClearScada.Client.Advanced.QueryExecuteParameters());

			if (queryResult.Status == ClearScada.Client.Advanced.QueryStatus.Succeeded || queryResult.Status == ClearScada.Client.Advanced.QueryStatus.NoDataFound)
			{
				if (queryResult.Rows.Count > 0)
				{
					// Found
					IEnumerator<ClearScada.Client.Advanced.QueryRow> e = queryResult.Rows.GetEnumerator();
					while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}
				}
			}
			serverQuery.Dispose();

See Answer In Context

Tags (1)
3 Replies 3
sbeadle
Janeway Janeway
Janeway
0 Likes
2
1624

Re: .NET API to query ClearSCADA View

What do you mean by a View - a SQL query?

 

An SQL query can be made on the .Net API using the Advanced connection type.

 

// Non-working code as an example:
                var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);

                AdvConnection = node.Connect("mytest", false); // New type argument
                using (var spassword = new System.Security.SecureString())
                {
                    foreach (var c in password)
                    {
                        spassword.AppendChar(c);
                    }

                    AdvConnection.LogOn(user, spassword);
                }
// Fix indenting!
			Int32 result = 0;
                        String sql = "select id from cgroup"
			// Find the database reference of the thing
			ClearScada.Client.Advanced.IQuery serverQuery = AdvConnection.PrepareQuery(sql, new ClearScada.Client.Advanced.QueryParseParameters());
			ClearScada.Client.Advanced.QueryResult queryResult = serverQuery.ExecuteSync(new ClearScada.Client.Advanced.QueryExecuteParameters());

			if (queryResult.Status == ClearScada.Client.Advanced.QueryStatus.Succeeded || queryResult.Status == ClearScada.Client.Advanced.QueryStatus.NoDataFound)
			{
				if (queryResult.Rows.Count > 0)
				{
					// Found
					IEnumerator<ClearScada.Client.Advanced.QueryRow> e = queryResult.Rows.GetEnumerator();
					while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}
				}
			}
			serverQuery.Dispose();
Tags (1)
Kan
Ensign
Ensign
0 Likes
0
1619

Re: .NET API to query ClearSCADA View

Hi sbeadle,

 

Thanks heaps for answering my question.

 

I tried your solution and it works! The view in my question refers to the Historic Views defined in Historic Configuration.

 

Thank you again and have a nice day!

 

Kan

Tags (1)
BevanWeiss
Spock
Spock
0 Likes
0
1605

Re: .NET API to query ClearSCADA View

Hey Steve,

 

That's quite some old style enumerator iteration there

while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}

 

You're not a fan of the 'foreach'?

There's really so much more power in the .NET stuff around this, like doing processing in parallel..


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 (1)