public static HourRowInfo GetHourInfo(SQLiteConnection connection, DataRow row) { // Get Unique Id string uniqueId = DataTable_Functions.GetRowValue("unique_id", row); if (!string.IsNullOrEmpty(uniqueId)) { var result = new HourRowInfo(); result.UniqueId = uniqueId; var hourInfo = new Data.HourInfo(); hourInfo.Date = DataTable_Functions.GetRowValue("date", row); hourInfo.Hour = DataTable_Functions.GetIntegerFromRow("hour", row); hourInfo.PlannedProductionTime = DataTable_Functions.GetDoubleFromRow("planned_production_time", row); hourInfo.OperatingTime = DataTable_Functions.GetDoubleFromRow("operating_time", row); hourInfo.IdealOperatingTime = DataTable_Functions.GetDoubleFromRow("ideal_operating_time", row); hourInfo.TotalPieces = DataTable_Functions.GetIntegerFromRow("total_pieces", row); hourInfo.GoodPieces = DataTable_Functions.GetIntegerFromRow("good_pieces", row); hourInfo.Active = DataTable_Functions.GetDoubleFromRow("active", row); hourInfo.Idle = DataTable_Functions.GetDoubleFromRow("idle", row); hourInfo.Alert = DataTable_Functions.GetDoubleFromRow("alert", row); hourInfo.Production = DataTable_Functions.GetDoubleFromRow("production", row); hourInfo.Setup = DataTable_Functions.GetDoubleFromRow("setup", row); hourInfo.Teardown = DataTable_Functions.GetDoubleFromRow("teardown", row); hourInfo.Maintenance = DataTable_Functions.GetDoubleFromRow("maintenance", row); hourInfo.ProcessDevelopment = DataTable_Functions.GetDoubleFromRow("process_development", row); result.HourInfo = hourInfo; return result; } return null; }
private void UpdatePartCount(EventData data) { if (data.Data01 != null && data.Data02 != null) { var infos = (List<Parts.PartInfo>)data.Data02; if (infos != null) { var pc = Parts.Configuration.Get(configuration); if (pc != null) { foreach (var info in infos) { var hourInfo = new Data.HourInfo(); hourInfo.Date = info.Timestamp.ToString(Data.HourInfo.DATE_FORMAT); hourInfo.Hour = info.Timestamp.Hour; hourInfo.TotalPieces = info.Count; lock (_lock) deviceInfo.AddHourInfo(hourInfo); } queue.Add(deviceInfo); } } } }
public static List<Data.HourInfo> GetHourInfos(List<GeneratedEvents.GeneratedEvent> gEvents) { var hours = new List<Data.HourInfo>(); foreach (var gEvent in gEvents) { if (gEvent.CurrentValue != null) { var hourInfo = new Data.HourInfo(); hourInfo.Date = gEvent.CurrentValue.Timestamp.ToString(Data.HourInfo.DATE_FORMAT); hourInfo.Hour = gEvent.CurrentValue.Timestamp.Hour; double duration = Math.Round(gEvent.Duration.TotalSeconds, 2); // Device Status if (gEvent.EventName == "device_status" && !string.IsNullOrEmpty(gEvent.CurrentValue.Value)) { switch (gEvent.CurrentValue.Value.ToLower()) { case "active": hourInfo.Active = duration; break; case "idle": hourInfo.Idle = duration; break; case "alert": hourInfo.Alert = duration; break; } } // Production Status if (gEvent.EventName == "production_status" && !string.IsNullOrEmpty(gEvent.CurrentValue.Value)) { switch (gEvent.CurrentValue.Value.ToLower()) { case "production": hourInfo.Production = duration; break; case "setup": hourInfo.Setup = duration; break; case "teardown": hourInfo.Teardown = duration; break; case "maintenance": hourInfo.Maintenance = duration; break; case "process_development": hourInfo.ProcessDevelopment = duration; break; } } hours.Add(hourInfo); } } return hours; }
private void UpdateOee(EventData data) { if (data.Data01 != null && data.Data02 != null) { var oeeDatas = (List<OEE.OEEData>)data.Data02; if (oeeDatas != null) { foreach (var oeeData in oeeDatas) { var info = new Data.HourInfo(); info.Date = oeeData.Timestamp.ToString(Data.HourInfo.DATE_FORMAT); info.Hour = oeeData.Timestamp.Hour; info.PlannedProductionTime = Math.Round(Math.Max(0, oeeData.PlannedProductionTime), 2); info.OperatingTime = Math.Round(Math.Max(0, oeeData.OperatingTime), 2); info.IdealOperatingTime = Math.Round(Math.Max(0, oeeData.IdealOperatingTime), 2); deviceInfo.AddHourInfo(info); } queue.Add(deviceInfo); } } }