private void buttonGoDownAndBrokeCartridge_Click(object sender, EventArgs e) { CartridgeCell cell = CartridgeCell.MixCell; if (selectFirstCell.Checked) { cell = CartridgeCell.FirstCell; } else if (selectSecondCell.Checked) { cell = CartridgeCell.SecondCell; } else if (selectThirdCell.Checked) { cell = CartridgeCell.ThirdCell; } else if (selectResultCell.Checked) { cell = CartridgeCell.ResultCell; } Analyzer.TaskExecutor.StartTask( () => { Analyzer.Needle.GoDownAndPerforateCartridge(cell); }); }
private void buttonTurnToCartridge_Click(object sender, EventArgs e) { CartridgeCell cell = CartridgeCell.MixCell; if (selectFirstCell.Checked) { cell = CartridgeCell.FirstCell; } else if (selectSecondCell.Checked) { cell = CartridgeCell.SecondCell; } else if (selectThirdCell.Checked) { cell = CartridgeCell.ThirdCell; } else if (selectResultCell.Checked) { cell = CartridgeCell.ResultCell; } Analyzer.TaskExecutor.StartTask( () => { Analyzer.Needle.HomeLifterAndRotator(); Analyzer.Needle.TurnToCartridge(cell); }); }
public void TurnToCartridge(CartridgeCell cell) { Logger.Debug($"[{nameof(NeedleUnit)}] - Start turn to cartridge."); List <ICommand> commands = new List <ICommand>(); int turnSteps = 0; //TODO: Что то тут не так (if-else) if (cell == CartridgeCell.ResultCell) { turnSteps = Options.RotatorStepsToResultCell; } if (cell == CartridgeCell.MixCell) { turnSteps = Options.RotatorStepsToMixCell; } else if (cell == CartridgeCell.FirstCell) { turnSteps = Options.RotatorStepsToFirstCell; } else if (cell == CartridgeCell.SecondCell) { turnSteps = Options.RotatorStepsToSecondCell; } else if (cell == CartridgeCell.ThirdCell) { turnSteps = Options.RotatorStepsToThirdCell; } commands.Add(new SetSpeedCommand(Options.RotatorStepper, 50)); steppers = new Dictionary <int, int>() { { Options.RotatorStepper, turnSteps - RotatorPosition } }; commands.Add(new MoveCncCommand(steppers)); executor.WaitExecution(commands); RotatorPosition = turnSteps; Logger.Debug($"[{nameof(NeedleUnit)}] - Turn to cartridge finished."); }
public void GoDownAndPerforateCartridge(CartridgeCell cartridgeCell, bool needSuction = true) { Logger.Debug($"[{nameof(NeedleUnit)}] - Start going down and perforating cartridge."); List <ICommand> commands = new List <ICommand>(); int steps = Options.LifterStepsToCell; if (cartridgeCell == CartridgeCell.MixCell) { if (needSuction) { steps = Options.LifterStepsToMixCellAtSuction; } else { steps = Options.LifterStepsToMixCell; } } if (LifterPositionUnderfined) { HomeLifter(); } // Протыкание commands.Add(new SetSpeedCommand(Options.LifterStepper, (uint)Options.LifterSpeed)); steppers = new Dictionary <int, int>() { { Options.LifterStepper, steps - LifterPosition } }; commands.Add(new MoveCncCommand(steppers)); executor.WaitExecution(commands); LifterPosition = steps; Logger.Debug($"[{nameof(NeedleUnit)}] - Going down and piercing cartridge finished."); }
/// <summary> /// Поместить ячеку картриджа в роторе под иглу /// </summary> /// <param name="cartridgePosition">Номер позиции картриджа в роторе</param> /// <param name="cartridgeCell">Ячейка катриджа</param> /// <param name="cellPosition">Позиция ячейки картриджа</param> public void PlaceCellUnderNeedle(int cartridgePosition, CartridgeCell cartridgeCell, CellPosition cellPosition = CellPosition.CellCenter) { Logger.Debug($"[{nameof(RotorUnit)}] - Start placing cell under needle."); List <ICommand> commands = new List <ICommand>(); commands.Add(new SetSpeedCommand(Options.RotorStepper, (uint)Options.RotorSpeed)); int turnSteps = 0; if (cartridgeCell == CartridgeCell.ResultCell) { turnSteps = Options.StepsToNeedleResultCenter; } else if (cartridgeCell == CartridgeCell.MixCell) { turnSteps = Options.StepsToNeedleWhiteCenter; } else if (cartridgeCell == CartridgeCell.FirstCell) { if (cellPosition == CellPosition.CellLeft) { turnSteps = Options.StepsToNeedleLeft1; } else if (cellPosition == CellPosition.CellRight) { turnSteps = Options.StepsToNeedleRight1; } else { turnSteps = Options.StepsToNeedleLeft1 + (Options.StepsToNeedleRight1 - Options.StepsToNeedleLeft1) / 2; } } else if (cartridgeCell == CartridgeCell.SecondCell) { if (cellPosition == CellPosition.CellLeft) { turnSteps = Options.StepsToNeedleLeft2; } else if (cellPosition == CellPosition.CellRight) { turnSteps = Options.StepsToNeedleRight2; } else { turnSteps = Options.StepsToNeedleLeft2 + (Options.StepsToNeedleRight2 - Options.StepsToNeedleLeft2) / 2; } } else if (cartridgeCell == CartridgeCell.ThirdCell) { if (cellPosition == CellPosition.CellLeft) { turnSteps = Options.StepsToNeedleLeft3; } else if (cellPosition == CellPosition.CellRight) { turnSteps = Options.StepsToNeedleRight3; } else { turnSteps = Options.StepsToNeedleLeft3 + (Options.StepsToNeedleRight3 - Options.StepsToNeedleLeft3) / 2; } } turnSteps += Options.StepsPerCell * cartridgePosition; steppers = new Dictionary <int, int>() { { Options.RotorStepper, turnSteps - Position } }; commands.Add(new MoveCncCommand(steppers)); executor.WaitExecution(commands); Position = turnSteps; Logger.Debug($"[{nameof(RotorUnit)}] - Placing cell under needle finished."); }
private void buttonMoveCell_Click(object sender, EventArgs e) { int cellNumber = (int)editCellNumber.Value; int chargePosition = (int)editChargePosition.Value; CartridgeCell cell = CartridgeCell.MixCell; if (selectFirstCell.Checked) { cell = CartridgeCell.FirstCell; } else if (selectSecondCell.Checked) { cell = CartridgeCell.SecondCell; } else if (selectThirdCell.Checked) { cell = CartridgeCell.ThirdCell; } else if (selectResultCell.Checked) { cell = CartridgeCell.ResultCell; } if (selectChargePlace.Checked) { Analyzer.TaskExecutor.StartTask( () => { Analyzer.Rotor.Home(); Analyzer.Rotor.PlaceCellAtCharge(cellNumber, chargePosition); }); } else if (selectNeedleLeftPlace.Checked) { Analyzer.TaskExecutor.StartTask( () => { Analyzer.Rotor.Home(); Analyzer.Rotor.PlaceCellUnderNeedle(cellNumber, cell, RotorUnit.CellPosition.CellLeft); }); } else if (selectNeedleRightPlace.Checked) { Analyzer.TaskExecutor.StartTask( () => { Analyzer.Rotor.Home(); Analyzer.Rotor.PlaceCellUnderNeedle(cellNumber, cell, RotorUnit.CellPosition.CellRight); }); } else if (selectWashBufferPlace.Checked) { Analyzer.TaskExecutor.StartTask( () => { Analyzer.Rotor.Home(); Analyzer.Rotor.PlaceCellUnderWashBuffer(cellNumber); }); } else if (selectDischargePlace.Checked) { Analyzer.TaskExecutor.StartTask( () => { Analyzer.Rotor.Home(); Analyzer.Rotor.PlaceCellAtDischarge(cellNumber); }); } }