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>(); }
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); }
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); }