private void executeAddStepper(object o) { if (StepperList.Count == 0) { MessageBoxResult result = MessageBox.Show( Translations.Main.EnablePulseEngineWarning, Translations.Main.EnablePulseEngineWarningCaption, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } InitPulseEngine(); } PoKeysStepper poStepper = new PoKeysStepper(); poStepper.setOwner(this); StepperList.Add(poStepper); InitStepperAxis(poStepper); RaisePropertyChanged("StepperSlotsAvailable"); }
private void EndHoming() { _homingTimer.Stop(); _homingTimer = null; _homingTimeoutTimer.Stop(); _homingTimeoutTimer = null; _isHoming = false; owner.PokeysDevice.PEv2_GetStatus(ref _PEconfig); // // Stop the Pulse Engine so we can set each axis (stepper) postion to zero since we are HOMED // _PEconfig.PulseEngineStateSetup = (byte)ePoKeysPEState.peSTOPPED; owner.PokeysDevice.PEv2_SetState(ref _PEconfig); if (_homingAxis == -1) { foreach (PoKeysStepper stepper in StepperList) { if ((!stepper.StepperId.HasValue) || (stepper.StepperId.GetValueOrDefault() <= 0)) { continue; } int i = stepper.StepperId.GetValueOrDefault() - 1; _PEconfig.param2 = (byte)(1 << i); // Set param2 bit to indicate which stepper _PEconfig.PositionSetup[i] = 0; // Set axis (stepper) position to Zero _PEconfig.ReferencePositionSpeed[i] = 0; owner.PokeysDevice.PEv2_SetPositions(ref _PEconfig); _PEconfig.MaxAcceleration[i] = (float)(stepper.MaxAcceleration / 1000000); _PEconfig.MaxDecceleration[i] = (float)(stepper.MaxDecceleration / 1000000); _PEconfig.param1 = (byte)i; // Set parameter param1 to the bit mask to indicate what have the above Axis Configs set owner.PokeysDevice.PEv2_SetAxisConfiguration(ref _PEconfig); // Configure the axis } } else { _PEconfig.param2 = (byte)(1 << _homingAxis); // Set param2 bit to indicate which stepper _PEconfig.PositionSetup[_homingAxis] = 0; // Set axis (stepper) position to Zero _PEconfig.ReferencePositionSpeed[_homingAxis] = 0; owner.PokeysDevice.PEv2_SetPositions(ref _PEconfig); _PEconfig.MaxAcceleration[_homingAxis] = (float)(StepperList.First(s => s.StepperId == _homingStepper).MaxAcceleration / 1000000); _PEconfig.MaxDecceleration[_homingAxis] = (float)(StepperList.First(s => s.StepperId == _homingStepper).MaxDecceleration / 1000000); _PEconfig.param1 = (byte)_homingAxis; // Set parameter param1 to the bit mask to indicate what have the above Axis Configs set owner.PokeysDevice.PEv2_SetAxisConfiguration(ref _PEconfig); // Configure the axis } _homingAxis = -2; _homingStepper = -1; // // Set Pulse Engine back to RUNNING _PEconfig.PulseEngineStateSetup = (byte)ePoKeysPEState.peRUNNING; owner.PokeysDevice.PEv2_SetState(ref _PEconfig); // // Get Pulse Engine Statue and Check to confirm we are RUNNING // owner.PokeysDevice.PEv2_GetStatus(ref _PEconfig); if (_PEconfig.PulseEngineState != (byte)ePoKeysPEState.peRUNNING) { // // Not sure what we do in F4toPokeys if this happens // Error = Translations.Main.StepperHomingError; return; } }