Ejemplo n.º 1
0
        private void btn_save_Click(object sender, RoutedEventArgs e)
        {
            string trcode = tb_code.Text;
            string trname = tb_name.Text;

            if (truckId == 0)
            {
                TruckInfo trInfo = new TruckInfo()
                {
                    Createtime = DateTime.Now,
                    Isvalid    = 1,
                    Updatetime = DateTime.Now
                };
                trInfo.Truckcode = trcode;
                trInfo.Truckname = trname;
                x_tService.Insert(trInfo);
            }
            else
            {
                x_tService.Update(() => new TruckInfo()
                {
                    Truckcode = trcode, Truckname = trname
                }, a => a.Id == truckId);
            }
            tb_code.Text = "";
            tb_name.Text = "";
            MsgBox.Show("保存成功");
            if (win_trIndex != null && win_trIndex.IsVisible)
            {
                win_trIndex.InitData();
            }
        }
Ejemplo n.º 2
0
    void Put()
    {
        Ray        ray = new Ray(placeCheckPoint.transform.position, transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, frontRayDistance) && Input.GetButtonDown(fire1String))
        {
            GameObject place = hit.collider.gameObject;

            if (place.tag.Equals("BeltConveyor") || place.tag.Equals("Wall"))
            {
                return;
            }

            if (!place.tag.Equals("Truck") && place.GetComponent <PlaceBase>().hasBox())
            {
                return;
            }

            TruckInfo truckInfo = truck.GetComponent <TruckController>().truckInfo;
            int       weight    = cardBoardBox.GetComponent <CardBoardBox>().cardBoardBoxInfo.Weight;
            if (place.tag.Equals("Truck") && truckInfo.SumWeight + weight > truckInfo.MaxWeight)
            {
                return;
            }

            place.GetComponent <PlaceBase>().SetBox(cardBoardBox);
            boxIK.leftHandTransform  = null;
            boxIK.rightHandTransform = null;
            isGetted = false;
        }
    }
Ejemplo n.º 3
0
        static void Main()
        {
            using (var db = new HumanModelContext())
            {
                var human = new Human();
                human.FirstName  = "Strahil";
                human.LastName   = "Voivoda";
                human.Age        = "30";
                human.Address    = "Ruse 7000, Bulgaria";
                human.NameOfFirm = "Trucks";

                var newFirm = new TheFirm();
                newFirm.Name    = "Trucks";
                newFirm.Address = "Ruse, Bulgaria";
                newFirm.Info    = " Truck Company";

                var trucks = new TruckInfo();
                trucks.TruckModel   = "VOLVO";
                trucks.TruckNumbers = "10";

                var country = new Country();
                country.CountryName = "Bulgaria";

                db.Humans.Add(human);
                db.TheFirms.Add(newFirm);
                db.TruckInfos.Add(trucks);
                db.Countries.Add(country);
                db.SaveChanges();
            }
        }
Ejemplo n.º 4
0
    float stopX;        //停車位置

    void Start()
    {
        truckInfo = new TruckInfo(gameDirector.GetComponent <PrefabGenerator>().PopCreateTruckWeight(playerNum), this.name);
        animator  = GetComponent <Animator>();
        animator.SetBool("isopen", true);
        stopX   = transform.position.x;
        targetX = stopX + 15;
    }
Ejemplo n.º 5
0
 private void chk_all_Unchecked(object sender, RoutedEventArgs e)
 {
     foreach (var item in dataGrid1.Items)
     {
         TruckInfo ri = item as TruckInfo;
         ri.IsChecked = false;
     }
 }
Ejemplo n.º 6
0
        private TruckInfo CreateTruck(Vector3 position, Vector3 rotation)
        {
            var truckHash = _truckHashes[_random.Next(0, _truckHashes.Length)];
            var truck     = new TruckInfo(API.createVehicle(truckHash, position, rotation, 0, 0));

            truck.Deleted += TruckDeleted;

            _trucks.Add(truck);

            return(truck);
        }
Ejemplo n.º 7
0
        private static VehicleInfo getVehicleInfo(eVehicleType i_VehicleType, string i_VehicleModelName,
                                                  string i_WheelsManufacturerName, string i_LicensePlate,
                                                  object[] i_SpecificVehicleParams)
        {
            VehicleInfo vehicleInfo;

            switch (i_VehicleType)
            {
            case eVehicleType.Car:
                Enums.eCarColor carColor =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eCarColor>(
                        i_SpecificVehicleParams[(int)eCarSpecificParams.CarColor]);
                Enums.eNumberOfDoors numberOfDoors =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eNumberOfDoors>(
                        i_SpecificVehicleParams[(int)eCarSpecificParams.NumberOfDoors]);

                vehicleInfo = new CarInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                          Constants.k_CarWheelsNumber,
                                          Constants.k_CarWheelsMaxAirPressure,
                                          carColor, numberOfDoors);

                break;

            case eVehicleType.Motorcycle:
                Enums.eLicenseType licenseType =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eLicenseType>(
                        i_SpecificVehicleParams[(int)eMotorcycelSpecificParams.LicenseType]);
                int engineVolume =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <int>(
                        i_SpecificVehicleParams[(int)eMotorcycelSpecificParams.EngineVolume]);

                vehicleInfo = new MotorcycleInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                                 Constants.k_MotorcycleWheelsNumber,
                                                 Constants.k_MotorcycleWheelsMaxAirPressure, licenseType, engineVolume);

                break;

            case eVehicleType.Truck:

                vehicleInfo = new TruckInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                            Constants.k_TruckWheelsNumber,
                                            Constants.k_TruckWheelsMaxAirPressure);

                break;

            default:
                throw new ArgumentOutOfRangeException("i_VehicleType");
            }
            return(vehicleInfo);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Maps API data parser to create TruckInfo object
        /// </summary>
        /// <param name="point">data from Maps API</param>
        /// <returns>TuckInfo object</returns>
        private async Task <TruckInfo> getTruckInfo(SqlConnection sqlConnection, dynamic point)
        {
            // build the return object
            var truckInfo = new TruckInfo
            {
                DistanceInMeters = Convert.ToDecimal(point.distanceInMeters),
                Position         = new GeoCoordinate
                {
                    Latitude  = Convert.ToDouble(point.position.lat),
                    Longitude = Convert.ToDouble(point.position.lon)
                }
            };

            // get truck details from permit database, using geometryId (from Maps API) which is PK
            string sqlQuery = $"SELECT [FacilityType],[Applicant],[Address],[Zip_Codes],[LocationDescription],[dayshours] FROM [dbo].[FacilityPermit] WHERE [locationid] = {point.geometryId}";

            SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection);
            await sqlConnection.OpenAsync();

            using (SqlDataReader sqlReader = sqlCommand.ExecuteReader())
            {
                // call Read before accessing data.
                if (await sqlReader.ReadAsync())
                {
                    truckInfo.FacilityType        = sqlReader[0] == null ? string.Empty : sqlReader[0].ToString();
                    truckInfo.Applicant           = sqlReader[1] == null ? string.Empty : sqlReader[1].ToString();
                    truckInfo.Address             = sqlReader[2] == null ? string.Empty : sqlReader[2].ToString();
                    truckInfo.Zip                 = sqlReader[3] == null ? 0 : Convert.ToInt32(sqlReader[3]);
                    truckInfo.LocationDescription = sqlReader[4] == null ? string.Empty : sqlReader[4].ToString();
                    truckInfo.DaysHours           = sqlReader[5] == null ? string.Empty : sqlReader[5].ToString();
                }
            }
            sqlConnection.Close();

            // -- EntityFramework -- //
            // get truck details from permit database, using geometryId (from Maps API) which is PK
            //int locId = Convert.ToInt32(point.geometryId);
            //var permit = await _dbContext.FacilityPermits.Where(p => p.locationid == locId).FirstOrDefaultAsync();
            //if (permit != null)
            //{
            //    truckInfo.FacilityType = permit.FacilityType;
            //    truckInfo.Applicant = permit.Applicant;
            //    truckInfo.Address = permit.Address;
            //    truckInfo.Zip = permit.Zip_Codes;
            //    truckInfo.LocationDescription = permit.LocationDescription;
            //    truckInfo.DaysHours = permit.dayshours;
            //}

            return(truckInfo);
        }
Ejemplo n.º 9
0
        public PermitView(Services services, NancyContext context)
        {
            User = context.CurrentUser as AuthUser;

            Hauler    = User.ToHaulerInfo();
            Company   = new CompanyInfo();
            Insurance = new InsuranceInfo();
            Vehicle   = new VehicleInfo();
            Truck     = new TruckInfo();
            Axle      = new AxleInfo();
            Trailer   = new TrailerInfo();
            Load      = new LoadInfo();
            Movement  = new MovementInfo();
        }
Ejemplo n.º 10
0
        private void TrailerDetachedOnDestination(TruckInfo truckInfo, TrailerInfo trailerInfo)
        {
            var driver = truckInfo.GetDriver();

            if (driver == null)
            {
                return;
            }

            API.sendNotificationToPlayer(driver, "Well done!");
            trailerInfo.Delete();

            SpawnTrailers();
        }
Ejemplo n.º 11
0
 private void dataGrid1_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.EditingElement is TextBox)
     {
         string newValue = (e.EditingElement as TextBox).Text;
         if (oldValue != newValue)
         {
             TruckInfo ri = e.Row.Item as TruckInfo;
             if (ri != null)
             {
                 x_tService.UpdateRow(e.Column.SortMemberPath, newValue, ri.Id);
             }
         }
     }
 }
Ejemplo n.º 12
0
        private void cb_trucklist_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox  cb     = sender as ComboBox;
            TruckInfo cbitem = (cb.SelectedItem as TruckInfo);

            if (cbitem != null)
            {
                string    vl = cbitem.Truckcode;
                TruckInfo tk = x_tService.Get(a => a.Truckcode == vl).FirstOrDefault();
                if (tk != null && !string.IsNullOrEmpty(tk.TruckrouteCode))
                {
                    cb_start_route.Text = tk.TruckrouteCode;
                }
            }
        }
Ejemplo n.º 13
0
 public ActionResult AddOrEditInfo(TruckInfo ti)
 {
     if (ti.ID == 0)
     {
         ti.Ngay = DateTime.Now.Date;
         db.TruckInfoes.Add(ti);
         db.SaveChanges();
         return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         ti.Ngay            = DateTime.Now.Date;
         db.Entry(ti).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 14
0
    void Update()
    {
        if (GetComponent <FadeController>().GetIsFading())
        {
            return;
        }

        TruckInfo truckInfo1 = truck1.GetComponent <TruckController>().truckInfo;
        TruckInfo truckInfo2 = truck2.GetComponent <TruckController>().truckInfo;

        if (truckInfo1 == null || truckInfo2 == null)
        {
            return;
        }

        weightText1.text = truckInfo1.SumWeight + "/" + truckInfo1.MaxWeight;
        weightText2.text = truckInfo2.SumWeight + "/" + truckInfo2.MaxWeight;

        if ((!readyP1 || !readyP2) && Input.GetKeyDown(KeyCode.Escape))
        {
            if (selectForm.activeSelf)
            {
                selectForm.SetActive(false);
            }
            else
            {
                selectForm.SetActive(true);
            }
        }

        if (!readyP1 && Input.GetKeyDown(KeyCode.E))
        {
            readyP1 = true;
            description1.SetActive(false);
        }
        if (!readyP2 && Input.GetKeyDown(KeyCode.Keypad9))
        {
            readyP2 = true;
            description2.SetActive(false);
        }
        if (readyP1 && readyP2)
        {
            escText.SetActive(false);
        }
    }
Ejemplo n.º 15
0
 void Update()
 {
     if (transform.position.x >= targetX)
     {
         delta += Time.deltaTime;
         if (delta > span)
         {
             if (truckInfo.SumWeight == 0)
             {
                 truckInfo.Push(new CardBoardBoxInfo(0, 0));
             }
             gameDirector.GetComponent <BaseGameController>().Save(truckInfo);
             truckInfo = new TruckInfo(gameDirector.GetComponent <PrefabGenerator>().PopCreateTruckWeight(playerNum), this.name);
             BackRun();
             delta = 0f;
         }
     }
 }
Ejemplo n.º 16
0
    /// <summary>
    /// Functionality for when a truck reaches its final path end
    /// </summary>
    /// <param name="truck"></param>
    /// <param name="arrivalWaypoint"></param>
    private void OnTruckReachedPathEnd(AwareTruck truck, GameObject arrivalWaypoint)
    {
        // Get the instantiated truck and it's info
        KeyValuePair <AwareTruck, TruckInfo> kvp = InstantiatedTrucks.FirstOrDefault(x => x.Key.gameObject.name == truck.gameObject.name);

        // Check it isn't null
        if (kvp.Key != null && kvp.Value != null)
        {
            TruckInfo info = kvp.Value;

            // Check if the arrivalWaypoint is equal to the set end point and not arriving at Start waypoint
            if (arrivalWaypoint == info.End)
            {
                StartCoroutine(WaitAndNavigate(3f, truck, info.End, info.Start));

                truck.DeliverPackage();
            }
        }
    }
Ejemplo n.º 17
0
        public void FixedObjectFileStreamAddTest()
        {
            var rcf  = RandomCharFunc();
            var rcfN = RandomCharFunc(true);
            var rdf  = RandomDayFunc();
            var rnf  = RandomNumberFunc(10, 100);

            int rnd = rnf();

            TruckInfo[] tis = new TruckInfo[rnd];
            for (int i = 0; i < tis.Length; i++)
            {
                TruckInfo ti = tis[i];
                ti                = new TruckInfo();
                ti.nrCrt          = RandomNumberFunc(0)();
                ti.nrAuto         = rcf().ToString() + rcf() + "-" + rcfN().ToString() + rcfN() + rcfN().ToString() + "-" + rcf().ToString() + rcf() + rcf().ToString();
                ti.payload        = "" + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString();
                ti.dateEntry      = rdf();
                ti.dateRegistered = rdf();
                tis[i]            = ti;
            }

            Stream ms = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(ms);

            instance.Add(tis);
            instance.FillTestStream(ms);

            ms.Seek(0, SeekOrigin.Begin);
            int count;

            byte[] b = new byte[4];
            ms.Read(b, 0, 4);
            count = BitConverter.ToInt32(b, 0);
            Assert.AreEqual(count, tis.Length);

            foreach (TruckInfo ti in tis)
            {
                TruckInfo result = new TruckInfo(ms);

                Assert.IsTrue(ti == result);
            }
        }
Ejemplo n.º 18
0
        public void FixedObjectFileStreamAddTest()
        {
            var rcf = RandomCharFunc();
            var rcfN = RandomCharFunc(true);
            var rdf = RandomDayFunc();
            var rnf = RandomNumberFunc(10, 100);

            int rnd = rnf();

            TruckInfo[] tis = new TruckInfo[rnd];
            for (int i = 0; i < tis.Length; i++) {
                TruckInfo ti = tis[i];
                ti = new TruckInfo();
                ti.nrCrt = RandomNumberFunc(0)();
                ti.nrAuto = rcf().ToString() + rcf() + "-" + rcfN().ToString() + rcfN() + rcfN().ToString() + "-" + rcf().ToString() + rcf() + rcf().ToString();
                ti.payload = "" + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString();
                ti.dateEntry = rdf();
                ti.dateRegistered = rdf();
                tis[i] = ti;
            }

            Stream ms = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(ms);
            instance.Add(tis);
            instance.FillTestStream(ms);

            ms.Seek(0, SeekOrigin.Begin);
            int count;
            byte[] b = new byte[4];
            ms.Read(b, 0, 4);
            count = BitConverter.ToInt32(b, 0);
            Assert.AreEqual(count, tis.Length);

            foreach (TruckInfo ti in tis) {
                TruckInfo result = new TruckInfo(ms);

                Assert.IsTrue(ti == result);
            }
        }
Ejemplo n.º 19
0
 public Truck(VehicleInfo i_VehicleInfo, EnergySource i_EnergySource, float i_CurrentAirPressure)
     : base(i_VehicleInfo, i_EnergySource, i_CurrentAirPressure)
 {
     r_TruckInfo = Helpers.StrongArgumentNeededTypeCheckAndCast <TruckInfo>(i_VehicleInfo);
 }
Ejemplo n.º 20
0
 public override void Save(TruckInfo truckInfo)
 {
     truckInfos.Add(truckInfo);
 }
Ejemplo n.º 21
0
 private void TruckDeleted(TruckInfo truckInfo)
 {
     _trucks.Remove(truckInfo);
 }
Ejemplo n.º 22
0
 private void TogglePlayerDestinationBlip(Client player, TruckInfo truck, bool showBlip)
 {
     API.triggerClientEvent(player, ClientSetDestinationEventName, showBlip ? truck.Trailer.Destination : null);
 }
Ejemplo n.º 23
0
 public virtual void Save(TruckInfo truckInfo)
 {
     return;
 }
Ejemplo n.º 24
0
    void Update()
    {
        TruckInfo truckInfo = truck.GetComponent <TruckController>().truckInfo;

        weightText.text = truckInfo.SumWeight + "/" + truckInfo.MaxWeight;
    }
Ejemplo n.º 25
0
        /// <summary>
        /// 构造指令地图
        /// </summary>
        /// <param name="iotype">出库入库</param>
        /// <param name="rackcode1">取货仓位编码</param>
        /// <param name="rackcode2">卸货仓位编码</param>
        /// <param name="tuopancode">托盘编码</param>
        /// <returns></returns>
        public InstructionInfo SetToMap(InOutType iotype, string rackcode1, string rackcode2, string tuopancode)
        {
            initData();
            InstructionInfo insInfo = new InstructionInfo();

            RackLayerService x_rlService = new RackLayerService();
            var rlayer = x_rlService.Get(a => a.RackLayerCode == rackcode1).FirstOrDefault();

            if (rlayer != null)
            {
                var rkitem = rackList.Single(a => a.Id == rlayer.RackId);
                insInfo.InPackCode  = rkitem.RouteCode;
                insInfo.InPackLayer = rlayer.RackLayerNum.ToString("x2");
            }
            var rlayer2 = x_rlService.Get(a => a.RackLayerCode == rackcode2).FirstOrDefault();

            if (rlayer2 != null)
            {
                var rkitem = rackList.Single(a => a.Id == rlayer2.RackId);
                insInfo.OutPackCode  = rkitem.RouteCode;
                insInfo.OutPackLayer = rlayer2.RackLayerNum.ToString("x2");
            }


            TruckInfo freetruck = getLatestTruck(insInfo.InPackCode); //寻找最近空闲叉车

            if (freetruck == null)
            {
                insInfo.StatusEnum = InstructionStatus.NoTruck;
                return(insInfo);
            }
            string truckcode      = freetruck.Truckcode;
            string truckcoderoute = freetruck.TruckrouteCode;

            insInfo.StartCode = insInfo.getStartType(StartType.Start);
            insInfo.InOut     = insInfo.getIOType(iotype);
            insInfo.TruckCode = truckcode;


            insInfo.TuopanCode = tuopancode;
            if (iotype == InOutType.In)
            {
                insInfo.RackLayerCode = rackcode2;
            }
            else
            {
                insInfo.RackLayerCode = rackcode1;
            }

            var          packList   = routelist.Where(a => a.Isstart == 2);
            TruckService x_tkServic = new TruckService();
            var          tkList     = x_tkServic.Get(a => a.Isvalid == 1 && a.HouseId == HouseId);

            //排除掉已占用的停车位,还需要排除掉已被规划的停车位
            foreach (var item in packList)
            {
                foreach (var titem in tkList)
                {
                    if (titem.TruckrouteCode == item.Routecode)
                    {
                        item.IsValid = 0;
                    }
                }
            }
            foreach (var item in waylist)
            {
                var code = item[item.Count - 1].RouteCode;
                foreach (var pitem in packList)
                {
                    if (pitem.Routecode == code)
                    {
                        pitem.IsValid = 0;
                    }
                }
            }
            string endroute = "";
            var    end_item = packList.Where(a => a.IsValid == 1).FirstOrDefault();

            if (end_item != null)
            {
                endroute = end_item.Routecode;
            }
            else
            {
                endroute = truckcoderoute;
                end_item = routelist.Where(a => a.Routecode == endroute).First();
            }

            //开始计算路径

            PathMathHelper.InitRouteNodes(nodeDict);
            PathMathResult result = PathMathHelper.Start(truckcoderoute, insInfo.InPackCode); //取货路径
            string         path1  = truckcoderoute + result.Path;                             //取货路径

            insInfo.PathList.Add(path1);
            PathMathHelper.InitRouteNodes(nodeDict);
            result = PathMathHelper.Start(insInfo.InPackCode, insInfo.OutPackCode);
            string path2 = result.Path;     //卸货路径

            insInfo.PathList.Add(path2);
            PathMathHelper.InitRouteNodes(nodeDict);
            result = PathMathHelper.Start(insInfo.OutPackCode, endroute); //停车路径
            string path3 = result.Path;                                   //停车路径

            insInfo.PathList.Add(path3);
            var rack_item     = rackList.Where(a => a.Rackcode == insInfo.InPackCode).FirstOrDefault();
            var out_rack_item = rackList.Where(a => a.Rackcode == insInfo.OutPackCode).FirstOrDefault();

            ComputePath(insInfo, path1, path2, rack_item);
            ComputePath(insInfo, path2, path3, out_rack_item);
            ComputePath(insInfo, path3);

            //如果终点是停车位,则反转停车位的转向
            if (end_item != null && end_item.Isstart == 2)
            {
                if (insInfo.RouteWay.Count > 2)
                {
                    var wayinfo = insInfo.RouteWay.Last();
                    if (wayinfo.Way == TurnWay.Left)
                    {
                        wayinfo.Way = TurnWay.Right;
                        insInfo.AddItem(wayinfo.RouteCode, TurnWay.Back);
                    }
                    else if (wayinfo.Way == TurnWay.Right)
                    {
                        wayinfo.Way = TurnWay.Left;
                        insInfo.AddItem(wayinfo.RouteCode, TurnWay.Back);
                    }
                }
            }
            insInfo.AddItem(end_item.Routecode, TurnWay.Stop);

            waylist.Add(insInfo.RouteWay);
            return(insInfo);
        }