void Awake () { body = GetComponent<Rigidbody> (); motors = GetComponent<Motors>(); selfLeveling = GetComponent<SelfLeveling>(); hover = (body.mass * Physics.gravity.y) / -4; }
public async Task StartAstro(Motors motors, AstroDirection direction, AstroSpeed speed, float gearReduction) { await _commService .SendAndReceiveAsync(new MoCoBusMainCommandFrame( _address, MoCoBusMainCommand.Start, new[] { (byte)motors, (byte)direction, (byte)speed }.Concat(BitConverter.GetBytes(gearReduction).Reverse()).ToArray())) .ConfigureAwait(false); }
public async Task StartAstro(Motors motors, AstroDirection direction, AstroSpeed speed, GearType gear) { await _commService .SendAndReceiveAsync(new MoCoBusMainCommandFrame( _address, MoCoBusMainCommand.Start, new[] { (byte)motors, (byte)direction, (byte)speed, (byte)gear })) .ConfigureAwait(false); }
public void MotorControl(Motors which, uint speed, bool direction) { if (speed >= 100) speed = 100; switch (which) { case Motors.M3: // This motor can have its speed controlled through PWM if (speed == 0) Motor2A.SetDutyCycle(0); else { latch_state = (byte) ((latch_state & 0xBE) | (direction ? 1 : 64)); latch_tx(); Motor2A.SetDutyCycle(speed); } break; case Motors.M4: // This motor can have its speed controlled through PWM if (speed == 0) Motor2B.SetDutyCycle(0); else { latch_state = (byte) ((latch_state & 0x5F) | (direction ? 32 : 128)); latch_tx(); Motor2B.SetDutyCycle(speed); } break; } }
public async Task ReverseAllMotorsStartStopPoints(Motors motors) { await _commService .SendAndReceiveAsync(new MoCoBusMainCommandFrame(_address, MoCoBusMainCommand.ReverseAllMotorsStartStopPoints, new[] { (byte)motors })) .ConfigureAwait(false); }
public async Task SetProgramStopPoint(Motors motors) { await _commService .SendAndReceiveAsync(new MoCoBusMainCommandFrame(_address, MoCoBusMainCommand.SetProgramStopPoint, new[] { (byte)motors })) .ConfigureAwait(false); }
public Motor GetMotorById(long motorId) { return(Motors.FirstOrDefault(m => m.Id == motorId)); }
void Awake () { body = GetComponent<Rigidbody> (); motors = GetComponent<Motors>(); }
private async void Delete(object value) { #if XBAP MessageBoxResult result = MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OK, MessageBoxImage.Warning); #else MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OKCancel, MessageBoxImage.Warning); #endif if (result == MessageBoxResult.OK) { if (DevicesIsSelected == true) { T_DeviceDiagnose t_model = DeviceDiagnoseClass.ConvertToDB(SelectedDevice); if (t_model.id != -1) { await _databaseComponent.Delete <T_DeviceDiagnose>(ServerIP, t_model.id); } Devices.Remove(SelectedDevice); } else if (ShaftsIsSelected == true) { T_Shaft t_model = ShaftClass.ConvertToDB(SelectedShaft); if (t_model.id != -1) { await _databaseComponent.Delete <T_Shaft>(ServerIP, t_model.id); } Shafts.Remove(SelectedShaft); } else if (BearingsIsSelected == true) { T_Bearing t_model = BearingClass.ConvertToDB(SelectedBearing); if (t_model.id != -1) { await _databaseComponent.Delete <T_Bearing>(ServerIP, t_model.id); } Bearings.Remove(SelectedBearing); } else if (BeltsIsSelected == true) { Belts.Remove(SelectedBelt); T_Belt t_model = BeltClass.ConvertToDB(SelectedBelt); if (t_model.id != -1) { await _databaseComponent.Delete <T_Belt>(ServerIP, t_model.id); } } else if (GearsIsSelected == true) { T_Gear t_model = GearClass.ConvertToDB(SelectedGear); if (t_model.id != -1) { await _databaseComponent.Delete <T_Gear>(ServerIP, t_model.id); } Gears.Remove(SelectedGear); } else if (ImpellersIsSelected == true) { T_Impeller t_model = ImpellerClass.ConvertToDB(SelectedImpeller); if (t_model.id != -1) { await _databaseComponent.Delete <T_Impeller>(ServerIP, t_model.id); } Impellers.Remove(SelectedImpeller); } else if (MotorsIsSelected == true) { T_Motor t_model = MotorClass.ConvertToDB(SelectedMotor); if (t_model.id != -1) { await _databaseComponent.Delete <T_Motor>(ServerIP, t_model.id); } Motors.Remove(SelectedMotor); } } }
private void Add(object value) { if (DevicesIsSelected == true) { SelectedDevice = new DeviceDiagnoseClass() { Name = "新建设备" }; Devices.Add(SelectedDevice); } else if (ShaftsIsSelected == true) { SelectedShaft = new ShaftClass() { Name = "新建轴" }; Shafts.Add(SelectedShaft); } else if (BearingsIsSelected == true) { SelectedBearing = new BearingClass() { Name = "新建轴承" }; Bearings.Add(SelectedBearing); } else if (BeltsIsSelected == true) { SelectedBelt = new BeltClass() { Name = "新建皮带" }; Belts.Add(SelectedBelt); } else if (GearsIsSelected == true) { SelectedGear = new GearClass() { Name = "新建齿轮" }; Gears.Add(SelectedGear); } else if (ImpellersIsSelected == true) { SelectedImpeller = new ImpellerClass() { Name = "新建叶轮" }; Impellers.Add(SelectedImpeller); } else if (MotorsIsSelected == true) { SelectedMotor = new MotorClass() { Name = "新建电机" }; Motors.Add(SelectedMotor); } ShowWin(); //立即更新到服务器 }
/// <summary> /// Sets the state of a motor /// </summary> /// <param name="Motor">The motor to change</param> /// <param name="Speed">The speed to move with; -100 (full speed backward) to 100 (full speed forward)</param> public void SetState(Motors Motor, sbyte Speed) { // We expect a value between -100 and 100 if (Speed < -100 || Speed > 100) { throw new System.ArgumentOutOfRangeException(); } // Gets the direction straight bool PinA = false; bool PinB = true; if (Speed < 0) { // Makes it positive again Speed = (sbyte)(0 - Speed); PinA = true; PinB = false; } else if (Speed == 0) { // No speed at all PinA = false; PinB = false; } switch (Motor) { case Motors.Motor1: if (this._Motor1Pwm == null) throw new InvalidOperationException("Can't drive motor 1 without PWM pin"); this._Motor1aPin.Write(PinA); this._Motor1bPin.Write(PinB); this._Motor1Pwm.SetDutyCycle((uint)Speed); break; case Motors.Motor2: if (this._Motor2Pwm == null) throw new InvalidOperationException("Can't drive motor 2 without PWM pin"); this._Motor2aPin.Write(PinA); this._Motor2bPin.Write(PinB); this._Motor2Pwm.SetDutyCycle((uint)Speed); break; case Motors.Motor3: if (this._Motor3Pwm == null) throw new InvalidOperationException("Can't drive motor 3 without PWM pin"); this._Motor3aPin.Write(PinA); this._Motor3bPin.Write(PinB); this._Motor3Pwm.SetDutyCycle((uint)Speed); break; case Motors.Motor4: if (this._Motor4Pwm == null) throw new InvalidOperationException("Can't drive motor 4 without PWM pin"); this._Motor4aPin.Write(PinA); this._Motor4bPin.Write(PinB); this._Motor4Pwm.SetDutyCycle((uint)Speed); break; default: // Should never happen!! :-) throw new System.ArgumentOutOfRangeException(); } }
public void SetOffset(Motors motor, int value) { _motorCommand[(int)motor] = value; }
public IEnumerable <Motor> GetMotorsByCategoryId(long categoryId) { return(Motors.Where(m => m.Category.Id == categoryId)); }
public IEnumerable <Motor> GetMotorsByBrandId(long brandId) { return(Motors.Where(m => m.Brand.Id == brandId)); }
/// <summary> /// Enables or disables the specified motor. (TestMode Only) /// </summary> /// <param name="motor">Motor to toggle.</param> /// <param name="enable">True to enable, false to disable specified motor.</param> public void ToggleMotor(Motors motor, bool enable) { if (!this.neato.TestMode) { throw new NotInTestModeException("ToggleMotor : SetMotor"); } string parameters = null; switch (motor) { case Motors.Brush: parameters = enable ? "BrushEnable" : "BrushDisable"; this.neato.MotorBrushEnabled = enable; break; case Motors.LeftWheel: parameters = enable ? "LWheelEnable" : "LWheelDisable"; this.neato.MotorLWheelEnabled = enable; break; case Motors.RightWheel: parameters = enable ? "RWheelEnable" : "RWheelDisable"; this.neato.MotorRWheelEnabled = enable; break; } this.neato.Connection.SendCommand("SetMotor " + parameters, true); }
/// <summary> /// Sets the state of a motor /// </summary> /// <param name="Motor">The motor to change</param> /// <param name="Speed">The speed to move with; -100 (full speed backward) to 100 (full speed forward)</param> public void SetState(Motors Motor, sbyte Speed) { // We expect a value between -100 and 100 if (Speed < -100 || Speed > 100) { throw new System.ArgumentOutOfRangeException(); } switch (Motor) { case Motors.Motor1: // When Speed is below zero, the direction pin is true this._Motor1Direction.Write(Speed < 0); // When Speed is below zero, it will be set to positive (double negative; 0 - -100 = 100) this._Motor1Speed.StopPulse(); this._Motor1Speed.SetDutyCycle((uint)(Speed < 0 ? 100 - (0 - Speed) : Speed)); this._Motor1Speed.StartPulse(); break; case Motors.Motor2: // Same as for Motor1 this._Motor2Direction.Write(Speed < 0); this._Motor2Speed.StopPulse(); this._Motor2Speed.SetDutyCycle((uint)(Speed < 0 ? 100 - (0 - Speed) : Speed)); this._Motor2Speed.StartPulse(); break; default: // Should never happen!! :-) throw new System.ArgumentOutOfRangeException(); } }
public GunSightMotor(Motors m) : base(m) { _motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) => { if (!player.hasAppearanceInterface) { return; } if (!player.appearanceInterface.Appearance.IsFirstPerson) { player.appearanceInterface.Appearance.SetFirstPerson(); player.characterBoneInterface.CharacterBone.SetFirstPerson(); player.UpdateCameraArchorPostion(); } }); _motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) => { if (!player.hasAppearanceInterface) { return; } var playerUtils = EffectUtility.GetEffect(player.RootGo(), "PlayerUtils"); if (playerUtils != null) { playerUtils.SetParam("GunViewBegin", (object)player.RootGo().gameObject); } }); _motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) => { if (!player.hasAppearanceInterface) { return; } var speed = player.WeaponController().HeldWeaponAgent.CmrFocusSpeed; player.stateInterface.State.SetSight(speed); Logger.InfoFormat("Enter sight!"); }); _motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) => { if (!player.hasAppearanceInterface) { return; } player.AudioController().PlaySimpleAudio(EAudioUniqueId.SightOpen, true); }); _motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) => { if (!player.hasAppearanceInterface) { return; } OpenDepthOfField(player); }); _motors.ActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId, (player, state) => { var speed = player.WeaponController().HeldWeaponAgent.CmrFocusSpeed; player.stateInterface.State.CancelSight(speed); Logger.InfoFormat("Leave sight!"); }); _motors.ActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId, (player, state) => { var playerUtils = EffectUtility.GetEffect(player.RootGo(), "PlayerUtils"); if (playerUtils != null) { playerUtils.SetParam("GunViewEnd", (object)player.RootGo().gameObject); } }); _motors.ActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId, (player, state) => { player.AudioController().PlaySimpleAudio(EAudioUniqueId.SightClose, true); }); _motors.ActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId, (player, state) => { CloseDepthOfField(player); }); }
private async void SwapStartStop(Motors motors) { try { await _protocolService.Main.ReverseAllMotorsStartStopPoints(motors).ConfigureAwait(false); _sliderStartPos = await _protocolService.MotorSlider.GetProgramStartPoint().ConfigureAwait(false); _panStartPos = await _protocolService.MotorPan.GetProgramStartPoint().ConfigureAwait(false); _tiltStartPos = await _protocolService.MotorTilt.GetProgramStartPoint().ConfigureAwait(false); _sliderStopPos = await _protocolService.MotorSlider.GetProgramStopPoint().ConfigureAwait(false); _panStopPos = await _protocolService.MotorPan.GetProgramStopPoint().ConfigureAwait(false); _tiltStopPos = await _protocolService.MotorTilt.GetProgramStopPoint().ConfigureAwait(false); _dispatcherHelper.RunOnUIThread(() => { RaisePropertyChanged(() => SliderStartPosition); RaisePropertyChanged(() => PanStartPosition); RaisePropertyChanged(() => TiltStartPosition); RaisePropertyChanged(() => SliderStopPosition); RaisePropertyChanged(() => PanStopPosition); RaisePropertyChanged(() => TiltStopPosition); }); } catch (TimeoutException toe) { Insights.Report(toe); } }
public static Motors CraeteMotors(Contexts contexts, CameraConfig config) { Motors motors = new Motors(); var pose = motors.GetDict(SubCameraMotorType.Pose); pose[(int)ECameraPoseMode.Stand] = new NormalPoseMotor(ECameraPoseMode.Stand, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ThirdPersonActice(), motors); pose[(int)ECameraPoseMode.Crouch] = new NormalPoseMotor(ECameraPoseMode.Crouch, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new CrouchActice(), motors); pose[(int)ECameraPoseMode.Prone] = new NormalPoseMotor(ECameraPoseMode.Prone, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ProneActice(), motors); pose[(int)ECameraPoseMode.Swim] = new NormalPoseMotor(ECameraPoseMode.Swim, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new SwimActice(), motors); pose[(int)ECameraPoseMode.Dying] = new NormalPoseMotor(ECameraPoseMode.Dying, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new DyingActice(), motors); pose[(int)ECameraPoseMode.Dead] = new DeadPoseMotor(ECameraPoseMode.Dead, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new DeadActice(), config.GetRoleConfig().DeadConfig, motors); pose[(int)ECameraPoseMode.Parachuting] = new NormalPoseMotor(ECameraPoseMode.Parachuting, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ParachutingActice(), motors); pose[(int)ECameraPoseMode.ParachutingOpen] = new NormalPoseMotor(ECameraPoseMode.ParachutingOpen, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ParachutingOpenActice(), motors); pose[(int)ECameraPoseMode.Gliding] = new GlidingPoseMotor(ECameraPoseMode.Gliding, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new GlidingActice(), motors); pose[(int)ECameraPoseMode.DriveCar] = new DrivePoseMotor(ECameraPoseMode.DriveCar, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), contexts.vehicle, contexts.freeMove, motors); pose[(int)ECameraPoseMode.AirPlane] = new AirplanePoseMotor(ECameraPoseMode.AirPlane, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), contexts.vehicle, contexts.freeMove, motors); pose[(int)ECameraPoseMode.Climb] = new NormalPoseMotor(ECameraPoseMode.Climb, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ClimbActive(), motors); pose[(int)ECameraPoseMode.Rescue] = new NormalPoseMotor(ECameraPoseMode.Rescue, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new RescueActive(), motors); var free = motors.GetDict(SubCameraMotorType.Free); free[(int)ECameraFreeMode.On] = new FreeOnMotor(motors); free[(int)ECameraFreeMode.Off] = new FreeOffMotor(config.GetRoleConfig().FreeConfig.TransitionTime, motors); var peek = motors.GetDict(SubCameraMotorType.Peek); peek[(int)ECameraPeekMode.Off] = new PeekOffMotor(config.GetRoleConfig().PeekConfig.TransitionTime, motors); peek[(int)ECameraPeekMode.Left] = new PeekOnMotor(false, config.GetRoleConfig().PeekConfig, motors); peek[(int)ECameraPeekMode.Right] = new PeekOnMotor(true, config.GetRoleConfig().PeekConfig, motors); var view = motors.GetDict(SubCameraMotorType.View); view[(int)ECameraViewMode.FirstPerson] = new FirstViewMotor(motors); view[(int)ECameraViewMode.GunSight] = new GunSightMotor(motors); view[(int)ECameraViewMode.ThirdPerson] = new ThirdViewMotor(motors); motors.ActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.Pose, (int)ECameraPoseMode.Parachuting, (player, state) => { var cameraEulerAngle = player.cameraFinalOutputNew.EulerAngle; var carEulerAngle = player.cameraArchor.ArchorEulerAngle; var t = cameraEulerAngle - carEulerAngle; state.FreeYaw = t.y; state.FreePitch = t.x; }); return(motors); }