コード例 #1
0
        ///<summary>
        ///<para>dictionary[day][shiftNo][lotsQty,modulesQty]</para>
        ///</summary>
        public static Dictionary <DateTime, Dictionary <int, lotPiecesQuantity> > quantityPerDayPerShift(DataTable sqlTable)
        {
            //DataCzasKoniec,LiniaSMT,Model,IloscWykonana
            Dictionary <DateTime, Dictionary <int, lotPiecesQuantity> > result = new Dictionary <DateTime, Dictionary <int, lotPiecesQuantity> >();

            //Dictionary<DateTime, Dictionary<int, DataTable>> tagTables = new Dictionary<DateTime, Dictionary<int, DataTable>>();


            //Tools.dateShiftNo startingDateShift = Tools.whatDayShiftIsit(DateTime.Parse(sqlTable.Rows[0]["DataCzasKoniec"].ToString()));

            foreach (DataRow row in sqlTable.Rows)
            {
                Tools.dateShiftNo dateShift = Tools.whatDayShiftIsit(DateTime.Parse(row["DataCzasKoniec"].ToString()));
                //Debug.WriteLine(row["DataCzasKoniec"].ToString() + " - " + dateShift.date.ToShortTimeString() + " - " + dateShift.shift);
                //if (dateShift.date == startingDateShift.date & dateShift.shift == startingDateShift.shift) continue;

                Int32 modulesQty = 0;
                if (!Int32.TryParse(row["IloscWykonana"].ToString(), out modulesQty))
                {
                    continue;
                }

                if (!result.ContainsKey(dateShift.date.Date))
                {
                    result.Add(dateShift.date.Date, new Dictionary <int, lotPiecesQuantity>());
                    //tagTables.Add(dateShift.date.Date, new Dictionary<int, DataTable>());
                }

                if (!result[dateShift.date.Date].ContainsKey(dateShift.shift))
                {
                    result[dateShift.date.Date].Add(dateShift.shift, new lotPiecesQuantity());
                    //tagTables[dateShift.date.Date].Add(dateShift.shift, new DataTable());
                }

                lotPiecesQuantity qty = new lotPiecesQuantity();
                qty.lots    = result[dateShift.date.Date][dateShift.shift].lots + 1;
                qty.modules = result[dateShift.date.Date][dateShift.shift].modules + modulesQty;

                if (result[dateShift.date.Date][dateShift.shift].tagAllLots == null)
                {
                    qty.tagAllLots = sqlTable.Clone();
                }
                else
                {
                    qty.tagAllLots = result[dateShift.date.Date][dateShift.shift].tagAllLots.Clone();
                    foreach (DataRow r in result[dateShift.date.Date][dateShift.shift].tagAllLots.Rows)
                    {
                        qty.tagAllLots.Rows.Add(r.ItemArray);
                    }
                }
                //if (qty.tagAllLots == null)


                qty.tagAllLots.Rows.Add(row.ItemArray);

                result[dateShift.date.Date][dateShift.shift] = qty;
            }

            return(result);
        }
コード例 #2
0
        private void EfficiencyTick2()
        {
            if (dataGridViewLg.Rows.Count > 0)
            {
                int lotsThisShift = EfficiencyTools.HowManyLotsThisShift(dataGridViewLg);
                if (lotsThisShift > 0)
                {
                    Tools.dateShiftNo shiftStart            = Tools.whatDayShiftIsit(DateTime.Now);
                    double            minutesFromShiftStart = (DateTime.Now - shiftStart.date).TotalMinutes;
                    double            lotsPerShift          = (480 * (double)lotsThisShift) / minutesFromShiftStart;
                    double            efficiency            = Math.Round(lotsPerShift / normLotsPerShift * 100, 1);

                    labelWasteLed.Text      = "Odpad diody LED: " + EfficiencyTools.CalculateLedDiodeWasteLevel(dataGridViewLg, normPerModel)[0] + "%";
                    labelModuleWaste.Text   = "Odpad modułów: " + EfficiencyTools.CalculateLedDiodeWasteLevel(dataGridViewLg, normPerModel)[1] + "%";
                    labelLotsThisShift.Text = "LOTy od początku zmiany: " + lotsThisShift;
                    labelEfficiency.Text    = "Wydajność: " + efficiency + "%";

                    bool debugOff = true;
#if DEBUG
                    debugOff = false;
#endif

                    if (debugOff)
                    {
                        if (DateTime.Now.Minute == 0 || DateTime.Now.Minute == 30)
                        {
                            Charting.DrawEfficiencyChart(pbChart, (float)efficiency);
                        }
                    }
                    else
                    {
                        Charting.DrawEfficiencyChart(pbChart, (float)efficiency);
                    }
                }
                else
                {
                    labelWasteLed.Text      = "Odpad diody LED: -";
                    labelModuleWaste.Text   = "Odpad modułów: ";
                    labelLotsThisShift.Text = "LOTy od początku zmiany: -";
                    labelEfficiency.Text    = "Wydajność: -";
                }

                if (dataGridViewLg.Rows.Count > 2)
                {
                    EfficiencyTools.QuantityDictionaryToGrid(dataGridView3DaysInfo, EfficiencyTools.quantityPerDayPerShift(SqlOperations.GetSmtRecordsFromDbQuantityOnly(5, smtLine)));
                    Charting.DrawDayByDayEfficiency(dataGridView3DaysInfo, pictureBoxShifts);
                }
            }
        }