Esempio n. 1
0
        public PhoutTable(string fileName)
        {
            var fileData = File.ReadAllLines(fileName);

            PhoutRows = new List <PhoutRow>();

            foreach (var line in fileData)
            {
                string[] dataRow = line.Split(_phoutInLineDelimiter, StringSplitOptions.None);

                var phoutRow = new PhoutRow
                {
                    time           = double.Parse(dataRow[0], CultureInfo.InvariantCulture),
                    tag            = dataRow[1],
                    interval_real  = float.Parse(dataRow[2]),
                    connect_time   = float.Parse(dataRow[3]),
                    send_time      = float.Parse(dataRow[4]),
                    latency        = float.Parse(dataRow[5]),
                    receive_time   = float.Parse(dataRow[6]),
                    interval_event = float.Parse(dataRow[7]),
                    size_out       = float.Parse(dataRow[8]),
                    size_in        = float.Parse(dataRow[9]),
                    net_code       = int.Parse(dataRow[10]),
                    proto_code     = int.Parse(dataRow[11])
                };

                PhoutRows.Add(phoutRow);
            }

            _firstTimeRun = PhoutRows.First().time;
        }
Esempio n. 2
0
        private void AddByReflection(ICollection <PlotData> plotCollections, PhoutRow phoutRow, string name)
        {
            var type     = phoutRow.GetType();
            var property = type.GetProperty(name);

            float value;

            if (property.PropertyType.Equals(typeof(int)))
            {
                value = (float)((int)property.GetValue(phoutRow));
            }
            else if (property.PropertyType.Equals(typeof(string)))
            {
                value = float.Parse((string)property.GetValue(phoutRow));
            }
            else if (property.PropertyType.Equals(typeof(float)))
            {
                value = (float)property.GetValue(phoutRow);
            }
            else
            {
                throw new Exception("Imposibble convert type");
            }

            var xProperty = type.GetProperty("time");
            var t         = new TimeSpan(ConvertFromUnixTimestamp((double)xProperty.GetValue(phoutRow) - _firstTimeRun).Ticks);
            var xValue    = string.Format("{0}:{1}:{2}.{3}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds);

            AddData(plotCollections, name, value, xValue);
        }