Ejemplo n.º 1
0
 public void MoverCreate(string route, string datatime, string stations, string stationpoints, string name, string Zfilepath, string Ffilepath, List <string> stationrecord)
 {
     this.StationsRecord = stationrecord;
     this.Route          = route;
     this.Routes         = route.Split('|');
     string[] xy = this.Routes[0].Split(',');
     this.X         = float.Parse(xy[0]);
     this.Y         = float.Parse(xy[1]);
     this.Oldleft   = float.Parse(xy[0]);
     this.Oldtop    = float.Parse(xy[1]);
     xy             = this.Routes[1].Split(',');
     this.step      = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1]));
     this.ZFilePath = Zfilepath;
     this.FFilePath = Ffilepath;
     if (datatime != null && datatime != "")
     {
         this.DateAndTime  = datatime;
         this.DataAndTimes = DateAndTime.Split('|');
     }
     if (stations != null && stations != "")
     {
         this.NextStation = stations;
         NextStations     = NextStation.Split('|');
     }
     if (stationpoints != null && stationpoints != "")
     {
         this.NextStationPoint = stationpoints;
         NextStationPoints     = NextStationPoint.Split('|');
     }
     //PicBox = new PictureBox();
     //PicBox.SizeMode = PictureBoxSizeMode.StretchImage;
     //PicBox.BackColor = System.Drawing.Color.Transparent;
     //PicBox.Size = new System.Drawing.Size(50, 50);
     labHead = name;
     labFoot = "";
     if (DataAndTimes.Length > 0)
     {
         labFoot = labFoot + DataAndTimes[0];
         //NowDatetime++;
     }
     if (NextStations.Length > 0)
     {
         labFoot = labFoot + "\r\n目的地:" + NextStations[0];
         //NowNextStation++;
     }
     if (Step.IsRtoL)
     {
         this.MoverImage  = new System.Drawing.Bitmap(ZFilePath);
         this.NowFilePath = ZFilePath;
     }
     else
     {
         this.MoverImage  = new System.Drawing.Bitmap(FFilePath);
         this.NowFilePath = FFilePath;
     }
 }
Ejemplo n.º 2
0
 public async Task StartWorking()
 {
     while (true)
     {
         Station nextStation;
         while (Airplane == null || Airplane.AirplaneStatus == AirplaneStatus.Moving)
         {
             await Task.Delay(200);
         }
         if (((Id == 6 || Id == 7) && Airplane.FlightState == FlightState.Landing) || (Id == 4 && Airplane.FlightState == FlightState.Departuring))
         {
             Console.Write("");
         }
         var nextStations = NextStation.Where(s => s.TypeOfStation == StationType.StationForLandingAndDeparture || (Airplane.FlightState == FlightState.Departuring ? StationType.StationForDeparture : StationType.StationForLanding) == s.TypeOfStation);
         if (nextStations.Count() == 0)
         {
             Airplane.AirplaneStatus = AirplaneStatus.Finished;
             PlaneFinished?.Invoke(Airplane, this);
             Airplane = null;
         }
         else
         {
             while (nextStations.Any(s => s.Airplane == null) == false)
             {
                 await Task.Delay(200);
             }
             nextStation             = nextStations.First(s => s.Airplane == null);
             nextStation.Airplane    = Airplane;
             Airplane.AirplaneStatus = AirplaneStatus.Moving;
             Airplane.Move();
             Trace.WriteLine($"airplane {Airplane.Id} moved from station {Id} to station {nextStation.Id}");
             Airplane = null;
         }
         StationUpdated?.Invoke();
     }
 }