EcoStruxure Geo SCADA Expert Forum
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-15 06:57 AM
Hi, I would like to find out which node is the main server. I wrote this code but the state (by monitor.GetNodeState) is always null:
static void Main(string[] args)
{
var credentials = new NetworkCredential("myusername", "mypw");
ServerNode mainNode;
ServerSystemCollection systems = new ServerSystemCollection();
using (XmlReader reader = XmlReader.Create(@"\\geoscadaweb\c$\ProgramData\Schneider Electric\ClearSCADA\Systems.xml"))
{
systems = new ServerSystemCollection(reader);
}
ServerSystem system = systems["GEOSCADA"];
ServerSystemMonitor monitor = new ServerSystemMonitor(system);
monitor.Start(false);
monitor.SetProvisionalLogOnCredentials(credentials.UserName, credentials.SecurePassword);
foreach (var node in system.Nodes)
{
var state = monitor.GetNodeState(node);
if (state != null && state.State == ServerState.Main)
{
mainNode = node;
break;
}
}
monitor.Stop();
}
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-18 02:30 AM
I suggest you look this up in the Object Browser for the .Net API:
ClearScada.Client.ServerStateDetails GetServerState()
Member of ClearScada.Client.Advanced.IServer
Summary:
Gets the current state of the server.
Returns:
The current server state.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-18 02:30 AM
I suggest you look this up in the Object Browser for the .Net API:
ClearScada.Client.ServerStateDetails GetServerState()
Member of ClearScada.Client.Advanced.IServer
Summary:
Gets the current state of the server.
Returns:
The current server state.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-18 10:20 PM
Thank you Sbeadle! It works! It's fantastic!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClearScada.Client;
using ClearScada.Client.Simple;
using System.Security;
using System.Net;
using System.Xml;
..........
var credentials = new NetworkCredential("myUser", "myPWD");
ServerNode mainNode;
ServerSystemCollection systems = new ServerSystemCollection();
using (XmlReader reader = XmlReader.Create(@"\\geoscadaweb\c$\ProgramData\Schneider Electric\ClearSCADA\Systems.xml"))
{
systems = new ServerSystemCollection(reader);
}
ServerSystem system = systems["GEOSCADA"];
Connection conn = new Connection("TestApp");
foreach (var node in system.Nodes)
{
if (node != null && !node.IsWebserver)
{
ServerNode serverNode = new ClearScada.Client.ServerNode(node.HostName, node.Port);
conn.Connect(serverNode);
var state = conn.Server.GetServerState();
if (state != null && state.State == ServerState.Main)
{
mainNode = node;
break;
}
conn.Disconnect();
}
}
//Connected with main Server
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-28 03:17 PM
And thank you for providing example code for the next person to use!
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-05-01 02:42 AM
You are welcome! That's the goal of a community! 😁
Link copied. Please paste this link to share this article on your social media post.
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.