Personalizzazione della griglia di calibrazione e dei parametri personalizzati di superamento/fallimento
Supponiamo che tu voglia eseguire alcune operazioni su una griglia di punti di prova di calibrazione. Ad esempio, se volessi impostare tu stesso i criteri per il superamento o il fallimento. Per farlo, occorre innanzitutto aggiungere un trigger di evento personalizzato per "Aggiungi equipaggiamento (dopo)". In questo stesso codice è anche possibile personalizzare la modalità di visualizzazione della risoluzione e del troncamento per ciascuna colonna, oltre alle normali modalità di impostazione della risoluzione. Impostando PassFailOverride su True, il codice "Override" verrà eseguito sia in caso di superamento che di fallimento. ResOverride indica al programma di collegare i campi in modo che la loro risoluzione venga ricavata da altri campi. È inoltre possibile impostare un "offset" per la risoluzione. Per fare in modo che un campo "tronchi" i dati in base alla propria risoluzione, impostare il valore di TruncFIELDNAME su True.
Potresti usare il seguente codice:
sCompany = LookupEquipmentCompany
sID = LookupEquipmentID
Se sID <> "" allora
CurrentTolDir = ReturnFromSQL("SELECT TOL_DIRECTION FROM GAGES WHERE COMPANY='" & sCompany & "' AND GAGE_SN='" & sID & "'")
Se CurrentTolDir = "SPECIAL TOL." allora
PassFailOverride = True <-- Questo
ResOverride = True
TruncTol = True
SetResTol = True
ResFieldTol = "AV_RES"
TruncStandard = True
SetResStandard = True
ResFieldStandard = "NUM_RESOLUTION"
ResStandardOffset = 1
TruncExtra4 = True
SetResExtra4 = True
ResFieldExtra4 = "NUM_RESOLUTION"
ResExtra4Offset = 1
TruncExtra3 = True
SetResExtra3 = True
ResFieldExtra3 = "AV_RES"
TruncExtra5 = True
SetResExtra5 = True
ResFieldExtra5 = "AV_RES"
SetResAVResult = True
ResFieldAVResult = "AV_RES"
SetResExtra2 = True
ResFieldExtra2 = "AV_RES"
SetResUsedWarnTol = True
ResFieldUsedWarnTol = "AV_RES"
ResUsedWarnTolOffset = 2
else
PassFailOverride = False
ResOverride = False
end if
end if
Nota: questa modifica influirebbe solo sulla griglia degli eventi nuovi dopo l'aggiunta delle attrezzature; ripeti la stessa procedura in un evento "Lancio (Fine)" per applicare la modifica anche agli eventi in fase di modifica.
Per sovrascrivere il risultato "Superato/Non superato", puoi utilizzare il codice riportato di seguito in un'azione trigger "Test Point Before Post":
Se PassFailOverride = True allora
dStandard = tpFieldByNameAsFloat("LINE_STANDARD")
dTolPlus = tpFieldByNameAsFloat("TOLERANCE1")
dTolMinus = tpFieldByNameAsFloat("TOLERANCE2")
dAsFound = tpFieldByNameAsFloat("RESULT1")
dAsLeft = tpFieldByNameAsFloat("RESULT2")
sFailed = tpFieldByNameAsString("OUT_OF_TOL")
sAdjusted = tpFieldByNameAsString("ADJUSTED")
sROV = tpFieldByNameAsString("ROV")
sLimited = tpFieldByNameAsString("LIMITED")
iAV_RES = tpFieldBynameAsInteger("AV_RES")
dCalTol = tpFieldByNameAsFloat("TEST_ACCURACY")
If (DualTolerance = True) then
dTolMinus2 = tpFieldByNameAsFloat("EXTRA_NUM3")
dStandard2 = tpFieldByNameAsFloat("EXTRA_NUM4")
dTolPlus2 = tpFieldByNameAsFloat("EXTRA_NUM5")
else
dTolMinus2 = dTolMinus
dStandard2 = dStandard
dTolPlus2 = dTolPlus2
end if
Se ((tpFieldIsNull("RESULT1") <> "1") e (tpFieldIsNull("LINE_STANDARD") <> "1")) then
dCalcDev = (dAsFound - dStandard)
tpSetFieldByNameAsFloat("UTOLERANCE2_WARN", dCalcDev)
dCalcDev = RoundToDecimal(dCalcDev,iAV_RES)
tpSetFieldByNameAsFloat("AV_AS_FOUND", dCalcDev)
else
tpSetFieldByNameNull("UTOLERANCE2_WARN")
tpSetFieldByNameNull("AV_AS_FOUND")
end if
Se (DualTolerance = True) allora
Se ((tpFieldIsNull("RESULT2") <> "1") e (tpFieldIsNull("EXTRA_NUM4") <> "1")) allora
dCalcDev2 = (dAsLeft - dStandard2)
tpSetFieldByNameAsFloat("UTOLERANCE1_WARN", dCalcDev2)
dCalcDev2 = RoundToDecimal(dCalcDev2,iAV_RES)
tpSetFieldByNameAsFloat("EXTRA_NUM2", dCalcDev2)
else
tpSetFieldByNameNull("UTOLERANCE1_WARN")
tpSetFieldByNameNull("EXTRA_NUM2")
end if
else
If ((tpFieldIsNull("RESULT2") <> "1") and (tpFieldIsNull("LINE_STANDARD") <> "1")) then
dCalcDev2 = (dAsLeft - dStandard2)
tpSetFieldByNameAsFloat("UTOLERANCE1_WARN", dCalcDev2)
dCalcDev2 = RoundToDecimal(dCalcDev2,iAV_RES)
tpSetFieldByNameAsFloat("EXTRA_NUM2", dCalcDev2)
else
tpSetFieldByNameNull("UTOLERANCE1_WARN")
tpSetFieldByNameNull("EXTRA_NUM2")
end if
end if
sVerdict = tpFieldByNameAsString("VERDICT")
Se sVerdict = "" allora
iFromType = 1
altrimentiSe sVerdict = "F" allora
iFromType = 2
altrimentiSe sVerdict = "A" allora
iFromType = 3
altrimentiSe sVerdict = "L" allora
iFromType = 4
altrimentiSe sVerdict = "R" allora
iFromType = 5
fine se
Se iFromType = 2 allora
CalFailed = (CalFailed - 1)
altrimenti se iFromType = 3 allora
CalFailed = (CalFailed - 1)
CalAdjusted = (CalAdjusted - 1)
altrimenti se iFromType = 4 allora
CalFailed = (CalFailed - 1)
CalLimited = (CalLimited - 1)
elseIf iFromType = 5 then
CalROV = (CalROV - 1)
end if
Se (tpFieldIsNull("AV_AS_FOUND") <> "1") allora
Se (CDbl(Abs(tpFieldByNameAsFloat("AV_AS_FOUND"))) <= CDbl(dCalTol)) then
sNewVerdict = ""
else
sNewVerdict = "F"
end if
else
sNewVerdict = ""
end if
If sFailed = "1" then
sNewVerdict = "F"
end if
If sNewVerdict = "F" then
If (tpFieldIsNull("EXTRA_NUM2") <> "1") then
If (CDbl(Abs(tpFieldByNameAsFloat("EXTRA_NUM2"))) <= CDbl(dCalTol)) then
sNewVerdict = "A"
end if
end if
If sAdjusted = "1" then
sNewVerdict = "A"
end if
end if
If sNewVerdict = "F" then
If sLimited = "1" then
sNewVerdict = "L"
end if
end if
If sROV = "1" then
sNewVerdict = "R"
end if
sVerdict = sNewVerdict
; se sVerdict = "" allora
; iToType = 1
; altrimenti se sVerdict = "F" allora
; iToType = 2
; altrimenti se sVerdict = "A" allora
; iToType = 3
; altrimenti se sVerdict = "L" allora
; iToType = 4
; altrimenti se sVerdict = "R" allora
; iToType = 5
; fine se
tpSetFieldByNameAsString("VERDICT", sVERDICT)
Se iToType = 2 allora
CalFailed = (CalFailed + 1)
altrimenti se iToType = 3 allora
CalFailed = (CalFailed + 1)
CalAdjusted = (CalAdjusted + 1)
altrimenti se iToType = 4 allora
CalFailed = (CalFailed + 1)
CalLimited = (CalLimited + 1)
elseIf iToType = 5 then
CalROV = (CalROV + 1)
end if
end if |