检测模块_0 成连续编号
This commit is contained in:
@@ -364,23 +364,24 @@ namespace XplorePlane.Services.Cnc
|
||||
private static IReadOnlyList<CncNode> RenumberNodes(List<CncNode> nodes)
|
||||
{
|
||||
var result = new List<CncNode>(nodes.Count);
|
||||
int referencePointNumber = 0;
|
||||
int savePositionNumber = 0;
|
||||
int inspectionModuleNumber = 0;
|
||||
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
result.Add(ApplyDefaultNodeName(nodes[i] with { Index = i }, i));
|
||||
var indexedNode = nodes[i] with { Index = i };
|
||||
result.Add(indexedNode switch
|
||||
{
|
||||
ReferencePointNode referencePointNode => referencePointNode with { Name = $"\u53C2\u8003\u70B9_{referencePointNumber++}" },
|
||||
SavePositionNode savePositionNode => savePositionNode with { Name = $"\u4FDD\u5B58\u4F4D\u7F6E_{savePositionNumber++}" },
|
||||
InspectionModuleNode inspectionModuleNode => inspectionModuleNode with { Name = $"\u68C0\u6D4B\u6A21\u5757_{inspectionModuleNumber++}" },
|
||||
_ => indexedNode
|
||||
});
|
||||
}
|
||||
return result.AsReadOnly();
|
||||
}
|
||||
|
||||
private static CncNode ApplyDefaultNodeName(CncNode node, int index)
|
||||
{
|
||||
return node switch
|
||||
{
|
||||
ReferencePointNode referencePointNode => referencePointNode with { Name = $"参考点_{index}" },
|
||||
SavePositionNode savePositionNode => savePositionNode with { Name = $"保存位置_{index}" },
|
||||
_ => node
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>创建参考点节点 | Create reference point node</summary>
|
||||
private ReferencePointNode CreateReferencePointNode(Guid id, int index)
|
||||
{
|
||||
@@ -424,7 +425,7 @@ namespace XplorePlane.Services.Cnc
|
||||
private SavePositionNode CreateSavePositionNode(Guid id, int index)
|
||||
{
|
||||
return new SavePositionNode(
|
||||
id, index, $"保存位置_{index}",
|
||||
id, index, $"检测位置_{index}",
|
||||
MotionState: _appStateService.MotionState);
|
||||
}
|
||||
private double TryReadCurrent()
|
||||
|
||||
@@ -475,10 +475,7 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
return;
|
||||
}
|
||||
|
||||
var normalizedNodes = _currentProgram.Nodes
|
||||
.Select((node, index) => ApplyDefaultNodeName(node with { Index = index }, index))
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
var normalizedNodes = ApplyDefaultNodeNames(_currentProgram.Nodes);
|
||||
|
||||
bool changed = false;
|
||||
for (int i = 0; i < normalizedNodes.Count; i++)
|
||||
@@ -510,6 +507,12 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
|
||||
if (!IsSavePositionChild(nodeType))
|
||||
{
|
||||
int? currentSavePositionIndex = FindOwningSavePositionIndex(SelectedNode?.Index);
|
||||
if (currentSavePositionIndex.HasValue)
|
||||
{
|
||||
return GetSavePositionBlockEndIndex(currentSavePositionIndex.Value);
|
||||
}
|
||||
|
||||
return SelectedNode?.Index ?? _currentProgram.Nodes.Count - 1;
|
||||
}
|
||||
|
||||
@@ -743,10 +746,7 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
|
||||
private CncProgram ReplaceProgramNodes(List<CncNode> nodes)
|
||||
{
|
||||
var renumberedNodes = nodes
|
||||
.Select((node, index) => ApplyDefaultNodeName(node with { Index = index }, index))
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
var renumberedNodes = ApplyDefaultNodeNames(nodes);
|
||||
|
||||
return _currentProgram with
|
||||
{
|
||||
@@ -755,14 +755,26 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
};
|
||||
}
|
||||
|
||||
private static CncNode ApplyDefaultNodeName(CncNode node, int index)
|
||||
private static IReadOnlyList<CncNode> ApplyDefaultNodeNames(IReadOnlyList<CncNode> nodes)
|
||||
{
|
||||
return node switch
|
||||
var result = new List<CncNode>(nodes.Count);
|
||||
int referencePointNumber = 0;
|
||||
int savePositionNumber = 0;
|
||||
int inspectionModuleNumber = 0;
|
||||
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
ReferencePointNode referencePointNode => referencePointNode with { Name = $"参考点_{index}" },
|
||||
SavePositionNode savePositionNode => savePositionNode with { Name = $"保存位置_{index}" },
|
||||
_ => node
|
||||
};
|
||||
var indexedNode = nodes[i] with { Index = i };
|
||||
result.Add(indexedNode switch
|
||||
{
|
||||
ReferencePointNode referencePointNode => referencePointNode with { Name = $"\u53C2\u8003\u70B9_{referencePointNumber++}" },
|
||||
SavePositionNode savePositionNode => savePositionNode with { Name = $"\u4FDD\u5B58\u4F4D\u7F6E_{savePositionNumber++}" },
|
||||
InspectionModuleNode inspectionModuleNode => inspectionModuleNode with { Name = $"\u68C0\u6D4B\u6A21\u5757_{inspectionModuleNumber++}" },
|
||||
_ => indexedNode
|
||||
});
|
||||
}
|
||||
|
||||
return result.AsReadOnly();
|
||||
}
|
||||
|
||||
private static bool IsSavePositionChild(CncNodeType type)
|
||||
|
||||
Reference in New Issue
Block a user