Ejemplo n.º 1
0
        private bool AdvanceSweepStep()
        {
            _isShotRequested = true;
            bool lastSweep = false;

            SweepStep++;
            if (SweepStep == CurrentSweepSettings.SweepCount.Width * CurrentSweepSettings.SweepCount.Height - 1) // zero-indexed
            {
                btnNextSweepStep.Enabled = btnStartSweep.Enabled = false;
                lastSweep = true;
            }

            if (SweepStep % CurrentSweepSettings.SweepCount.Height != 0)
            {
                SemanticComms.Move(new Point(0, CurrentSweepSettings.SweepDelta.Height));
                return(!lastSweep);
            }

            SemanticComms.Move(new Point(
                                   -CurrentSweepSettings.SweepDelta.Width,
                                   -CurrentSweepSettings.SweepDelta.Height * (CurrentSweepSettings.SweepCount.Height - 1) - BACKLASH
                                   ));
            MoveQueue.Add(new Point(0, BACKLASH));

            return(!lastSweep);
        }
Ejemplo n.º 2
0
        public MainScannerForm()
        {
            InitializeComponent();
            NavigationIcons = new List <ScannerIcon>()
            {
                iconLeft,
                iconRight,
                iconUp,
                iconDown,
                iconStop,
            };
            foreach (var icon in NavigationIcons)
            {
                icon.Initialize();
            }

            ResetCommPortList();
            LoadSweepSettings();

            SemanticComms.Initialize();
            SemanticComms.OnLogMessage        += RawCommsLogMessage;
            SemanticComms.OnRawScannerCommand += RawCommsLogScannerCommand;
            SemanticComms.OnRawScannerOutput  += RawCommsLogScannerOutput;
            SemanticComms.OnScannerMoveChange += ProcessScannerMoveChange;
            SemanticComms.OnPositionChange    += ScannerPositionChanged;
        }
Ejemplo n.º 3
0
        private bool HandleKeyOrders()
        {
            CurrentKeyOrders = KeyMoveOrders.Stop;
            if (!Keyboard.IsKeyDown(Key.LeftAlt))
            {
                if (WasAltDown)
                {
                    StopMoving();
                }
                WasAltDown = false;
                return(false);
            }

            WasAltDown = true;

            if (Keyboard.IsKeyDown(Key.Escape))
            {
                StopMoving();
                return(true);
            }

            int x = 0;
            int y = 0;

            if (Keyboard.IsKeyDown(Key.Left))
            {
                CurrentKeyOrders |= KeyMoveOrders.Left;
                x = -INFINITE_STEPS;
            }
            else if (Keyboard.IsKeyDown(Key.Right))
            {
                CurrentKeyOrders |= KeyMoveOrders.Right;
                x = INFINITE_STEPS;
            }
            if (Keyboard.IsKeyDown(Key.Up))
            {
                CurrentKeyOrders |= KeyMoveOrders.Up;
                y = INFINITE_STEPS;
            }
            else if (Keyboard.IsKeyDown(Key.Down))
            {
                CurrentKeyOrders |= KeyMoveOrders.Down;
                y = -INFINITE_STEPS;
            }

            if (CurrentKeyOrders == PreviousKeyOrders)
            {
                return(true);
            }
            PreviousKeyOrders = CurrentKeyOrders;

            if (CurrentKeyOrders == KeyMoveOrders.Stop)
            {
                StopMoving();
                return(true);
            }

            SemanticComms.Move(new Point(x, y));
            return(true);
        }
Ejemplo n.º 4
0
        private void commPortCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (commPortCombo.SelectedIndex < 0)
            {
                return;
            }

            var selectedPort = commPortCombo.SelectedItem.ToString();

            if (ComPort != null && ComPort.Equals(selectedPort))
            {
                return;
            }

            var result = SemanticComms.Connect(selectedPort);

            if (result == PortStatus.Ok)
            {
                SetInterfaceEnabled(true);
                ResetNavigation(ScannerIcon.IconStates.Default);
                Settings.SerialPortName = selectedPort;
            }
            else
            {
                SetInterfaceEnabled(false);
                ResetNavigation(ScannerIcon.IconStates.Disabled);
            }

            ComPort = selectedPort;
        }
Ejemplo n.º 5
0
 private void btnSetNegativeSize_Click(object sender, EventArgs e)
 {
     CurrentSweepSettings.FilmSize = new Size(
         Math.Abs(SemanticComms.GetCurrentPos().X),
         Math.Abs(SemanticComms.GetCurrentPos().Y)
         );
     LogMessage("Negative size set to " + CurrentSweepSettings.FilmSize.Width + " by " + CurrentSweepSettings.FilmSize.Height + " steps.");
 }
Ejemplo n.º 6
0
        private bool HandleMovementQueue()
        {
            if (MoveQueue.Count == 0)
            {
                return(false);
            }

            SemanticComms.Move(new Point(MoveQueue[0].X, MoveQueue[0].Y));
            MoveQueue.RemoveAt(0);
            return(true);
        }
Ejemplo n.º 7
0
        // TODO: This is horrible, need to address it more elegantly
        private void ExecuteMoveToOrigin()
        {
            MoveToOriginRequested = false;
            var currentPos = SemanticComms.GetCurrentPos();

            if (currentPos.Equals(new Point(0, 0)))
            {
                return; // Duh!
            }

            MoveWithBacklash(new Point(-currentPos.X, -currentPos.Y));
        }
Ejemplo n.º 8
0
 private void MoveWithBacklash(Point relativeMove)
 {
     SemanticComms.Move(new Point(relativeMove.X + BACKLASH, relativeMove.Y - BACKLASH));
     MoveQueue.Add(new Point(-BACKLASH, BACKLASH));
 }
Ejemplo n.º 9
0
 private void StopMoving()
 {
     MoveQueue.Clear();
     SemanticComms.Stop();
 }
Ejemplo n.º 10
0
 private void btnResetOrigin_Click(object sender, EventArgs e)
 {
     SemanticComms.ResetOrigin();
     btnSetDslrSize.Enabled     = true;
     btnSetNegativeSize.Enabled = true;
 }
Ejemplo n.º 11
0
 private void iconLeft_Click(object sender, EventArgs e)
 {
     SemanticComms.Move(new Point(-INFINITE_STEPS, 0));
 }
Ejemplo n.º 12
0
 private void iconDown_Click(object sender, EventArgs e)
 {
     SemanticComms.Move(new Point(0, -INFINITE_STEPS));
 }