Example #1
0
        /// <summary>
        /// returns the maybe user altered point within the interval series, denoting the sequence to execute next
        /// the randomly chosen point is supplied; the sequence with the intervals and their corresponding sequences is supplied
        /// </summary>
        public double ChoosePoint(double pointToExecute, SequenceWeightedOne seq)
        {
            ycompClient.UpdateDisplay();
            ycompClient.Sync();

            context.workaround.PrintHighlighted("Please choose: Which point in the interval series (corresponding to a sequence) to execute?", HighlightingMode.Choicepoint);
            Console.WriteLine(" Pre-selecting point " + pointToExecute + " chosen by random.");
            Console.WriteLine("Press (e) to enter a point in the interval series of the sequence to show."
                                + " Press (s) or (n) to commit to the pre-selected sequence and continue.");

            while(true)
            {
                context.highlightSeq = seq.Sequences[seq.GetSequenceFromPoint(pointToExecute)];
                context.choice = true;
                context.sequences = seq.Sequences;
                PrintSequence(debugSequences.Peek(), context, debugSequences.Count);
                Console.WriteLine();
                context.choice = false;
                context.sequences = null;

                ConsoleKeyInfo key = ReadKeyWithCancel();
                switch(key.KeyChar)
                {
                    case 'e':
                        double num;
                        Console.Write("Enter point in interval series of sequence to show: ");
                        String numStr = Console.ReadLine();
                        if(double.TryParse(numStr, System.Globalization.NumberStyles.Float,
                                System.Globalization.CultureInfo.InvariantCulture, out num))
                        {
                            if(num < 0.0 || num > seq.Numbers[seq.Numbers.Count - 1])
                            {
                                Console.WriteLine("You must specify a floating point number between 0.0 and " + seq.Numbers[seq.Numbers.Count - 1] + "!");
                                break;
                            }
                            pointToExecute = num;
                            break;
                        }
                        Console.WriteLine("You must enter a valid floating point number!");
                        break;
                    case 's':
                    case 'n':
                        return pointToExecute;
                    default:
                        Console.WriteLine("Illegal choice (Key = " + key.Key
                            + ")! Only (e)nter number and (s)/(n) to commit and continue allowed! ");
                        break;
                }
            }
        }
 public double ChoosePoint(double pointToExecute, SequenceWeightedOne seq)
 {
     return pointToExecute;
 }
 public void EmitSequenceWeighted(SequenceWeightedOne seqWeighted, SourceBuilder source)
 {
     source.AppendFrontFormat("double pointtoexec_{0} = GRGEN_LIBGR.Sequence.randomGenerator.NextDouble() * {1};\n", seqWeighted.Id, seqWeighted.Numbers[seqWeighted.Numbers.Count - 1].ToString(System.Globalization.CultureInfo.InvariantCulture));
     for(int i = 0; i < seqWeighted.Sequences.Count; ++i)
     {
         if(i == 0)
             source.AppendFrontFormat("if(pointtoexec_{0} <= {1})\n", seqWeighted.Id, seqWeighted.Numbers[i].ToString(System.Globalization.CultureInfo.InvariantCulture));
         else if(i == seqWeighted.Sequences.Count - 1)
             source.AppendFrontFormat("else\n");
         else
             source.AppendFrontFormat("else if(pointtoexec_{0} <= {1})\n", seqWeighted.Id, seqWeighted.Numbers[i].ToString(System.Globalization.CultureInfo.InvariantCulture));
         source.AppendFront("{\n");
         source.Indent();
         EmitSequence(seqWeighted.Sequences[i], source);
         source.AppendFront(SetResultVar(seqWeighted, GetResultVar(seqWeighted.Sequences[i])));
         source.Unindent();
         source.AppendFront("}\n");
     }
 }