/// <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> /// Retourne le nom de la position en fonction du moteur (Haut, Bas, etc...) /// </summary> /// <param name="position">Position du moteur</param> /// <param name="moteur">Moteur</param> /// <returns>Nom de la position</returns> public static String GetName(int position, MotorID moteur) { PropertyInfo[] properties = typeof(Config).GetProperties(); foreach (PropertyInfo p in properties) { if (p.PropertyType.IsSubclassOf(typeof(PositionableMotorPosition))) { PositionableMotorPosition positionnableMoteur = (PositionableMotorPosition)(p.GetValue(Config.CurrentConfig, null)); if (positionnableMoteur.ID == moteur) { PropertyInfo[] proprietesMoteur = positionnableMoteur.GetType().GetProperties(); foreach (PropertyInfo ps in proprietesMoteur) { if (ps.Name.StartsWith("Position") && ((int)(ps.GetValue(positionnableMoteur, null)) == position)) { return(Config.PropertyNameToScreen(ps) + " (" + position + ")"); } } } } } return(position.ToString()); }
public virtual void SetMotorSpeed(MotorID moteur, SensGD sens, int vitesse) { if (MotorState.ContainsKey(moteur)) { MotorState[moteur] = vitesse == 0 ? false : true; } Historique.AjouterAction(new ActionMoteur(this, vitesse, moteur)); }
public override void SetMotorAcceleration(MotorID motor, int acceleration) { base.SetMotorAcceleration(motor, acceleration); Frame trame = UdpFrameFactory.MoteurAcceleration(_boardMotor[motor], motor, acceleration); Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame); }
public override void SetMotorStop(MotorID motor, StopMode mode) { base.SetMotorStop(motor, mode); Frame trame = UdpFrameFactory.MoteurStop(_boardMotor[motor], motor, mode); Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame); }
public override void SetMotorReset(MotorID motor) { base.SetMotorReset(motor); Frame trame = UdpFrameFactory.MoteurResetPosition(_boardMotor[motor], motor); Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame); }
public override void SetMotorSpeed(MotorID motor, SensGD sens, int speed) { base.SetMotorSpeed(motor, sens, speed); Frame trame = UdpFrameFactory.MoteurVitesse(_boardMotor[motor], motor, sens, speed); Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame); }
static public Frame MoteurOrigin(Board board, MotorID moteur) { byte[] tab = new byte[3]; tab[0] = (byte)board; tab[1] = (byte)UdpFrameFunction.MoteurOrigin; tab[2] = (byte)moteur; return(new Frame(tab)); }
static public Frame MoteurStop(Board board, MotorID moteur, StopMode mode) { byte[] tab = new byte[4]; tab[0] = (byte)board; tab[1] = (byte)UdpFrameFunction.MoteurStop; tab[2] = (byte)moteur; tab[3] = (byte)mode; return(new Frame(tab)); }
static public Frame MoteurAcceleration(Board board, MotorID moteur, int acceleration) { byte[] tab = new byte[5]; tab[0] = (byte)board; tab[1] = (byte)UdpFrameFunction.MoteurAccel; tab[2] = (byte)moteur; tab[3] = (byte)ByteDivide(acceleration, true); tab[4] = (byte)ByteDivide(acceleration, false); return(new Frame(tab)); }
static public Frame MoteurVitesse(Board board, MotorID moteur, SensGD sens, int vitesse) { byte[] tab = new byte[6]; tab[0] = (byte)board; tab[1] = (byte)UdpFrameFunction.MoteurVitesse; tab[2] = (byte)moteur; tab[3] = (byte)sens; tab[4] = (byte)ByteDivide(vitesse, true); tab[5] = (byte)ByteDivide(vitesse, false); return(new Frame(tab)); }
/// <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); }
public override void SetMotorAtOrigin(MotorID motor, bool wait) { base.SetMotorAtOrigin(motor); if (wait) { _lockMotor[motor] = new Semaphore(0, int.MaxValue); } Frame frame = UdpFrameFactory.MoteurOrigin(_boardMotor[motor], motor); Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(frame); if (wait) { _lockMotor[motor].WaitOne(30000); } }
public ActionMoteur(Robot r, int vi, MotorID mo) { robot = r; vitesse = vi; moteur = mo; }
public virtual void SetMotorAcceleration(MotorID moteur, int acceleration) { Historique.AjouterAction(new ActionMoteur(this, acceleration, moteur)); }
public virtual void SetMotorStop(MotorID moteur, StopMode mode) { }
public virtual void SetMotorReset(MotorID moteur) { }
/// <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"); } }
public virtual void SetMotorAtPosition(MotorID motor, int position, bool waitEnd = false) { //Historique.AjouterAction(new ActionMoteur(this, position, motor)); }
/// <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"); }
public override void SetMotorAcceleration(MotorID motor, int acceleration) { base.SetMotorAcceleration(motor, acceleration); }
public override void SetMotorSpeed(MotorID motor, SensGD sens, int speed) { base.SetMotorSpeed(motor, sens, speed); }
public override void SetMotorAtPosition(MotorID motor, int vitesse, bool wait) { base.SetMotorAtPosition(motor, vitesse); }
public virtual void SetMotorAtOrigin(MotorID motor, bool waitEnd = false) { //TODO historique ? }
public virtual void MotorWaitEnd(MotorID moteur) { }
public override void MotorWaitEnd(MotorID motor) { base.MotorWaitEnd(motor); _lockMotor[motor].WaitOne(5000); }
/// <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"); }