Пример #1
0
            public void CombineHours()
            {
                lock (_lock)
                {
                    if (Hours != null && Hours.Count > 0)
                    {
                        var newHours = new List<HourInfo>();

                        var _hours = Hours.ToList();
                        if (_hours != null) _hours = _hours.FindAll(o => o != null); // Clean list of any null HourInfos

                        var distinctDates = _hours.Select(o => o.Date).Distinct();

                        foreach (string distinctDate in distinctDates.ToList())
                        {
                            var sameDate = _hours.FindAll(o => o.Date == distinctDate);

                            var distinctHours = sameDate.Select(o => o.Hour).Distinct();

                            foreach (int distinctHour in distinctHours.ToList())
                            {
                                var hourInfo = new HourInfo();
                                hourInfo.Date = distinctDate;
                                hourInfo.Hour = distinctHour;

                                double plannedProductionTime = 0;
                                double operatingtime = 0;
                                double idealOperatingTime = 0;
                                int totalPieces = 0;
                                int goodPieces = 0;

                                double active = 0;
                                double idle = 0;
                                double alert = 0;

                                double production = 0;
                                double setup = 0;
                                double teardown = 0;
                                double maintenance = 0;
                                double processDevelopment = 0;

                                var sameHours = _hours.FindAll(o => o.Hour == distinctHour);
                                foreach (var sameHour in sameHours.ToList())
                                {
                                    // OEE
                                    plannedProductionTime += sameHour.PlannedProductionTime;
                                    operatingtime += sameHour.OperatingTime;
                                    idealOperatingTime += sameHour.IdealOperatingTime;
                                    totalPieces += sameHour.TotalPieces;
                                    goodPieces += sameHour.GoodPieces;

                                    // Device Status
                                    active += sameHour.Active;
                                    idle += sameHour.Idle;
                                    alert += sameHour.Alert;

                                    // Production Status
                                    production += sameHour.Production;
                                    setup += sameHour.Setup;
                                    teardown += sameHour.Teardown;
                                    maintenance += sameHour.Maintenance;
                                    processDevelopment += sameHour.ProcessDevelopment;
                                }

                                hourInfo.PlannedProductionTime = Math.Round(plannedProductionTime, 2);
                                hourInfo.OperatingTime = Math.Round(operatingtime, 2);
                                hourInfo.IdealOperatingTime = Math.Round(idealOperatingTime, 2);
                                hourInfo.TotalPieces = totalPieces;
                                hourInfo.GoodPieces = goodPieces;

                                hourInfo.Active = Math.Round(active, 2);
                                hourInfo.Idle = Math.Round(idle, 2);
                                hourInfo.Alert = Math.Round(alert, 2);

                                hourInfo.Production = Math.Round(production, 2);
                                hourInfo.Setup = Math.Round(setup, 2);
                                hourInfo.Teardown = Math.Round(teardown, 2);
                                hourInfo.Maintenance = Math.Round(maintenance, 2);
                                hourInfo.ProcessDevelopment = Math.Round(processDevelopment, 2);

                                newHours.Add(hourInfo);
                            }
                        }

                        Hours = newHours;
                    }
                }
            }
Пример #2
0
            public static List<HourInfo> CombineHours(List<HourInfo> hours)
            {
                var newHours = new List<HourInfo>();

                // Used 'lock' since it sometimes threw a 'source array was not long enough' exception
                var _hours = hours.ToList();

                // Clean list of any null HourInfos
                _hours = _hours.FindAll(o => o != null);

                var distinctDates = _hours.Select(o => o.Date).Distinct();
                foreach (string distinctDate in distinctDates.ToList())
                {
                    var sameDate = _hours.FindAll(o => o.Date == distinctDate);

                    var distinctHours = sameDate.Select(o => o.Hour).Distinct();
                    foreach (int distinctHour in distinctHours.ToList())
                    {
                        var hourInfo = new HourInfo();
                        hourInfo.Date = distinctDate;
                        hourInfo.Hour = distinctHour;

                        double plannedProductionTime = 0;
                        double operatingtime = 0;
                        double idealOperatingTime = 0;
                        int totalPieces = 0;
                        int goodPieces = 0;

                        double active = 0;
                        double idle = 0;
                        double alert = 0;

                        double production = 0;
                        double setup = 0;
                        double teardown = 0;
                        double maintenance = 0;
                        double processDevelopment = 0;

                        var sameHours = _hours.FindAll(o => o.Hour == distinctHour);
                        foreach (var sameHour in sameHours.ToList())
                        {
                            // OEE
                            plannedProductionTime += sameHour.PlannedProductionTime;
                            operatingtime += sameHour.OperatingTime;
                            idealOperatingTime += sameHour.IdealOperatingTime;
                            totalPieces += sameHour.TotalPieces;
                            goodPieces += sameHour.GoodPieces;

                            // Device Status
                            active += sameHour.Active;
                            idle += sameHour.Idle;
                            alert += sameHour.Alert;

                            // Production Status
                            production += sameHour.Production;
                            setup += sameHour.Setup;
                            teardown += sameHour.Teardown;
                            maintenance += sameHour.Maintenance;
                            processDevelopment += sameHour.ProcessDevelopment;
                        }

                        hourInfo.PlannedProductionTime = Math.Round(plannedProductionTime, 2);
                        hourInfo.OperatingTime = Math.Round(operatingtime, 2);
                        hourInfo.IdealOperatingTime = Math.Round(idealOperatingTime, 2);
                        hourInfo.TotalPieces = totalPieces;
                        hourInfo.GoodPieces = goodPieces;

                        hourInfo.Active = Math.Round(active, 2);
                        hourInfo.Idle = Math.Round(idle, 2);
                        hourInfo.Alert = Math.Round(alert, 2);

                        hourInfo.Production = Math.Round(production, 2);
                        hourInfo.Setup = Math.Round(setup, 2);
                        hourInfo.Teardown = Math.Round(teardown, 2);
                        hourInfo.Maintenance = Math.Round(maintenance, 2);
                        hourInfo.ProcessDevelopment = Math.Round(processDevelopment, 2);

                        newHours.Add(hourInfo);
                    }
                }

                return newHours;
            }
Пример #3
0
            public void AddHourInfo(HourInfo hourInfo)
            {
                lock (_lock)
                {
                    if (hourInfo != null)
                    {

                        var hours = Hours;
                        if (hours == null) hours = new List<HourInfo>();

                        hours.Add(hourInfo);

                        Hours = hours;
                    }
                }
            }