Beispiel #1
0
        private void LoadMotorInfo()
        {
            if (!this.motorInfo.IsValid)
            {
                return;
            }

            var info   = new MotorInfoMap <MotorInfoUnit>();
            var axises = EnumHelper.GetAllEnumMembers <AxisTypes>();

            foreach (var m in axises)
            {
                info[m].Counter = this.motorInfo.GetCurrentPos(m);
                info[m].Encoder = this.motorInfo.GetEncoder(m);
            }

            var bytes = Requestor.CreatePosInfoCmd(info);

            try
            {
                bytes = this.tcpClient.Query(bytes, x => Protocol.Verify(x), out bool valid);
                if (!valid)
                {
                    throw new Exception();
                }
            }
            catch
            {
                throw new Exception("Error occurred when loading motor information!");
            }
        }
 public DummyMotorController()
 {
     this.CurrentPosInfo    = new MotorInfoMap <double>();
     this.CurrentStatusInfo = new MotorInfoMap <MotorStatus>();
     this.CurrentSpeedInfo  = new MotorInfoMap <double>();
     this.CurrentAlarmInfo  = new MotorInfoMap <bool>();
 }
Beispiel #3
0
        public static MotorInfoMap <bool> ParseAlarmInfo(uint data)
        {
            var info   = new MotorInfoMap <bool>();
            var axises = EnumHelper.GetAllEnumMembers <AxisTypes>();

            foreach (var m in axises)
            {
                info[m] = (data & (1 << (int)m)) != 0;
            }
            return(info);
        }
Beispiel #4
0
        public static MotorInformation GetMotorInformation(Dictionary <AxisTypes, MotorParameter> motorParaMap, MotorInfoMap <MotorInfoUnit> motorInfoMap)
        {
            var res = new MotorInformation();

            foreach (var m in motorParaMap.Keys)
            {
                res.PosInfo[m]     = ConvertBackDistance(motorParaMap[m], motorInfoMap[m].Counter);
                res.EncoderInfo[m] = ConvertBackDistance(motorParaMap[m], motorInfoMap[m].Encoder);
                res.SpeedInfo[m]   = ConvertBackSpeed(motorParaMap[m], motorInfoMap[m].Speed);
                res.StatusInfo[m]  = MotorStatus.FromRegContent((uint)motorInfoMap[m].Status);
            }
            return(res);
        }