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); } }
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; } }
public void ReadFile() { _driveAction = DriveAction.Read; if (_googleApiClient.IsConnected) { GoogleDriveAction(); return; } Connect(); }
public void SaveFile() { _driveAction = DriveAction.Write; if (_googleApiClient.IsConnected) { GoogleDriveAction(); return; } Connect(); }
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); }
public void Drive() { DriveAction.DoAction(); }
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); }
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; }