Example #1
0
 private static void Compare(ObjectTypeDesign expected, ObjectTypeDesign actual)
 {
     CompareTypeDesign(expected, actual);
     Assert.IsFalse(expected.SupportsEventsSpecified, "Field not supported for types - should always be false");
     Assert.IsFalse(actual.SupportsEventsSpecified, "Field not supported for types - should always be false");
     Assert.IsFalse(expected.SupportsEvents, "Field not supported for types - should always be false");
     Assert.IsFalse(actual.SupportsEvents, "Field not supported for types - should always be false");
 }
Example #2
0
        //internal API
        internal override NodeDesign Export(List <string> path, Action <InstanceDesign, List <string> > createInstanceType)
        {
            ObjectTypeDesign _ret = new ObjectTypeDesign()
            {
                SupportsEvents          = false,
                SupportsEventsSpecified = false
            };

            base.Update(_ret, path, createInstanceType);
            return(_ret);
        }
 /// <summary>
 /// Merge in object type design
 /// </summary>
 /// <param name="type"></param>
 /// <param name="merge"></param>
 private static void MergeIn(this TypeDesign type, ObjectTypeDesign merge)
 {
     if (!(type is ObjectTypeDesign objType))
     {
         throw new FormatException(nameof(merge));
     }
     if (merge.SupportsEventsSpecified)
     {
         objType.SupportsEvents          = merge.SupportsEvents;
         objType.SupportsEventsSpecified = true;
     }
 }
 /// <summary>
 /// Analizes the state machine from tree.
 /// </summary>
 /// <param name="imna">The analized node.</param>
 internal static void AnalizeStateMachine(IModelNodeAdvance imna)
 {
     if (CustomEditors.IsLicensed)
     {
         if ((((TypeDesign <Opc.Ua.ModelCompiler.ObjectTypeDesign>)imna.Wrapper4PropertyGrid).BaseType.ToString() == finiteStateMachineTypeString))
         {
             TypeDesign <Opc.Ua.ModelCompiler.ObjectTypeDesign> selectedNodeObjectTypeDesign = (TypeDesign <Opc.Ua.ModelCompiler.ObjectTypeDesign>)imna.Wrapper4PropertyGrid;
             try
             {
                 string            symbolicNameNameSpace = selectedNodeObjectTypeDesign.SymbolicName.NameSpace;
                 ObjectTypeDesign  machineObjectDesign   = (ObjectTypeDesign)selectedNodeObjectTypeDesign.Parent;
                 List <string>     allStates             = new List <string>();
                 List <Transition> allTransitions        = new List <Transition>();
                 Dictionary <FolderType, IEnumerable <IModelNodeAdvance> > folders = imna.GetFolders();
                 foreach (Folder folder in folders.Values)
                 {
                     if (folder is ChildrenFolder)
                     {
                         foreach (IModelNode machineIModelNode in folder)
                         {
                             if (machineIModelNode.NodeClass == NodeClassesEnum.Object)
                             {
                                 FindStatesAndTransitionsInStateMachine((InstanceDesign <Opc.Ua.ModelCompiler.ObjectDesign>)machineIModelNode.Wrapper4PropertyGrid, allStates, allTransitions);
                             }
                         }
                     }
                 }
                 bool transitionAnalized = false;
                 while (transitionAnalized == false)
                 {
                     transitionAnalized = StateMachineCrossTable.AddImagesOnTransitionButtons(allStates, allTransitions, symbolicNameNameSpace, machineObjectDesign, imna.IsReadOnly);
                 }
             }
             catch (Exception)
             {
                 MessageBox.Show(Resources.ProblemWithStateMachine_Header, Resources.ProblemwithDisplayingStateMachine_Info, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                 return;
             }
         }
         else
         {
             MessageBox.Show(Resources.ProblemWithStateMachine_Header, Resources.ProblemWithStateMachine_Info, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
             return;
         }
     }
     else
     {
         MessageBox.Show(Resources.ModelDesignerProLicenseWarning);
     }
 }
Example #5
0
        /// <summary>
        /// Merge with type design
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="objectType"></param>
        private static void MergeIn(this InstanceDesign mergedInstance, ObjectTypeDesign objectType)
        {
            if (!(mergedInstance is ObjectDesign mergedObject))
            {
                throw new ArgumentException(nameof(mergedInstance));
            }
            mergedObject.TypeDefinition     = objectType.SymbolicId;
            mergedObject.TypeDefinitionNode = objectType;

            if (objectType.SupportsEventsSpecified)
            {
                mergedObject.SupportsEvents          = objectType.SupportsEvents;
                mergedObject.SupportsEventsSpecified = true;
            }
        }
Example #6
0
        /// <summary>
        /// Analizes the transition states and add buttons.
        /// </summary>
        /// <param name="allStates">All states.</param>
        /// <param name="allTransitions">All transitions.</param>
        /// <param name="symbolicNameNameSpace">The symbolic name name space.</param>
        /// <param name="machineObjectDesign">The machine object design.</param>
        /// <returns>
        /// True if transitions are correctly analized.
        /// </returns>
        internal static bool AddImagesOnTransitionButtons(List <string> allStates, List <Transition> allTransitions, string symbolicNameNameSpace, ObjectTypeDesign machineObjectDesign, bool isReadOnly)
        {
            StateMachineCrossTable crossTableWindow = DrawStateMachineCrossTableWindow(allStates, allTransitions, symbolicNameNameSpace, machineObjectDesign, isReadOnly);
            int    toStateNumber      = 0;
            int    fromStateNumber    = 0;
            bool   fromStateExists    = false;
            bool   toStateExists      = false;
            string fromStateFoundName = "";
            string toStateFoundName   = "";
            string shortFromState;
            string shortToState;

            foreach (Transition transitionOnList in allTransitions)
            {
                if (transitionOnList.FromState.Contains("_"))
                {
                    shortFromState = (transitionOnList.FromState).Substring((transitionOnList.FromState).LastIndexOf("_"), (transitionOnList.FromState).Length - (transitionOnList.FromState).LastIndexOf("_")).Replace("_", "");
                }
                else
                {
                    shortFromState = transitionOnList.FromState;
                }
                if (transitionOnList.ToState.Contains("_"))
                {
                    shortToState = (transitionOnList.ToState).Substring((transitionOnList.ToState).LastIndexOf("_"), (transitionOnList.ToState).Length - (transitionOnList.ToState).LastIndexOf("_")).Replace("_", "");
                }
                else
                {
                    shortToState = transitionOnList.ToState;
                }
                if (shortFromState == shortToState)
                {
                    for (int statesCounter = 0; statesCounter < allStates.Count; statesCounter++)
                    {
                        if ((allStates[statesCounter] == shortFromState))
                        {
                            fromStateNumber    = statesCounter + 1;
                            fromStateFoundName = allStates[statesCounter];
                            fromStateExists    = true;
                            toStateNumber      = statesCounter + 1;
                            toStateFoundName   = allStates[statesCounter];
                            toStateExists      = true;
                        }
                    }
                }
                else
                {
                    for (int statesCounter = 0; statesCounter < allStates.Count; statesCounter++)
                    {
                        if ((allStates[statesCounter] == shortFromState))
                        {
                            fromStateNumber    = statesCounter + 1;
                            fromStateFoundName = allStates[statesCounter];
                            fromStateExists    = true;
                        }
                        else if ((allStates[statesCounter] == shortToState))
                        {
                            toStateNumber    = statesCounter + 1;
                            toStateFoundName = allStates[statesCounter];
                            toStateExists    = true;
                        }
                    }
                }
                if (fromStateExists == true && toStateExists == true)
                {
                    foreach (Control ctrl in crossTableWindow.tableLayoutPanelCrossTable.Controls)
                    {
                        StateMachineControl smc = ctrl as StateMachineControl;
                        if ((smc != null) && (smc.buttonTransition.TransitionData.FromState == fromStateFoundName) && (smc.buttonTransition.TransitionData.ToState == toStateFoundName))
                        {
                            smc.buttonTransition.TransitionData.Update(transitionOnList);
                            smc.buttonTransition.Image     = global::CAS.UA.Model.Designer.Properties.Resources.transition;
                            smc.buttonTransition.FlatStyle = FlatStyle.Standard;
                        }
                    }
                }
                else
                if (fromStateExists == false)
                {
                    allStates.Add(shortFromState);
                    crossTableWindow = DrawStateMachineCrossTableWindow(allStates, allTransitions, symbolicNameNameSpace, machineObjectDesign, isReadOnly);
                    return(false);
                }
                else
                {
                    allStates.Add(shortToState);
                    crossTableWindow = DrawStateMachineCrossTableWindow(allStates, allTransitions, symbolicNameNameSpace, machineObjectDesign, isReadOnly);
                    return(false);
                }
            }
            crossTableWindow.tableLayoutPanelCrossTable.SuspendLayout();
            crossTableWindow.SuspendLayout();
            crossTableWindow.Height = crossTableWindow.tableLayoutPanelCrossTable.Height + 50;
            crossTableWindow.Width  = crossTableWindow.tableLayoutPanelCrossTable.Width + 50;
            crossTableWindow.tableLayoutPanelCrossTable.ResumeLayout(false);
            crossTableWindow.tableLayoutPanelCrossTable.PerformLayout();
            crossTableWindow.ResumeLayout(false);
            crossTableWindow.PerformLayout();
            crossTableWindow.Show();
            return(true);
        }
Example #7
0
 public ObjectTypeDesignTreeNodeControl(ObjectTypeDesign parent) : base(parent)
 {
 }