private void listBoxBatches_MouseClick(object sender, MouseEventArgs e)
        {
            int     itemIndex         = listBoxBatches.SelectedIndex;
            BatchDO chosenBatchReport = reports[itemIndex];

            chosenReport.Text = batchReportShower.ShowBatchInfo(chosenBatchReport);
        }
Exemple #2
0
        public bool UpdateBatchReport(LiveRelevantDataDO liveRelevantData)
        {
            bool success = false;

            using (DataContext context = new DataContext())
            {
                //Returns the latest Batch report saved in the database.
                BatchDO batchReport = context.BatchReports.Find(liveRelevantData.BatchID);
                //Update batchReport data
                batchReport.ProducedProducts  = liveRelevantData.ProducedProducts;
                batchReport.DefectProducts    = liveRelevantData.DefectProducts;
                batchReport.ProductionEndTime = System.DateTime.Now;

                //Create a new entry of environmental log
                EnvironmentalLogDO environmentalLog = new EnvironmentalLogDO
                {
                    BatchReportID = batchReport.BatchReportID,
                    Temperature   = liveRelevantData.Temperature,
                    Vibration     = liveRelevantData.Vibration,
                    Humidity      = liveRelevantData.Humidity,
                    Time          = System.DateTime.Now
                };
                //Save environmental log entry
                batchReport.EnvironmentalLogs.Add(environmentalLog);

                StateLogDO stateLog = context.StateLogs.FirstOrDefault(s => s.BatchReportID == batchReport.BatchReportID);
                stateLog.SetTimeInStates(liveRelevantData.StateDictionary);

                context.SaveChanges();

                success = true;
            }
            return(success);
        }
        private void getBatches_Click(object sender, EventArgs e)
        {
            reports.Clear();
            int     batchId        = -1;
            BatchDO specificReport = null;

            if (searchTextBox.Text != null && int.TryParse(searchTextBox.Text, out batchId))
            {
                specificReport = logicFacade.GetSpecificReport(batchId);
            }

            if (specificReport != null)
            {
                reports.Add(specificReport);
                chosenReport.Text = batchReportShower.ShowBatchInfo(specificReport);
            }
            else
            {
                reports = logicFacade.GetAllBatchReports();
            }


            List <string> selectedReports = new List <string>();

            for (int i = 0; i < reports.Count; i++)
            {
                selectedReports.Add("Batchreport ID: " + reports[i].BatchReportID);
            }

            listBoxBatches.DataSource = selectedReports;
        }
        private double CalculateQuality(BatchDO batchDO)
        {
            double quality;
            double AcceptableProducts = (double)(batchDO.ProducedProducts - batchDO.DefectProducts);

            quality = AcceptableProducts / (double)batchDO.ProducedProducts;
            return(quality);
        }
        private double CalculateAvailability(BatchDO batchDO)
        {
            double availability;
            double runTime  = batchDO.ProductionEndTime.Subtract(batchDO.ProductionStartTime).TotalMinutes;
            double downTime = GetStateDownTime(batchDO.StateDictionary);

            availability = (runTime - downTime) / runTime;
            return(availability);
        }
Exemple #6
0
        public BatchDO LoadBatchReport(int BatchID)
        {
            DataContext context = new DataContext();

            BatchDO    batchDO    = context.BatchReports.Find(BatchID);
            StateLogDO stateLogDO = context.StateLogs.FirstOrDefault(s => s.BatchReportID == BatchID);

            return(loadStateDictionaryOnBatchDO(batchDO, stateLogDO));
        }
 public string ShowBatchInfo(BatchDO chosenBatchReport)
 {
     return("Batch ID: " + chosenBatchReport.BatchReportID + "\n" +
            "Producttype: " + (ProductType)chosenBatchReport.ProductType + "\n" +
            "Created products: " + chosenBatchReport.BatchSize + "\n" +
            "Acceptable products: " + chosenBatchReport.ProducedProducts + "\n" +
            "Defective products: " + chosenBatchReport.DefectProducts + "\n" +
            GetTimeInStates(chosenBatchReport.StateDictionary) + "\n" +
            GetAllEnvironmentalInfo(chosenBatchReport.EnvironmentalLogs));
 }
        private double CalculatePerformance(BatchDO batchDO)
        {
            double performance;
            //Gather necessary data and calculate Performance
            double          runTime         = batchDO.ProductionEndTime.Subtract(batchDO.ProductionStartTime).TotalMinutes;
            ProductType     productType     = (ProductType)batchDO.ProductType;
            ProductMaxSpeed productMaxSpeed = (ProductMaxSpeed)Enum.Parse(typeof(ProductMaxSpeed), productType.ToString());
            double          idealCycleTime  = 60 / (double)((int)productMaxSpeed);

            performance = (idealCycleTime * (double)batchDO.ProducedProducts) / runTime;
            return(performance);
        }
Exemple #9
0
        public bool SaveBatchReport(BatchDO batchReport)
        {
            bool success = false;

            using (DataContext context = new DataContext())
            {
                //Create empty StateLog entry
                StateLogDO stateLog = new StateLogDO();
                stateLog.BatchReportID = batchReport.BatchReportID;
                //Save Batch Report
                context.BatchReports.Add(batchReport);
                context.StateLogs.Add(stateLog);
                context.SaveChanges();

                success = true;
            }
            return(success);
        }
Exemple #10
0
        public int GetLastBatchReportID()
        {
            int batchReportID = 0;

            using (DataContext context = new DataContext())
            {
                try
                {
                    //Returns the latest Batch report saved in the database.
                    BatchDO batchReport = context.BatchReports.OrderByDescending(
                        b => b.BatchReportID).FirstOrDefault();
                    batchReportID = batchReport.BatchReportID;
                }
                catch (NullReferenceException)
                {
                }
            }
            return(batchReportID);
        }
Exemple #11
0
 private BatchDO loadStateDictionaryOnBatchDO(BatchDO batchDO, StateLogDO stateLogDO)
 {
     batchDO.StateDictionary.Add((int)MachineState.Deactivated, new TimeSpan((stateLogDO.DeactivatedState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Clearing, new TimeSpan((stateLogDO.ClearingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Stopped, new TimeSpan((stateLogDO.StoppedState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Starting, new TimeSpan((stateLogDO.StartingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Idle, new TimeSpan((stateLogDO.IdleState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Suspended, new TimeSpan((stateLogDO.SuspendedState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Execute, new TimeSpan((stateLogDO.ExecuteState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Stopping, new TimeSpan((stateLogDO.StoppingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Aborting, new TimeSpan((stateLogDO.AbortingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Aborted, new TimeSpan((stateLogDO.AbortedState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Holding, new TimeSpan((stateLogDO.HoldingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Held, new TimeSpan((stateLogDO.HeldState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Resetting, new TimeSpan((stateLogDO.ResettingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Completing, new TimeSpan((stateLogDO.CompletingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Complete, new TimeSpan((stateLogDO.CompleteState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Deactivating, new TimeSpan((stateLogDO.DeactivatingState.Value)));
     batchDO.StateDictionary.Add((int)MachineState.Activating, new TimeSpan((stateLogDO.ActivatingState.Value)));
     return(batchDO);
 }
Exemple #12
0
 public bool SaveBatchReport(BatchDO batchReport)
 {
     return(databaseManager.SaveBatchReport(batchReport));
 }