/// <summary> /// Get the time from the build start time until bottom temperature reached 100 degrees /// </summary> /// <param name="db"></param> /// <param name="startTime"></param> /// <param name="endTime">Time when build is stopped</param> /// <returns></returns> public static TimeSpan?GetTotalBuildTime(IItemDatabase db, DateTime startTime, DateTime endTime) { LogRowDataPoint dataPoint = db.GetFirstItemDP("OPC.Temperature.BottomTemperature", p => (p.TimeStamp >= endTime && p.Value <= 110d)); if (dataPoint == null) { dataPoint = db.GetLastItemDP("OPC.Temperature.BottomTemperature"); } return(dataPoint.TimeStamp - startTime); }
/// <summary> /// Get the end time of the build. /// </summary> /// <param name="db"></param> /// <param name="buildEnd"></param> /// <param name="completed"></param> /// <remarks> /// Will return the timestamp of the following in prioritized order: /// 1. Build is done, completed is set to true /// 2. Build is crashed. /// 3. Time of the last action in the log file. /// 4. Time of the last task. /// </remarks> public static void GetBuildEnd(IItemDatabase db, out DateTime buildEnd, out bool completed) { LogRowDataPoint buildDone = db.GetLastItemDP("Process.ProcessManager.BuildDone", x => x.Value == 1); LogRowDataPoint buildCrashed = db.GetLastItemDP("Process.ProcessManager.BuildCrashed", x => x.Value == 1); LogRowDataPoint stopProcess = db.GetLastItemDP("Process.ProcessManager.StopProcess", x => x.Value == 1); LogRowDataPoint lastTask = db.GetLastItemDP("Process.ProcessManager.Task"); LogRowDataPoint lastMeltAction = db.GetLastItemDP("Process.ProcessManager.Action"); completed = false; if (buildDone != null && buildDone.Value == 1) { buildEnd = buildDone.TimeStamp; completed = true; } else if (buildCrashed != null && buildCrashed.Value == 1) { buildEnd = buildCrashed.TimeStamp; } else if (lastMeltAction != null) { buildEnd = lastMeltAction.TimeStamp; } else if (stopProcess != null) { buildEnd = stopProcess.TimeStamp; } else if (lastTask != null) { buildEnd = lastTask.TimeStamp; } else { throw new ApplicationException("End of build not found."); } }
/// <summary> /// Get the time from the first layer until Internal Process State not running /// </summary> /// <param name="db"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static TimeSpan?GetMeltTime(IItemDatabase db, DateTime startTime, DateTime endTime) { LogRowDataPoint processStopped = db.GetLastItemDP("Process.ProcessManager.InternalProcessStop", p => p.TimeStamp > startTime && p.Value >= 0.5); if (processStopped == null) { return(null); } LogRowDataPoint firstLayer = db.GetFirstItemDP("Beam.LayerThickness", p => p.TimeStamp >= startTime && p.TimeStamp <= endTime && p.Value > 0); if (firstLayer == null) { return(null); } //throw new ApplicationException("Did not find the time of the first layer in the log file."); return(processStopped.TimeStamp - firstLayer.TimeStamp); }