From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-16-2017 12:33 PM
So I just started using version 2017 and noticed that due to the new property organization, the property name from calculation results have changed.
Specifically, I've been working with the StatBlockCalc call in the script. In 2015, this created a property called "ResultStatArithMean" and now the resulting property is "Result~Statistics~MeanValues~ArithmeticMean".
I have several scripts that rely on using Channel.Properties.Exists("Name of Property") to check if a property exists, then do something based on the result or set a variable to that value. Now my scripts that I developed in 2015 doesn't appear to work when I try to run it in 2017 because of this name change.
Is there a recommended way to update my scripts to work with 2017 as well as maintain backwards compatibility?
Thanks,
Nick
Solved! Go to Solution.
06-19-2017 07:46 AM
Accessing the properties still works with the old names while Exists returns false.
So it was tried to not break the scripts.
option explicit data.Root.Clear Call DataFileLoad("EXAMPLE.TDM","","Load") call ChnStatisticsChannelCalc("[1]/[2]",98,0,0,0,0,0,"NameName") dim txt : txt = "" txt = txt & "Exists new " & data.root.ChannelGroups(1).Channels(2).Properties.Exists("Result~Statistics~MeanValues~ArithmeticMean") & VBCRLF txt = txt & "Exists old " & data.root.ChannelGroups(1).Channels(2).Properties.Exists("ResultStatArithMean") & VBCRLF txt = txt & "Value new " & data.root.ChannelGroups(1).Channels(2).Properties("Result~Statistics~MeanValues~ArithmeticMean").value & VBCRLF txt = txt & "Value old " & data.root.ChannelGroups(1).Channels(2).Properties("ResultStatArithMean").value & VBCRLF MsgBox txt
To generate Code that works with 2015 and 2017 you need to exchange the Exists code
option explicit ' create an instance to be used in script data.Root.Clear Call DataFileLoad("EXAMPLE.TDM","","Load") dim i : for i = 1 to 23 : StatSel(i) = "No" : next StatSel(6) = "Yes" StatClipCopy = 0 StatClipValue = 0 StatFormat = "" StatResChn = 0 StatResChnNames = 0 StatResChnNameFormat= "NameName" Call StatBlockCalc("Channel","1-","[1]/[2]") dim txt : txt = "" txt = txt & "Exists new " & data.root.ChannelGroups(1).Channels(2).Properties.Exists("Result~Statistics~MeanValues~ArithmeticMean") & VBCRLF txt = txt & "Exists old " & data.root.ChannelGroups(1).Channels(2).Properties.Exists("ResultStatArithMean") & VBCRLF txt = txt & "Value new " & IsEmpty(GetResultVal(data.root.ChannelGroups(1).Channels(2),"Result~Statistics~MeanValues~ArithmeticMean")) & VBCRLF txt = txt & "Value old " & IsEmpty(GetResultVal(data.root.ChannelGroups(1).Channels(2), "ResultStatArithMean")) & VBCRLF MsgBox txt function GetResultVal(byref chO, byref propertyName) GetResultVal = vbEmpty on error resume next GetResultVal = chO.Properties("ResultStatArithMean").value on error goto 0 end function
option explicit ' create an instance to be used in script dim mp : set mp = new CMapPropNames data.Root.Clear Call DataFileLoad("EXAMPLE.TDM","","Load") dim i : for i = 1 to 23 : StatSel(i) = "No" : next StatSel(6) = "Yes" StatClipCopy = 0 StatClipValue = 0 StatFormat = "" StatResChn = 0 StatResChnNames = 0 StatResChnNameFormat= "NameName" Call StatBlockCalc("Channel","1-","[1]/[2]") dim txt : txt = "" txt = txt & "Exists new " & data.root.ChannelGroups(1).Channels(2).Properties.Exists(mp.M("ResultStatArithMean")) & VBCRLF txt = txt & "Exists old " & data.root.ChannelGroups(1).Channels(2).Properties.Exists("ResultStatArithMean") & VBCRLF txt = txt & "Value new " & data.root.ChannelGroups(1).Channels(2).Properties(mp.M("ResultStatArithMean")).value & VBCRLF txt = txt & "Value old " & data.root.ChannelGroups(1).Channels(2).Properties("ResultStatArithMean").value & VBCRLF MsgBox txt class CMapPropNames function M(byRef name) if dict.Exists(name) then M = dict.item(name) else M = name end if end function Private Sub Class_Initialize() set dict = CreateObject("Scripting.Dictionary") dict.CompareMode = vbTextCompare if ProgramVersion < 17 then ' no mapping needed exit sub end if dict.Add "DAC_Calibration_ExpirationDate", "DAC~Calibration~ExpirationDate" dict.Add "DAC_Channel_HighRange", "DAC~Channel~HighRange" dict.Add "DAC_Channel_Id", "DAC~Channel~Id" dict.Add "DAC_Channel_Info", "DAC~Channel~Info" dict.Add "DAC_Channel_LowRange", "DAC~Channel~LowRange" dict.Add "DAC_Device_Id", "DAC~Device~Id" dict.Add "DAC_Device_Name", "DAC~Device~Name" dict.Add "DAQ_Calibration_Date", "DAQ~Calibration~Date" dict.Add "NI_Sensor_TEDSCalibrationDate", "NI~Sensor~TEDS~CalibrationDate" dict.Add "NI_Sensor_TEDSCalibrationInitials", "NI~Sensor~TEDS~CalibrationInitials" dict.Add "NI_Sensor_TEDSCalibrationPeriod", "NI~Sensor~TEDS~CalibrationPeriod" dict.Add "NI_Sensor_TEDSManufacturer", "NI~Sensor~TEDS~Manufacturer" dict.Add "NI_Sensor_TEDSManufacturerID", "NI~Sensor~TEDS~ManufacturerID" dict.Add "NI_Sensor_TEDSMeasurementLocationID", "NI~Sensor~TEDS~MeasurementLocationID" dict.Add "NI_Sensor_TEDSModelID", "NI~Sensor~TEDS~ModelID" dict.Add "NI_Sensor_TEDSSerialNumber", "NI~Sensor~TEDS~SerialNumber" dict.Add "NI_Sensor_TEDSType", "NI~Sensor~TEDS~Type" dict.Add "NI_Sensor_TEDSVersionLetter", "NI~Sensor~TEDS~VersionLetter" dict.Add "NI_Sensor_TEDSVersionNumber", "NI~Sensor~TEDS~VersionNumber" dict.Add "ResultACompAverage", "Result~AComp~Average" dict.Add "ResultACompEndTime", "Result~AComp~EndTime" dict.Add "ResultACompVersion", "Result~AComp~Version" dict.Add "ResultASIMax", "Result~ASI~Max" dict.Add "ResultASIVersion", "Result~ASI~Version" dict.Add "ResultApprAnsatzCoef1", "Result~Approximation~AnsatzFunction~Coefficient1" dict.Add "ResultApprAnsatzCoef2", "Result~Approximation~AnsatzFunction~Coefficient2" dict.Add "ResultApprAnsatzCoef3", "Result~Approximation~AnsatzFunction~Coefficient3" dict.Add "ResultApprAnsatzName1", "Result~Approximation~AnsatzFunction~Name1" dict.Add "ResultApprAnsatzName2", "Result~Approximation~AnsatzFunction~Name2" dict.Add "ResultApprAnsatzName3", "Result~Approximation~AnsatzFunction~Name3" dict.Add "ResultApprFctStr", "Result~Approximation~ModelFunction" dict.Add "ResultApprPrecision", "Result~Approximation~Precision" dict.Add "ResultCorridorCheck", "Result~CorridorCheck" dict.Add "ResultCorridorCheckTIdx", "Result~CorridorCheck~TIdx" dict.Add "ResultCorridorCheckVersion", "Result~CorridorCheck~Version" dict.Add "ResultDCLevel", "Result~ACDCCoupling~DCLevel" dict.Add "ResultGaussFitAmplitude", "Result~GaussFit~Amplitude" dict.Add "ResultGaussFitCenter", "Result~GaussFit~Center" dict.Add "ResultGaussFitResidue", "Result~GaussFit~Residue" dict.Add "ResultGaussFitStdDev", "Result~GaussFit~StandardDeviation" dict.Add "ResultGenLSFitMSE", "Result~GeneralLSLinearFit~MSE" dict.Add "ResultHCD15MeanAcc", "Result~HCD15~MeanAcceleration" dict.Add "ResultHCD15T1", "Result~HCD15~T1" dict.Add "ResultHCD15T2", "Result~HCD15~T2" dict.Add "ResultHCD15Value", "Result~HCD15~Value" dict.Add "ResultHCD36MeanAcc", "Result~HCD36~MeanAcceleration" dict.Add "ResultHCD36T1", "Result~HCD36~T1" dict.Add "ResultHCD36T2", "Result~HCD36~T2" dict.Add "ResultHCD36Value", "Result~HCD36~Value" dict.Add "ResultHCDMeanAcc", "Result~HCD~MeanAcceleration" dict.Add "ResultHCDT1", "Result~HCD~T1" dict.Add "ResultHCDT2", "Result~HCD~T2" dict.Add "ResultHCDUser", "Result~HCDUser~WindowWidth" dict.Add "ResultHCDUserMeanAcc", "Result~HCDUser~MeanAcceleration" dict.Add "ResultHCDUserT1", "Result~HCDUser~T1" dict.Add "ResultHCDUserT2", "Result~HCDUser~T2" dict.Add "ResultHCDUserValue", "Result~HCDUser~Value" dict.Add "ResultHCDValue", "Result~HCD~Value" dict.Add "ResultHCDVersion", "Result~HCD~Version" dict.Add "ResultHCDdMeanAcc", "Result~HCDd~MeanAcceleration" dict.Add "ResultHCDdT1", "Result~HCDd~T1" dict.Add "ResultHCDdValue", "Result~HCDd~Value" dict.Add "ResultHIC15MeanAcc", "Result~HIC15~MeanAcceleration" dict.Add "ResultHIC15T1", "Result~HIC15~T1" dict.Add "ResultHIC15T2", "Result~HIC15~T2" dict.Add "ResultHIC15Value", "Result~HIC15~Value" dict.Add "ResultHIC36MeanAcc", "Result~HIC36~MeanAcceleration" dict.Add "ResultHIC36T1", "Result~HIC36~T1" dict.Add "ResultHIC36T2", "Result~HIC36~T2" dict.Add "ResultHIC36Value", "Result~HIC36~Value" dict.Add "ResultHICMeanAcc", "Result~HIC~MeanAcceleration" dict.Add "ResultHICT1", "Result~HIC~T1" dict.Add "ResultHICT2", "Result~HIC~T2" dict.Add "ResultHICUser", "Result~HICUser~WindowWidth" dict.Add "ResultHICUserMeanAcc", "Result~HICUser~MeanAcceleration" dict.Add "ResultHICUserT1", "Result~HICUser~T1" dict.Add "ResultHICUserT2", "Result~HICUser~T2" dict.Add "ResultHICUserValue", "Result~HICUser~Value" dict.Add "ResultHICValue", "Result~HIC~Value" dict.Add "ResultHICVersion", "Result~HIC~Version" dict.Add "ResultHICdMeanAcc", "Result~HICd~MeanAcceleration" dict.Add "ResultHICdT1", "Result~HICd~T1" dict.Add "ResultHICdValue", "Result~HICd~Value" dict.Add "ResultHPC15MeanAcc", "Result~HPC15~MeanAcceleration" dict.Add "ResultHPC15T1", "Result~HPC15~T1" dict.Add "ResultHPC15T2", "Result~HPC15~T2" dict.Add "ResultHPC15Value", "Result~HPC15~Value" dict.Add "ResultHPC36MeanAcc", "Result~HPC36~MeanAcceleration" dict.Add "ResultHPC36T1", "Result~HPC36~T1" dict.Add "ResultHPC36T2", "Result~HPC36~T2" dict.Add "ResultHPC36Value", "Result~HPC36~Value" dict.Add "ResultHPCMeanAcc", "Result~HPC~MeanAcceleration" dict.Add "ResultHPCT1", "Result~HPC~T1" dict.Add "ResultHPCT2", "Result~HPC~T2" dict.Add "ResultHPCUser", "Result~HPCUser~WindowWidth" dict.Add "ResultHPCUserMeanAcc", "Result~HPCUser~MeanAcceleration" dict.Add "ResultHPCUserT1", "Result~HPCUser~T1" dict.Add "ResultHPCUserT2", "Result~HPCUser~T2" dict.Add "ResultHPCUserValue", "Result~HPCUser~Value" dict.Add "ResultHPCValue", "Result~HPC~Value" dict.Add "ResultHPCVersion", "Result~HPC~Version" dict.Add "ResultHPCdMeanAcc", "Result~HPCd~MeanAcceleration" dict.Add "ResultHPCdT1", "Result~HPCd~T1" dict.Add "ResultHPCdValue", "Result~HPCd~Value" dict.Add "ResultMeanPulsePeriod", "Result~PulseDetection~MeanPulsePeriod" dict.Add "ResultMeanSpeed", "Result~PulseDetection~MeanSpeed" dict.Add "ResultMissingPulses", "Result~PulseDetection~MissingPulses" dict.Add "ResultNICRearMax", "Result~NICRear~Max" dict.Add "ResultNICRearTime", "Result~NICRear~Time" dict.Add "ResultNICRearVersion", "Result~NICRear~Version" dict.Add "ResultNijMax", "Result~Nij~Max" dict.Add "ResultNijTime", "Result~Nij~Time" dict.Add "ResultNijVersion", "Result~Nij~Version" dict.Add "ResultNonLinearFitCoef1..20", "Result~NonLinearFit~Coefficient1..20" dict.Add "ResultNonLinearFitCoefName1..20", "Result~NonLinearFit~CoefficientName1..20" dict.Add "ResultNonLinearFitMSE", "Result~NonLinearFit~MSE" dict.Add "ResultNonLinearFitModelFunction", "Result~NonLinearFit~ModelFunction" dict.Add "ResultOIVTimeFlight", "Result~OIV~TimeFlight" dict.Add "ResultOIVVelocity", "Result~OIV~Velocity" dict.Add "ResultOIVVersion", "Result~OIV~Version" dict.Add "ResultORAMax", "Result~ORA~Max" dict.Add "ResultORATime", "Result~ORA~Time" dict.Add "ResultORAVersion", "Result~ORA~Version" dict.Add "ResultOptDataTypeRoundingError", "Result~OptDataType~RoundingError" dict.Add "ResultOptDataTypeStorageSavings", "Result~OptDataType~StorageSavings" dict.Add "ResultPHDMax", "Result~PHD~Max" dict.Add "ResultPHDTime0", "Result~PHD~Time0" dict.Add "ResultPHDTime", "Result~PHD~Time" dict.Add "ResultPHDVersion", "Result~PHD~Version" dict.Add "ResultPulseLimit", "Result~PulseLimit" dict.Add "ResultPulseLimitTIdx", "Result~PulseLimit~TIdx" dict.Add "ResultPulseLimitVersion", "Result~PulseLimit~Version" dict.Add "ResultRegrCoeffA", "Result~Regression~CoefficientA" dict.Add "ResultRegrCoeffB", "Result~Regression~CoefficientB" dict.Add "ResultRegrName", "Result~Regression~Name" dict.Add "ResultRegrPrecision", "Result~Regression~Precision" dict.Add "ResultRoundingError", "Result~Rounding~Error" dict.Add "ResultSINADDetectedFrequency", "Result~SINAD~DetectedFrequency" dict.Add "ResultSINADResult", "Result~SINAD~Value" dict.Add "ResultSINADTHDPlusNoise", "Result~SINAD~THDPlusNoise" dict.Add "ResultSPCCp", "Result~SPC~CapabilityIndexes~Cp" dict.Add "ResultSPCCpL", "Result~SPC~CapabilityIndexes~CpL" dict.Add "ResultSPCCpU", "Result~SPC~CapabilityIndexes~CpU" dict.Add "ResultSPCCpk", "Result~SPC~CapabilityIndexes~Cpk" dict.Add "ResultSPCFracNConf", "Result~SPC~NonconformingParts~FracNConf" dict.Add "ResultSPCLFracNConf", "Result~SPC~NonconformingParts~LowerFracNConf" dict.Add "ResultSPCLowerNPL", "Result~SPC~Limits~LowerNPL" dict.Add "ResultSPCProcessMean", "Result~SPC~ProcessMean" dict.Add "ResultSPCProcessSigma", "Result~SPC~ProcessSigma" dict.Add "ResultSPCUFracNConf", "Result~SPC~NonconformingParts~UpperFracNConf" dict.Add "ResultSPCUpperNPL", "Result~SPC~Limits~UpperNPL" dict.Add "ResultSingleToneAmplitude", "Result~SingleTone~Amplitude" dict.Add "ResultSingleToneFrequency", "Result~SingleTone~Frequency" dict.Add "ResultSingleTonePhase", "Result~SingleTone~Phase" dict.Add "ResultStatArithMean", "Result~Statistics~MeanValues~ArithmeticMean" dict.Add "ResultStatAvDevMean", "Result~Statistics~AverageAbsDeviation~FromMean" dict.Add "ResultStatAvDevMedian", "Result~Statistics~AverageAbsDeviation~FromMedian" dict.Add "ResultStatDeviation", "Result~Statistics~Dispersion~StandardDeviation" dict.Add "ResultStatGeoMean", "Result~Statistics~MeanValues~GeometricMean" dict.Add "ResultStatHarMean", "Result~Statistics~MeanValues~HarmonicMean" dict.Add "ResultStatKurtosis", "Result~Statistics~Form~Kurtosis" dict.Add "ResultStatLowerQuartile", "Result~Statistics~Quantiles~LowerQuartile" dict.Add "ResultStatMax", "Result~Statistics~ExtremeValues~Maximum" dict.Add "ResultStatMedian", "Result~Statistics~Quantiles~Median" dict.Add "ResultStatMin", "Result~Statistics~ExtremeValues~Minimum" dict.Add "ResultStatQuartilDist", "Result~Statistics~Dispersion~QuartileDistance" dict.Add "ResultStatRange", "Result~Statistics~Dispersion~Range" dict.Add "ResultStatRelVarCoeff", "Result~Statistics~Dispersion~RelativeVariationCoefficient" dict.Add "ResultStatSkew", "Result~Statistics~Form~Skewness" dict.Add "ResultStatSqrMean", "Result~Statistics~MeanValues~SquareMean" dict.Add "ResultStatStdError", "Result~Statistics~Dispersion~StandardError" dict.Add "ResultStatSum", "Result~Statistics~Sums~Sum" dict.Add "ResultStatSumSqr", "Result~Statistics~Sums~SumOfSquares" dict.Add "ResultStatUpperQuartile", "Result~Statistics~Quantiles~UpperQuartile" dict.Add "ResultStatVarCoeff", "Result~Statistics~Dispersion~VariationCoefficient" dict.Add "ResultStatVariance", "Result~Statistics~Dispersion~Variance" dict.Add "ResultTHIVFlailSpace", "Result~THIV~FlailSpace" dict.Add "ResultTHIVTimeFlight", "Result~THIV~TimeFlight" dict.Add "ResultTHIVVelocity", "Result~THIV~Velocity" dict.Add "ResultTHIVVersion", "Result~THIV~Version" dict.Add "ResultTIRes", "Result~TI~Value" dict.Add "ResultTITime", "Result~TI~Time" dict.Add "ResultTIVersion", "Result~TI~Version" dict.Add "ResultTTIRes", "Result~TTI~Value" dict.Add "ResultTTIVersion", "Result~TTI~Version" dict.Add "ResultUsedPulses", "Result~PulseDetection~UsedPulses" dict.Add "ResultXOffset", "Result~XOffset" dict.Add "ResultXOffsetCorrCoefficient", "Result~XOffset~CorrelationCoefficient" dict.Add "ResultXOffsetDeltaN", "Result~XOffset~DeltaN" dict.Add "ResultXOffsetDeltaT", "Result~XOffset~DeltaT" dict.Add "ResultXgDeltaX", "Result~Xg~DeltaX" dict.Add "ResultXgMaxPeak", "Result~Xg~MaxPeak" dict.Add "ResultXgTimeBegin", "Result~Xg~TimeBegin" dict.Add "ResultXgTimeEnd", "Result~Xg~TimeEnd" dict.Add "ResultXgVersion", "Result~Xg~Version" dict.Add "ResultXmsAcceleration", "Result~Xms~Acceleration" dict.Add "ResultXmsDeltaX", "Result~Xms~DeltaX" dict.Add "ResultXmsTimeBegin", "Result~Xms~TimeBegin" dict.Add "ResultXmsTimeEnd", "Result~Xms~TimeEnd" dict.Add "ResultXmsVersion", "Result~Xms~Version" end sub private dict end class
06-20-2017 04:27 PM
Thanks, this is what I was looking for.