예제 #1
0
        //public static string rawCommand(string function, string command)
        //{
        //    return rawCommand(function, command, false);
        //}

        //public static string rawCommand(string function, string command, bool raw)
        public static string rawCommand(string command, bool raw)
        {
            try
            {
                string answer = SharedResources.SendMessage(command);
                if (raw)
                {
                    return(answer.Trim());
                }
                else
                {
                    return(answer.Substring(2).Trim());
                }
            }
            catch (System.TimeoutException e)
            {
                tl.LogMessage("Arduino Timeout exception", e.Message);
            }
            catch (ASCOM.Utilities.Exceptions.SerialPortInUseException e)
            {
                tl.LogMessage("Arduino Serial port in use exception", "Command: " + command + ", " + e.Message);
            }
            catch (ASCOM.NotConnectedException e)
            {
                tl.LogMessage("Arduino Not connected exception", e.Message);
            }
            catch (ASCOM.DriverException e)
            {
                tl.LogMessage("Arduino Driver exception", e.Message);
            }

            return(String.Empty);
        }
예제 #2
0
        public void Halt()
        {
            SharedResources.Halt();

            //  CommandString("S#", false);
            //  tl.LogMessage("Halt", "Not implemented");
            //   throw new ASCOM.MethodNotImplementedException("Halt");
        }
예제 #3
0
        //     private string ASCOMfunction = "f"; // may not be needed
        public string CommandString(string command, bool raw)
        {
            CheckConnected("CommandString");
            // it's a good idea to put all the low level communication with the device here,
            // then all communication calls this function
            // you need something to ensure that only one command is in progress at a time

            // throw new ASCOM.MethodNotImplementedException("CommandString");
            //  return SharedResources.rawCommand(ASCOMfunction, command, raw); //? ascomfunction ???? maynot be needed.....
            return(SharedResources.rawCommand(command, raw)); //? ascomfunction ???? maynot be needed.....
        }
예제 #4
0
        //public double RelativeAngleToMotorSteps(float angle)
        //{
        //    var targetSteps1 = angle % 360.00F * stepsPerDegree;
        //    return targetSteps1;
        //}
        //public double PositionAngleToMotorSteps(float targetPositionAngle)
        //{
        //    float targetAngle = 0;
        //    var absTargetAngle1 = targetPositionAngle + 360;
        //    var absTargetAngle2 = targetPositionAngle;
        //    var angleDelta1 = absTargetAngle1 - StepperPos / stepsPerDegree;
        //    var angleDelta2 = StepperPos / stepsPerDegree - absTargetAngle2;
        //    if (absTargetAngle1 < 0 || absTargetAngle1 > 720)
        //    {
        //        targetAngle = absTargetAngle2;
        //        return targetAngle * stepsPerDegree;
        //    }
        //    if (absTargetAngle2 < 0 || absTargetAngle2 > 720)
        //    {
        //        targetAngle = absTargetAngle1;
        //        return targetAngle * stepsPerDegree;
        //    }



        //    if (angleDelta1 < angleDelta2)
        //    {
        //        // if target is close to 0 or 72000 AND the move is < 90 degrees then go there(acceptable if close)...otherwise want to stay close to 36000
        //        if ((absTargetAngle1 < 90 && angleDelta1 < 90) || (absTargetAngle1 > 630 && angleDelta1 < 90))
        //            targetAngle = absTargetAngle1;
        //        else
        //            targetAngle = absTargetAngle2;
        //        if (absTargetAngle1 >= 90 && absTargetAngle1 <= 630) // if outside the close to 0/72000 zone then use smaller delta
        //            targetAngle = absTargetAngle1;


        //    }
        //    else // delta 2 is smaller so in general use it unless within 90 of 0/72000 OR if close then ok
        //    {
        //        if ((absTargetAngle2 < 90 && angleDelta2 < 90) || (absTargetAngle2 > 630 && angleDelta2 < 90))
        //            targetAngle = absTargetAngle2;
        //        else
        //            targetAngle = absTargetAngle1;
        //        if (absTargetAngle2 >= 90 && absTargetAngle2 <= 630)
        //            targetAngle = absTargetAngle2;

        //    }
        //    return targetAngle * stepsPerDegree;
        //}



        public void MoveAbsolute(float pos)
        {
            SharedResources.MoveAbsolute(pos);

            //var stepPosition = PositionAngleToMotorSteps(pos);
            //targetPosition = pos;
            ////   TargetPosition = pos;
            //CommandString("M " + Math.Round(stepPosition, 0) + "#", false);  // Position was 'int value' for focuser  // corrects for 100 steps per degree, need to replace with user defined variable.
            //lastMoving = true;  //remd 1-12-15


            //tl.LogMessage("MoveAbsolute", Position.ToString()); // Move to this position
            //rotatorPosition = Position;
            //rotatorPosition = (float)astroUtilities.Range(rotatorPosition, 0.0, true, 360.0, false); // Ensure value is in the range 0.0..359.9999...
        }
예제 #5
0
        //remd 4-24-17
        //public bool Link
        //{
        //    get
        //    {
        //        long now = DateTime.Now.Ticks;
        //        if (now - lastL > UPDATETICKS)
        //        {
        //            if (serialPort != null)
        //                lastLink = serialPort.Connected;

        //            lastL = now;
        //            return lastLink;
        //        }

        //        return lastLink;
        //    }
        //    set
        //    {
        //        this.Connected = value;
        //    }


        //    /*
        //    get
        //    {
        //        tl.LogMessage("Link Get", this.Connected.ToString());
        //        return this.Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility
        //    }
        //    set
        //    {
        //        tl.LogMessage("Link Set", value.ToString());
        //        this.Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility
        //    }
        //     */
        //}


        public void Move(float pos)
        {
            SharedResources.Move(pos);

            //double moveTo = StepperPos + RelativeAngleToMotorSteps(pos);  // current position in steps + number of steps needed to
            //targetPosition = pos;
            //if (moveTo >= 720 * stepsPerDegree) // was 72000
            //    moveTo -= 360 * stepsPerDegree;
            //if (moveTo < 0)
            //    moveTo += 360 * stepsPerDegree;
            //CommandString("M " + Math.Round(moveTo, 0) + "#", false);  // Position was 'int value' for focuser
            //lastMoving = true;  //remd 1-12-15

            //tl.LogMessage("Move", Position.ToString()); // Move by this amount
            //rotatorPosition += Position;
            //rotatorPosition = (float)astroUtilities.Range(rotatorPosition, 0.0, true, 360.0, false); // Ensure value is in the range 0.0..359.9999...
        }
예제 #6
0
        //
        // PUBLIC COM INTERFACE IRotatorV2 IMPLEMENTATION
        //

        #region Common properties and methods.

        /// <summary>
        /// Displays the Setup Dialog form.
        /// If the user clicks the OK button to dismiss the form, then
        /// the new settings are saved, otherwise the old values are reloaded.
        /// THIS IS THE ONLY PLACE WHERE SHOWING USER INTERFACE IS ALLOWED!
        /// </summary>
        public void SetupDialog()
        {
            SharedResources.RunSetupDialog();


            // consider only showing the setup dialog if not connected
            // or call a different dialog if connected

            //if (SharedResources.SharedSerial.Connected)
            //{
            //   System.Windows.Forms.MessageBox.Show("Already connected, just press OK");
            //}
            //else
            //{

            //using (SetupDialogForm F = new SetupDialogForm())
            //{
            //    var result = F.ShowDialog();
            //    if (result == System.Windows.Forms.DialogResult.OK)
            //    {
            //        WriteProfile(); // Persist device configuration values to the ASCOM Profile store
            //    }
            //}


            //using (ServerSetupDialog setupSerial = new ServerSetupDialog())
            //{
            //    setupSerial.ShowDialog();
            //}
            //   }



            // remd 4-24-17
            //if (IsConnected)
            //    System.Windows.Forms.MessageBox.Show("Already connected, just press OK");
        }