コード例 #1
0
ファイル: SignalData.cs プロジェクト: Podlewski/CPS
        public List <(double, double, int)> GetDataForHistogram(int count)
        {
            List <(double, double, int)> result = new List <(double, double, int)>(count);

            double max = ConversionSamplesY.Max();
            double min = ConversionSamplesY.Min();

            double range    = max - min;
            double interval = range / count;

            for (int i = 0; i < count - 1; i++)
            {
                int points = SamplesY.Count(n => n >= min + (interval * i) && n < min + (interval * (i + 1)));
                result.Add((Math.Round(min + (interval * i), 2), Math.Round(min + (interval * (i + 1)), 2), points));
            }
            int lastPoints = SamplesY.Count(n => n >= min + (interval * (count - 1)) && n <= min + (interval * count));

            result.Add((Math.Round(min + (interval * (count - 1)), 2), Math.Round(min + (interval * count), 2), lastPoints));

            return(result);
        }
コード例 #2
0
ファイル: SignalData.cs プロジェクト: Podlewski/CPS
        public void LoadFromFile(string filePath)
        {
            using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath)))
            {
                SamplesY           = new List <double>();
                StartTime          = reader.ReadDouble();
                ConversionSampling = reader.ReadInt32();
                Type = reader.ReadByte();

                int length = reader.ReadInt32();
                for (int i = 0; i < length; i++)
                {
                    ConversionSamplesY.Add(reader.ReadDouble());
                }

                List <double> points = new List <double>();
                for (double i = 0; i < ConversionSamplesY.Count; i++)
                {
                    points.Add(StartTime + (i / ConversionSampling));
                }

                ConversionSamplesX = points;
            }
        }