Exemplo n.º 1
0
        private static void GetACCESSRIGHTS(VariableDesign var, Opc.Da.ItemProperty itemProperty)
        {
            if ((itemProperty == null) || (itemProperty.Value == null))
            {
                return;
            }
            var.AccessLevelSpecified = true;
            switch (((Opc.Da.accessRights)itemProperty.Value))
            {
            case Opc.Da.accessRights.readWritable:
                var.AccessLevel = AccessLevel.ReadWrite;
                break;

            case Opc.Da.accessRights.readable:
                var.AccessLevel = AccessLevel.Read;
                break;

            case Opc.Da.accessRights.writable:
                var.AccessLevel = AccessLevel.Write;
                break;

            default:
                var.AccessLevelSpecified = false;
                break;
            }
        }
Exemplo n.º 2
0
 private static void Compare(VariableDesign expected, VariableDesign actual)
 {
     Compare(expected.DefaultValue, actual.DefaultValue);
     Compare(expected.DataType, actual.DataType, "VariableDesign.DataType");
     if (expected.ValueRankSpecified && expected.ValueRank == ValueRank.Scalar)
     {
         expected.ValueRankSpecified = false;
     }
     Assert.AreEqual <bool>(expected.ValueRankSpecified, actual.ValueRankSpecified);
     if (expected.ValueRankSpecified)
     {
         Assert.AreEqual <ValueRank>(expected.ValueRank, actual.ValueRank);
     }
     Assert.AreEqual <string>(expected.ArrayDimensions, actual.ArrayDimensions);
     Assert.AreEqual <bool>(expected.AccessLevelSpecified, actual.AccessLevelSpecified, actual.SymbolicName.ToString());
     if (expected.AccessLevelSpecified)
     {
         Assert.AreEqual <AccessLevel>(expected.AccessLevel, actual.AccessLevel);
     }
     Assert.AreEqual <bool>(expected.MinimumSamplingIntervalSpecified, actual.MinimumSamplingIntervalSpecified);
     if (expected.MinimumSamplingIntervalSpecified)
     {
         Assert.AreEqual <int>(expected.MinimumSamplingInterval, actual.MinimumSamplingInterval);
     }
     Assert.AreEqual <bool>(expected.HistorizingSpecified, actual.HistorizingSpecified);
     if (expected.HistorizingSpecified)
     {
         Assert.AreEqual <bool>(expected.Historizing, actual.Historizing);
     }
     CompareInstanceDesign(expected, actual);
 }
Exemplo n.º 3
0
        //internal API
        internal override NodeDesign Export(List <string> path, Action <InstanceDesign, List <string> > createInstanceType)
        {
            VariableDesign _ret = new VariableDesign()
            {
            };

            Update(_ret, path, createInstanceType);
            return(_ret);
        }
Exemplo n.º 4
0
        private static void GetEUTYPE(VariableDesign var, SortedDictionary <int, Opc.Da.ItemProperty> prprts)
        {
            if (!prprts.ContainsKey(Opc.Da.Property.EUTYPE.Code))
            {
                return;
            }
            Opc.Da.ItemProperty eut = prprts[Opc.Da.Property.EUTYPE.Code];
            if (eut.Value == null)
            {
                return;
            }
            switch ((Opc.Da.euType)eut.Value)
            {
            case Opc.Da.euType.analog:
            {
                var.TypeDefinition = GetAnalogItemType();
                Opc.Da.ItemProperty higheu = null;
                Opc.Da.ItemProperty loweu  = null;
                if (prprts.ContainsKey(Opc.Da.Property.HIGHEU.Code))
                {
                    higheu = prprts[Opc.Da.Property.HIGHEU.Code];
                }
                if (prprts.ContainsKey(Opc.Da.Property.LOWEU.Code))
                {
                    loweu = prprts[Opc.Da.Property.LOWEU.Code];
                }
                if (higheu != null && loweu != null)
                {
                    PropertyDesign prop = new PropertyDesign()
                    {
                        SymbolicName = CreateXmlQualifiedName(BrowseNames.EURange),
                        DataType     = CreateXmlQualifiedName(BrowseNames.Range),
                        DefaultValue = CAS.UA.Common.Types.Range.CreateRange(higheu, loweu).XmlElement,
                        ValueRank    = ValueRank.Scalar,
                        AccessLevel  = AccessLevel.Read
                    };
                    var.Children = new ListOfChildren()
                    {
                        Items = new InstanceDesign[] { prop }
                    };
                }
                break;
            }

            case Opc.Da.euType.enumerated:
                var.TypeDefinition = GetMultiStateDiscreteType();
                break;

            case Opc.Da.euType.noEnum:
                var.TypeDefinition = GetTwoStateDiscreteType();
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
 //private
 protected void Update(VariableDesign node, List <string> path, Action <InstanceDesign, List <string> > createInstanceType)
 {
     node.AccessLevel                      = this.AccessLevel.GetAccessLevel(x => node.AccessLevelSpecified = x, TraceEvent);
     node.ValueRank                        = this.ValueRank.GetValueRank(x => node.ValueRankSpecified = x, TraceEvent);
     node.ArrayDimensions                  = this.ArrayDimensions;
     node.DataType                         = this.DataType;     //TODO must be DataType, must not be abstract
     node.DefaultValue                     = this.DefaultValue; //TODO must be of type defined by DataType
     node.Historizing                      = this.Historizing.GetValueOrDefault();
     node.HistorizingSpecified             = this.Historizing.HasValue;
     node.MinimumSamplingInterval          = this.MinimumSamplingInterval.GetValueOrDefault();
     node.MinimumSamplingIntervalSpecified = this.MinimumSamplingInterval.HasValue;
     base.UpdateInstance(node, path, TraceEvent, createInstanceType);
 }
Exemplo n.º 6
0
 public VariableDesignTreeNodeControl(VariableDesign parent) : base(parent)
 {
 }
Exemplo n.º 7
0
        private static void GetDATATYPE(VariableDesign var, Opc.Da.ItemProperty prprty)
        {
            if (prprty == null || prprty.Value == null)
            {
                return;
            }
            Type   vt = (Type)prprty.Value;
            NodeId id = Opc.Ua.TypeInfo.GetDataTypeId(vt);

            if (id == null)
            {
                return;
            }
            Debug.Assert(id.IdType == IdType.Numeric);
            BuiltInType bit = TypeInfo.GetBuiltInType(id);

            switch (bit)
            {
            case BuiltInType.Boolean:
            case BuiltInType.Byte:
            case BuiltInType.ByteString:
            case BuiltInType.DataValue:
            case BuiltInType.DateTime:
            case BuiltInType.Double:
            case BuiltInType.Float:
            case BuiltInType.Int16:
            case BuiltInType.Int32:
            case BuiltInType.Int64:
            case BuiltInType.SByte:
            case BuiltInType.String:
            case BuiltInType.UInt16:
            case BuiltInType.UInt32:
            case BuiltInType.UInt64:
            {
                string sn = Enum.GetName(typeof(BuiltInType), TypeInfo.GetBuiltInType(id));
                var.DataType = CreateXmlQualifiedName(sn);
                break;
            }

            case BuiltInType.UInteger:
            case BuiltInType.Integer:
            case BuiltInType.LocalizedText:
            case BuiltInType.Enumeration:
            case BuiltInType.ExpandedNodeId:
            case BuiltInType.ExtensionObject:
            case BuiltInType.Guid:
            case BuiltInType.NodeId:
            case BuiltInType.Null:
            case BuiltInType.Number:
            case BuiltInType.QualifiedName:
            case BuiltInType.StatusCode:
            case BuiltInType.Variant:
            case BuiltInType.XmlElement:
            case BuiltInType.DiagnosticInfo:
            default:
                break;
            }
            if (vt.IsArray)
            {
                var.ValueRank = ValueRank.OneOrMoreDimensions;
            }
        }
Exemplo n.º 8
0
 private static void ImportTag
 (
     AddressSpaceDataBase.TagsTableRow parentItem,
     string targetNamespace,
     UniqueName uniqueName,
     XmlQualifiedName parentObject,
     List <NodeDesign> nodes,
     List <InstanceDesign> parentChildren
 )
 {
     Opc.Da.BrowseElement pbe = parentItem.GetBrowseElement();
     if (pbe.IsItem)
     {
         VariableDesign var = new VariableDesign()
         {
             SymbolicName = new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace),
             DisplayName  = new LocalizedText()
             {
                 Value = pbe.Name
             },
             DataType       = GetBaseDataType(),
             TypeDefinition = GetBaseDataVariableType(),
             Description    = new LocalizedText()
             {
                 Value = pbe.ItemName
             },
             AccessLevel          = AccessLevel.ReadWrite,
             AccessLevelSpecified = true,
             ValueRank            = ValueRank.Scalar,
             ValueRankSpecified   = true,
             WriteAccess          = 0
         };
         parentChildren.Add(var);
         SortedDictionary <int, Opc.Da.ItemProperty> prprts = new SortedDictionary <int, Opc.Da.ItemProperty>();
         foreach (Opc.Da.ItemProperty item in pbe.Properties)
         {
             prprts.Add(item.ID.Code, item);
         }
         if (prprts.ContainsKey(Opc.Da.Property.DATATYPE.Code))
         {
             GetDATATYPE(var, prprts[Opc.Da.Property.DATATYPE.Code]);
         }
         GetEUTYPE(var, prprts);
         if (prprts.ContainsKey(Opc.Da.Property.ACCESSRIGHTS.Code))
         {
             GetACCESSRIGHTS(var, prprts[Opc.Da.Property.ACCESSRIGHTS.Code]);
         }
     }
     else
     {
         ObjectDesign sf = CreateFolder(new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace), pbe.ItemName, pbe.Name);
         nodes.Add(sf);
         List <InstanceDesign> myChildren = new List <InstanceDesign>();
         foreach (AddressSpaceDataBase.TagsTableRow item in parentItem.GetTagsTableRows())
         {
             ImportTag(item, targetNamespace, uniqueName, sf.SymbolicName, nodes, myChildren);
         }
         sf.Children = new ListOfChildren()
         {
             Items = myChildren.ToArray()
         };
         sf.References = new Reference[]
         { new Reference()
           {
               IsInverse     = true,
               ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
               TargetId      = parentObject
           } };
     }
 }