Exemple #1
0
        private static void ImportServer
            (AddressSpaceDataBase.ServersTableRow svr, string targetNamespace, UniqueName uniqueName, List <NodeDesign> nodes)
        {
            string           name    = NewName;
            XmlQualifiedName sftName = new XmlQualifiedName(NewName, targetNamespace);
            ObjectDesign     sft     = CreateFolder(sftName, svr.URLString, svr.URL.Path);

            sft.References = new Reference[] { new Reference()
                                               {
                                                   IsInverse     = true,
                                                   ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
                                                   TargetId      = CreateXmlQualifiedName("ObjectsFolder")
                                               } };
            nodes.Add(sft);
            List <InstanceDesign> cldrn = new List <InstanceDesign>();

            foreach (AddressSpaceDataBase.TagsTableRow item in svr.GetTagsTableRows())
            {
                ImportTag(item, targetNamespace, uniqueName, sft.SymbolicName, nodes, cldrn);
            }
            sft.Children = new ListOfChildren()
            {
                Items = cldrn.ToArray()
            };
        }
Exemple #2
0
 //Instances
 private static void Compare(ObjectDesign expected, ObjectDesign actual)
 {
     Assert.AreEqual <bool>(expected.SupportsEventsSpecified, actual.SupportsEventsSpecified);
     if (expected.SupportsEventsSpecified)
     {
         Assert.AreEqual <bool>(expected.SupportsEvents, actual.SupportsEvents);
     }
     CompareInstanceDesign(expected, actual);
 }
Exemple #3
0
        /// <summary>
        /// Called when [add transition].
        /// </summary>
        private void OnAddTransition()
        {
            ObjectDesign newTransitionObjectDesign = new ObjectDesign();

            newTransitionObjectDesign.Wrapper.MaxCardinality            = 0;
            newTransitionObjectDesign.Wrapper.MinCardinality            = 0;
            newTransitionObjectDesign.Wrapper.PreserveDefaultAttributes = false;
            newTransitionObjectDesign.Wrapper.TypeDefinition.Name       = transitionTypeString;
            newTransitionObjectDesign.Wrapper.TypeDefinition.NameSpace  = uaNamesaceString;
            newTransitionObjectDesign.Wrapper.SymbolicName.Name         = "From" + selectedTransitionButton.TransitionData.FromState + "To" + selectedTransitionButton.TransitionData.ToState;
            newTransitionObjectDesign.Wrapper.SymbolicName.NameSpace    = selectedTransitionButton.SymbolicNameNameSpace;
            newTransitionObjectDesign.Wrapper.WriteAccess   = 0;
            newTransitionObjectDesign.Wrapper.IsDeclaration = false;
            Reference fromStateReference = new Reference();

            fromStateReference.Wrapper.IsOneWay                = false;
            fromStateReference.Wrapper.IsInverse               = false;
            fromStateReference.Wrapper.ReferenceType.Name      = fromStateString;
            fromStateReference.Wrapper.ReferenceType.NameSpace = uaNamesaceString;
            fromStateReference.Wrapper.TargetId.Name           = selectedTransitionButton.TransitionData.FromState;
            fromStateReference.Wrapper.TargetId.NameSpace      = selectedTransitionButton.SymbolicNameNameSpace;
            fromStateReference.Wrapper.Validate();
            Reference toStateReference = new Reference();

            toStateReference.Wrapper.IsOneWay                = false;
            toStateReference.Wrapper.IsInverse               = false;
            toStateReference.Wrapper.ReferenceType.Name      = toStateString;
            toStateReference.Wrapper.ReferenceType.NameSpace = uaNamesaceString;
            toStateReference.Wrapper.TargetId.Name           = selectedTransitionButton.TransitionData.ToState;
            toStateReference.Wrapper.TargetId.NameSpace      = selectedTransitionButton.SymbolicNameNameSpace;
            toStateReference.Wrapper.Validate();
            Reference hasCauseReference = new Reference();

            if (selectedTransitionButton.TransitionData.HasCause != null)
            {
                hasCauseReference.Wrapper.IsOneWay                = false;
                hasCauseReference.Wrapper.IsInverse               = false;
                hasCauseReference.Wrapper.ReferenceType.Name      = hasCauseString;
                hasCauseReference.Wrapper.ReferenceType.NameSpace = uaNamesaceString;
                hasCauseReference.Wrapper.TargetId.Name           = selectedTransitionButton.TransitionData.HasCause;
                hasCauseReference.Wrapper.TargetId.NameSpace      = selectedTransitionButton.SymbolicNameNameSpace;
                hasCauseReference.Wrapper.Validate();
            }
            newTransitionObjectDesign.References.Add(fromStateReference);
            newTransitionObjectDesign.References.Add(toStateReference);
            newTransitionObjectDesign.Wrapper.Validate();
            if (!string.IsNullOrEmpty(hasCauseReference.Wrapper.TargetId.Name))
            {
                newTransitionObjectDesign.References.Add(hasCauseReference);
            }
            selectedTransitionButton.MachineObjectDesign.Children.Add(newTransitionObjectDesign);
            selectedTransitionButton.TransitionData = new Transition(selectedTransitionButton.TransitionData.FromState, selectedTransitionButton.TransitionData.ToState, selectedTransitionButton.TransitionData.HasCause, newTransitionObjectDesign.Wrapper);
            selectedTransitionButton.Image          = Resources.transition;
            selectedTransitionButton.FlatStyle      = FlatStyle.Standard;
        }
Exemple #4
0
 /// <summary>
 /// Called when [ok].
 /// </summary>
 private void OnOk()
 {
     if (selectedTransitionButton.TransitionData != null)
     {
         ObjectDesign myObjectDesign = selectedTransitionButton.TransitionData.InstanceDesignNode.Parent as ObjectDesign;
         if (myObjectDesign != null)
         {
             if (myObjectDesign.References.Count > 2)
             {
                 foreach (Reference referenceAsBaseTreeNode in myObjectDesign.References)
                 {
                     Reference reference = referenceAsBaseTreeNode as Reference;
                     if (reference != null && reference.Wrapper.ReferenceType.Name == hasCauseString)
                     {
                         string referenceNameOriginal;
                         if (reference.Wrapper.TargetId.Name.Contains("_") == true)
                         {
                             referenceNameOriginal = (reference.Wrapper.TargetId.Name).Substring((reference.Wrapper.TargetId.Name).LastIndexOf("_"), (reference.Wrapper.TargetId.Name).Length - (reference.Wrapper.TargetId.Name).LastIndexOf("_")).Replace("_", "");
                         }
                         else
                         {
                             referenceNameOriginal = reference.Wrapper.TargetId.Name;
                         }
                         if ((referenceNameOriginal != selectedTransitionButton.TransitionData.HasCause) && (string.IsNullOrEmpty(selectedTransitionButton.TransitionData.HasCause) != true) && (string.IsNullOrEmpty(referenceNameOriginal) != true))
                         {
                             (referenceAsBaseTreeNode as Reference).Wrapper.TargetId.Name = selectedTransitionButton.TransitionData.HasCause;
                             return;
                         }
                         else if ((referenceNameOriginal != selectedTransitionButton.TransitionData.HasCause) && (string.IsNullOrEmpty(selectedTransitionButton.TransitionData.HasCause) == true))
                         {
                             ((BaseTreeNode)(referenceAsBaseTreeNode as Reference).Wrapper.Parent).Parent.Remove((BaseTreeNode)(referenceAsBaseTreeNode as Reference).Wrapper.Parent);
                             reference = null;
                             return;
                         }
                     }
                 }
             }
             else if ((myObjectDesign.References.Count <= 2) && (string.IsNullOrEmpty(selectedTransitionButton.TransitionData.HasCause) != true))
             {
                 Reference reference = new Reference();
                 reference.Wrapper.IsOneWay                = false;
                 reference.Wrapper.IsInverse               = false;
                 reference.Wrapper.ReferenceType.Name      = hasCauseString;
                 reference.Wrapper.ReferenceType.NameSpace = myObjectDesign.References.References[0].ReferenceType.Namespace;
                 reference.Wrapper.TargetId.Name           = selectedTransitionButton.TransitionData.HasCause;
                 reference.Wrapper.TargetId.NameSpace      = myObjectDesign.References.References[0].TargetId.Namespace;
                 reference.Wrapper.Validate();
                 myObjectDesign.References.Add(reference);
                 myObjectDesign.Wrapper.Validate();
                 return;
             }
         }
     }
 }
Exemple #5
0
        internal override NodeDesign Export(List <string> path, Action <InstanceDesign, List <string> > createInstanceType)
        {
            ObjectDesign _ret = new ObjectDesign()
            {
                SupportsEvents          = this.SupportsEvents.GetValueOrDefault(),
                SupportsEventsSpecified = this.SupportsEvents.HasValue
            };

            base.UpdateInstance(_ret, path, TraceEvent, createInstanceType);
            return(_ret);
        }
Exemple #6
0
        /// <summary>
        /// Merge in object design
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="objectDesign"></param>
        private static void MergeIn(this InstanceDesign mergedInstance, ObjectDesign objectDesign)
        {
            if (!(mergedInstance is ObjectDesign mergedObject))
            {
                throw new ArgumentException(nameof(mergedInstance));
            }
            if (objectDesign.TypeDefinition != null &&
                objectDesign.TypeDefinition != Constants.BaseObjectType)
            {
                mergedObject.TypeDefinition     = objectDesign.TypeDefinition;
                mergedObject.TypeDefinitionNode = objectDesign.TypeDefinitionNode;
            }

            if (objectDesign.SupportsEventsSpecified)
            {
                mergedObject.SupportsEvents          = objectDesign.SupportsEvents;
                mergedObject.SupportsEventsSpecified = true;
            }
        }
 public ObjectDesignTreeNodeControl(ObjectDesign parent) : base(parent)
 {
 }
Exemple #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
           } };
     }
 }