Compile function WO_Mat_QA_Services(@Service, @Params) /*********************************************************************************************************************** Name : WO_Mat_QA_Services Description : Handler program for all WO_Mat_QA services. Notes : Application errors should be logged using the Error Services module. There are a few methodological assumptions built into way errors are managed which are important to understand in order to properly work with Error Services: - The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger this will appear backwards since the originating procedure always appears at the bottom of the list and the current routine appears at the top of the list. We are using this orientation because it is common to refer to the process of calling other procedures as 'drilling down'. - The reason for defining the orientation of the call stack is because Error_Services allows for multiple error conditions to be appended to an original error. In most cases this will happen when a procedure at the bottom of the stack generates an error condition and then returns to its calling procedure. This higher level procedure can optionally add more information relevant to itself. This continues as the call stack 'bubbles' its way back to the top to where the originating procedure is waiting. - Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus) preserve their error state until explicitly cleared. This can hinder the normal execution of code since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists. Our philosophy is that error conditions should automatically be cleared before a new procedure is executed to avoid this problem. However, the nature of Basic+ does not make this easy to automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our philosophy then it should include a call into the 'Clear' service request at the top of the program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.) - Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any error conditions that were set before. Parameters : Service [in] -- Name of the service being requested Param1-10 [in/out] -- Additional request parameter holders Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure Metadata : History : (Date, Initials, Notes) 11/16/22 djs Original programmer. ***********************************************************************************************************************/ #pragma precomp SRP_PreCompiler $Insert LOGICAL $Insert SERVICE_SETUP $Insert WO_LOG_EQUATES $Insert WO_MAT_EQUATES $Insert WO_STEP_EQUATES $Insert WO_MAT_QA_EQUATES $Insert PRS_LAYER_EQUATES $Insert PRS_STAGE_EQUATES $Insert PROD_VER_EQUATES $Insert QA_MET_EQUATES ;* Used in GetQAMet data structure return variable Declare function Database_Services, SRP_JSON, Error_Services, obj_Prod_Spec Declare subroutine Database_Services, SRP_JSON, Error_Services GoToService Return Response or "" //----------------------------------------------------------------------------- // SERVICES //----------------------------------------------------------------------------- Service ConvertRecordToJSON(KeyID, Record, ItemURL) jsonRecord = '' If KeyID NE '' then If Record EQ '' then Record = Database_Services('ReadDataRow', 'WO_MAT_QA', KeyID) If Error_Services('NoError') then @DICT = Database_Services('GetTableHandle', 'DICT.WO_MAT_QA') @ID = KeyID @RECORD = Record objJSON = '' If SRP_JSON(objJSON, 'New', 'Object') then objWOMatQA = '' If SRP_JSON(objWOMatQA, 'New', 'Object') then SRP_JSON(objWOMatQA, 'SetValue', 'keyId', @ID) Stages = {STAGE} Profiles = {PROFILE} Props = {PROP} ToolClasses = {TOOL_CLASS} Recipes = {RECIPE} RecipePatterns = {RECIPE_PATTERN} SpecMins = {MIN} SpecMaxes = {MAX} SpecSlots = {SLOT} TestSlots = {SLOT_TEST} TestResults = {RESULT} TestSigs = {SIG} TestSigDtms = {SIG_DTM} SpecStdDevs = {STD_MAX} TestStdDevs = {STD_RESULT} SpecWfrQty = {WFR_QTY} TestData = {DATA_POINTS} TestMins = {MIN_RESULT} TestMaxes = {MAX_RESULT} OutOfSpec = {OUT_OF_SPEC} PhaseMins = {PHASE_MIN} FailReasons = {FAIL_REASON} If Stages NE '' then objTestArray = '' If SRP_JSON(objTestArray, 'New', 'Array') then For each Stage in Stages using @VM setting vPos objTest = '' If SRP_JSON(objTest, 'New', 'Object') then SRP_JSON(objTest, 'SetValue', 'stage', Stage) SRP_JSON(objTest, 'SetValue', 'profile', Profiles<0, vPos>) SRP_JSON(objTest, 'SetValue', 'prop', Props<0, vPos>) SRP_JSON(objTest, 'SetValue', 'toolClass', ToolClasses<0, vPos>) SRP_JSON(objTest, 'SetValue', 'recipe', Recipes<0, vPos>) SRP_JSON(objTest, 'SetValue', 'recipePattern', RecipePatterns<0, vPos>) SRP_JSON(objTest, 'SetValue', 'specMin', SpecMins<0, vPos>) SRP_JSON(objTest, 'SetValue', 'specMax', SpecMaxes<0, vPos>) SRP_JSON(objTest, 'SetValue', 'specSlot', SpecSlots<0, vPos>) SRP_JSON(objTest, 'SetValue', 'testSlot', TestSlots<0, vPos>) SRP_JSON(objTest, 'SetValueArray', 'testResult', TestResults<0, vPos>, @SVM) SRP_JSON(objTest, 'SetValue', 'testSig', TestSigs<0, vPos>) SRP_JSON(objTest, 'SetValue', 'testSigDtm', OConv(TestSigDtms<0, vPos>, 'DT2/^H')) SRP_JSON(objTest, 'SetValue', 'specStdDev', SpecStdDevs<0, vPos>) SRP_JSON(objTest, 'SetValue', 'testStdDev', TestStdDevs<0, vPos>) SRP_JSON(objTest, 'SetValue', 'specWfrQty', SpecWfrQty<0, vPos>) objDataArray = '' If SRP_JSON(objDataArray, 'New', 'Array') then DataPoints = TestData<0, vPos> For each Row in DataPoints using @SVM SRP_JSON(objDataArray, 'AddValueArray', Row, @TM) Next Row SRP_JSON(objTest, 'Set', 'dataPoints', objDataArray) SRP_JSON(objDataArray, 'Release') end SRP_JSON(objTest, 'SetValueArray', 'testResultMin', TestMins<0, vPos>, @SVM) SRP_JSON(objTest, 'SetValueArray', 'testResultMax', TestMaxes<0, vPos>, @SVM) SRP_JSON(objTest, 'SetValue', 'testOutOfSpec', OutOfSpec<0, vPos>, 'Boolean') SRP_JSON(objTest, 'SetValue', 'phaseMin', PhaseMins<0, vPos>) SRP_JSON(objTest, 'SetValue', 'failReason', FailReasons<0, vPos>) end SRP_JSON(objTestArray, 'Add', objTest) SRP_JSON(objTest, 'Release') Next Stage end SRP_JSON(objWOMatQA, 'Set', 'tests', objTestArray) SRP_JSON(objTestArray, 'Release') end SRP_JSON(objJSON, 'Set', 'woMatQa', objWOMatQA) SRP_JSON(objWOMatQA, 'Release') end If itemURL NE '' then // The itemURL was passed in so add HAL+JSON properties. // Create the _links property and then all link objects needed for this resource. objLinks = '' If SRP_JSON(objLinks, 'New', 'Object') then // Create a self link. objLink = '' If SRP_JSON(objLink, 'New', 'Object') then SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String') SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String') SRP_JSON(objLinks, 'Set', 'self', objLink) SRP_JSON(objLink, 'Release') end SRP_JSON(objJSON, 'Set', '_links', objLinks) SRP_JSON(objLinks, 'Release') end // Create the _class property for this resource. SRP_JSON(objJSON, 'SetValue', '_class', 'resource') end jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled') SRP_JSON(objJSON, 'Release') end else Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.') end end end else Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.') end Response = jsonRecord End Service Service UpdateQAMet(WOMatKey) WOMatQARec = '' ErrorMsg = '' If (WOMatKey NE '') then WONo = Field(WOMatKey, '*', 1) CassNo = Field(WOMatKey, '*', 2) * * * * * * * * Build QA_MET profile - Work Order scheduled only * * * * * * * * WOStepKeys = XLATE('WO_LOG', WONo, WO_LOG_WO_STEP_KEY$, 'X') StepCnt = DCount(WOStepKeys,@VM) EpiProPSNo = '' EpiProPSRec = '' MetLine = 1 // Get original WO_MAT_QA record to copy any test results OrigWOMatQARec = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatKey) OrigQAStages = OrigWOMatQARec OrigQAProfiles = OrigWOMatQARec OrigQASlots = OrigWOMatQARec OrigQASlotTests = OrigWOMatQARec OrigQAResults = OrigWOMatQARec OrigQASigs = OrigWOMatQARec OrigQASigDtms = OrigWOMatQARec OrigQAStdResults = OrigWOMatQARec OrigQADataPoints = OrigWOMatQARec OrigQAMinResults = OrigWOMatQARec OrigQAMaxResults = OrigWOMatQARec OrigQARangeResults = OrigWOMatQARec OrigQAEdgeResults = OrigWOMatQARec OrigQA5mmResults = OrigWOMatQARec OrigQAOutOfSpecs = OrigWOMatQARec OrigQAFailReasons = OrigWOMatQARec * WO_MAT record is used to check for pre-existing signatures jch 6/7/2015 WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey) FOR WOStepNo = 1 TO StepCnt PSNo = XLATE('WO_STEP', WOStepKeys<1,WOStepNo>, WO_STEP_PROD_SPEC_ID$, 'X') PSRec = Database_Services('ReadDataRow', 'PROD_SPEC', PSNo) QAMetData = obj_Prod_Spec('GetQAMet',PSNo:@RM:PSRec) QAStages = QAMetData StageCnt = COUNT(QAStages,@VM) + (QAStages NE '') FOR StageNo = 1 TO StageCnt Stage = QAMetData MetTest = QAMetData ;* StageRec Interval = QAMetData ;* StageRec Start = QAMetData ;* StageRec ReactSched = QAMetData ;* StageRec TestFlag = 0 IF Interval NE '' AND Start NE '' THEN IF Interval = Start THEN IF REM(CassNo,Interval) = 0 THEN TestFlag = 1 END ELSE IF ABS((Start + INT(CassNo/Interval)*Interval) - CassNo) = 0 THEN TestFlag = 1 END IF TestFlag AND NOT(ReactSched) THEN WOMatQARec = WOStepNo:QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = ReactSched ;* StageRec WOMatQARec = QAMetData ;* StageRec WOMatQARec = QAMetData If OrigWOMatQARec NE '' then CurrStage = QAMetData CurrProfile = WOStepNo:QAMetData CurrSlot = QAMetData // Copy any existing results from the original WO_MAT_QA record. If OrigQAStages NE '' then Found = False$ For each OrigQAStage in OrigQAStages using @VM setting sPos OrigQAProfile = OrigQAProfiles<0, sPos> OrigQASlot = OrigQASlots<0, sPos> If ( (CurrStage EQ OrigQAStage) and (CurrProfile EQ OrigQAProfile) and (CurrSlot EQ OrigQASlot) ) then Found = True$ WOMatQARec = OrigQASlotTests<0, sPos> WOMatQARec = OrigQAResults<0, sPos> WOMatQARec = OrigQASigs<0, sPos> WOMatQARec = OrigQASigDtms<0, sPos> WOMatQARec = OrigQAStdResults<0, sPos> WOMatQARec = OrigQADataPoints<0, sPos> WOMatQARec = OrigQAMinResults<0, sPos> WOMatQARec = OrigQAMaxResults<0, sPos> WOMatQARec = OrigQARangeResults<0, sPos> WOMatQARec = OrigQAEdgeResults<0, sPos> WOMatQARec = OrigQA5mmResults<0, sPos> WOMatQARec = OrigQAOutOfSpecs<0, sPos> WOMatQARec = OrigQAFailReasons<0, sPos> end Until Found Next OrigQAStage end end MetLine += 1 END END NEXT StageNo NEXT WOStepNo Database_Services('WriteDataRow', 'WO_MAT_QA', WONo:'*':CassNo, WOMatQARec) end else ErrorMsg = 'Error in ':Service:' service. Null WOMatKey passed in.' end If ErrorMsg NE '' then Error_Services('Add', ErrorMsg) end else Response = WOMatQARec end end service Service ClearSignatureByStage(WOMatQaKey, StageToClear) If ( (WOMatQAKey NE '') and (StageToClear NE '') ) then WOMatQaRec = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatQaKey) If Error_Services('NoError') then Stages = WOMatQaRec If Stages NE '' then For each Stage in Stages using @VM setting sPos If Stage EQ StageToClear then WOMatQaRec = '' WOMatQaRec = '' end Next Stage Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatQaKey, WOMatQaRec, True$, False$, True$) If Error_Services('HasError') then Error_Services('Add', 'Error in ' :Service : ' service. Error writing WO_MAT_QA record. ' : WOMatQaKey) end end else Error_Services('Add', 'Error in ' :Service : ' service. WO_MAT_QA_STAGE column is null!') end end end else Error_Services('Add', 'Missing parameter in ' : service : ' service. WOOMatQaKey = ' WOMatQaKey : ', StageToClear = ' : StageToClear) end end service Service ClearResultsByStage(WOMatQaKey, StageToClear) If ( (WOMatQAKey NE '') and (StageToClear NE '') ) then WOMatQaRec = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatQaKey) If Error_Services('NoError') then Stages = WOMatQaRec If Stages NE '' then For each Stage in Stages using @VM setting sPos If Stage EQ StageToClear then WOMatQaRec = '' WOMatQaRec = '' WOMatQaRec = '' end Next Stage Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatQaKey, WOMatQaRec, True$, False$, True$) If Error_Services('HasError') then Error_Services('Add', 'Error in ' :Service : ' service. Error writing WO_MAT_QA record. ' : WOMatQaKey) end end else Error_Services('Add', 'Error in ' :Service : ' service. WO_MAT_QA_STAGE column is null!') end end end else Error_Services('Add', 'Missing parameter in ' : service : ' service. WOOMatQaKey = ' WOMatQaKey : ', StageToClear = ' : StageToClear) end end service Service AllWafersWereTested(WoMatQAKey, StageToInspect) if WOMatQAKey NE '' and StageToInspect NE '' then WOMatQaRec = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatQaKey) WoMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatQaKey) MUFlag = Xlate('WO_MAT', WOMatQAKey, 'MU_BOX', 'X') for stageIdx = 1 to len(WOMatQaRec) Stage = WoMatQaRec if Stage _EQC StageToInspect then If Not(MUFlag) then //Not a MU box. Use what is in the WAFER_QTY field to ensure 25 wafers WoWaferQty = WoMatRec end else //This is a MU box and probably has less than the WoWaferQty. For some reason that field is a static value =( WoWaferQty = 0 Slots = XLATE('WO_MAT', WOMatQAKey, 'SLOT_WAFER_ID', 'X') Slot = '' for each Slot in Slots using @VM setting sPos If Slot NE '' then WoWaferQty = WoWaferQty + 1 end Next Slot end WafersWithValues = 0 for WaferIdx = 1 to 25 ThicknessValue = WoMatRec If ThicknessValue NE '' then WafersWithValues += 1 Next WaferIdx if WafersWithValues GE WoWaferQty then Response = True$ end Until Response EQ True$ Next stageIdx end if Response NE True$ then Response = False$ end service