public override void HandleSpeedInfo(MotorInfoMap <double> speedInfo) { base.HandleSpeedInfo(speedInfo); bool need = SystemContext.Hardware.IsLaserOn; if (need) { //TODO: Adjust power base on speed double speed = Math.Sqrt(Math.Pow(speedInfo[AxisTypes.AxisX], 2) + Math.Pow(speedInfo[AxisTypes.AxisY], 2)); this.laserController.Adjust(speed / this.layerPara.CutSpeed * 100.0); } }
public static byte[] CreatePosInfoCmd(MotorInfoMap <MotorInfoUnit> posInfo) { var part1 = new List <uint>(); var part2 = new List <uint>(); foreach (var m in Protocol.Axises) { part1.Add((uint)posInfo[m].Counter); part2.Add((uint)posInfo[m].Encoder); } part1.AddRange(part2); return(Protocol.CreateRequest(Commands.SetMotorStatus, part1.ToArray())); }
private bool HandlePosInfo(MotorInfoMap <double> posInfo) { bool valid = false; //Update len of dataprovider float x = (float)posInfo[AxisTypes.AxisX]; float y = (float)posInfo[AxisTypes.AxisY]; PointF p1 = new PointF(x, y); //if (!string.IsNullOrEmpty(this.figureId)) //{ // OperationEngine.Instance.NotityMarkPathAdd(this.figureId, p1); //} double len = MathEx.GetDistance(p1, this.point); if (len > MIN_SAMPLE_DISTANCE) { valid = true; this.point = p1; bool condition1 = SystemContext.MachineControlPara.OperationType == OperationTypes.Step; bool condition2 = SystemContext.MachineControlPara.Step < 0; if (condition1 && condition2) { this.data.CurrentLen -= len; } else { this.data.CurrentLen += len; } //Report len, update mark OperationEngine.Instance.NotifyMarkPointChanged(p1); if (!string.IsNullOrEmpty(this.figureId)) { OperationEngine.Instance.NotityMarkPathAdd(this.figureId, p1); } OperationEngine.Instance.ReportMotorPos(posInfo); OperationEngine.Instance.ReportProgress(this.data.CurrentLen / totalLen); } return(valid); }
public static MotorInfoMap <MotorInfoUnit> GetMotorStatus(byte[] response) { var content = Protocol.GetResponseContent(Protocol.GetList(response)); var result = new MotorInfoMap <MotorInfoUnit>(); foreach (var m in Protocol.Axises) { int index = (int)m; result[m].Counter = (int)content[index]; index += 9; result[m].Encoder = (int)content[index]; index += 9; result[m].Status = (int)content[index]; index += 9; result[m].Speed = (int)content[index]; } return(result); }
private void Engine_OnMotorSpeedReport(MotorInfoMap <double> speedInfo) { this.XSpeed = speedInfo[AxisTypes.AxisX]; this.YSpeed = speedInfo[AxisTypes.AxisY]; this.Speed = Math.Sqrt(Math.Pow(this.XSpeed, 2) + Math.Pow(this.YSpeed, 2)); }
private void Engine_OnMotorPosReport(MotorInfoMap <double> posInfo) { this.XPos = posInfo[AxisTypes.AxisX]; this.YPos = posInfo[AxisTypes.AxisY]; this.ZPos = posInfo[AxisTypes.AxisZ]; }
public void ReportMotorSpeed(MotorInfoMap <double> speedInfo) { this.OnMotorSpeedReport?.Invoke(speedInfo); }
public void ReportMotorPos(MotorInfoMap <double> posInfo) { this.OnMotorPosReport?.Invoke(posInfo); }
public virtual void HandleSpeedInfo(MotorInfoMap <double> speedInfo) { OperationEngine.Instance.ReportMotorSpeed(speedInfo); }
private void HandleMotorInfo(MotorInfoMap <double> posInfo, MotorInfoMap <double> speedInfo) { OperationEngine.Instance.ReportMotorPos(posInfo); OperationEngine.Instance.ReportMotorSpeed(speedInfo); OperationEngine.Instance.NotifyMarkPointChanged(new PointF((float)posInfo[AxisTypes.AxisX], (float)posInfo[AxisTypes.AxisY])); }