296 lines
9.2 KiB
Plaintext
296 lines
9.2 KiB
Plaintext
' DxDesigner 7.9.5 read-only compatibility probe. Keep this file ASCII-only.
|
|
|
|
Sub DxToolsRunCompatibilityProbe()
|
|
Call DxToolsProbeExecute("named")
|
|
End Sub
|
|
|
|
Sub DxToolsProbeExecute(routeName)
|
|
Dim payload
|
|
Dim outputPath
|
|
Dim shell
|
|
Dim process
|
|
Dim commandLine
|
|
Dim yieldMethod
|
|
Dim retainedComponent
|
|
Dim retainedOk
|
|
Dim executablePath
|
|
|
|
payload = DxToolsProbeCapabilities(retainedComponent)
|
|
outputPath = CreateObject("WScript.Shell").ExpandEnvironmentStrings( _
|
|
"%LOCALAPPDATA%\DxProductivity\compatibility.json")
|
|
|
|
Set shell = CreateObject("WScript.Shell")
|
|
executablePath = DxToolsHome & "\DxDesignerTools.exe"
|
|
commandLine = DxToolsProbeQuote(executablePath) & " probe" & _
|
|
" --output " & DxToolsProbeQuote(outputPath) & _
|
|
" --route " & routeName & _
|
|
" --payload-json " & DxToolsProbeQuote(payload) & _
|
|
" --hold-seconds 1.5"
|
|
|
|
On Error Resume Next
|
|
Set process = shell.Exec(commandLine)
|
|
If Err.Number <> 0 Then
|
|
Dim launchError
|
|
launchError = Err.Description
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
MsgBox DxToolsProbePythonError() & vbCrLf & launchError, vbExclamation
|
|
Exit Sub
|
|
End If
|
|
On Error GoTo 0
|
|
|
|
yieldMethod = DxToolsProbePumpWhileRunning(process)
|
|
retainedOk = DxToolsProbeRetainedReferenceReadable(retainedComponent)
|
|
payload = DxToolsProbeAppendResult(payload, yieldMethod, retainedOk)
|
|
|
|
commandLine = DxToolsProbeQuote(executablePath) & " probe" & _
|
|
" --output " & DxToolsProbeQuote(outputPath) & _
|
|
" --route " & routeName & _
|
|
" --payload-json " & DxToolsProbeQuote(payload)
|
|
Set process = shell.Exec(commandLine)
|
|
Call DxToolsProbeWait(process, yieldMethod)
|
|
|
|
If process.ExitCode = 0 Then
|
|
MsgBox DxToolsProbeCompleteMessage() & vbCrLf & outputPath, vbInformation
|
|
Else
|
|
MsgBox DxToolsProbePythonError(), vbExclamation
|
|
End If
|
|
End Sub
|
|
|
|
Function DxToolsProbeCapabilities(ByRef retainedComponent)
|
|
Dim selectedOk
|
|
Dim selectedCount
|
|
Dim fullOk
|
|
Dim fullCount
|
|
Dim refdesOk
|
|
Dim uidOk
|
|
Dim attributesOk
|
|
Dim sheetOk
|
|
Dim pathMethod
|
|
Dim positionMethod
|
|
Dim sample
|
|
|
|
selectedOk = DxToolsProbeSelected(sample, selectedCount)
|
|
fullOk = DxToolsProbeFullDesign(retainedComponent, fullCount)
|
|
If sample Is Nothing Then Set sample = retainedComponent
|
|
|
|
refdesOk = DxToolsProbeProperty(sample, "refdes")
|
|
uidOk = DxToolsProbeProperty(sample, "uid")
|
|
attributesOk = DxToolsProbeProperty(sample, "attributes")
|
|
sheetOk = DxToolsProbeSheetNumber()
|
|
pathMethod = DxToolsProbePathMethod(sample)
|
|
positionMethod = DxToolsProbePositionMethod(sample)
|
|
|
|
DxToolsProbeCapabilities = "{" & _
|
|
"""script_path_source"":""" & _
|
|
DxToolsProbeJson(DxToolsScriptPathSource) & """," & _
|
|
"""script_path"":""" & DxToolsProbeJson(DxToolsScriptFullName) & _
|
|
"""," & _
|
|
"""portable_root_valid"":" & _
|
|
DxToolsProbeBoolean(DxToolsHome <> "") & "," & _
|
|
"""selected_query"":" & DxToolsProbeBoolean(selectedOk) & "," & _
|
|
"""selected_count"":" & CStr(selectedCount) & "," & _
|
|
"""full_design_enumeration"":" & DxToolsProbeBoolean(fullOk) & "," & _
|
|
"""full_design_count"":" & CStr(fullCount) & "," & _
|
|
"""refdes_readable"":" & DxToolsProbeBoolean(refdesOk) & "," & _
|
|
"""uid_readable"":" & DxToolsProbeBoolean(uidOk) & "," & _
|
|
"""attributes_readable"":" & DxToolsProbeBoolean(attributesOk) & "," & _
|
|
"""sheet_number_readable"":" & DxToolsProbeBoolean(sheetOk) & "," & _
|
|
"""path_method"":""" & DxToolsProbeJson(pathMethod) & """," & _
|
|
"""position_method"":""" & DxToolsProbeJson(positionMethod) & """}"
|
|
End Function
|
|
|
|
Function DxToolsProbeSelected(ByRef sample, ByRef count)
|
|
Dim comp
|
|
count = 0
|
|
Set sample = Nothing
|
|
On Error Resume Next
|
|
For Each comp In ActiveView.Query(VDM_COMP, VD_SELECTED)
|
|
count = count + 1
|
|
If sample Is Nothing Then Set sample = comp
|
|
Next
|
|
DxToolsProbeSelected = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbeFullDesign(ByRef sample, ByRef count)
|
|
Dim projectData
|
|
Dim designs
|
|
Dim designName
|
|
Dim topBlock
|
|
Dim comp
|
|
count = 0
|
|
Set sample = Nothing
|
|
On Error Resume Next
|
|
Set projectData = Application.GetProjectData()
|
|
Set designs = projectData.GetiCDBDesigns()
|
|
designName = designs.GetItem(1)
|
|
topBlock = projectData.GetiCDBDesignRootBlock(designName)
|
|
For Each comp In Application.DesignComponents("", topBlock, "-1", "STD", True)
|
|
count = count + 1
|
|
If sample Is Nothing Then Set sample = comp
|
|
Next
|
|
DxToolsProbeFullDesign = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbeProperty(comp, propertyName)
|
|
Dim ignored
|
|
DxToolsProbeProperty = False
|
|
If comp Is Nothing Then Exit Function
|
|
On Error Resume Next
|
|
Select Case propertyName
|
|
Case "refdes"
|
|
ignored = CStr(comp.Refdes)
|
|
Case "uid"
|
|
ignored = CStr(comp.UID)
|
|
Case "attributes"
|
|
ignored = comp.Attributes.Count
|
|
End Select
|
|
DxToolsProbeProperty = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbeSheetNumber()
|
|
Dim ignored
|
|
On Error Resume Next
|
|
ignored = CStr(ActiveView.Block.SheetNum)
|
|
DxToolsProbeSheetNumber = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbePathMethod(comp)
|
|
Dim ignored
|
|
DxToolsProbePathMethod = ""
|
|
If comp Is Nothing Then Exit Function
|
|
|
|
On Error Resume Next
|
|
ignored = CStr(comp.Parent) & "\" & CStr(comp.GetName(SHORT_NAME))
|
|
If Err.Number = 0 Then DxToolsProbePathMethod = "Parent+GetName(SHORT_NAME)"
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbePositionMethod(comp)
|
|
Dim x
|
|
Dim y
|
|
DxToolsProbePositionMethod = ""
|
|
If comp Is Nothing Then Exit Function
|
|
|
|
On Error Resume Next
|
|
x = comp.X
|
|
y = comp.Y
|
|
If Err.Number = 0 Then DxToolsProbePositionMethod = "X/Y"
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
If DxToolsProbePositionMethod <> "" Then Exit Function
|
|
|
|
On Error Resume Next
|
|
x = comp.PositionX
|
|
y = comp.PositionY
|
|
If Err.Number = 0 Then DxToolsProbePositionMethod = "PositionX/PositionY"
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbePumpWhileRunning(process)
|
|
Dim methodName
|
|
methodName = DxToolsProbeFindYieldMethod()
|
|
Do While process.Status = 0
|
|
Call DxToolsProbeYield(methodName)
|
|
Loop
|
|
DxToolsProbePumpWhileRunning = methodName
|
|
End Function
|
|
|
|
Function DxToolsProbeFindYieldMethod()
|
|
If DxToolsProbeTryYield("Scripting.DoEvents") Then
|
|
DxToolsProbeFindYieldMethod = "Scripting.DoEvents"
|
|
ElseIf DxToolsProbeTryYield("Application.DoEvents") Then
|
|
DxToolsProbeFindYieldMethod = "Application.DoEvents"
|
|
ElseIf DxToolsProbeTryYield("ActiveView.Refresh") Then
|
|
DxToolsProbeFindYieldMethod = "ActiveView.Refresh"
|
|
Else
|
|
DxToolsProbeFindYieldMethod = ""
|
|
End If
|
|
End Function
|
|
|
|
Function DxToolsProbeTryYield(methodName)
|
|
On Error Resume Next
|
|
Call DxToolsProbeYield(methodName)
|
|
DxToolsProbeTryYield = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Sub DxToolsProbeYield(methodName)
|
|
Select Case methodName
|
|
Case "Scripting.DoEvents"
|
|
Scripting.DoEvents
|
|
Case "Application.DoEvents"
|
|
Application.DoEvents
|
|
Case "ActiveView.Refresh"
|
|
ActiveView.Refresh
|
|
End Select
|
|
End Sub
|
|
|
|
Sub DxToolsProbeWait(process, methodName)
|
|
Do While process.Status = 0
|
|
Call DxToolsProbeYield(methodName)
|
|
Loop
|
|
End Sub
|
|
|
|
Function DxToolsProbeRetainedReferenceReadable(comp)
|
|
Dim ignored
|
|
DxToolsProbeRetainedReferenceReadable = False
|
|
If comp Is Nothing Then Exit Function
|
|
On Error Resume Next
|
|
ignored = CStr(comp.Refdes)
|
|
DxToolsProbeRetainedReferenceReadable = (Err.Number = 0)
|
|
Err.Clear
|
|
On Error GoTo 0
|
|
End Function
|
|
|
|
Function DxToolsProbeAppendResult(payload, yieldMethod, retainedOk)
|
|
DxToolsProbeAppendResult = Left(payload, Len(payload) - 1) & "," & _
|
|
"""yield_method"":""" & DxToolsProbeJson(yieldMethod) & """," & _
|
|
"""retained_reference"":" & DxToolsProbeBoolean(retainedOk) & "}"
|
|
End Function
|
|
|
|
Function DxToolsProbeBoolean(value)
|
|
If CBool(value) Then
|
|
DxToolsProbeBoolean = "true"
|
|
Else
|
|
DxToolsProbeBoolean = "false"
|
|
End If
|
|
End Function
|
|
|
|
Function DxToolsProbeJson(value)
|
|
Dim text
|
|
text = CStr(value)
|
|
text = Replace(text, Chr(92), Chr(92) & Chr(92))
|
|
text = Replace(text, Chr(34), Chr(92) & Chr(34))
|
|
text = Replace(text, vbCr, Chr(92) & "r")
|
|
text = Replace(text, vbLf, Chr(92) & "n")
|
|
DxToolsProbeJson = text
|
|
End Function
|
|
|
|
Function DxToolsProbeQuote(value)
|
|
DxToolsProbeQuote = Chr(34) & Replace(CStr(value), Chr(34), _
|
|
Chr(92) & Chr(34)) & Chr(34)
|
|
End Function
|
|
|
|
Function DxToolsProbeCompleteMessage()
|
|
DxToolsProbeCompleteMessage = ChrW(&H517C) & ChrW(&H5BB9) & _
|
|
ChrW(&H6027) & ChrW(&H68C0) & ChrW(&H6D4B) & ChrW(&H5B8C) & _
|
|
ChrW(&H6210)
|
|
End Function
|
|
|
|
Function DxToolsProbePythonError()
|
|
DxToolsProbePythonError = ChrW(&H5DE5) & ChrW(&H5177) & _
|
|
ChrW(&H542F) & ChrW(&H52A8) & ChrW(&H5931) & ChrW(&H8D25)
|
|
End Function
|