Example #1
0
        public Supplier(int id, DetroitDataSet detroit, LogProvider logProvider, Dispatcher lineDispatcher)
        {
            this.id             = id;
            this.detroitDataSet = detroit;
            this.myLog          = logProvider;
            this.lineDispatcher = lineDispatcher;

            this.lineSnapshotTableAdapter = new LineSnapshotTableAdapter();
            this.lineSnapshotTable        = this.detroitDataSet.LineSnapshot;
            this.lineSnapshotTableAdapter.Fill(this.lineSnapshotTable, this.detroitDataSet.LineId);

            this.productOutBufferTableAdapter   = new ProductBufferTableAdapter();
            this.productInboxBufferTableAdapter = new ProductBufferTableAdapter();

            this.productBuffer = new ProductBuffer();
            this.lineQueue     = new LineQueue(detroit, logProvider);

            this.batchesOnLine = new BatchesOnLine();
            //this.batchesOnLine.OnListChange += new EventHandler(this.batchesOnLine_OnListChange);
            this.productsOnLine = new ProductsOnLine();

            this.productStock = new ProductStock(detroit);
            this.batchStock   = new BatchStock();

            this.uncompletedProducts                   = new UncompletedProducts(detroit);
            this.lineDispatcher.OnProductMoved        += new EventHandler <DispatcherMoveArgs>(lineDispatcher_OnProductMoved);
            this.lineDispatcher.OnProductFinishedLine += new EventHandler <DispatcherMoveArgs>(lineDispatcher_OnProductFinishedLine);
            this.lineDispatcher.OnFreeStations        += new EventHandler <DispatcherStationArgs>(lineDispatcher_OnFreeStations);
        }
Example #2
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);
 }
Example #3
0
        public DbProductRouter(int transTableCode, DetroitDataSet detroit, int typeId)
            : base(0)
        {
            this.detroitDataSet = detroit;
            this.typeId         = typeId;
            this.lineId         = detroit.LineId;

            this.transTable.Clear();
            this.stateStationsTable.Clear();
            this.symbolStationsTable.Clear();

            this.fillTransTable_1();
            this.fillStationTable_1();
        }
Example #4
0
        public LineQueue(DetroitDataSet detroit, LogProvider logProvider)
        {
            this.myLog          = logProvider;
            this.detroitDataSet = detroit;
            this.lineName       = this.detroitDataSet.LineId.ToString();

            //...
            // connect to database
            try
            {
                this.myLog.LogAlert(AlertType.System, this.lineName, this.GetType().ToString(), "LineQueue()",
                                    "Connecting to the database ... " + LineService.Properties.Settings.Default.DetroitConnectionString.ToString()
                                    , "system");

                this.lineQueueTableAdapter = new DetroitDataSetTableAdapters.LineQueueExtTableAdapter();
                this.lineQueueTableAdapter.FillByLineId(this.detroitDataSet.LineQueueExt, this.detroitDataSet.LineId);
                this.myLog.LogAlert(AlertType.System, this.lineName, this.GetType().ToString(), "LineQueue()",
                                    "Connection string: " + this.lineQueueTableAdapter.Connection.ConnectionString.ToString()
                                    , "system");

                // read Bathes from LineQueue in routine
                // add every Batch

                for (int i = 0; i <= this.detroitDataSet.LineQueueExt.Rows.Count - 1; i++)
                {
                    DataRow queueRow = this.detroitDataSet.LineQueueExt.Rows[i];
                    Batch   newBatch = new Batch(
                        null
                        , queueRow["Nummer"].ToString()
                        , queueRow["BatchType_Name"].ToString()
                        , (int)queueRow["Capacity"]
                        , (int)queueRow["BatchId"]
                        , (int)queueRow["BatchTypeId"]
                        , (int)queueRow["Length"]
                        , (int)queueRow["Takt"]
                        );

                    newBatch.PutInQueue();
                    this.Enqueue(newBatch);
                    this.cache.Add(newBatch.Id.ToString(), newBatch);
                }
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                this.myLog.LogAlert(AlertType.Error, this.lineName, this.GetType().ToString(), "LineQueue()",
                                    e.Message + ", Line number = " + e.LineNumber.ToString()
                                    , "system");
            }
        }
Example #5
0
        public BatchMap(Batch owner, Line line, LogProvider logProvider)
        {
            // ------------------------------------------
            // Method description:
            // ------------------------------------------
            // get BatchType from Detroit
            // get BatchTypeMap from Detroit
            // get MapPoints by BatchTypeMapId from Detroit
            // in routine :
            //      get MapPoint
            //      get station object by StationId
            //      create new BatchMapItem
            //      if it's main station add new BatchMapItem to the BatchMap list
            //      if it's assistant station add it to the exact main station
            //      (exact station == last elem in list, because adapter's rows ordered "step, isMain DESC")
            // ------------------------------------------
            this.owner = owner;
            this.line  = line;
            this.myLog = logProvider;
            int line_capacity = line.GetStations().Count();


            // connect to database
            this.detroitDataSet            = new DetroitDataSet();
            this.batchMapPointTableAdapter = new DetroitDataSetTableAdapters.BatchMapPointTableAdapter();
            this.batchMapPointTableAdapter.FillByBatchTypeId(this.detroitDataSet.BatchMapPoint, owner.TypeId, line.Id);

            this.batchTypeMapTableAdapter = new DetroitDataSetTableAdapters.BatchTypeMapTableAdapter();
            this.batchTypeMapTableAdapter.FillBy(this.detroitDataSet.BatchTypeMap, owner.TypeId, line.Id);

            if (this.detroitDataSet.BatchTypeMap.Rows.Count > 0)
            {
                object objNextLineId   = this.detroitDataSet.BatchTypeMap.Rows[0]["NextLineId"];
                object objNextLineAuto = this.detroitDataSet.BatchTypeMap.Rows[0]["NextLineAuto"];
                object objTakt         = this.detroitDataSet.BatchTypeMap.Rows[0]["Takt"];
                if (objNextLineId != null && objNextLineId != DBNull.Value && objTakt != DBNull.Value)
                {
                    this.nextLineId = Convert.ToInt32(objNextLineId);
                    this.takt       = Convert.ToInt32(objTakt);
                    if (objNextLineAuto != null && objNextLineAuto != DBNull.Value)
                    {
                        this.nextLineAuto = Convert.ToInt32(objNextLineAuto);
                    }
                }
                else
                {
                    this.nextLineId   = 0;
                    this.nextLineAuto = 0;
                    this.takt         = 1; //tbd ?!
                }
            }


            for (int i = 0; i <= this.detroitDataSet.BatchMapPoint.Rows.Count - 1; i++)
            {
                // read key data from databse
                DataRow mapPointRow = this.detroitDataSet.BatchMapPoint.Rows[i];
                int     stationId   = (int)mapPointRow["StationId"];
                int     isMain      = (int)mapPointRow["IsMain"];

                // find station object on AssemblyLine
                LineStation enStation = (LineStation)line.GetStation(stationId);

                // ALWAYS CHECK null VALUES !!!
                if (enStation == null)
                {
                    //this.myLog.LogAlert(AppLog.AlertType.System, this.GetType().ToString(), "Map constructor can't find station object (id=" + stationId.ToString() + ") in AssemblyLine");
                }

                BatchMapItem newMapItem = new BatchMapItem(enStation);

                if (isMain == 1)
                {
                    this.AddLast(newMapItem);
                    //this.myLog.LogAlert(AppLog.AlertType.System, this.GetType().ToString(), "Batch "+ owner.Name + ", add map item: " + enStation.Name);
                }
                else
                {
                    // handle assist station,
                    // link it to the last main staion
                    BatchMapItem mainStationMapItem = this.Last();
                    mainStationMapItem.AssistLineStations.Add(newMapItem);
                    //this.myLog.LogAlert(AppLog.AlertType.System, this.GetType().ToString(), "Batch " + owner.Name + ", add assist map item: " + enStation.Name + " to main: " + mainStationMapItem.LineStation.Name);
                }
            }
        }
Example #6
0
 public UncompletedProducts(DetroitDataSet detroit)
 {
     this.detroitDataSet = detroit;
     this.uncompletedProductTableAdapter = new DetroitDataSetTableAdapters.UncompletedProductTableAdapter();
 }
Example #7
0
        protected override void fillTransTable_1()
        {
            //transTable.Add(this.startState + "-" + this.startState, "FA0.1");
            //transTable.Add("FA0.1-FA0.1", "FA0.2");
            //transTable.Add("FA2.2-FA2.2", "FINISH_STATE");

            //this.owner = owner;
            //this.line = line;
            //this.myLog = logProvider;
            //int line_capacity = line.GetStations().Count();


            // connect to database
            this.detroitDataSet            = new DetroitDataSet();
            this.batchMapPointTableAdapter = new DetroitDataSetTableAdapters.BatchMapPointTableAdapter();
            this.batchMapPointTableAdapter.FillByBatchTypeId(this.detroitDataSet.BatchMapPoint, this.typeId, this.lineId);

            this.batchTypeMapTableAdapter = new DetroitDataSetTableAdapters.BatchTypeMapTableAdapter();
            this.batchTypeMapTableAdapter.FillBy(this.detroitDataSet.BatchTypeMap, this.typeId, this.lineId);

            if (this.detroitDataSet.BatchTypeMap.Rows.Count > 0)
            {
                object objNextLineId   = this.detroitDataSet.BatchTypeMap.Rows[0]["NextLineId"];
                object objNextLineAuto = this.detroitDataSet.BatchTypeMap.Rows[0]["NextLineAuto"];
                object objTakt         = this.detroitDataSet.BatchTypeMap.Rows[0]["Takt"];
                if (objNextLineId != null && objNextLineId != DBNull.Value)
                {
                    this.nextLineId = Convert.ToInt32(objNextLineId);
                    if (objNextLineAuto != null && objNextLineAuto != DBNull.Value)
                    {
                        this.nextLineAuto = Convert.ToInt32(objNextLineAuto);
                    }
                }
                else
                {
                    this.nextLineId   = 0;
                    this.nextLineAuto = 0;
                }

                if (objTakt != DBNull.Value)
                {
                    this.taktDuration = Convert.ToInt32(objTakt);
                }
                else
                {
                    this.taktDuration = 1;
                }
            }

            //transTable.Add(this.startState + "-" + this.startState, "FA0.1");

            // create station structure
            //----------------------------------------------------------------------
            List <StationGrafNode> stationGraf = new List <StationGrafNode>();

            for (int i = 0; i <= this.detroitDataSet.BatchMapPoint.Rows.Count - 1; i++)
            {
                // read key data from databse
                DataRow mapPointRow = this.detroitDataSet.BatchMapPoint.Rows[i];
                int     step        = (int)mapPointRow["Step"];
                int     stationId   = (int)mapPointRow["StationId"];
                int     isMain      = (int)mapPointRow["IsMain"];
                string  stationName = mapPointRow["StationName"].ToString();

                // TODO: construct trans table
                if (isMain == 1)
                {
                    stationGraf.Add(new StationGrafNode()
                    {
                        StationName = stationName, Step = step
                    });
                }
                else
                {
                    StationGrafNode mainStepStation = stationGraf.FirstOrDefault(p => p.Step.Equals(step));
                    if (mainStepStation != null)
                    {
                        if (mainStepStation.AssistSationNames == null)
                        {
                            mainStepStation.AssistSationNames = new List <string>();
                        }
                        mainStepStation.AssistSationNames.Add(stationName);
                    }
                }
            }

            // process station structure
            //-------------------------------------------------------------------------
            string state    = this.startState;
            string symbol   = this.startState;
            string newState = "";

            for (int i = 0; i < stationGraf.Count; i++)
            {
                StationGrafNode stationNode = stationGraf[i];
                if (stationNode.AssistSationNames == null || stationNode.AssistSationNames.Count == 0)
                {
                    newState = stationNode.StationName;
                    this.transTable.Add(state + "-" + symbol, newState);

                    state  = newState;
                    symbol = newState;
                }
                else
                {
                    newState = stationNode.StationName;
                    List <string> stationNames = new List <string>();
                    stationNames.Add(stationNode.StationName);

                    for (int j = 0; j < stationNode.AssistSationNames.Count; j++)
                    {
                        newState = newState + "+" + stationNode.AssistSationNames[j].ToString();
                        stationNames.Add(stationNode.AssistSationNames[j].ToString());
                    }
                    this.transTable.Add(state + "-" + symbol, newState);

                    List <Transition> transitions = this.getTransitions(stationNames, stationGraf[i + 1].StationName);
                    foreach (Transition transition in transitions)
                    {
                        this.transTable.Add(transition.State + "-" + transition.Symbol, transition.NewState);
                    }

                    state  = stationGraf[i + 1].StationName;
                    symbol = state;
                    i++;
                }
            }

            this.transTable.Add(state + "-" + symbol, this.finishState);
        }
Example #8
0
 public ProductStock(DetroitDataSet enDetroit) : base()
 {
     this.detroit = enDetroit;
     this.productStockTableAdapter = new DetroitDataSetTableAdapters.ProductStockTableAdapter();
 }