Example #1
0
 public override string GetFullName()
 {
     return(qualifiedName.ToString());
 }
Example #2
0
        /// <summary>
        /// Provides a mechanism to assemble a fully qualified Area name in a hierarchical space.
        /// </summary>
        /// <param name="szAreaName">The name of an Area at the current level, obtained from the string enumerator returned by BrowseOPCAreas with a BrowseFilterType of OPC_AREA</param>
        /// <param name="pszQualifiedAreaName">Where to return the resulting fully qualified area name.</param>
        public void GetQualifiedAreaName(string szAreaName, out string pszQualifiedAreaName)
        {
            pszQualifiedAreaName = String.Empty;

            try
            {
                pszQualifiedAreaName = szAreaName;
                // Make sure the stack is not null
                INode parent = m_browseStack.Peek();
                if (parent == null)
                {
                    throw ComUtils.CreateComException(ResultIds.E_FAIL);
                }

                // And make sure this is avalid Area name at the level
                INode child = FindChildByName(parent.NodeId, szAreaName);
                if (child == null)
                {
                    throw ComUtils.CreateComException(ResultIds.E_INVALIDARG);
                }
                pszQualifiedAreaName = "";
                INode[] stack = m_browseStack.ToArray();
                for (int i = stack.Length - 2; i >= 0; i--)
                {
                    // Translate the server namespace index in browsename to the corresponding client namespace index
                    QualifiedName QName = stack[i].BrowseName;
                    QualifiedName translatedName = new QualifiedName(QName.Name, (ushort)m_server.ServerMappingTable[QName.NamespaceIndex]);
                    if (pszQualifiedAreaName.Length != 0)
                        pszQualifiedAreaName = pszQualifiedAreaName + "/" + translatedName.ToString();
                    else
                        pszQualifiedAreaName = translatedName.ToString();
                }
                //Also translate the areaname
                QualifiedName QualifiedAreaName =  QualifiedName.Parse(szAreaName);
                QualifiedName TranslatedAreaName = new QualifiedName(QualifiedAreaName.Name, (ushort)m_server.ServerMappingTable[QualifiedAreaName.NamespaceIndex]);
                pszQualifiedAreaName = pszQualifiedAreaName + "/" + TranslatedAreaName.ToString();

            }
            catch (COMException e)
            {
                throw ComUtils.CreateComException(e);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error in GetQualifiedAreaName");
                throw ComUtils.CreateComException(e);
            }
        }
Example #3
0
        internal static bool CompareLastNVGDirectories(KnowledgeBase KB, IOutputService output)
        {
            try
            {
                bool     isSuccess        = true;
                string   pathNvg          = Path.Combine(Utility.SpcDirectory(KB), "NvgComparer");
                string   fileWildcard     = @"*.*";
                string[] Files            = Directory.GetDirectories(pathNvg, fileWildcard);
                string[] Last2directories = GetLast2Directorys(Files, output);
                int      cant_error       = 0;
                if (Last2directories == null || Last2directories.Length != 2)
                {
                    output.AddErrorLine("OcurriĆ³ un error procesando los directorios de navegaciones.");
                    output.AddErrorLine("AsegĆŗrece de que existen al menos dos directorios con nombres en el formato vĆ”lido (NVG-AAAA-MM-DD-HHMM)");
                }
                else
                {
                    output.AddLine("Se utilizarƔn los siguientes directorios para comparar:");
                    output.AddLine("-- " + Last2directories[0].ToString());
                    output.AddLine("-- " + Last2directories[1].ToString());
                    List <string> Diffs = EqualNavigationDirectories(Last2directories[0], Last2directories[1], output);
                    output.AddLine("-- Los directorios se procesaron correctamente.");
                    if (Diffs.Count > 0)
                    {
                        output.AddLine("-- Se encontraron diferencias en las navegaciones de los siguientes objetos:");
                        List <string> FilesDiff = new List <string>();
                        foreach (string x in Diffs)
                        {
                            string[]           objectnametype = Utility.ReadQnameTypeFromNVGFile(x, output);
                            string             filename       = Path.GetFileName(x);
                            string             objtype        = objectnametype[0];
                            string             objmodule      = objectnametype[1];
                            string             objname        = objectnametype[2];
                            KBObjectDescriptor kbod           = KBObjectDescriptor.Get(objtype);
                            QualifiedName      qname          = new QualifiedName(objmodule, objname);
                            //Null in HCIHisMo
                            KBObject obj = KB.DesignModel.Objects.Get(kbod.Id, qname);
                            if (obj != null)
                            {
                                if (obj.Timestamp <= Utility.GetDateTimeNVGDirectory(Last2directories[1].ToString()))
                                {
                                    FilesDiff.Add(filename);
                                    if (objmodule != "")
                                    {
                                        output.AddLine("-- ERROR " + objmodule + '.' + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                    else
                                    {
                                        output.AddLine("-- ERROR " + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }

                                    isSuccess = false;
                                    cant_error++;
                                }
                                else
                                {
                                    if (objmodule != "")
                                    {
                                        output.AddLine("-- -- OK " + objmodule + '.' + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                    else
                                    {
                                        output.AddLine("-- -- OK " + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                }
                            }
                            else
                            {
                                output.AddLine("-- NO SE ENCONTRO EL OBJETO: " + qname.ToString());
                            }
                        }
                        CopyDifferences(FilesDiff, Last2directories[0], Last2directories[1], "NvgErrors");
                    }
                    else
                    {
                        DeleteDifferenceDir(KB);
                        output.AddLine("No se encontraron diferencias en las navegaciones");
                    }
                }
                if (cant_error > 0)
                {
                    output.AddErrorLine("Se encontraron " + cant_error + " errores en la comparaciĆ³n.");
                }
                return(isSuccess);
            }
            catch (Exception e)
            {
                output.AddLine(e.Message);
                return(false);
            }
        }
Example #4
0
 public override string ToString() => _className.ToString();
Example #5
0
        public void NullPrefixAndNonEmptyNamespace()
        {
            QualifiedName name = new QualifiedName("root", "urn:my-uri", null);

            Assert.AreEqual("root [urn:my-uri]", name.ToString());
        }
Example #6
0
 public bool Matches(QualifiedName name)
 {
     return(this.Matches(name.ToString()));
 }
Example #7
0
        public void NameAndPrefixOnly()
        {
            QualifiedName name = new QualifiedName("root", String.Empty, "b");

            Assert.AreEqual("b:root", name.ToString());
        }
Example #8
0
        public void NullPrefix()
        {
            QualifiedName name = new QualifiedName("root", String.Empty, null);

            Assert.AreEqual("root", name.ToString());
        }
Example #9
0
        public void NameOnly()
        {
            QualifiedName name = new QualifiedName("root", String.Empty);

            Assert.AreEqual("root", name.ToString());
        }
Example #10
0
        public void NameNamespaceAndPrefix()
        {
            QualifiedName name = new QualifiedName("root", "urn:my-uri", "a");

            Assert.AreEqual("a:root [urn:my-uri]", name.ToString());
        }
Example #11
0
        public void EmptyQualifiedName()
        {
            QualifiedName name = new QualifiedName();

            Assert.AreEqual(String.Empty, name.ToString());
        }
 private string GetMetadataString(string componentType,
                                  ComponentName componentName,
                                  QualifiedName property)
 {
     return GetComponentMetadata(componentType, componentName)
         .GetString(property.ToString());
 }
Example #13
0
 public int CompareTo(QualifiedSelection other)
 {
     return(other.QualifiedName == QualifiedName
         ? Selection.CompareTo(other.Selection)
         : string.Compare(QualifiedName.ToString(), other.QualifiedName.ToString(), StringComparison.CurrentCultureIgnoreCase));
 }
Example #14
0
        public void RecalculateNodeIdsUANodeSetTest()
        {
            UANodeSet _toTest = new UANodeSet()
            {
                NamespaceUris = new string[] { @"http://cas.eu/UA/Demo/" },
                Aliases       = new NodeIdAlias[] { },
                Items         = new UANode[] { new UAObject()
                                               {
                                                   NodeId      = "ns=1;i=1",
                                                   BrowseName  = "1:NewUAObject",
                                                   DisplayName = new LocalizedText[] { new LocalizedText()
                                                                                       {
                                                                                           Value = "New UA Object"
                                                                                       } },
                                                   References = new Reference[]
                                                   {
                                                       new Reference()
                                                       {
                                                           ReferenceType = ReferenceTypeIds.HasTypeDefinition.ToString(), Value = ObjectTypeIds.BaseObjectType.ToString()
                                                       },
                                                       new Reference()
                                                       {
                                                           ReferenceType = ReferenceTypeIds.Organizes.ToString(), IsForward = false, Value = "i=85"
                                                       }
                                                   },
                                                   // UAInstance
                                                   ParentNodeId = string.Empty,
                                                   // UAObject
                                                   EventNotifier = 0x01,
                                               },
                                               new UAVariableType()
                                               {
                                                   NodeId      = "ns=1;i=1",
                                                   BrowseName  = "1:NewUAObject",
                                                   DisplayName = new LocalizedText[] { new LocalizedText()
                                                                                       {
                                                                                           Value = "New UA Object"
                                                                                       } },
                                                   References = new Reference[] {},
                                                   // UAObject
                                                   DataType = "ns=1;i=2",
                                               } }
            };
            Mock <IUAModelContext> _uAModelContext = new Mock <IUAModelContext>();

            _uAModelContext.Setup <string>(x => x.ImportNodeId(It.IsAny <string>())).Returns <string>
                (x =>
            {
                NodeId nodeId = NodeId.Parse(x);
                if (nodeId.NamespaceIndex == 1)
                {
                    nodeId.SetNamespaceIndex(10);
                }
                return(nodeId.ToString());
            });
            _uAModelContext.Setup <string>(x => x.ImportQualifiedName(It.IsAny <string>())).Returns <string>
                (x =>
            {
                QualifiedName nodeId = QualifiedName.Parse(x);
                if (nodeId.NamespaceIndex == 1)
                {
                    nodeId.NamespaceIndex = 10;
                }
                return(nodeId.ToString());
            });
            _toTest.Aliases = new NodeIdAlias[] { new NodeIdAlias()
                                                  {
                                                      Alias = "Alias name", Value = "ns=1;i=24"
                                                  } };
            _toTest.RecalculateNodeIds(_uAModelContext.Object);
            Assert.AreEqual <string>("ns=10;i=24", _toTest.Aliases[0].Value);
            Assert.AreEqual <string>("Alias name", _toTest.Aliases[0].Alias);
            Assert.AreEqual <string>("ns=10;i=1", _toTest.Items[0].NodeId);
            Assert.AreEqual <string>("ns=10;i=2", ((UAVariableType)_toTest.Items[1]).DataType);
        }
Example #15
0
        public void RecalculateNodeIdsUADataTypeTest()
        {
            UADataType _enumeration = new UADataType()
            {
                NodeId      = "ns=1;i=11",
                BrowseName  = "1:EnumerationDataType",
                DisplayName = new LocalizedText[] { new LocalizedText()
                                                    {
                                                        Value = "EnumerationDataType"
                                                    } },
                References = new Reference[]
                {
                    new Reference()
                    {
                        ReferenceType = ReferenceTypeIds.HasProperty.ToString(), Value = "ns=1;i=12", IsForward = true
                    },
                    new Reference()
                    {
                        ReferenceType = ReferenceTypeIds.HasSubtype.ToString(), Value = "ns=1;i=9", IsForward = false
                    }
                },
                Definition = new DataTypeDefinition()
                {
                    Name  = "EnumerationDataType",
                    Field = new DataTypeField[]
                    {
                        new DataTypeField()
                        {
                            Name = "Field3", Value = 1
                        },
                        new DataTypeField()
                        {
                            Name = "Field4", DataType = "ns=1;i=24"
                        }
                    }
                }
            };
            Mock <IUAModelContext> _uAModelContext = new Mock <IUAModelContext>();

            _uAModelContext.Setup <string>(x => x.ImportNodeId(It.IsAny <string>())).Returns <string>
                (x =>
            {
                NodeId nodeId = NodeId.Parse(x);
                if (nodeId.NamespaceIndex == 1)
                {
                    nodeId.SetNamespaceIndex(10);
                }
                return(nodeId.ToString());
            });
            _uAModelContext.Setup <string>(x => x.ImportQualifiedName(It.IsAny <string>())).Returns <string>
                (x =>
            {
                QualifiedName nodeId = QualifiedName.Parse(x);
                if (nodeId.NamespaceIndex == 1)
                {
                    nodeId.NamespaceIndex = 10;
                }
                return(nodeId.ToString());
            });
            _enumeration.RecalculateNodeIds(_uAModelContext.Object);
            Assert.AreEqual <string>("10:EnumerationDataType", _enumeration.BrowseName);
            Assert.AreEqual <int>(10, NodeId.Parse(_enumeration.NodeId).NamespaceIndex);
            Assert.AreEqual <int>(10, NodeId.Parse(_enumeration.References[0].Value).NamespaceIndex);
            Assert.AreEqual <int>(0, NodeId.Parse(_enumeration.References[0].ReferenceType).NamespaceIndex);
            Assert.AreEqual <int>(10, NodeId.Parse(_enumeration.References[1].Value).NamespaceIndex);
            Assert.AreEqual <int>(0, NodeId.Parse(_enumeration.References[1].ReferenceType).NamespaceIndex);
            Assert.AreEqual <string>("i=24", _enumeration.Definition.Field[0].DataType);
            Assert.AreEqual <string>("ns=10;i=24", _enumeration.Definition.Field[1].DataType);
        }