diff --git a/LSL2/STPROC/METROLOGY_SERVICES.txt b/LSL2/STPROC/METROLOGY_SERVICES.txt index b6d6910..0944961 100644 --- a/LSL2/STPROC/METROLOGY_SERVICES.txt +++ b/LSL2/STPROC/METROLOGY_SERVICES.txt @@ -96,6 +96,7 @@ Declare function SRP_Sort_Array, Metrology_Services, obj_RDS_Test, obj_Test_P Declare function Work_Order_Services, SRP_JSON, Logging_Services, Environment_Services, SRP_Trim, Min, Max Declare function QA_Services, SRP_Join_Arrays, Get_Status, Obj_Clean_Insp, Datetime, SRP_Datetime Declare function Httpclient_Services, PM_Services, Signature_Services, SRP_Array, Math_Services +Declare function Tool_Class_Services LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Metrology' LogDate = Oconv(Date(), 'D4/') @@ -608,7 +609,6 @@ end service Service ImportBioRadData(RunData, FileName) - Machine = 'BioRad' IsProdTest = False$ ParseArray = '' @@ -685,14 +685,19 @@ Service ImportBioRadData(RunData, FileName) If IsProdTest EQ True$ then Metrology_Services('LogResults',RDSKeyID,Machine,'HgCV','Product test recognized. Recipe name: ':ScanRecipe) end // ------------------------------------------------------------------------------------------------------------- - CassNo = RDSRec WorkOrder = Work_Order_Services('GetWorkOrder', WorkOrderNo, False$) GoSub ParseWorkOrder IsEpiPro = (WOReactorType _EQC 'EpiPro') OR (WOReactorType _EQC 'EPP') RunDataZone = Metrology_Services('FormatZoneKeyID', RunDataZone) ; // 1, 2 - RunDataLayer = Metrology_Services('FormatLayerKeyID', RunDataLayer) ; // L1, L2, 2 + RunDataLayer = Metrology_Services('FormatLayerKeyID', RunDataLayer) ; // L1, L2, 2 + + ZoneForValidation = RunDataZone + LayerForValidation = RunDataLayer + If LayerForValidation EQ '' then + LayerForValidation = 'L1' + end CalculatedZone = Metrology_Services('GetCalculatedZone', RDSKeyID, IsEpiPro, RunDataZone) If RunDataZone NE CalculatedZone then @@ -851,28 +856,51 @@ Service ImportBioRadData(RunData, FileName) SigProfFound = True$ UnloadSigned = Signature_Services('GetStageSummary', WoMatKey, 'UNLOAD')<2> IF (Stage EQ 'UNLOAD' AND UnloadSigned EQ True$) OR Stage NE 'UNLOAD' then - If WOMatQARec EQ '' OR IsViewerFile then - WOMatQARec = Average - WOMatQARec = Oconv(Iconv(Min, 'MD3'), 'MD3') - WOMatQARec = Oconv(Iconv(Max, 'MD3'), 'MD3') - SpecMin = WOMatQARec - SpecMax = WOMatQARec - For each DataPoint in RawDataPoints using @FM setting SubValuePos - FormatedData = Oconv(Iconv(DataPoint, 'MD3'), 'MD3') - If NumDataPoints LT 14 then - If ( ( FormatedData LT SpecMin ) OR ( FormatedData GT SpecMax ) and (SubValuePos LT 10) ) then - WOMatQARec = True$ - end - end else - If ( FormatedData LT SpecMin ) OR ( FormatedData GT SpecMax ) then - WOMatQARec = True$ - end - end - WOMatQARec = FormatedData - Next DataPoint - WOMatQARec = '' - WOMatQARec = '' - Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatQAID, WOMatQARec, True$, False$, True$) + // verify recipe is correct + WoMatQaRecipe = WOMatQARec + WoMatQaRecipeMatchesScanRecipe = ScanRecipe _EQC WoMatQaRecipe + If WoMatQaRecipeMatchesScanRecipe EQ False$ then + ErrMsg = 'Scan recipe [ ' : ScanRecipe : ' ] does not match WoMatQa recipe [ ' : WoMatQaRecipe : ' ] for RDS [ ' : RDSKeyID : ' ] layer [ ' : CalculatedLayer : ' ].' + Error_Services('Add', ErrMsg) + Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) + end + + // verify number of points is correct + WoMatQaToolClass = WOMatQARec + WoMatQaRecipePattern = WOMatQARec + NumDataPointsInSpec = Tool_Class_Services('GetNumberOfPointsForPattern', WoMatQaToolClass, WoMatQaRecipePattern) + WoMatQaRecipePatternNumPointsMatchesScanNumDataPoints = NumDataPointsInSpec EQ NumDataPoints + + If WoMatQaRecipePatternNumPointsMatchesScanNumDataPoints EQ False$ then + ErrMsg = 'Scan data point count [ ' : NumDataPoints : ' ] does not match WoMatQa recipe pattern data point count [ ' : NumDataPointsInSpec : ' ] for RDS [ ' : RDSKeyID : ' ] layer [ ' : CalculatedLayer : ' ].' + Error_Services('Add', ErrMsg) + Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) + end + + If (WOMatQARec EQ '' OR IsViewerFile) then + If WoMatQaRecipeMatchesScanRecipe and WoMatQaRecipePatternNumPointsMatchesScanNumDataPoints then + WOMatQARec = Average + WOMatQARec = Oconv(Iconv(Min, 'MD3'), 'MD3') + WOMatQARec = Oconv(Iconv(Max, 'MD3'), 'MD3') + SpecMin = WOMatQARec + SpecMax = WOMatQARec + For each DataPoint in RawDataPoints using @FM setting SubValuePos + FormatedData = Oconv(Iconv(DataPoint, 'MD3'), 'MD3') + If NumDataPoints LT 14 then + If ( ( FormatedData LT SpecMin ) OR ( FormatedData GT SpecMax ) and (SubValuePos LT 10) ) then + WOMatQARec = True$ + end + end else + If ( FormatedData LT SpecMin ) OR ( FormatedData GT SpecMax ) then + WOMatQARec = True$ + end + end + WOMatQARec = FormatedData + Next DataPoint + WOMatQARec = '' + WOMatQARec = '' + Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatQAID, WOMatQARec, True$, False$, True$) + end end else Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : UID001 - Data for this metrology test already exists and is not from the metrology viewer.') end @@ -890,7 +918,36 @@ Service ImportBioRadData(RunData, FileName) end Case Otherwise$ // If not an above case, then the run is a conventional THICK_ONLY RDS metrology test. - GoSub LoadRunDataToDatabase + + RDSLayerKeyID = RDSKeyID : '*' : LayerForValidation + RDSLayerRec = Database_Services('ReadDataRow', 'RDS_LAYER', RDSLayerKeyID) + If Error_Services('NoError') then + RDSTestKeyIDs = RDSLayerRec + + // Verify the scan recipe matches the spec recipe + RecipeMatches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', RDSKeyID, LayerForValidation, ScanRecipe, RDSTestKeyIDs, ZoneForValidation) + If RecipeMatches EQ False$ then + ErrMsg = 'Scan recipe [ ' : ScanRecipe : ' ] does not match RDS Test recipe for RDS [ ' : RDSKeyID : ' ] layer [ ' : CalculatedLayer : ' ] zone [ ' : CalculatedZone : ' ].' + Error_Services('Add', ErrMsg) + Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) + end + + // Verfiy the scan number of points matches the spec number of points + NumPointsMatches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', RDSKeyID, LayerForValidation, NumDataPoints, RDSTestKeyIDs, 'FTIR', ZoneForValidation) + If NumPointsMatches EQ False$ then + ErrMsg = 'Scan data point count [ ' : NumDataPoints : ' ] does not match RDS Test recipe pattern data point count for RDS [ ' : RDSKeyID : ' ] layer [ ' : CalculatedLayer : ' ] zone [ ' : CalculatedZone : ' ].' + Error_Services('Add', ErrMsg) + Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) + end + + If RecipeMatches and NumPointsMatches then + GoSub LoadRunDataToDatabase + end + end else + ErrMsg = 'RDS Test scan failed for RDS [' : RDSKeyID : '] layer [' : LayerForValidation : '], because unable to get RDS_LAYER record [' : RDSLayerKeyID : ']' + Error_Services('Add', ErrMsg) + Metrology_Services('LogResults', RDSKeyID, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) + end End Case end else Error_Services('Add', 'Data type / Spec not found for Layer [' : RunDataLayer : '].') @@ -2416,6 +2473,88 @@ Service GetIQSViolations() end end service +Service ScanRecipeMatchesRdsTestSpecThickMrecipe(RdsNo, RecipeLayer, RecipeInScan, RdsTestKeysFromRdsLayer, Zone='') + If Unassigned(RecipeLayer) or RecipeLayer EQ '' then + RecipeLayer = 'L1' + end + + MatchFound = False$ + ValidArgs = Assigned(RdsNo) and RdsNo NE '' and Assigned(RecipeInScan) and RecipeInScan NE '' + ValidArgs = ValidArgs and Assigned(RdsTestKeysFromRdsLayer) and Dcount(RdsTestKeysFromRdsLayer, @VM) GT 0 + If ValidArgs then + For Each RDSTestKeyID in RdsTestKeysFromRdsLayer using @VM setting mkPos + RdsTestRec = Database_Services('ReadDataRow', 'RDS_TEST', RDSTestKeyID) + If Error_Services('NoError') then + RdsTestRdsNo = RdsTestRec + If RdsNo EQ RdsTestRdsNo then + RdsTestRecLayer = RdsTestRec + If RecipeLayer EQ RdsTestRecLayer then + Continue = True$ + If Zone NE '' then + RdsTestRecZone = RdsTestRec + If RdsTestRecZone NE Zone then + Continue = False$ + end + end + If Continue then + SpecThickMrecipe = RdsTestRec + If RecipeInScan _EQC SpecThickMrecipe then + MatchFound = True$ + end + end + end + end + end + Until MatchFound + Next RDSTestKeyID + end + + Response = MatchFound +end service + +Service ScanNumDataPointsMatchesRdsTestSpecThickMPattern(RdsNo, RecipeLayer, ScanNumDataPoints, RdsTestKeysFromRdsLayer, ToolClass, Zone='') + If Unassigned(RecipeLayer) or RecipeLayer EQ '' then + RecipeLayer = 'L1' + end + + MatchFound = False$ + + ValidArgs = Assigned(RdsNo) and RdsNo NE '' and Assigned(ScanNumDataPoints) and Num(ScanNumDataPoints) + ValidArgs = ValidArgs and Assigned(RdsTestKeysFromRdsLayer) and Dcount(RdsTestKeysFromRdsLayer, @VM) GT 0 + ValidArgs = ValidArgs and Assigned(ToolClass) and ToolClass NE '' + + If ValidArgs then + For Each RDSTestKeyID in RdsTestKeysFromRdsLayer using @VM setting mkPos + RdsTestRec = Database_Services('ReadDataRow', 'RDS_TEST', RDSTestKeyID) + If Error_Services('NoError') then + RdsTestRdsNo = RdsTestRec + If RdsNo EQ RdsTestRdsNo then + RdsTestRecLayer = RdsTestRec + If RecipeLayer EQ RdsTestRecLayer then + Continue = True$ + If Zone NE '' then + RdsTestRecZone = RdsTestRec + If RdsTestRecZone NE Zone then + Continue = False$ + end + end + If Continue then + SpecPatternName = RdsTestRec + SpecNumDataPoints = Tool_Class_Services('GetNumberOfPointsForPattern', ToolClass, SpecPatternName) + If ScanNumDataPoints EQ SpecNumDataPoints then + MatchFound = True$ + end + end + end + end + end + Until MatchFound + Next RDSTestKeyID + end + + Response = MatchFound +end service + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2877,3 +3016,4 @@ return + diff --git a/LSL2/STPROC/TEST_METROLOGYSERVICES.txt b/LSL2/STPROC/TEST_METROLOGYSERVICES.txt index 85510e8..b9d1485 100644 --- a/LSL2/STPROC/TEST_METROLOGYSERVICES.txt +++ b/LSL2/STPROC/TEST_METROLOGYSERVICES.txt @@ -1,9 +1,12 @@ Compile function Test_MetrologyServices(@Test) #pragma precomp SRP_PreCompiler -Declare function Metrology_Services +$Insert LOGICAL -// TODO: Code to run before each test goes here +Declare subroutine Metrology_Services, Error_Services +Declare function Metrology_Services, Error_Services + +Error_Services('Clear') GotoTest @@ -15,44 +18,164 @@ Return TestResult or 1 // TESTS //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// GetCalculatedLayer Tests +//----------------------------------------------------------------------------- + Test GetCalculatedLayerEpiProWithoutWoIsEpiProOrScannedLayerShouldReturnL2 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649130, 'BioRad', 2) Assert CalculatedLayer equals 2 end test Test GetCalculatedLayerEpiProShouldReturnL2 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649130, 'BioRad', 2, 1, 1) Assert CalculatedLayer equals 2 end test Test GetCalculatedLayerSingleLayerNonEpiProWithoutWoIsEpiProOrScannedLayerShouldReturnL1 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 648685, 'BioRad', '') Assert CalculatedLayer equals 'L1' end test Test GetCalculatedLayerSingleLayerNonEpiProShouldReturnL1 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 648685, 'BioRad', '', 0, 1) Assert CalculatedLayer equals 'L1' end test Test GetCalculatedLayerMultiLayerNonEpiProWithoutWoIsEpiProOrScannedLayerShouldReturn2 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649834, 'BioRad', '') Assert CalculatedLayer equals 2 end test Test GetCalculatedLayerMultiLayerNonEpiProShouldReturnL1 - // GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) - CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649834, 'BioRad', '', 0, 'L1') Assert CalculatedLayer equals 'L1' end test + +//----------------------------------------------------------------------------- +// ScanRecipeMatchesRdsTestSpecThickMrecipe Tests +//----------------------------------------------------------------------------- + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRdsNoShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '', 'peach', 'mango', 'banana':@VM:'apple') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRecipeLayerShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', '', 'mango', 'banana':@VM:'apple') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyScanRecipeShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'mango', '', 'banana':@VM:'apple') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRdsTestKeysShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'apple', 'banana', '') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRdsNoShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'L2', 'Thin8inch', '1722576') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongLayerShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L2', 'Thin8inch', '1722576') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRecipeShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'banana', '1722576') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRdsTestKeysShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'Thin8inch', '1722578') + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithCorrectArgsShouldReturnTrue + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'Thin8inch', '1722576') + Assert Matches equals True$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeEpiProWithWrongZoneShouldReturnFalse + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650028', '2', '6inTHICK', '1722253':@VM:'1722259', 4) + Assert Matches equals False$ +end test + +Test ScanRecipeMatchesRdsTestSpecThickMrecipeEpiProWithCorrectArgsShouldReturnTrue + Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650028', '2', '6inTHICK', '1722253':@VM:'1722259', 2) + Assert Matches equals True$ +end test + +//----------------------------------------------------------------------------- +// ScanNumDataPointsMatchesRdsTestSpecThickMPattern Tests +//----------------------------------------------------------------------------- + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRdsNoShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '', 'peach', 5, 'banana':@VM:'apple', 'mango') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRecipeLayerShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', '', 5, 'banana':@VM:'apple', 'mango') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithStringScanNumDataPointsShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'mango', 'potato', 'banana':@VM:'apple', 'pineapple') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRdsTestKeysShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'apple', 5, '', 'banana') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyToolClassShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'apple', 5, 'banana':@VM:'apple', '') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongRdsNoShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'L2', 10, '1722576', 'FTIR') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongLayerShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L2', 10, '1722576', 'FTIR') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongScanNumDataPointsShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 5, '1722576', 'FTIR') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongRdsTestKeysShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722578', 'FTIR') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongToolClassShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722576', 'banana') + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithCorrectArgsShouldReturnTrue + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722576', 'FTIR') + Assert Matches equals True$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternEpiProWithWrongZoneShouldReturnFalse + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650028', '2', 9, '1722253':@VM:'1722259', 'FTIR', 4) + Assert Matches equals False$ +end test + +Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternEpiProWithCorrectArgsShouldReturnTrue + Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650028', '2', 9, '1722253':@VM:'1722259', 'FTIR', 2) + Assert Matches equals True$ +end test diff --git a/LSL2/STPROC/TEST_TOOL_CLASS_SERVICES.txt b/LSL2/STPROC/TEST_TOOL_CLASS_SERVICES.txt new file mode 100644 index 0000000..5652489 --- /dev/null +++ b/LSL2/STPROC/TEST_TOOL_CLASS_SERVICES.txt @@ -0,0 +1,43 @@ +Compile function Test_Tool_Class_Services(@Test) +#pragma precomp SRP_PreCompiler + +$Insert LOGICAL + +Declare function Tool_Class_Services, Error_Services +Declare subroutine Tool_Class_Services, Error_Services + +Error_Services('Clear') + +GotoTest + +Return TestResult or 1 + +//----------------------------------------------------------------------------- +// TESTS +//----------------------------------------------------------------------------- + +Test GetNumberOfPointsForPatternWithEmptyToolClassShouldThrowError + Tool_Class_Services('GetNumberOfPointsForPattern', '' , 'super cool pattern') + Assert Error_Services('HasError') equals True$ +End Test + +Test GetNumberOfPointsForPatternWithEmptyPatternNameShouldThrowError + Tool_Class_Services('GetNumberOfPointsForPattern', 'best tool class ever' , '') + Assert Error_Services('HasError') equals True$ +End Test + +Test GetNumberOfPointsForPatternWithInvalidToolClassShouldThrowError + Tool_Class_Services('GetNumberOfPointsForPattern', 'bestToolClassEver' , '10PT_5mm') + Assert Error_Services('HasError') equals True$ +End Test + +Test GetNumberOfPointsForPatternWithInvalidPatternNameShouldThrowError + Tool_Class_Services('GetNumberOfPointsForPattern', 'FTIR' , 'superCoolPattern') + Assert Error_Services('HasError') equals True$ +End Test + +Test GetNumberOfPointsForPatternWithValidArgsShouldReturnCorrectNumberOfPoints + ExpectedNumberOfPoints = 10 + ActualNumberOfPoints = Tool_Class_Services('GetNumberOfPointsForPattern', 'FTIR' , '10PT_5mm') + Assert ActualNumberOfPoints equals ExpectedNumberOfPoints +End Test diff --git a/LSL2/STPROC/TOOL_CLASS_SERVICES.txt b/LSL2/STPROC/TOOL_CLASS_SERVICES.txt new file mode 100644 index 0000000..d2e6470 --- /dev/null +++ b/LSL2/STPROC/TOOL_CLASS_SERVICES.txt @@ -0,0 +1,50 @@ +Compile function Tool_Class_Services(@Service, @Params) +#pragma precomp SRP_PreCompiler +$insert LOGICAL +$Insert SERVICE_SETUP + +$Insert TOOL_CLASS_EQUATES + +Declare subroutine Error_Services +Declare function Error_Services, Database_Services + +GoToService + +Return Response or "" + +//----------------------------------------------------------------------------- +// SERVICES +//----------------------------------------------------------------------------- + +Service GetNumberOfPointsForPattern(ToolClass, PatternName) + If Unassigned(ToolClass) or ToolClass EQ '' then + Error_Services('Add', 'invalid tool class') + end + + If Error_Services('NoError') then + If Unassigned(PatternName) or PatternName EQ '' then + Error_Services('Add', 'invalid pattern name') + end + end + + If Error_Services('NoError') then + ToolClassRecord = Database_Services('ReadDataRow', 'TOOL_CLASS', ToolClass) + If Error_Services('HasError') then + Error_Services('Add', 'tool class record not found') + end + If Error_Services('NoError') then + Locate PatternName in ToolClassRecord using @VM Setting idx then + Response = ToolClassRecord + end + + NumberOfPatterns = DCount(ToolClassRecord, @VM) + If idx GT NumberOfPatterns then + Error_Services('Add', 'pattern name not found') + end + PatternSizeCount = DCount(ToolClassRecord, @VM) + If idx GT PatternSizeCount then + Error_Services('Add', 'number of points not found') + end + end + end +End Service