/// <summary> /// Retourne le nom usuel d'un moteur /// </summary> /// <param name="capteur">Moteur à nommer</param> /// <returns>Nom du Moteur</returns> public static String GetName(MotorID motor) { switch (motor) { case MotorID.ElevatorLeft: return("ascenseur gauche"); case MotorID.ElevatorRight: return("ascenseur droite"); case MotorID.AvailableOnRecIO2: return("RecIO 2"); case MotorID.AvailableOnRecIO3: return("RecIO 3"); case MotorID.AvailableOnRecMove11: return("RecMove 1"); case MotorID.AvailableOnRecMove12: return("RecMove 2"); default: return(motor.ToString()); } }
/// <summary> /// Launches a configuration dialog box for the driver. The call will not return until the user clicks OK or cancel manually. /// /// Must be implemented /// Namespace: ASCOM.DeviceInterface /// Assembly: ASCOM.DeviceInterfaces(in ASCOM.DeviceInterfaces.dll) Version: 6.0.0.0 (6.4.1.2695) /// </summary> public void SetupDialog() { // consider only showing the setup dialog if not connected // or call a different dialog if connected if (IsConnected) { SharedResources.LogMessage(MotorID.ToString() + "::SetupDialog", "Disconnect first before changing driver settings."); System.Windows.Forms.MessageBox.Show("Disconnect first before changing driver settings."); } else { SharedResources.LogMessage(MotorID.ToString() + "::SetupDialog", "Execute external helper program"); System.Diagnostics.Process.Start(string.Format("{0}\\ASCOM.Ardufocus.Setup.exe", AppDomain.CurrentDomain.BaseDirectory)); } }
/// <summary> /// Moves the focuser by the specified amount or to the specified position depending on the value of the Absolute property. /// /// Must be implemented /// Namespace: ASCOM.DeviceInterface /// Assembly: ASCOM.DeviceInterfaces(in ASCOM.DeviceInterfaces.dll) Version: 6.0.0.0 (6.4.1.2695) /// </summary> public void Move(int Position) { CheckConnected("Move"); if (Position > MaxStep) { Position = MaxStep; } string command = string.Format( (SharedResources.Config.HighResolution) ? SET_TARGET_POS : SET_TARGET_POS_HIRES, Position); SharedResources.SendSerialMessageBlind(command); SharedResources.SendSerialMessageBlind(START_MOTION); SharedResources.LogMessage(MotorID.ToString() + "::Move", "Move motor to '{0}' (cmd: {1})", Position, command); }
/// <summary> /// Immediately stop any focuser motion due to a previous Move(Int32) method call. /// /// Can throw a not implemented exception /// Namespace: ASCOM.DeviceInterface /// Assembly: ASCOM.DeviceInterfaces(in ASCOM.DeviceInterfaces.dll) Version: 6.0.0.0 (6.4.1.2695) /// </summary> public void Halt() { CheckConnected("Halt"); SharedResources.SendSerialMessageBlind(STOP_MOTION); SharedResources.LogMessage(MotorID.ToString() + "::Halt", "Stop motor movement"); }
/// <summary> /// Invokes the specified device-specific action. /// /// Can throw a not implemented exception /// Namespace: ASCOM.DeviceInterface /// Assembly: ASCOM.DeviceInterfaces(in ASCOM.DeviceInterfaces.dll) Version: 6.0.0.0 (6.4.1.2695) /// </summary> public string Action(string actionName, string actionParameters) { SharedResources.LogMessage(MotorID.ToString() + "::Action", "Action {0}, parameters {1} not implemented", actionName, actionParameters); throw new ActionNotImplementedException("Action " + actionName + " is not implemented by this driver"); }
/// <summary> /// Helper functiion to handle the initial device initializatioon /// </summary> private void InitDevice() { MotorConfig_t Motor = (MotorID == Motor_t.MOTOR_ONE) ? SharedResources.Config.M1 : SharedResources.Config.M2; // // Auto select the motor resolution // string hex; SharedResources.SendSerialMessageBlind(START_ADC_READING); hex = SharedResources.SendSerialMessage(GET_CURRENT_POS); if (hex.Length == 4) { SharedResources.Config.HighResolution = false; SharedResources.LogMessage(MotorID.ToString() + "::InitDevice", "Activating standard resolution mode (16-bit)"); } else if (hex.Length == 8) { SharedResources.Config.HighResolution = true; SharedResources.LogMessage(MotorID.ToString() + "::InitDevice", "Activating high resolution mode (32-bit)"); } else { throw new FormatException("Invalid hex string received"); } // // Set the motor stepping speed // string Speed = String.Empty; SharedResources.LogMessage(MotorID.ToString() + "::InitDevice", "Set motor speed to {0}", Motor.SteppingSpeed.ToString()); switch (Motor.SteppingSpeed) { case speed_t.SPEED100: Speed = "02"; break; case speed_t.SPEED50: Speed = "04"; break; case speed_t.SPEED25: Speed = "08"; break; case speed_t.SPEED20: Speed = "10"; break; case speed_t.SPEED10: Speed = "20"; break; default: throw new NotSupportedException("Selected SteppingSpeed not supported"); } CommandBlind(string.Format(SET_SPEED, Speed), true); // // Set the motor mode // SharedResources.LogMessage(MotorID.ToString() + "::InitDevice", "Set motor stepping mode to {0}", Motor.SteppingMode.ToString()); switch (Motor.SteppingMode) { case step_t.FULL: CommandBlind("SetModeFull", false); break; case step_t.ONE_HALF: CommandBlind("SetModeHalf", false); break; default: throw new NotSupportedException("Selected SteppingMode not supported"); } }