Ejemplo n.º 1
0
 public Product(Batch batch, int id, LogProvider logProvider, DetroitDataSet detroitDataSet)
 {
     this.router         = new DbProductRouter(1, detroitDataSet, batch.TypeId);
     this.batch          = batch;
     this.id             = id;
     this.name           = batch.Name + "/" + id.ToString();
     this.map            = null; // new ProductMap(this, batch.Map, logProvider);
     this.Map            = map;
     this.failedStations = new List <string>();
     batch.AddProduct(this);
 }
Ejemplo n.º 2
0
        private void fillProductBuffer()
        {
            try
            {
                // fill the buffer only if it is empty !
                if (this.productBuffer.Count == 0)
                {
                    Batch enBatch = null;

                    // check database for new batches in queue ?!
                    lineQueue.Refresh();

                    // check and get first batch from LineQueue
                    if (lineQueue.Count > 0)
                    {
                        enBatch = lineQueue.Peek();
                    }
                    if (enBatch == null)
                    {
                        //myLog.LogAlert(AlertType.System, detroitDataSet.LineId.ToString(), this.GetType().ToString(), "fillProductBuffer()",
                        //    String.Format("Line Queue is empty! There is no any batch."), "system");
                    }
                    else
                    {
                        lineQueue.Dequeue();  // remove the batch from LineQueue !!
                        enBatch.PutOnLine();  // change state of the Batch

                        myLog.LogAlert(AlertType.Info, detroitDataSet.LineId.ToString(), this.GetType().ToString(), "fillProductBuffer()",
                                       String.Format("Putting batch {0} on line #{1}.", enBatch.Name, detroitDataSet.LineId.ToString()), "system");

                        int i = 0;
                        while (i < enBatch.Capacity)
                        {
                            i++;
                            Product newProduct = new Product(enBatch, i, this.myLog, this.detroitDataSet);
                            this.productBuffer.Enqueue(newProduct);
                            enBatch.AddProduct(newProduct);
                            myLog.LogAlert(AlertType.Info, detroitDataSet.LineId.ToString(), this.GetType().ToString(), "fillProductBuffer()",
                                           String.Format("Putting new product {0} on line #{1}.", newProduct.Name, detroitDataSet.LineId.ToString()), "system");

                            // This functionality is providing by SlowTask!
                            // put product in table in Detroit LineSnapshot for plan calculation
                            //
                            //this.lineSnapshotTable.AddLineSnapshotRow(
                            //    -1,
                            //    enBatch.Id,
                            //    newProduct.Id,
                            //    (int)ProductState.InBuffer,
                            //    this.detroitDataSet.LineId,
                            //    newProduct.Name,
                            //    123456, //TODO: this.taktDuration - this.lineCounter,
                            //    DateTime.Now,
                            //    newProduct.Router.State
                            //);
                        }
                        //x this.lineSnapshotTableAdapter.Update(this.lineSnapshotTable);
                        batchesOnLine.Enqueue(enBatch);
                    }
                }
            }
            catch (Exception ex)
            {
                this.myLog.LogAlert(AlertType.Error, this.detroitDataSet.LineId.ToString(), ex.TargetSite.ToString(),
                                    ex.Source.ToString(), ex.Message.ToString(), "system");
            }
        }