示例#1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,Name")] MotorType motorType)
        {
            if (id != motorType.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(motorType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MotorTypeExists(motorType.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(motorType));
        }
示例#2
0
 protected Plane(string name, MotorType motor, WingType wing, WheelType wheel)
 {
     this._name  = name;
     this._motor = motor;
     this._wheel = wheel;
     this._wing  = wing;
 }
示例#3
0
 public MotorDescriptor()
 {
     unchecked
     {
         type = MotorType.MOTOR_NONE;
     }
 }
示例#4
0
        /// <summary>
        /// 初始化Ecat
        /// </summary>
        public void InitializeEcat()
        {
            try
            {
                while (clsECatFunctions.clsEcatFunction.EcatInitial() != conProg.process.Success)
                {
                    System.Windows.Forms.Application.DoEvents();
                }

                MotorType[] motorType = new MotorType[3] {
                    MotorType.X_Axis, MotorType.Y_Axis, MotorType.θ_Axis
                };
                foreach (MotorType item in motorType)
                {
                    int uIndex = 0;
                    //Get VenderID
                    foreach (ushort MapNodeID in clsECatFunctions.clsEcatFunction.Ecat_DeltaEcatCard[motors[item].ECatAxisDevice.CardNum].MapNodeID_List)
                    {
                        if (motors[item].ECatAxisDevice.NodeID == MapNodeID)
                        {
                            motors[item].ECatAxisDevice.SeqNodeID = clsECatFunctions.clsEcatFunction.Ecat_DeltaEcatCard[motors[item].ECatAxisDevice.CardNum].SeqNodeID_List[uIndex];
                            motors[item].ECatAxisDevice.uVendorID = clsECatFunctions.clsEcatFunction.Ecat_DeltaEcatCard[motors[item].ECatAxisDevice.CardNum].VenderID_List[uIndex];
                            break;
                        }
                        uIndex += 1;
                    }
                }
            }
            catch (Exception err)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                LogFile.LogTryCatch(stackFrames, err.Message, true, true);
            }
        }
示例#5
0
 public Vehicle(Driver driver, MotorType motorType = MotorType.Normal,
                bool trumpSticker = false)
 {
     Motor        = motorType;
     Driver       = driver;
     TrumpSticker = trumpSticker;
 }
示例#6
0
 public MotorValue(int pow, MotorType motor, EncoderType encoder, int value)
 {
     Pow     = pow;
     Motor   = motor;
     Encoder = encoder;
     Value   = value;
 }
        /// <summary>
        /// Get description for TextChatStatus enum
        /// </summary>
        /// <param name="chatStatus"></param>
        /// <returns></returns>
        public static string GetMotorDescription(this MotorType motorType)
        {
            // get the field
            var field  = motorType.GetType().GetField(motorType.ToString());
            var result = GetDescriptionAttributeValue(field);

            return(string.IsNullOrWhiteSpace(result) ? motorType.ToString() : result);
        }
示例#8
0
 public MotorData()
 {
     // The initial type doesn't matter since the abstract base
     // class will never be instantiated.
     type    = MotorType.Attractor;
     Enabled = Defaults.Motor.Enabled;
     Name    = "";
 }
 public override void Read(PackFileDeserializer des, BinaryReaderEx br)
 {
     base.Read(des, br);
     m_type = (MotorType)br.ReadSByte();
     br.ReadUInt32();
     br.ReadUInt16();
     br.ReadByte();
 }
 private MotorTypeModel MapMotorTypeEntity(MotorType motorType)
 {
     return(new MotorTypeModel
     {
         BrandId = motorType.BrandId,
         Name = motorType.Name,
         Id = motorType.Id
     });
 }
        protected AngleController(int controllerChannel)
        {
            this.controllerChannel = controllerChannel;
            this.motorType = (MotorType)controllerChannel;

            ControllerData = new List<ControllerDataPoint>();

            Log.DebugFormat("Created new {0} motor", motorType);
        }
示例#12
0
        public void ShowPos(MotorType motorType, ref double feedback)
        {
            int nCmd = 0, nPos = 0;

            motors[motorType].ECAT_Slave_Motion_Get_Command(ref nCmd);
            motors[motorType].ECAT_Slave_Motion_Get_Position(ref nPos);
            double actualUnit = motors[motorType].ECatAxisDevice.MM_PerRev / motors[motorType].ECatAxisDevice.Pulse_PerRev;

            feedback = (double)nPos * actualUnit;
        }
示例#13
0
 public Motor(
     decimal price,
     int weight,
     int acceleration,
     int topSpeed,
     int horsepower,
     TunningGradeType gradeType,
     CylinderType cylinderType,
     MotorType engineType)
 {
 }
示例#14
0
 public Motor(
     decimal price,
     int weight,
     int acceleration,
     int topSpeed,
     int horsepower,
     TunningGradeType gradeType,
     CylinderType cylinderType,
     MotorType engineType)
 {
 }
示例#15
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int Mtype = (int)value;

            MotorType motortype = (MotorType)Enum.Parse(typeof(MotorType), Mtype.ToString());
            string    Motor     = "";

            Motor = motortype.GetMotorDescription();

            return(Motor);
        }
示例#16
0
 public static void *Create(int deviceId, MotorType type)
 {
     lock (lockObject)
     {
         if (driver == null)
         {
             driver = new CANSparkMaxDriverNative(NativeLibraryLoader.LoadNativeLibrary("CANSparkMaxDriver") !);
         }
     }
     return(driver.c_SparkMax_Create(deviceId, type));
 }
示例#17
0
 public void Emg_Stop(MotorType motorType)
 {
     try
     {
         motors[motorType].ECAT_Slave_Motion_Emg_stop();
     }
     catch (Exception e)
     {
         StackFrame[] stackFrames = new StackTrace(true).GetFrames();
         LogFile.LogTryCatch(stackFrames, e.Message, true, true);
     }
 }
示例#18
0
        public async Task <IActionResult> Create([Bind("ID,Name")] MotorType motorType)
        {
            if (ModelState.IsValid)
            {
                motorType.ID = Guid.NewGuid();
                _context.Add(motorType);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(motorType));
        }
示例#19
0
        public bool MoveUpDown(bool up, MotorType type = MotorType.Linear)
        {
            bool result = false;

            try
            {
                serialPorts[(int)type].Move(up ? Direction.CCW : Direction.CW, 100);
                result = true;
            }catch (Exception ex)
            {
                Console.WriteLine("Failed to move up/down: " + ex.Message);
                result = false;
            }
            return(result);
        }
示例#20
0
 protected Motor(
     decimal price,
     int weight,
     int acceleration,
     int topSpeed,
     int horsepower,
     TunningGradeType gradeType,
     CylinderType cylinderType,
     MotorType engineType)
     : base(price, weight, acceleration, topSpeed, gradeType)
 {
     this.Horsepower   = horsepower;
     this.CylinderType = cylinderType;
     this.EngineType   = engineType;
 }
示例#21
0
 public void GoHome(MotorType motorType, ushort zero_Org)
 {
     try
     {
         motors[motorType].ECAT_Slave_GoHome(zero_Org, false);
         while (motors[motorType].ECAT_Slave_GoHome(zero_Org) != conProg.process.Success)
         {
             System.Windows.Forms.Application.DoEvents();
         }
     }
     catch (Exception err)
     {
         StackFrame[] stackFrames = new StackTrace(true).GetFrames();
         LogFile.LogTryCatch(stackFrames, err.Message, true, true);
     }
 }
示例#22
0
        public bool Homing(MotorType type = MotorType.Linear)
        {
            bool result = false;

            try
            {
                serialPorts[(int)type].Homing();
                result = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to homing: " + ex.Message);
                result = false;
            }
            return(result);
        }
示例#23
0
        public void AxisPVMove(MotorType motorType, RotateDirection rotateDirection, int iniVelocity, int maxVelocity, double tAcc, ushort m_curve = 2)
        {
            try
            {
                double actualUnit = motors[motorType].ECatAxisDevice.Pulse_PerRev / motors[motorType].ECatAxisDevice.MM_PerRev;

                ushort dir = (ushort)rotateDirection;
                iniVelocity = Convert.ToInt32(iniVelocity * actualUnit);
                maxVelocity = Convert.ToInt32(maxVelocity * actualUnit);

                motors[motorType].ECAT_Slave_CSP_Start_V_Move(dir, iniVelocity, maxVelocity, tAcc, m_curve);
            }
            catch (Exception err)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                LogFile.LogTryCatch(stackFrames, err.Message, true, true);
            }
        }
示例#24
0
        public void AxisPPMove(MotorType motorType, double dist, int iniVelocity, int maxVelocity, double tAcc, double tDec, ushort m_abs = 0, ushort m_curve = 2)
        {
            try
            {
                double actualUnit = motors[motorType].ECatAxisDevice.Pulse_PerRev / motors[motorType].ECatAxisDevice.MM_PerRev;

                dist        = Convert.ToInt32(dist * actualUnit);
                iniVelocity = Convert.ToInt32(iniVelocity * actualUnit);
                maxVelocity = Convert.ToInt32(maxVelocity * actualUnit);

                motors[motorType].ECAT_Slave_CSP_Start_Move((int)dist, iniVelocity, maxVelocity, iniVelocity, tAcc, tDec, m_curve, m_abs);
            }
            catch (Exception err)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                LogFile.LogTryCatch(stackFrames, err.Message, true, true);
            }
        }
示例#25
0
        public void Servo_On_Off(MotorType motorType)
        {
            try
            {
                ushort uCheckOnOff = 0;
                ushort StatusWord  = 0;
                //===== Get the Motor's Status =====
                motors[motorType].ECAT_Slave_Motion_Get_StatusWord(ref StatusWord);
                //=== Check Servo ON/OFF
                uCheckOnOff = (StatusWord & 0x2) == 0x2 ? (ushort)0 : (ushort)1;

                motors[motorType].ECAT_Slave_Motion_Set_Svon(uCheckOnOff);
            }
            catch (Exception err)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                LogFile.LogTryCatch(stackFrames, err.Message, true, true);
            }
        }
示例#26
0
 public Motor(
     decimal price,
     int weight,
     int acceleration,
     int topSpeed,
     int horsepower,
     TunningGradeType gradeType,
     CylinderType cylinderType,
     MotorType engineType)
 {
     this.Price        = price;
     this.Weight       = weight;
     this.Acceleration = acceleration;
     this.TopSpeed     = topSpeed;
     this.Horsepower   = horsepower;
     this.GradeType    = gradeType;
     this.CylinderType = cylinderType;
     this.EngineType   = engineType;
 }
示例#27
0
        /// <summary>
        /// Invert a motor direction
        /// </summary>
        /// <remarks>This is used when a motor should run in the opposite direction
        /// as the drive code would normally run it. Motors that are direct drive would be inverted,
        /// the drive code assumes that the motors are geared with 1 reversal.</remarks>
        /// <param name="motor">The motor index to invert</param>
        /// <param name="isInverted">True if the motor should be inverted.</param>
        public void SetInvertedMotor(MotorType motor, bool isInverted)
        {
            switch (motor)
            {
            case MotorType.FrontLeft:
                FrontLeftMotor.Inverted = isInverted;
                break;

            case MotorType.FrontRight:
                FrontRightMotor.Inverted = isInverted;
                break;

            case MotorType.RearLeft:
                RearLeftMotor.Inverted = isInverted;
                break;

            case MotorType.RearRight:
                RearRightMotor.Inverted = isInverted;
                break;
            }
        }
示例#28
0
        public async Task <Response> Handle(CreateMotorTypeCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var dbMotorType = await _unitOfWork.Repository <MotorType>().FindOne(x => x.Type == request.Type);

                if (dbMotorType == null)
                {
                    var motorType = new MotorType()
                    {
                        Type        = request.Type,
                        Description = request.Description
                    };
                    _unitOfWork.Repository <MotorType>().Insert(dbMotorType);

                    await _unitOfWork.SaveChangeAsync();

                    return(await Task.FromResult(new Response
                    {
                        Code = ErrorCodeMessage.Success.Key,
                        Message = ErrorCodeMessage.Success.Value,
                        Data = _mapper.Map <MotorTypeDTO>(motorType)
                    }));
                }

                return(await Task.FromResult(new Response
                {
                    Code = ErrorCodeMessage.IdentityDuplicate.Key,
                    Message = ErrorCodeMessage.IdentityDuplicate.Value,
                }));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
示例#29
0
        public bool RotateStage(bool enable, MotorType type = MotorType.Rotation)
        {
            bool result = false;

            if (!enable)
            {
                serialPorts[(int)type].StopMotor();
                return(true);
            }
            else
            {
                try
                {
                    serialPorts[(int)type].ContinuousMotion(Direction.CW);
                    result = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to rotate the stage: " + ex.Message);
                    result = false;
                }
                return(result);
            }
        }
示例#30
0
        public StageMotor(SerialPort serialPort, MotorType motorType)
        {
            _serialPort = serialPort;
            _motortype  = motorType;

            if (motorType == MotorType.Rotation)
            {
                ContinuousVelocity = App.Settings.MotorContinuousVelocity;
            }
            else
            {
                CheckLimitHoming();
            }

            serialPort.DiscardInBuffer();
            serialPort.DiscardOutBuffer();

            ResetPosition();

            _statusTimer           = new Timer();
            _statusTimer.Interval  = 50;
            _statusTimer.AutoReset = false;
            _statusTimer.Elapsed  += new ElapsedEventHandler(_statusTimer_Elapsed);
        }
示例#31
0
 /// <summary>
 /// Invert a motor direction
 /// </summary>
 /// <remarks>This is used when a motor should run in the opposite direction
 /// as the drive code would normally run it. Motors that are direct drive would be inverted,
 /// the drive code assumes that the motors are geared with 1 reversal.</remarks>
 /// <param name="motor">The motor index to invert</param>
 /// <param name="isInverted">True if the motor should be inverted.</param>
 public void SetInvertedMotor(MotorType motor, bool isInverted)
 {
     switch (motor)
     {
         case MotorType.FrontLeft:
             FrontLeftMotor.Inverted = isInverted;
             break;
         case MotorType.FrontRight:
             FrontRightMotor.Inverted = isInverted;
             break;
         case MotorType.RearLeft:
             RearLeftMotor.Inverted = isInverted;
             break;
         case MotorType.RearRight:
             RearRightMotor.Inverted = isInverted;
             break;
     }
 }
示例#32
0
        bool SetSerialPort(SerialPort serialPort, MotorType motorType)
        {
            bool result = false;

            try
            {
                //make sure in SCL mode
                serialPort.WriteLine("PM");
                if (serialPort.ReadLine().Substring(3) != "2")
                {
                    serialPort.WriteLine("PM2");
                    //CheckAck();
                    App.LogEntry.AddEntry("ST5 : Please power cycle the Motor Drive and try connecting again", true);
                    return(false);
                }

                serialPort.WriteLine("PR5");
                if (!CheckAck(serialPort))
                {
                    return(false);
                }
                serialPort.WriteLine("SKD"); //Stop and Kill
                if (!CheckAck(serialPort))
                {
                    return(false);
                }
                serialPort.WriteLine("MV");
                string mvRead = serialPort.ReadLine();
                try
                {
                    SERVO_MOTOR_MODEL _model = (SERVO_MOTOR_MODEL)Convert.ToInt32(mvRead.Substring(4, 3));;
                }
                catch (Exception /*ex*/)
                {
                    App.LogEntry.AddEntry("Unsupported Motor Drive", true);
                    return(false);
                }
                App.LogEntry.AddEntry("ST5 Model/Revision: " + mvRead);
                serialPort.WriteLine("OP");
                App.LogEntry.AddEntry("ST5 Option Board: " + serialPort.ReadLine());

                serialPort.WriteLine("SC");
                string response = serialPort.ReadLine().Substring(3);
                App.LogEntry.AddEntry("ST5 Status: 0x" + response);
                bool _motorEnabled = (Convert.ToInt32(response.Substring(3, 1)) % 2) == 1;
                bool _driveBusy    = (Convert.ToInt32(response.Substring(2, 1)) % 2) != 0;

                serialPort.WriteLine("AC100");
                if (!CheckAck(serialPort))
                {
                    return(false);
                }
                serialPort.WriteLine("DC100");
                if (!CheckAck(serialPort))
                {
                    return(false);
                }
                result = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed in SetSerialPort: " + motorType.ToString() + " exception: " + ex.Message);
                result = false;
            }

            return(result);
        }
示例#33
0
 public Bus(Driver driver, MotorType motorType = MotorType.Normal, bool trumpSticker = false) : base(driver, motorType, trumpSticker)
 {
 }