コード例 #1
0
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        /// <param name="server">The interface that a server exposes to objects that it contains..</param>
        /// <param name="configuration">Configuration for the server.</param>
        /// <param name="dataBindings">Data bindings manager provides infrastructure to bind predefined nodes to the real data source.</param>
        public GenericNodeManager
        (
            Opc.Ua.Server.IServerInternal server, CASConfiguration configuration, DataBindingsManager dataBindings
        )
            : base(server)
        {
            m_SampleConfiguration = configuration;
            m_DataBindings        = dataBindings;
            List <FilePaths> m_allPredefinedNodesList = new List <FilePaths>();
            List <string>    nsList = new List <string>();

            foreach (ModelLayer ml in m_SampleConfiguration.CASExtension.ModelLayers)
            {
                nsList.Add(ml.NamespaceUri);
                m_allPredefinedNodesList.Add(new FilePaths(ml.FilePathUanodes, ml.FilePathCsv));
            }
            NamespaceUris        = nsList.ToArray();
            m_allPredefinedNodes = m_allPredefinedNodesList.ToArray();
            if (m_SampleConfiguration.CASExtension.ModelLayers != null && m_SampleConfiguration.CASExtension.ModelLayers.Length > 0)
            {
                TraceEvent.Tracer.TraceVerbose(52, this.GetType().Name + ".ctor", "m_namespaceIndex:" + m_SampleConfiguration.CASExtension.ModelLayers[0]);
                m_namespaceIndex = Server.NamespaceUris.GetIndexOrAppend(m_SampleConfiguration.CASExtension.ModelLayers[0].NamespaceUri);
            }
            else
            {
                TraceEvent.Tracer.TraceError(69, this.GetType().Name + ".ctor", "No namespaces are defined");
            }
            m_lastUsedId = 0;
        }
コード例 #2
0
        /// <summary>
        /// Initializes the server before it starts up.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <remarks>
        /// This method is called before any startup processing occurs. The sub-class may update the
        /// configuration object or do any other application specific startup tasks.
        /// </remarks>
        protected override void OnServerStarting(ApplicationConfiguration configuration)
        {
            //TODO Comiterop
            //Opc.Ua.Com.ComUtils.InitializeSecurity();
            CASConfiguration config = configuration as CASConfiguration;

            if (config == null)
            {
                throw new ArgumentNullException(typeof(CASConfiguration).FullName);
            }
            Utils.Trace("The server is starting and the configuration is loaded.");
            try
            {
                m_DataBindings = new CAS.UA.Server.DataBindings.DataBindingsManager();
                m_DataBindings.Initialize(config);
                m_DataBindings.Start();
            }
            catch (Exception ex)
            {
                TraceEvent.Tracer.TraceWarning(51, this.GetType().Name + ".OnServerStarting", "Unable to do the bindings: " + ex.Message);
                Utils.Trace("Unable to do the bindings: " + ex.Message);
            }
            base.OnServerStarting(configuration);
            // it is up to the application to decide how to validate user identity tokens.
            // this function creates validators for SAML and X509 identity tokens.
            CreateUserIdentityValidators(configuration);
        }
コード例 #3
0
 public void LoadTestMethod()
 {
     using (Main _MAIN = new Main())
     {
         FileInfo         _FileInfo      = new FileInfo(AssemblyInitializeClass.FilePath);
         CASConfiguration _configuration = CASConfiguration.Load(_FileInfo, ApplicationType.Server, typeof(CASConfiguration), false);
         Assert.IsNotNull(_configuration);
     }
 }
コード例 #4
0
 public void CheckApplicationInstanceCertificateNoGeneratorTestMethod1()
 {
     using (Main _main = new Main())
     {
         _main.CreateDefaultConfiguration();
         CASConfiguration _default = _main.Configuration;
         Assert.IsNotNull(_default);
         X509Certificate2 _certificate = ApplicationCertificate.CheckApplicationInstanceCertificate(_default, 1028, (x, y) => true, false);
     }
 }
コード例 #5
0
 public void DisplayUaTcpImplementationForDefaultConfigurationTest()
 {
     using (Main _main = new Main())
     {
         _main.CreateDefaultConfiguration();
         CASConfiguration _default  = _main.Configuration;
         string           _result   = null;
         string           _formText = "Form text";
         ApplicationCertificate.DisplayUaTcpImplementation(x => _result = x, _formText, _default);
         Assert.IsNull(_result);
     }
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstancesConfigurationDictionary"/> class from the configuration file.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public InstancesConfigurationDictionary(CASConfiguration configuration)
 {
     TraceEvent.Tracer.TraceVerbose(37, this.GetType().Name + ".InstancesConfigurationDictionary", "At creating process data binding dictionary");
     foreach (InstanceConfiguration item in configuration.CASExtension.NodesConfiguration)
     {
         string key = String.Format(m_KeyFormat, item.NodeDescriptor.NodeIdentifier.Namespace, item.NodeDescriptor.NodeIdentifier.Name);
         string _db = String.Format("{0}: {1}", item.NodeDescriptor, String.Join("'", item.DataSources == null ? new string[] { "No Defined" } :
                                                                                 item.DataSources.Select <DataSourceConfiguration, string>(x => x.ToString()).ToArray <string>()));
         TraceEvent.Tracer.TraceVerbose(37, "Add new item", String.Format("Key: {0} Binding: {1}", key, _db));
         this.Add(key, item);
     }
     TraceEvent.Tracer.TraceVerbose(37, this.GetType().Name + ".InstancesConfigurationDictionary", "Finished process data binding dictionary creation");
 }
コード例 #7
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            for (int ix = 0; ix < m_allPredefinedNodes.Length; ix++)
            {
                FileInfo fiPredifinedNodes = CASConfiguration.PreparePathBasedOnBaseDirectory(m_allPredefinedNodes[ix].PredefinedNodes);
                using (Stream reader = File.Open(fiPredifinedNodes.FullName, FileMode.Open))
                {
                    predefinedNodes.LoadFromBinary(context, reader, true);
                }
                FileInfo csvFi = CASConfiguration.PreparePathBasedOnBaseDirectory(m_allPredefinedNodes[ix].CSVFile);
                m_DataBindings.LoadIdentifiersFromFile(csvFi.FullName);
            }
            return(predefinedNodes);
        }
コード例 #8
0
 /// <summary>
 /// Initializes all process data sources.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public void Initialize(CASConfiguration configuration)
 {
     m_SimulatorDictionary = new Simulator.SimulatorDictionary();
     //TODO - initialize and setup m_ExtrernalDataSource
     try
     {
         if (!string.IsNullOrEmpty(configuration.CASExtension.CommServer.FileName))
         {
             m_CommServer.Initialize(CASConfiguration.PreparePathBasedOnBaseDirectory(configuration.CASExtension.CommServer.FileName).FullName);
         }
     }
     catch (FileNotFoundException ex)
     {
         TraceEvent.Tracer.TraceError(69, this.GetType().Name + ".Initialize",
                                      "Unable to find CommServer communication engine configuration file: " + ex.Message);
     }
     catch (Exception ex)
     {
         TraceEvent.Tracer.TraceWarning(74, this.GetType().Name + ".Initialize",
                                        "Unable to create CommServer communication engine: " + ex.ToString());
     }
     try
     {
         m_OPCDAClient = new Client(CASConfiguration.PreparePathBasedOnBaseDirectory(configuration.CASExtension.OPCDAClient.FileName).FullName);
     }
     catch (FileNotFoundException ex)
     {
         TraceEvent.Tracer.TraceError(83, this.GetType().Name + ".Initialize",
                                      "Unable to find OPC client configuration file: " + ex.Message);
     }
     catch (Exception ex)
     {
         TraceEvent.Tracer.TraceWarning(88, this.GetType().Name + ".Initialize",
                                        "Unable to create OPC client: " + ex.ToString());
     }
     try
     {
         m_InstancesConfigurationDictionary = new InstancesConfigurationDictionary(configuration);
     }
     catch (Exception ex)
     {
         TraceEvent.Tracer.TraceWarning(98, this.GetType().Name + ".Initialize",
                                        "Unable to create InstancesConfigurationDictionary: " + ex.Message);
     }
 }
コード例 #9
0
        public void ConstructorTestMethod()
        {
            CASConfiguration _newConfiguration = new CASConfiguration();

            Assert.IsNull(_newConfiguration.CASExtension);
        }