12-12-2023 10:27 AM
So I have been trying to use some the inbuilt of the examples to practice external debugging using Visual Studio Code. However I have been unable to get it to work consistently so far it only work once but most the time it's just fails with Visual Studio Code say it can't connect
and Diadem giving the following error see bellow:
In Visual Studio Code my json file is as what is bellow:
Python code :
import sys
if 'DIAdem' in sys.modules:
from DIAdem import Application as dd
if dd.AppEnableScriptDebugger:
import debugpy
debugpy.configure(python = sys.prefix + '\\python.exe')
if not debugpy.is_client_connected():
try:
debugpy.listen(5678)
except:
pass
debugpy.wait_for_client()
sPathDocuments = dd.ProgramDrv + "Examples\\Documents\\"
sPathData = dd.ProgramDrv + "Examples\\Data\\"
dd.Data.Root.Clear()
dd.DataFileLoad(sPathData + "Example_data.tdm", "TDM", "Load|ChnXYRelation")
oResultChnList = dd.Data.CreateElementList()
oResultGroup = dd.Data.Root.ChannelGroups.Add("Quantize")
oResultGroup.Activate()
oSourceChn = dd.Data.GetChannel("[1]/[3]")
dMax = oSourceChn.Maximum
dMin = oSourceChn.Minimum
dResolution = 100
sChnResultName = oSourceChn.Name + "_Quantize_" + dd.str(dResolution, "d.")
oResultChnTempList = dd.ChnQuantize(oSourceChn, sChnResultName, dResolution, dMin, dMax)
oResultChnList.Add(oResultChnTempList(1))
dResolution = 2**8
sChnResultName = oSourceChn.Name + "_Quantize_" + dd.str(dResolution, "d.")
oResultChnTempList = dd.ChnQuantize(oSourceChn, sChnResultName, dResolution, dMin, dMax)
oResultChnList.Add(oResultChnTempList(1))
dResolution = 2**15 - 1
sChnResultName = oSourceChn.Name + "_Quantize_" + dd.str(dResolution, "d.")
oResultChnTempList = dd.ChnQuantize(oSourceChn, sChnResultName, dResolution, dMin, dMax)
oResultChnList.Add(oResultChnTempList(1))
dResolution = 2**16 - 1
sChnResultName = oSourceChn.Name + "_Quantize_" + dd.str(dResolution, "d.")
oResultChnTempList = dd.ChnQuantize(oSourceChn, sChnResultName, dResolution, dMin, dMax)
oResultChnList.Add(oResultChnTempList(1))
dResolution = 2**31 - 1
sChnResultName = oSourceChn.Name + "_Quantize_" + dd.str(dResolution, "d.")
oResultChnTempList = dd.ChnQuantize(oSourceChn, sChnResultName, dResolution, dMin, dMax)
oResultChnList.Add(oResultChnTempList(1))
dd.CHNSUB(oSourceChn, oResultChnList(1), "Err_" + oResultChnList(1).Name)
dd.CHNSUB(oSourceChn, oResultChnList(2), "Err_" + oResultChnList(2).Name)
dd.CHNSUB(oSourceChn, oResultChnList(3), "Err_" + oResultChnList(3).Name)
dd.CHNSUB(oSourceChn, oResultChnList(4), "Err_" + oResultChnList(4).Name)
dd.CHNSUB(oSourceChn, oResultChnList(5), "Err_" + oResultChnList(5).Name)
oQChnName = oResultGroup.Channels.Add("Quantize_ChnName", dd.DataTypeChnString)
oQChnTyp = oResultGroup.Channels.Add("Quantize_ChnTyp", dd.DataTypeChnString)
oQChnMaxErrVal = oResultGroup.Channels.Add("Quantize_MaxErrVal", dd.DataTypeChnFloat64)
debugpy.breakpoint()
for iLoop in range(1, 6):
oQChnName[iLoop] = oResultGroup.Channels(iLoop + 5).Name
oQChnMaxErrVal[iLoop] = oResultGroup.Channels(iLoop + 5).Maximum
oQChnTyp[1] = "Byte"
oQChnTyp[2] = "Byte"
oQChnTyp[3] = "Integer"
oQChnTyp[4] = "Integer"
oQChnTyp[5] = "LongInteger"
dd.Report.LoadLayout( sPathDocuments + "Channel_Quantize.TDR")
dd.Report.Refresh()
My Python version is 3.10 and environment was installed with Anaconda
Solved! Go to Solution.
12-13-2023 10:26 AM
I have been able to get it to work now . i don't really know what's changed but it works so this can be closed now.