/// <summary> /// Add all available node manager factories to the server. /// </summary> public static void AddDefaultNodeManagers(StandardServer server) { foreach (var nodeManagerFactory in NodeManagerFactories) { server.AddNodeManager(nodeManagerFactory); } }
/// <summary> /// Initializes a new instance of the <see cref="ServerContext"/> class. /// </summary> /// <param name="server">The server.</param> /// <param name="configuration">The configuration.</param> /// <param name="serverSocket">The server socket.</param> internal ServerContext(StandardServer server, IServerConfiguration configuration, Socket serverSocket) { this.ListeningSocket = serverSocket; this.Server = server; this.windowsServer = server; this.Configuration = configuration; }
public void Initialize(StandardServer server, ApplicationConfiguration configuration, ApplicationInstance application) { m_server = server; m_configuration = configuration; m_application = application; ComboBox adlist = new ComboBox(); foreach (EndpointDescription endpoint in m_server.GetEndpoints()) { if (adlist.FindStringExact(endpoint.EndpointUrl) == -1) { adlist.Items.Add(endpoint.EndpointUrl); } } TCP_Adresss_Label.Text = "(" + adlist.Items[0].ToString() + ")"; // if (adlist.Items[1] != null) // { // HTTPS_Address_Label.Text = "(" + adlist.Items[1].ToString() + ")"; // HTTPS_AddressTB.Text = adlist.Items[1].ToString(); // } UA_AddressTB.Text = adlist.Items[0].ToString(); CheckPolicies(m_configuration); // m_configuration.ServerConfiguration.BaseAddresses. }
/// <summary> /// Create new instance of <see cref="OpcUaServerHelper"/> /// </summary> /// <param name="server"></param> /// <param name="port"></param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> public OpcUaServerHelper(StandardServer server, int port) { this.Server = server ?? throw new ArgumentNullException(nameof(server)); this.Port = port == 0 ? throw new ArgumentException(nameof(port)) : port; }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> /// <param name="server">The server displayed in the form.</param> /// <param name="configuration">The configuration used to initialize the server.</param> public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; m_dispatcherTimer = new DispatcherTimer(); m_dispatcherTimer.Tick += UpdateTimerCTRL_Tick; m_dispatcherTimer.Interval = new TimeSpan(0, 0, 5); // tick every 5 seconds m_dispatcherTimer.Start(); // add the urls to the drop down. UrlCB.Items.Clear(); foreach (EndpointDescription endpoint in m_server.GetEndpoints()) { if (!UrlCB.Items.Contains(endpoint.EndpointUrl)) { UrlCB.Items.Add(endpoint.EndpointUrl); } } if (UrlCB.Items.Count > 0) { UrlCB.SelectedIndex = 0; } }
public MinimalServerMainForm() { InitializeComponent(); _config = CreateOpcUaAppConfiguration(); CheckApplicationInstanceCertificate(_config); _server = new StandardServer(); _server.Start(_config); UrlCB.Items.Clear(); foreach (EndpointDescription endpoint in _server.GetEndpoints()) { if (UrlCB.FindStringExact(endpoint.EndpointUrl) == -1) { UrlCB.Items.Add(endpoint.EndpointUrl); } } if (UrlCB.Items.Count > 0) { UrlCB.SelectedIndex = 0; } }
public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; User_PasswordLV.Enabled = true; User_PasswordLV.FullRowSelect = true; CertificateKeyLV.Enabled = true; CertificateKeyLV.FullRowSelect = true; AnonymousCkB.Checked = false; UserPassCkB.Checked = false; CertificateCkb.Checked = false; foreach (UserTokenPolicy userToken in m_configuration.ServerConfiguration.UserTokenPolicies) { if (userToken.TokenType == UserTokenType.Anonymous) { AnonymousCkB.Checked = true; } if (userToken.TokenType == UserTokenType.UserName) { UserPassCkB.Checked = true; } if (userToken.TokenType == UserTokenType.Certificate) { CertificateCkb.Checked = true; } } }
/// <summary> /// Initializes the server and game. /// </summary> /// <param name="startedCallback">The callback to invoke when initalization is completed.</param> public Task Initialize() { // Server setup IServerConfiguration serverConfig = new ServerConfiguration(); serverConfig.Port = 2000; var server = new StandardServer(new TestPlayerFactory(), new ConnectionFactory()); server.Configure(serverConfig); server.Owner = "@Scionwest"; this.Server = server; // Commanding setup var commandManager = new CommandManager(); commandManager.Configure(new CommandingConfiguration(new CommandFactory(new Type[] { typeof(LoginCommand), typeof(WalkCommand) }))); IGameConfiguration gameConfig = new GameConfiguration(); gameConfig.UseAdapter(server); gameConfig.UseAdapter(commandManager); IGame game = new MudGame(); game.Configure(gameConfig); this.Game = game; return(game.StartAsync()); }
public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; UpdateSessions(); UpdateTimerCtrl.Enabled = true; SessionsLV.Enabled = true; }
public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); m_server = server; m_configuration = configuration; this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration); TrayIcon.Text = this.Text = m_configuration.ApplicationName; }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> /// <param name="server">The server displayed in the form.</param> /// <param name="configuration">The configuration used to initialize the server.</param> public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; BrowseTreeView.Nodes.Clear(); AttributesView.Items.Clear(); BrowseTreeView.Enabled = true; AttributesView.Enabled = true; PopulateBranch(ObjectIds.RootFolder, BrowseTreeView.Nodes); }
/// <summary> /// Initializes a new instance of the <see cref="ServerForm"/> class. /// </summary> /// <param name="server">The server.</param> /// <param name="configuration">The configuration.</param> /// <param name="application">The application.</param> public ServerForm(StandardServer server, ApplicationConfiguration configuration, CASApplicationInstance application) { InitializeComponent(); m_application = application; m_server = server; this.ServerDiagnosticsCTRL.Initialize(m_server, configuration); ApplicationCertificate.DisplayUaTcpImplementation(x => this.Text = x, this.Text, configuration); m_server.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); TrayIcon.Text = this.Text; }
/// <summary> /// Initializes a new instance of the <see cref="AsyncPublishOperation"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="request">The request.</param> /// <param name="server">The server.</param> public AsyncPublishOperation( OperationContext context, IEndpointIncomingRequest request, StandardServer server) { m_context = context; m_request = request; m_server = server; m_response = new PublishResponse(); m_request.Calldata = this; }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); m_server = server; m_configuration = configuration; this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration); TrayIcon.Text = this.Text = m_configuration.ApplicationName; this.Icon = TrayIcon.Icon = ConfigUtils.GetAppIcon(); }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); m_server = server; m_configuration = configuration; this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration); //TrayIcon.Text = this.Text = m_configuration.ApplicationName; //ComponentResourceManager resources = new ComponentResourceManager(typeof(ServerForm)); //TrayIcon.Icon = (Icon)(resources.GetObject("App.ico")); }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); m_server = server; m_configuration = configuration; this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration); TrayIcon.Text = this.Text = m_configuration.ApplicationName; ComponentResourceManager resources = new ComponentResourceManager(typeof(ServerForm)); TrayIcon.Icon = (Icon)(resources.GetObject("App.ico")); }
private void Form1_Load(object sender, EventArgs e) { // 配置opc ua的日志输出 Opc.Ua.Utils.SetTraceLog(Application.StartupPath + @"\Logs\Opc.Ua.Huibo.txt", true); Opc.Ua.Utils.SetTraceMask(515); // http://117.48.203.204:62547/DataAccessServer // opc.tcp://localhost:62547/DataAccessServer server = new OpcUaServer("opc.tcp://localhost:62547/DataAccessServer", new DataAccessServer());//117.48.203.204 StandardServer server2 = server.AppInstance.Server as StandardServer; dataAccessServer = server.AppInstance.Server as DataAccessServer; serverDiagnosticsCtrl1.Initialize(server2, server.AppConfig); }
public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); this.Icon = this.TrayIcon.Icon = ClientUtils.GetAppIcon(); GuiUtils.DisplayUaTcpImplementation(this, configuration); m_server = server; if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates) { m_server.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); } }
public ServerForm_Next(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); timer1.Enabled = true; m_server = server; m_configuration = configuration; this.statusCtrl1.Initialize(m_server, m_configuration); this.endpointCtrl1.Initialize(m_server, m_configuration, m_application); this.sessionCtrl1.Initialize(m_server, m_configuration); this.addressSpaceCtrl1.Initialize(m_server, m_configuration); this.usersCtrl1.Initialize(m_server, m_configuration); // TrayIcon.Text = this.Text = m_configuration.ApplicationName; // this.Icon = TrayIcon.Icon = ServerUtils.GetAppIcon(); }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> public ServerForm(StandardServer server, ApplicationConfiguration configuration) { InitializeComponent(); m_server = server; m_configuration = configuration; this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration); if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates) { configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); } TrayIcon.Text = this.Text = m_configuration.ApplicationName; this.Icon = TrayIcon.Icon = ServerUtils.GetAppIcon(); }
private void TrayIcon_MouseMove(object sender, MouseEventArgs e) { try { StandardServer server = m_application.Server as StandardServer; if (server != null) { TrayIcon.Text = String.Format( "{0} [{1} {2:HH:mm:ss}]", m_application.ApplicationName, server.CurrentInstance.CurrentState, DateTime.Now); } } catch (Exception exception) { Utils.Trace(exception, "Error getting server status."); } }
/// <summary> /// Initializes the server and game. /// </summary> /// <param name="startedCallback">The callback to invoke when initalization is completed.</param> public void Initialize(Action<IGame, StandardServer> startedCallback) { var serverConfig = new ServerConfiguration(); var server = new StandardServer(new TestPlayerFactory(), new ConnectionFactory()); server.Configure(serverConfig); server.Owner = "@Scionwest"; this.Server = server; var gameConfig = new GameConfiguration(); gameConfig.UseAdapter(server); var game = new MudGame(); game.Configure(gameConfig); this.Game = game; game.BeginStart(runningGame => startedCallback(runningGame, server)); }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> /// <param name="server">The server displayed in the form.</param> /// <param name="configuration">The configuration used to initialize the server.</param> public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; UpdateTimerCtrl.Enabled = true; ComboBox adlist = new ComboBox(); foreach (EndpointDescription endpoint in m_server.GetEndpoints()) { if (adlist.FindStringExact(endpoint.EndpointUrl) == -1) { adlist.Items.Add(endpoint.EndpointUrl); } } TCP_Adresss_Label.Text = adlist.Items[0].ToString(); // if (adlist.Items[1] != null) HTTPS_Address_Label.Text = adlist.Items[1].ToString(); StartingTimeLabel.Text = String.Format("{0:HH:mm:ss dd/MM/yyyy}", DateTime.Now); }
/// <summary> /// Applies custom settings to quickstart servers for CTT run. /// </summary> /// <param name="server"></param> public static void ApplyCTTMode(TextWriter output, StandardServer server) { var methodsToCall = new CallMethodRequestCollection(); var index = server.CurrentInstance.NamespaceUris.GetIndex(Alarms.Namespaces.Alarms); if (index > 0) { try { methodsToCall.Add( // Start the Alarms with infinite runtime new CallMethodRequest { MethodId = new NodeId("Alarms.Start", (ushort)index), ObjectId = new NodeId("Alarms", (ushort)index), InputArguments = new VariantCollection() { new Variant((UInt32)UInt32.MaxValue) } }); var requestHeader = new RequestHeader() { Timestamp = DateTime.UtcNow, TimeoutHint = 10000 }; var context = new OperationContext(requestHeader, RequestType.Call); server.CurrentInstance.NodeManager.Call(context, methodsToCall, out CallMethodResultCollection results, out DiagnosticInfoCollection diagnosticInfos); foreach (var result in results) { if (ServiceResult.IsBad(result.StatusCode)) { Opc.Ua.Utils.LogError("Error calling method {0}.", result.StatusCode); } } output.WriteLine("The Alarms for CTT mode are active."); return; } catch (Exception ex) { Opc.Ua.Utils.LogError(ex, "Failed to start alarms for CTT."); } } output.WriteLine("The alarms could not be enabled for CTT, the namespace does not exist."); }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> /// <param name="server">The server displayed in the form.</param> /// <param name="configuration">The configuration used to initialize the server.</param> public void Initialize(StandardServer server, ApplicationConfiguration configuration) { m_server = server; m_configuration = configuration; UpdateTimerCTRL.Enabled = true; // add the urls to the drop down. UrlCB.Items.Clear(); foreach (EndpointDescription endpoint in m_server.GetEndpoints()) { if (UrlCB.FindStringExact(endpoint.EndpointUrl) == -1) { UrlCB.Items.Add(endpoint.EndpointUrl); } } if (UrlCB.Items.Count > 0) { UrlCB.SelectedIndex = 0; } }
/// <summary> /// 实例化一个 <see cref="OpcUaServer"/> 对象 /// </summary> /// <param name="url"></param> /// <param name="standardServer">服务器的实例对象</param> public OpcUaServer(string url, StandardServer standardServer) { m_application = new ApplicationInstance(); m_application.ApplicationType = ApplicationType.Server; // load the application configuration. //application.LoadApplicationConfiguration(false); m_application.ApplicationConfiguration = GetDefaultConfiguration(url); // check the application certificate. m_application.CheckApplicationInstanceCertificate(false, 0); m_server = standardServer ?? throw new ArgumentNullException("standardServer"); // start the server. m_application.Start(m_server); m_configuration = m_application.ApplicationConfiguration; }
private ReferenceDescriptionCollection Browse(StandardServer server, BrowseDescriptionCollection nodesToBrowse, bool throwOnError) { try { ReferenceDescriptionCollection references = new ReferenceDescriptionCollection(); BrowseDescriptionCollection unprocessedOperations = new BrowseDescriptionCollection(); while (nodesToBrowse.Count > 0) { // start the browse operation. OperationContext context = new OperationContext(new RequestHeader(), RequestType.Browse); BrowseResultCollection results = null; DiagnosticInfoCollection diagnosticInfos = null; server.CurrentInstance.NodeManager.Browse( context, null, 0, nodesToBrowse, out results, out diagnosticInfos); ByteStringCollection continuationPoints = new ByteStringCollection(); for (int ii = 0; ii < nodesToBrowse.Count; ii++) { // check for error. if (StatusCode.IsBad(results[ii].StatusCode)) { // this error indicates that the server does not have enough simultaneously active // continuation points. This request will need to be resent after the other operations // have been completed and their continuation points released. if (results[ii].StatusCode == StatusCodes.BadNoContinuationPoints) { unprocessedOperations.Add(nodesToBrowse[ii]); } continue; } // check if all references have been fetched. if (results[ii].References.Count == 0) { continue; } // save results. references.AddRange(results[ii].References); // check for continuation point. if (results[ii].ContinuationPoint != null) { continuationPoints.Add(results[ii].ContinuationPoint); } } // process continuation points. ByteStringCollection revisedContiuationPoints = new ByteStringCollection(); while (continuationPoints.Count > 0) { // continue browse operation. server.CurrentInstance.NodeManager.BrowseNext( context, false, continuationPoints, out results, out diagnosticInfos); for (int ii = 0; ii < continuationPoints.Count; ii++) { // check for error. if (StatusCode.IsBad(results[ii].StatusCode)) { continue; } // check if all references have been fetched. if (results[ii].References.Count == 0) { continue; } // save results. references.AddRange(results[ii].References); // check for continuation point. if (results[ii].ContinuationPoint != null) { revisedContiuationPoints.Add(results[ii].ContinuationPoint); } } // check if browsing must continue; revisedContiuationPoints = continuationPoints; } // check if unprocessed results exist. nodesToBrowse = unprocessedOperations; } // return complete list. return(references); } catch (Exception exception) { if (throwOnError) { throw new ServiceResultException(exception, StatusCodes.BadUnexpectedError); } return(null); } }
/// <summary> /// Creates a form which displays the status for a UA server. /// </summary> public ServerForm(StandardServer server, ApplicationConfiguration configuration) : base(server, configuration) { }