public void ReInitWithiRealAgv() { bool res = false; int count = 1; while (res == false && count < REINIT_COUNT) { Thread.Sleep(count * 50); for (int i = 0; i < vehicles.Length; i++) { if (vehicles[i].agvInfo != null) { vehicles[i].BeginX = (int)Math.Round(vehicles[i].agvInfo.CurLocation.CurNode.X / 1000.0); vehicles[i].BeginY = (int)Math.Round(vehicles[i].agvInfo.CurLocation.CurNode.Y / 1000.0); res = true; Console.WriteLine("小车编号" + i + "初始化完成,起点(" + vehicles[i].BeginX + "," + vehicles[i].BeginY + ")"); } } count++; } ////把小车所在的节点设为占用状态 RouteUtil.VehicleOcuppyNode(ElecMap.Instance, vehicles); if (count >= REINIT_COUNT) { MessageBox.Show("没有小车连接,请检查ip设置是否有问题"); } }
/// <summary> /// 初始化小车 /// </summary> public void InitialVehicle() { vehicleInited = false; //初始化小车位置 if (null == FileUtil.sendData || FileUtil.sendData.Length < 1) { throw new ArgumentNullException(); } int vehicleCount = FileUtil.sendData.Length; vehicles = new Vehicle[vehicleCount]; for (int i = 0; i < vehicleCount; i++) { VehicleConfiguration config = new VehicleConfiguration(); vehicles[i] = new Vehicle(FileUtil.sendData[i].BeginX, FileUtil.sendData[i].BeginY, i, false, Direction.Right, config); //MyPoint endPoint = RouteUtil.RandPoint(ElecMap.Instance); //MyPoint mp = SqlManager.Instance.GetVehicleCurLocationWithId(i); //if (mp != null) //{ // vehicles[i].BeginX = mp.X; // vehicles[i].BeginY = mp.Y; //} int R = rand.Next(20, 225); int G = rand.Next(20, 225); int B = rand.Next(20, 225); vehicles[i].pathColor = Color.FromArgb(80, R, G, B); vehicles[i].showColor = Color.FromArgb(255, R, G, B); } vehicleInited = true; ////把小车所在的节点设为占用状态 RouteUtil.VehicleOcuppyNode(ElecMap.Instance, vehicles); }