Exemplo n.º 1
0
 public MachineRelation(GeneratorData data, BasicRelation bindir)
     : base(bindir as IBasicGlobal, data)
 {
     Root = bindir;
 }
Exemplo n.º 2
0
 private void GetUsedObjects(DrawingSheet sheet, VariableCollection variables)
 {
     if (sheet is ModelSheet model)
     {
         UsedModels.Add(model);
     }
     else
     {
         UsedSheets.Add(sheet);
     }
     foreach (DrawableObject obj in sheet.Sketch.Objects)
     {
         if (obj is Relation indir)
         {
             Variable input  = VariableCollection.GetIndirectInput(sheet, indir.Trigger);
             Variable output = VariableCollection.GetIndirectOutput(sheet, indir.Output);
             if (input == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation trigger variable not found.", indir));
             }
             if (output == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation output variable not found.", indir));
             }
             if (input != null && output != null)
             {
                 BasicRelation ibindir = RelationsList.FirstOrDefault(ind => ind.Input.Name == input.Name);
                 BasicRelation obindir = RelationsList.FirstOrDefault(ind => ind.Action.Output.Name == input.Name);
                 if (ibindir != null)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation has same input than other one.", indir, ibindir.Relation));
                 }
                 if (obindir != null)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation has same output than other one.", indir, obindir.Relation));
                 }
                 if (ibindir == null && obindir == null)
                 {
                     BasicOutput   action = indir.Action == null ? null : new BasicOutput((OperationType)Enum.Parse(typeof(OperationType), indir.Action), output);
                     BasicRelation bindir = new BasicRelation(indir, input, action);
                     RelationsList.Add(bindir);
                 }
             }
         }
         else if (obj is Equation eq)
         {
             IInternalOutput output = variables.IndirectOutputs.FirstOrDefault(io => io.Name == eq.AssignTo);
             if (output == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation trigger variable not found.", eq));
             }
             if (eq.Operation == "")
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Equation does not have operation.", eq));
             }
             LexicalAnalyzer lexAnalyzer = new LexicalAnalyzer();
             SyntaxAnalyzer  syntaxAnalyzer;
             lexAnalyzer.Source = eq.Operation;
             syntaxAnalyzer     = new SyntaxAnalyzer(lexAnalyzer, VariableCollection.GetConditionDictionary(eq.OwnerDraw.OwnerSheet).Keys.ToList());
             foreach (SyntaxToken token in syntaxAnalyzer.Tokens)
             {
                 if (token.Qualifier != SyntaxToken.Qualifiers.Correct)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, string.Format("{0}: {1}.", eq.Name, token.ToString()), eq));
                 }
             }
             EquationsList.Add(new BasicEquation(eq));
         }
         else if (obj is Transition trans)
         {
             TransitionsList.Add(trans);
             if (trans.StartObject == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition without start connection.", trans));
             }
             if (trans.EndObject == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition without end connection.", trans));
             }
             if (trans is SimpleTransition strans && strans.Condition == "" && strans.Timeout == 0)
             {
                 if (strans.StartObject is Origin origin)
                 {
                     if (strans.EndObject is End || strans.EndObject is Abort)
                     {
                         MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "One shot machine Transition should have a condition.", trans));
                     }
                 }
                 else if (!strans.DefaultTransition)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition does not have condition or timeout value.", trans));
                 }
             }
             else if (trans is SuperTransition sptrans && sptrans.Links == "")
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition is not linking any object.", trans));
             }
         }