예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
            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);
            }
예제 #3
0
            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);
            }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
            public static void InsertHourInfo(SQLiteConnection connection, string uniqueId, Data.HourInfo hourInfo)
            {
                string columnFormat = "`{0}`";
                string valueFormat  = "'{0}'";

                string query = "INSERT OR REPLACE INTO `hours` (" +

                               string.Format(columnFormat, "unique_id") + ", " +

                               string.Format(columnFormat, "date") + ", " +
                               string.Format(columnFormat, "hour") + ", " +

                               string.Format(columnFormat, "planned_production_time") + ", " +
                               string.Format(columnFormat, "operating_time") + ", " +
                               string.Format(columnFormat, "ideal_operating_time") + ", " +
                               string.Format(columnFormat, "total_pieces") + ", " +
                               string.Format(columnFormat, "good_pieces") + ", " +

                               string.Format(columnFormat, "active") + ", " +
                               string.Format(columnFormat, "idle") + ", " +
                               string.Format(columnFormat, "alert") + ", " +

                               string.Format(columnFormat, "production") + ", " +
                               string.Format(columnFormat, "setup") + ", " +
                               string.Format(columnFormat, "teardown") + ", " +
                               string.Format(columnFormat, "maintenance") + ", " +
                               string.Format(columnFormat, "process_development") +

                               ") VALUES (" +

                               string.Format(valueFormat, uniqueId) + ", " +

                               string.Format(valueFormat, hourInfo.Date) + ", " +
                               string.Format(valueFormat, hourInfo.Hour) + ", " +

                               string.Format(valueFormat, hourInfo.PlannedProductionTime) + ", " +
                               string.Format(valueFormat, hourInfo.OperatingTime) + ", " +
                               string.Format(valueFormat, hourInfo.IdealOperatingTime) + ", " +
                               string.Format(valueFormat, hourInfo.TotalPieces) + ", " +
                               string.Format(valueFormat, hourInfo.GoodPieces) + ", " +

                               string.Format(valueFormat, hourInfo.Active) + ", " +
                               string.Format(valueFormat, hourInfo.Idle) + ", " +
                               string.Format(valueFormat, hourInfo.Alert) + ", " +

                               string.Format(valueFormat, hourInfo.Production) + ", " +
                               string.Format(valueFormat, hourInfo.Setup) + ", " +
                               string.Format(valueFormat, hourInfo.Teardown) + ", " +
                               string.Format(valueFormat, hourInfo.Maintenance) + ", " +
                               string.Format(valueFormat, hourInfo.ProcessDevelopment) +

                               ")";


                Query.Run(connection, query);
            }