private static BartlettReportLine GetSegmentMeta(BartlettSegment segment, BartlettReportLine reportRow)
 {
     reportRow.SegmentNumber     = segment.Number;
     reportRow.SegmentStart      = segment.StartTime.ToString();
     reportRow.SegmentEnd        = segment.EndTime.ToString();
     reportRow.SegmentTargetTemp = segment.TargetTemp.ToString();
     reportRow.SegmentStartTemp  = segment.StartTemp.ToString();
     reportRow.SegmentEndTemp    = segment.EndTemp.ToString();
     reportRow.SegmentHoldTime   = segment.HoldTime;
     reportRow.SegmentClimbRate  = segment.ClimbRate.ToString();
     return(reportRow);
 }
        /// <summary>
        /// ent
        /// </summary>
        /// <param name="logRecords"></param>
        /// <param name="startTime"></param>
        /// <returns></returns>
        private static List <BartlettSegment> GetSegmentsFromRawLogRecords(List <BartlettLogRecordRaw> logRecords, DateTime startTime)
        {
            var             segments    = new List <BartlettSegment>();
            var             lastSegment = 0;
            BartlettSegment segment     = null;

            foreach (var record in logRecords)
            {
                if (record.Event.Equals("block continue"))
                {
                    continue;
                }

                if (record.Event.Equals("start ramp"))
                {
                    if (segment != null && segment.TempRecords.Count > 0)
                    {
                        segment.EndTime = DateTime.Parse(record.DateTime.Replace("Z", ""));
                        segments.Add(segment);
                        segment = null;
                    }

                    if (segment == null)
                    {
                        segment = new BartlettSegment();
                    }

                    if (record.DateTime != null && record.DateTime.Length > 0)
                    {
                        segment.StartTime = DateTime.Parse(record.DateTime.Replace("Z", ""));
                    }

                    if (record.EventName.Equals("segment"))
                    {
                        segment.Number = Int32.Parse(record.EventValue);
                    }
                    if (record.EventName.Equals("rate"))
                    {
                        segment.ClimbRate = Int32.Parse(record.EventValue);
                    }
                    if (record.EventName.Equals("temp"))
                    {
                        segment.TargetTemp = Int32.Parse(record.EventValue);
                    }
                }

                if (record.TimeOffset != null && !record.TimeOffset.Equals(""))
                {
                    segment.TempRecords.Add(new BartlettTempRecord()
                    {
                        Time     = startTime.AddSeconds(Int32.Parse(record.TimeOffset) * 30),
                        Setpoint = Int32.Parse(record.SetPoint),
                        TempAvg  = Int32.Parse(record.Temp2),
                        OutAvg   = Int32.Parse(record.Out2)
                    });
                }

                if (record.Event.Equals("start hold"))
                {
                    if (record.EventName.Equals("hold time"))
                    {
                        segment.HoldTime = record.EventValue;
                    }
                    if (record.DateTime != null && record.DateTime.Length > 0)
                    {
                        segment.EndTime = DateTime.Parse(record.DateTime.Replace("Z", ""));
                    }
                    if (record.EventName.Equals("temp"))
                    {
                        segment.EndTemp = Int32.Parse(record.EventValue);
                        if (segment.TempRecords != null && segment.TempRecords[0] != null)
                        {
                            segment.StartTemp = segment.TempRecords[0].TempAvg;
                        }
                        if (segment.HoldTime.Equals("0h0m"))
                        {
                            segments.Add(segment);
                            segment = null;
                        }
                        continue;
                    }
                }
                if (record.Event.Equals("manual stop firing") || record.Event.Equals("firing complete"))
                {
                    if (record.DateTime != null && record.DateTime.Length > 0)
                    {
                        segment.EndTime = DateTime.Parse(record.DateTime.Replace("Z", ""));
                    }

                    if (segment.TempRecords != null && segment.TempRecords[0] != null)
                    {
                        segment.StartTemp = segment.TempRecords[0].TempAvg;
                        segment.EndTemp   = segment.TempRecords.TakeLast(1).ToList()[0].TempAvg;
                    }

                    if (segment.HoldTime == null || segment.HoldTime.Length < 1)
                    {
                        segment.HoldTime = "0h0m";
                    }

                    segments.Add(segment);
                    segment = null;
                    continue;
                }
            }

            return(segments);
        }