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); } } }
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); }