Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Transition"/> class.
 /// </summary>
 /// <param name="fromState">From state.</param>
 /// <param name="toState">To state.</param>
 /// <param name="hasCause">The has cause.</param>
 /// <param name="instanceDesignNode">The instance design node.</param>
 internal Transition(string fromState, string toState, string hasCause, InstanceDesign <Opc.Ua.ModelCompiler.ObjectDesign> instanceDesignNode)
 {
     this.FromState          = fromState;
     this.ToState            = toState;
     this.HasCause           = hasCause;
     this.instanceDesignNode = instanceDesignNode;
 }
Exemple #2
0
 /// <summary>
 /// Updates the specified transition on list.
 /// </summary>
 /// <param name="transitionOnList">The transition on list.</param>
 internal void Update(Transition transitionOnList)
 {
     this.FromState          = transitionOnList.FromState;
     this.ToState            = transitionOnList.ToState;
     this.HasCause           = transitionOnList.HasCause;
     this.InstanceDesignNode = transitionOnList.InstanceDesignNode;
 }
        /// <summary>
        /// Finds the states and transitions in state machine.
        /// </summary>
        /// <param name="instanceDesignNode">The instance design node.</param>
        /// <param name="allStates">All states.</param>
        /// <param name="allTransitions">All transitions.</param>
        private static void FindStatesAndTransitionsInStateMachine(InstanceDesign <UAOOI.SemanticData.UAModelDesignExport.XML.ObjectDesign> instanceDesignNode, List <string> allStates, List <Transition> allTransitions)
        {
            string fromState = "";
            string toState   = "";
            string hasCause  = "";
            NodeDesign <OpcUaModelCompiler.ObjectDesign> nd = (NodeDesign <UAOOI.SemanticData.UAModelDesignExport.XML.ObjectDesign>)instanceDesignNode;

            if ((instanceDesignNode.TypeDefinition.Name.ToString() == initialStateTypeString) ||
                (instanceDesignNode.TypeDefinition.Name.ToString() == stateTypeString) ||
                (instanceDesignNode.TypeDefinition.Name.ToString().Contains(stateTypeString)))
            {
                allStates.Add(nd.SymbolicName.Name);
            }
            else if (instanceDesignNode.TypeDefinition.Name.ToString() == transitionTypeString)
            {
                foreach (OpcUaModelCompiler.Reference reference in ((ObjectDesign)nd.Parent).References.References)
                {
                    if (reference.ReferenceType.Name == fromStateString)
                    {
                        fromState = reference.TargetId.Name;
                    }
                    else if (reference.ReferenceType.Name == toStateString)
                    {
                        toState = reference.TargetId.Name;
                    }
                    else if (reference.ReferenceType.Name == hasCauseString)
                    {
                        hasCause = reference.TargetId.Name;
                    }
                }
                allTransitions.Add(new Transition(fromState, toState, hasCause, instanceDesignNode));
            }
            return;
        }
 /// <summary>
 /// Updates the instance.
 /// </summary>
 /// <param name="nodeDesign">The node design.</param>
 /// <param name="path">The path.</param>
 /// <param name="traceEvent">The trace event.</param>
 /// <param name="createInstanceType">Type of the create instance.</param>
 protected void UpdateInstance(InstanceDesign nodeDesign, List <string> path, System.Action <TraceMessage> traceEvent, Action <InstanceDesign, List <string> > createInstanceType)
 {
     nodeDesign.Declaration               = null;
     nodeDesign.MaxCardinality            = 0;
     nodeDesign.MinCardinality            = 0;
     nodeDesign.ModellingRule             = this.ModelingRule.ConvertModellingRule(x => nodeDesign.ModellingRuleSpecified = x);
     nodeDesign.PreserveDefaultAttributes = false;
     nodeDesign.ReferenceType             = this.ReferenceType;
     nodeDesign.TypeDefinition            = this.TypeDefinition;
     base.UpdateNode(nodeDesign, path, createInstanceType);
 }
        private void CreateInstanceType(InstanceDesign instance, List <string> browsePath, List <NodeDesign> mdNodes)
        {
            Debug.Assert(instance != null, "CreateInstanceType.instance cannot be null");
            InstanceDesign _ret = null;

            if (instance is MethodDesign _src)
            {
                XmlQualifiedName _newSymbolicName = new XmlQualifiedName(browsePath.SymbolicName(), instance.SymbolicName.Namespace);
                MethodDesign     _method          = new MethodDesign
                {
                    BrowseName             = _src.BrowseName,
                    Children               = null,
                    Declaration            = _src.Declaration,
                    Description            = _src.Description,
                    DisplayName            = _src.DisplayName,
                    InputArguments         = _src.InputArguments,
                    IsDeclaration          = _src.IsDeclaration,
                    MaxCardinality         = _src.MaxCardinality,
                    MinCardinality         = _src.MinCardinality,
                    ModellingRule          = ModellingRule.None,
                    ModellingRuleSpecified = false,
                    NonExecutable          = _src.NonExecutable,
                    NonExecutableSpecified = _src.NonExecutableSpecified,
                    NumericId              = _src.NumericId,
                    NumericIdSpecified     = _src.NumericIdSpecified,
                    OutputArguments        = _src.OutputArguments,
                    PartNo = _src.PartNo,
                    PreserveDefaultAttributes = _src.PreserveDefaultAttributes,
                    References     = _src.References,
                    ReferenceType  = _src.ReferenceType,
                    StringId       = _src.StringId,
                    SymbolicId     = _src.SymbolicId,
                    SymbolicName   = _newSymbolicName,
                    TypeDefinition = null,
                    WriteAccess    = _src.WriteAccess,
                };
                _src.InputArguments  = null;
                _src.OutputArguments = null;
                if (instance.Children == null || instance.Children.Items == null || instance.Children.Items.Length == 0)
                {
                    instance.Children = null;
                }
                _src.TypeDefinition = _newSymbolicName;
                _ret = _method;
            }
            else
            {
                Debug.Fail("In this release expected Method");
            }
            if (_ret != null)
            {
                mdNodes.Add(_ret);
            }
        }
 private void CreateInstanceType(InstanceDesign instance, List <string> browsePath, List <NodeDesign> mdNodes)
 {
     return;
     //TODO #40: ValidateAndExportModel shall export also instances #40
     //Debug.Assert(instance != null, "CreateInstanceType.instance cannot be null");
     //InstanceDesign _ret = null;
     //if (instance is MethodDesign _src)
     //{
     //  XmlQualifiedName _newSymbolicName = new XmlQualifiedName(browsePath.SymbolicName(), instance.SymbolicName.Namespace);
     //  MethodDesign _method = new MethodDesign
     //  {
     //    BrowseName = _src.BrowseName,
     //    Children = null,
     //    Declaration = _src.Declaration,
     //    Description = _src.Description,
     //    DisplayName = _src.DisplayName,
     //    InputArguments = _src.InputArguments,
     //    IsDeclaration = _src.IsDeclaration,
     //    MaxCardinality = _src.MaxCardinality,
     //    MinCardinality = _src.MinCardinality,
     //    ModellingRule = ModellingRule.None,
     //    ModellingRuleSpecified = false,
     //    NonExecutable = _src.NonExecutable,
     //    NonExecutableSpecified = _src.NonExecutableSpecified,
     //    NumericId = _src.NumericId,
     //    NumericIdSpecified = _src.NumericIdSpecified,
     //    OutputArguments = _src.OutputArguments,
     //    PartNo = _src.PartNo,
     //    PreserveDefaultAttributes = _src.PreserveDefaultAttributes,
     //    References = _src.References,
     //    ReferenceType = _src.ReferenceType,
     //    StringId = _src.StringId,
     //    SymbolicId = _src.SymbolicId,
     //    SymbolicName = _newSymbolicName,
     //    TypeDefinition = null,
     //    WriteAccess = _src.WriteAccess,
     //  };
     //  _src.InputArguments = null;
     //  _src.OutputArguments = null;
     //  if (instance.Children == null || instance.Children.Items == null || instance.Children.Items.Length == 0)
     //    instance.Children = null;
     //  _src.TypeDefinition = _newSymbolicName;
     //  _ret = _method;
     //}
     //else
     //  Debug.Fail("In this release expected Method");
     //if (_ret != null)
     //  mdNodes.Add(_ret);
 }
Exemple #7
0
 private static void CompareInstanceDesign(InstanceDesign expected, InstanceDesign actual)
 {
     Assert.IsTrue(expected.GetType() == actual.GetType());
     Compare(expected.ReferenceType, actual.ReferenceType, "InstanceDesign.ReferenceType");
     Compare(expected.TypeDefinition, actual.TypeDefinition, "InstanceDesign.TypeDefinition");
     Assert.AreEqual <bool>(expected.ModellingRuleSpecified, actual.ModellingRuleSpecified, actual.SymbolicName.ToString());
     if (expected.ModellingRuleSpecified)
     {
         Assert.AreEqual <ModellingRule>(expected.ModellingRule, actual.ModellingRule);
     }
     //test base type
     CompareNodeDesign(expected, actual);
     //Not supported attributes
     Assert.IsNull(actual.Declaration, "InstanceDesign.Declaration");
     Assert.AreEqual <uint>(0, actual.MinCardinality);
     Assert.AreEqual <uint>(0, actual.MaxCardinality);
     Assert.IsFalse(actual.PreserveDefaultAttributes);
 }