//更新储位信息 private void UpdateStock() { try { this.Invoke((EventHandler)(delegate { IList <StorageInfo> all_stocks = AGVClientDAccess.LoadStorages(); if (all_stocks != null) { foreach (StorageInfo item in all_stocks) { StorageTool storage = m_data.ActiveLayer.Objects.Where(p => p.Id == "StorageTool" && (p as StorageTool).StcokID == item.ID).FirstOrDefault() as StorageTool; if (storage != null) { storage.OwnArea = item.OwnArea; storage.SubOwnArea = item.SubOwnArea; storage.matterType = item.matterType; storage.StorageState = item.StorageState; storage.LockState = item.LockState; storage.MaterielType = item.MaterielType; } } } m_canvas.DoInvalidate(true); })); ClearMemory(); ReConnect(); } catch (Exception ex) { } }
public bool Inital() { try { MoniCars.Clear(); AllCar = AGVClientDAccess.LoadAGVAchive(); AllLands = AGVClientDAccess.LoadLandByCondition("1=1"); AllSegs = AGVClientDAccess.LoadAllSegment(); SimulatorVar.AllSegs = AllSegs; Stores = AGVClientDAccess.LoadStorages(); System = AGVSimulationDAccess.LoadSystem(); foreach (CarBaseStateInfo item in AllCar) { CarMonitor moniCar = new CarMonitor(); moniCar.AgvID = item.AgvID; moniCar.CurrSite = Convert.ToInt32(item.StandbyLandMark); moniCar.StandbyLandMark = item.StandbyLandMark; double ScalingRate = 0; string ScalingRateStr = System["ScalingRate"].ToString(); try { ScalingRate = Convert.ToDouble(ScalingRateStr); } catch { } if (ScalingRate > 0) { LandmarkInfo CurrLand = AllLands.FirstOrDefault(p => p.LandmarkCode == item.StandbyLandMark); if (CurrLand != null) { moniCar.X = (float)(CurrLand.LandX * ScalingRate); moniCar.Y = (float)(CurrLand.LandY * ScalingRate); } } moniCar.ScalingRate = ScalingRate; MoniCars.Add(moniCar); } if (Car_Ini != null) { Car_Ini(MoniCars); } //Juncts.Clear(); //IList<TrafficController> Traffics = AGVClientDAccess.GetTraffics(); //foreach (TrafficController item in Traffics) //{ // JunctionInfo junct = new JunctionInfo(); // foreach (string s in item.EnterLandCode.Split(',')) // { junct.JunctionLandMarkCodes.Add(s); } // junct.JunctionID = item.JunctionID; // foreach (string s in item.JunctionLandMarkCodes.Split(',')) // { junct.JunctionLandMarkCodes.Add(s); } // junct.RealseLandMarkCode = item.RealseLandMarkCode; // Juncts.Add(junct); //} CountRoute = new RoutePlanData(AllSegs); Traffic = new TrafficController(MoniCars, AllSegs, System, AllLands); timerStarBeStopedCar.Enabled = true; timerStarBeStopedCar.AutoReset = true; timerStarBeStopedCar.Elapsed += TimerStarBeStopedCar_Elapsed; timerFreshTask.Enabled = true; timerFreshTask.AutoReset = true; timerFreshTask.Elapsed += TimerFreshTask_Elapsed; return(true); } catch (Exception ex) { return(false); throw ex; } }