fix(execution): bind explicit target cells to native save and recovery
This commit is contained in:
1 parent
976a72d572
commit
bb506a3550
7 files changed
+356
-20
No files matched your search
@@ -1174,6 +1174,8 @@ Sub QPCaptureAndSelect(ByRef Command, ByVal SnapshotPath)
|
||||
If Not Selectors Is Nothing Then _
|
||||
Snapshot = Snapshot & vbTab & QPEncode("targets") & vbTab & CStr(Command("target_selectors"))
|
||||
Snapshot = Snapshot & vbCrLf
|
||||
If Len(QPTargetCell(Command)) > 0 Then _
|
||||
Snapshot = Snapshot & "L" & vbTab & QPEncode(QPTargetCell(Command)) & vbCrLf
|
||||
Set MatchedUids = CreateObject("Scripting.Dictionary")
|
||||
For Index = 0 To Matches.Count - 1
|
||||
Set Comp = Matches.Item(CStr(Index))
|
||||
@@ -1632,6 +1634,8 @@ Sub QPRestoreAfterOperatorReplace(ByRef Command, ByVal SnapshotPath)
|
||||
CStr(Command("new_part_number")))
|
||||
SuccessMessage = "Native replacement and parameter readback passed on current sheet. Replacements: " & _
|
||||
ReplacementSummary & " " & QPDisplayVerificationSummary(Records)
|
||||
If Len(QPTargetCell(Command)) > 0 Then SuccessMessage = SuccessMessage & _
|
||||
" Target Cell verified: " & QPTargetCell(Command) & "."
|
||||
If Len(QP_NcSyncSummary) > 0 Then SuccessMessage = SuccessMessage & _
|
||||
" NC synced: " & QP_NcSyncSummary
|
||||
QPWriteStatus QP_Root, CStr(Command("job_id")), "restored_ok", "", SuccessMessage
|
||||
@@ -1665,6 +1669,7 @@ Sub QPRestorePlans(ByRef Command, ByRef Records, ByRef Plans)
|
||||
ValueStates.Item(CStr(Index)).Add "custom_value", QPCustomValue(Command)
|
||||
QPRestoreComponent Candidate, ComponentRecord, Records.Item("attributes"), _
|
||||
QPValueMode(Command), QPCustomValue(Command), QPSyncNc(Command)
|
||||
QPSetTargetCell Candidate, Command
|
||||
QPProgress "restore_attributes", Index + 1, Plans.Count
|
||||
Next
|
||||
QPVerifyRestoredPlans Command, Records, Plans, ValueStates
|
||||
@@ -1677,6 +1682,7 @@ Sub QPVerifyRestoredPlans(ByRef Command, ByRef Records, ByRef Plans, ByRef Value
|
||||
For Index = 0 To Plans.Count - 1
|
||||
Set ComponentRecord = Records.Item("components").Item(CStr(Index))
|
||||
Set Candidate = Plans.Item(CStr(Index))
|
||||
QPVerifyTargetCell Candidate, Command
|
||||
' Captured only after native library identity validation (or recovery
|
||||
' command validation), before restoration/save; never derive this expected
|
||||
' identity from the reopened result or from its current Value.
|
||||
@@ -1713,6 +1719,13 @@ Sub QPRecoverSavedJob(ByRef Command, ByVal SnapshotPath)
|
||||
Dim Records, Plans, Used, ValueStates, Index, Record, Candidate, PartNumber
|
||||
Dim OldCount, NewCount, ErrorNumber, ErrorDescription, RecoveryDocuments, RecoveryDocument, RecoveryProjectData
|
||||
QPRequireCommandSnapshot Command, SnapshotPath
|
||||
If Len(QPTargetCell(Command)) > 0 Then
|
||||
If Not Command.Exists("recovery_library_path") Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "recovery Cell library proof missing"
|
||||
If QPCanonicalPath(CStr(QP_App.GetProjectData().CentralLibraryPath)) <> _
|
||||
QPCanonicalPath(QPDecode(CStr(Command("recovery_library_path")))) Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "recovery active library changed"
|
||||
End If
|
||||
Set Records = QPReadSnapshot(SnapshotPath)
|
||||
QPVerifyUntouched Records
|
||||
Set Plans = CreateObject("Scripting.Dictionary")
|
||||
@@ -2200,6 +2213,8 @@ Sub QPRequireCommandSnapshot(ByRef Command, ByVal SnapshotPath)
|
||||
Err.Raise vbObjectError + 830, "QuickPartReplace", "snapshot rule mismatch"
|
||||
If QPValueMode(Meta) <> QPValueMode(Command) Then _
|
||||
Err.Raise vbObjectError + 842, "QuickPartReplace", "snapshot Value policy mismatch"
|
||||
If QPTargetCell(Meta) <> QPTargetCell(Command) Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "target Cell changed since snapshot"
|
||||
If QPCustomValue(Meta) <> QPCustomValue(Command) Or _
|
||||
QPSyncNc(Meta) <> QPSyncNc(Command) Then _
|
||||
Err.Raise vbObjectError + 842, "QuickPartReplace", "snapshot Value or NC option mismatch"
|
||||
@@ -2218,6 +2233,39 @@ Sub QPRequireCommandSnapshot(ByRef Command, ByVal SnapshotPath)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Function QPTargetCell(ByRef Record)
|
||||
Dim Value, Index
|
||||
QPTargetCell = ""
|
||||
If Not Record.Exists("target_cell") Then Exit Function
|
||||
Value = QPDecode(CStr(Record("target_cell")))
|
||||
If Len(Value) = 0 Or Trim(Value) <> Value Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "target Cell selection is empty or invalid"
|
||||
For Index = 1 To Len(Value)
|
||||
If AscW(Mid(Value, Index, 1)) >= 0 And AscW(Mid(Value, Index, 1)) < 32 Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "invalid control character in target Cell"
|
||||
Next
|
||||
QPTargetCell = Value
|
||||
End Function
|
||||
|
||||
Sub QPSetTargetCell(ByRef Comp, ByRef Command)
|
||||
Dim Value, Attr
|
||||
Value = QPTargetCell(Command)
|
||||
If Len(Value) = 0 Then Exit Sub
|
||||
Set Attr = QPFindCurrentAttribute(Comp, "Cell Name")
|
||||
If Attr Is Nothing Then Err.Raise vbObjectError + 878, _
|
||||
"QuickPartReplace.Cell", "replaced target has no Cell Name attribute"
|
||||
Attr.InstanceValue = Value
|
||||
QPVerifyTargetCell Comp, Command
|
||||
End Sub
|
||||
|
||||
Sub QPVerifyTargetCell(ByRef Comp, ByRef Command)
|
||||
Dim Value
|
||||
Value = QPTargetCell(Command)
|
||||
If Len(Value) = 0 Then Exit Sub
|
||||
If QPRequiredAttributeValue(Comp, "Cell Name") <> Value Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "effective target Cell does not match explicit selection"
|
||||
End Sub
|
||||
|
||||
Function QPValueMode(ByRef Record)
|
||||
QPValueMode = "legacy_part_label"
|
||||
If Not Record.Exists("value_mode") Then Exit Function
|
||||
@@ -2871,6 +2919,12 @@ Function QPReadSnapshot(ByVal Path)
|
||||
Meta.Add "target_selectors", CStr(Fields(9))
|
||||
End If
|
||||
Result.Add "meta", Meta
|
||||
Case "L"
|
||||
If UBound(Fields) <> 1 Or Not Result.Exists("meta") Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "invalid target Cell snapshot"
|
||||
Result.Item("meta").Add "target_cell", CStr(Fields(1))
|
||||
If Len(QPTargetCell(Result.Item("meta"))) = 0 Then _
|
||||
Err.Raise vbObjectError + 878, "QuickPartReplace.Cell", "missing target Cell snapshot"
|
||||
Case "C"
|
||||
If UBound(Fields) <> 7 Then Err.Raise vbObjectError + 813, _
|
||||
"QuickPartReplace", "invalid snapshot component"
|
||||
|
||||
Reference in new issue
Block a user