예제 #1
0
        public void ModelDesignTest()
        {
            OpcUaModelCompiler.ModelDesign _node = new OpcUaModelCompiler.ModelDesign()
            {
                AnyAttr                        = null,
                DefaultLocale                  = null,
                Items                          = null,
                Namespaces                     = new OpcUaModelCompiler.Namespace[] { },
                TargetNamespace                = "TargetNamespace",
                TargetPublicationDate          = DateTime.Today,
                TargetPublicationDateSpecified = false,
                TargetVersion                  = "TargetVersion",
                TargetXmlNamespace             = "TargetXmlNamespace"
            };
            ModelDesign _model = new ModelDesign(_node);

            Assert.IsNull(_model.AnyAttr);
            Assert.IsNull(_model.DefaultLocale);
            Assert.IsNull(_model.Parent);
            Assert.AreEqual <string>("TargetNamespace", _model.TargetNamespace);
            Assert.IsFalse(_model.TargetPublicationDate.HasValue);
            Assert.AreEqual <string>("TargetVersion", _model.TargetVersion);
            Assert.AreEqual <string>("TargetXmlNamespace", _model.TargetXmlNamespace);
            OpcUaModelCompiler.ModelDesign _nodeExported = _model.Update();
            Assert.IsNotNull(_nodeExported);
            Assert.IsNull(_nodeExported.AnyAttr);
            Assert.IsNull(_nodeExported.DefaultLocale);
            Assert.IsNull(_nodeExported.Items);
            Assert.IsNull(_nodeExported.Namespaces);
            Assert.AreEqual <string>("TargetNamespace", _nodeExported.TargetNamespace);
            Assert.IsFalse(_nodeExported.TargetPublicationDateSpecified);
            Assert.AreEqual <string>("TargetVersion", _nodeExported.TargetVersion);
            Assert.AreEqual <string>("TargetXmlNamespace", _nodeExported.TargetXmlNamespace);
        }
예제 #2
0
 internal NamespacesFolder(OpcUaModelCompiler.ModelDesign child) : base("Namespaces", WrapperResources.NamespaceFolderToolTipText)
 {
     TypesAvailableToBePasted.Add(typeof(OpcUaModelCompiler.Namespace));
     if (child.Namespaces == null || child.Namespaces.Length == 0)
     {
         return;
     }
     foreach (OpcUaModelCompiler.Namespace ns in child.Namespaces)
     {
         this.Add(new Namespace(ns));
     }
 }
예제 #3
0
 private void InitializeTypes()
 {
     try
     {
         AssemblyTraceEvent.Tracer.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 37, "Loading the OPC UA Defined Types.");
         OpcUaModelCompiler.ModelDesign _modelTypes = UAResources.LoadUADefinedTypes(); //TODO UAModelDesignExport must provide also ModelDesign but not only export to a file. #498
         if (Properties.Settings.Default.OnlyItemsInAddressSpace)
         {
             _modelTypes.Items = _modelTypes.Items.Where <OpcUaModelCompiler.NodeDesign>((x) => { OpcUaModelCompiler.DataTypeDesign _dt = x as OpcUaModelCompiler.DataTypeDesign; return(_dt == null ? true : !_dt.NotInAddressSpace); }).ToArray <OpcUaModelCompiler.NodeDesign>();
             AssemblyTraceEvent.Tracer.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 41, "Removed DataTypeDesign items not belonging to the model.");
         }
         AssemblyTraceEvent.Tracer.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 37, "Creating the LibraryTreeNode containing standard model");
         Add(new LibraryTreeNode(_modelTypes, "UA Defined Types"));
     }
     catch (Exception _ex)
     {
         string _tmp = "Cannot load Defined OPC UA Types in {0} from {1} because of error {2}";
         AssemblyTraceEvent.Tracer.TraceEvent(System.Diagnostics.TraceEventType.Critical, 37, _tmp, typeof(Libraries).FullName, typeof(UAResources), _ex.Message);
     }
 }
예제 #4
0
        internal LibraryTreeNode(OpcUaModelCompiler.ModelDesign config, string nodeName)
            : base(nodeName)
        {
            List <OpcUaModelCompiler.NodeDesign> _nodes = new List <OpcUaModelCompiler.NodeDesign>();

            if (config.Items != null)
            {
                _nodes.AddRange(config.Items);
                _nodes.Sort((x, y) =>
                {
                    int _ret = x.GetType().Name.CompareTo(y.GetType().Name);
                    if (_ret == 0)
                    {
                        _ret = x.SymbolicName.Name.CompareTo(y.SymbolicName.Name);
                    }
                    return(_ret);
                });
                config.Items = _nodes.ToArray();
            }
            ModelDesign m_ModelDesignTypes = new ModelDesign(config, true);

            Add(m_ModelDesignTypes);
        }