public void AddPoint(string key, AxisUnitPoint value) { if (axisUnitPoints.ContainsKey(key)) { throw new Exception($"the keyname {key} is already exist"); } axisUnitPoints.Add(key, value); }
public void MoveToPoint(string PointName) { foreach (var mem in logicAxisS) { if (mem.Value.Motor.Busy) { MessageBox.Show("Axis is busy"); return; } } AxisUnitPoint axisUnitPoint = axisUnitPoints[PointName]; if (axisUnitPoint != null) { uint maxIndex = axisUnitPoint.AxisPoints.Max(x => x.MoveIndex); uint minIndex = axisUnitPoint.AxisPoints.Min(x => x.MoveIndex); for (uint i = minIndex; i < maxIndex + 1; i++) { List <AxisPoint> axisPoints = axisUnitPoint.AxisPoints.FindAll(x => x.MoveIndex == i); if (axisPoints == null) { continue; } Task[] tasks = new Task[axisPoints.Count]; for (int m = 0; m < axisPoints.Count; m++) { logicAxisS[axisPoints[m].LogicAxisName].Motor.MoveVM = axisPoints[m].Speed; tasks[m] = logicAxisS[axisPoints[m].LogicAxisName].Motor.AbsMoveAsync((int)axisPoints[m].Position); } Task.WaitAll(tasks); } } else { throw new KeyNotFoundException($"not exist the point named as {PointName}"); } }