예제 #1
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[] {
         new StateVariable
         {
             Name = nameof(Key),
             Value = Key,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(StepSize),
             Value = StepSize.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(CounterType),
             Value = CounterType,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(Result),
             Value = Result,
             Type = StateVariable.StateType.Output
         }
         ,
         new StateVariable
         {
             Name = nameof(Response),
             Value = Response,
             Type = StateVariable.StateType.Output
         },
         new StateVariable
         {
             Name = nameof(SourceId),
             Value = SourceId.ToString(),
             Type = StateVariable.StateType.Input
         }
     });
 }
예제 #2
0
        /// <summary>
        /// Exports events to PlantUML.
        /// </summary>
        /// <param name="Output">PlantUML output.</param>
        /// <param name="TimeUnit">Time unit to use.</param>
        /// <param name="GoalWidth">Goal width of diagram, in pixels.</param>
        public void ExportPlantUml(StringBuilder Output, TimeUnit TimeUnit, int GoalWidth)
        {
            switch (TimeUnit)
            {
            case TimeUnit.DynamicPerEvent:
            case TimeUnit.DynamicPerThread:
                throw new InvalidOperationException("Diagram requires the same time base to be used through-out.");
            }

            Output.AppendLine("@startuml");

            foreach (ProfilerThread Thread in this.threads)
            {
                if (Thread.Parent is null)
                {
                    Thread.ExportPlantUmlDescription(Output, TimeUnit);
                }
            }

            lock (this.eventOrdinals)
            {
                foreach (KeyValuePair <string, int> P in this.eventOrdinals)
                {
                    Output.Append("concise \"");
                    Output.Append(P.Key);
                    Output.Append("\" as E");
                    Output.AppendLine(P.Value.ToString());
                }
            }

            lock (this.exceptionOrdinals)
            {
                foreach (KeyValuePair <string, int> P in this.exceptionOrdinals)
                {
                    Output.Append("concise \"");
                    Output.Append(P.Key);
                    Output.Append("\" as X");
                    Output.AppendLine(P.Value.ToString());
                }
            }

            double TimeSpan;
            double StepSize;
            int    NrSteps;

            do
            {
                KeyValuePair <double, string> TotalTime = this.ToTime(this.mainThread.StoppedAt ?? this.ElapsedTicks, this.mainThread, TimeUnit);

                TimeSpan = TotalTime.Key;
                StepSize = Math.Pow(10, Math.Round(Math.Log10(TimeSpan / 10)));
                NrSteps  = (int)Math.Floor(TimeSpan / StepSize);

                if (NrSteps >= 50)
                {
                    StepSize *= 5;
                }
                else if (NrSteps >= 25)
                {
                    StepSize *= 2.5;
                }
                else if (NrSteps >= 20)
                {
                    StepSize *= 2;
                }
                else if (NrSteps <= 2)
                {
                    StepSize /= 5;
                }
                else if (NrSteps <= 4)
                {
                    StepSize /= 2.5;
                }
                else if (NrSteps <= 5)
                {
                    StepSize /= 2;
                }

                if (StepSize < 1)
                {
                    this.timeScale *= 1e-3;
                }
            }while (StepSize < 1);

            StepSize = Math.Floor(StepSize);
            NrSteps  = (int)Math.Floor(TimeSpan / StepSize);
            int PixelsPerStep = GoalWidth / NrSteps;

            Output.Append("scale ");
            Output.Append(StepSize.ToString("F0"));
            Output.Append(" as ");
            Output.Append(PixelsPerStep);
            Output.AppendLine(" pixels");

            PlantUmlStates States = new PlantUmlStates(TimeUnit);

            foreach (ProfilerThread Thread in this.threads)
            {
                if (Thread.Parent is null)
                {
                    Thread.ExportPlantUmlEvents(States);
                }
            }

            foreach (KeyValuePair <long, StringBuilder> P in States.ByTime)
            {
                KeyValuePair <double, string> Time = this.ToTime(P.Key, null, TimeUnit);
                Output.Append('@');
                Output.AppendLine(Time.Key.ToString("F3").Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."));
                Output.Append(P.Value.ToString());
            }

            Output.Append(States.Summary.ToString());
            Output.AppendLine("@enduml");
        }
예제 #3
0
        private void buttonLK2ASC_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "LK8000 DEM files (*.dem)|*.dem";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                String fileName       = openFileDialog1.FileName;
                String outFileAscName = Path.ChangeExtension(fileName, ".asc");

                double Left;
                double Right;
                double Top;
                double Bottom;
                double StepSize;
                uint   Rows;
                uint   Columns;

                if (File.Exists(fileName))
                {
                    using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
                    {
                        Left     = reader.ReadDouble();
                        Right    = reader.ReadDouble();
                        Top      = reader.ReadDouble();
                        Bottom   = reader.ReadDouble();
                        StepSize = reader.ReadDouble();
                        Rows     = reader.ReadUInt32();
                        Columns  = reader.ReadUInt32();

                        //uint nsize = Rows * Columns;

                        var          utf8WithoutBom = new System.Text.UTF8Encoding(false);
                        FileStream   ostream        = new FileStream(outFileAscName, FileMode.Create, FileAccess.ReadWrite);
                        StreamWriter writer         = new StreamWriter(ostream, utf8WithoutBom);


                        writer.WriteLine("ncols         " + Columns.ToString());
                        writer.WriteLine("nrows         " + Rows.ToString());
                        writer.WriteLine("xllcorner     " + Left.ToString());
                        writer.WriteLine("yllcorner     " + Bottom.ToString());
                        writer.WriteLine("cellsize      " + StepSize.ToString());

                        writer.WriteLine("NODATA_value  0");
                        writer.Flush();


                        for (int r = 0; r < Rows; r++)
                        {
                            String line = "";
                            short  val;
                            for (int c = 0; c < Columns; c++)
                            {
                                val   = reader.ReadInt16();
                                line += val.ToString() + " ";
                            }
                            writer.WriteLine(line);
                        }

                        writer.Flush();
                        ostream.Close();

                        MessageBox.Show("Done");
                    }
                }
            }
        }