コード例 #1
0
        void CheckIDriveApiDriveContentsResult(Java.Lang.Object result)
        {
            try
            {
                var res = result.JavaCast <IDriveApiDriveContentsResult>();
                if (res != null)
                {
                    Stream stream = null;
                    if (!res.Status.IsSuccess)
                    {
                        Debug.WriteLine("U AR A MORON! Error while trying to create new file contents");
                        return;
                    }

                    try
                    {
                        stream = res.DriveContents.OutputStream;
                        WriteDriveFile(stream, res);
                        _driveAction = DriveAction.None;
                    }
                    catch (Exception e)
                    {
                        stream = res.DriveContents.InputStream;
                        ReadDriveFile(stream);
                        _driveAction = DriveAction.None;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("miscast", e);
            }
        }
コード例 #2
0
ファイル: MyLegoCarService.cs プロジェクト: gokulm/LEGO.Bot
        public void Drive(DriveAction driveAction)
        {
            switch (driveAction)
            {
                case DriveAction.Front:
                    _nxtSetDriveRequest.LeftPower = -GearPower;
                    _nxtSetDriveRequest.RightPower = -GearPower;
                    _nxtDrivePort.DriveDistance(_nxtSetDriveRequest);

                    break;
                case DriveAction.Back:
                    _nxtSetDriveRequest.LeftPower = GearPower;
                    _nxtSetDriveRequest.RightPower = GearPower;
                    _nxtDrivePort.DriveDistance(_nxtSetDriveRequest);
                    break;
                case DriveAction.Left:
                    _nxtSetDriveRequest.LeftPower = -.4;
                    _nxtSetDriveRequest.RightPower = .4;
                    _nxtDrivePort.DriveDistance(_nxtSetDriveRequest);

                    break;
                case DriveAction.Right:
                      _nxtSetDriveRequest.LeftPower = .4;
                    _nxtSetDriveRequest.RightPower = -.4;
                    _nxtDrivePort.DriveDistance(_nxtSetDriveRequest);
                    break;
                case DriveAction.Stop:
                    _nxtDrivePort.AllStop(MotorStopState.Coast);
                    break;
                default:
                    break;
            }
        }
コード例 #3
0
 public void ReadFile()
 {
     _driveAction = DriveAction.Read;
     if (_googleApiClient.IsConnected)
     {
         GoogleDriveAction();
         return;
     }
     Connect();
 }
コード例 #4
0
 public void SaveFile()
 {
     _driveAction = DriveAction.Write;
     if (_googleApiClient.IsConnected)
     {
         GoogleDriveAction();
         return;
     }
     Connect();
 }
コード例 #5
0
        public TaskDrive Add(DriveAction driveAction, int time)
        {
            if (TaskSequence == null || TaskSequence.IsClosed)
            {
                Create();
            }

            Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, Ped, Vehicle, (int)driveAction, time);

            DriveActions.Add(driveAction);

            return(this);
        }
コード例 #6
0
ファイル: TaxiDriver.cs プロジェクト: DmytroKu/Lab
 public void Drive()
 {
     DriveAction.DoAction();
 }
コード例 #7
0
        public int CalculateEstimate(State state)
        {
            int freePlaneStorageCount = 1; // + state.Planes.Min(p => p.FreeStorageCount);
            int freeVanStorageCount   = 1; // + state.Vans.Min(v => v.FreeStorageCount);

            int other          = 0;
            int totalFlyCost   = 0;
            int totalDriveCost = 0;

            foreach (var package in state.Packages.Where(p => !p.IsInDestination))
            {
                //have to fly
                if (package.Location.City != package.Destination.City)
                {
                    //have to get to the airport
                    if (!package.Location.IsAirport)
                    {
                        //no empty van there
                        if (!package.Location.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        if (package.LocationType != PackageLocationEnum.Van)
                        {
                            other += new LoadAction().ActionCost;
                        }

                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }

                    //no plane there
                    if (!package.Location.City.Planes.Any(p => !p.IsFull))
                    {
                        other += new FlyAction().ActionCost;
                    }

                    //fly
                    if (package.LocationType != PackageLocationEnum.Plane)
                    {
                        other += new PickUpAction().ActionCost;
                    }

                    totalFlyCost += new FlyAction().ActionCost;

                    other += new DropOffAction().ActionCost;

                    //have to get from the airport
                    if (!package.Destination.IsAirport)
                    {
                        //no empty van there
                        if (!package.Destination.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        other          += new LoadAction().ActionCost;
                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }
                }
                else //move just in city
                {
                    //no empty van there
                    if (!package.Location.Vans.Any(v => !v.IsFull))
                    {
                        other += new DriveAction().ActionCost;
                    }

                    if (package.LocationType == PackageLocationEnum.Plane)
                    {
                        other += new UnLoadAction().ActionCost;
                    }

                    if (package.LocationType != PackageLocationEnum.Van)
                    {
                        other += new LoadAction().ActionCost;
                    }

                    totalDriveCost += new DriveAction().ActionCost;

                    other += new UnLoadAction().ActionCost;
                }
            }
            return(other + totalFlyCost / freePlaneStorageCount + totalDriveCost / freeVanStorageCount);
        }
コード例 #8
0
ファイル: PTRobot.cs プロジェクト: kapysh/archiver
        public static PTRobotReturn OpenCloseDrive(uint driveID, DriveAction action)
        {
            uint nValue = 0;
            PTRobotReturn ret = PTRobotReturn.Ok;
            try
            {
                nValue = PTRobot_OpenCloseDrive(driveID, Convert.ToUInt32(action));
                ret = (PTRobotReturn)nValue;
            }
            catch
            {
                ret = PTRobotReturn.Internal;
            }

            return ret;
        }