Function Wafer_Counter_Services(@Service, @Params) /*********************************************************************************************************************** This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written permission from SRP Computer Solutions, Inc. Name : Wafer_Counter_Services Description : Handler program for all module related services. Notes : The generic parameters should contain all the necessary information to process the services. Often this will be information like the data Record and Key ID. 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) 09/26/23 djs Adapted from FlatFinder_Services. ***********************************************************************************************************************/ #pragma precomp SRP_PreCompiler $insert LOGICAL $insert SERVICE_SETUP $insert RDS_EQUATES $insert WO_LOG_EQUATES $insert WM_OUT_EQUATES Equ Tab$ to \09\ Equ CRLF$ to \0D0A\ Equ LF$ to \0A\ Equ Comma$ to ',' Declare subroutine Error_Services, Database_Services, Logging_Services Declare function Database_Services, Environment_Services, Logging_Services LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WaferCounter' LogDate = Oconv(Date(), 'D4/') LogTime = Oconv(Time(), 'MTS') LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Wafer Counter Import Log.csv' Headers = 'Logging DTM':@FM:'ToolID':@FM:'Operation':@FM:'Datetime':@FM:'LotID':@FM:'CassNo':@FM:'Wafer Count':@FM:'Import Result' objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$) LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM GoToService else Error_Services('Set', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.') end Return Response else '' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Services //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------------------------------------------------- // ImportWaferCounterFiles // // Looks for available wafer counter CSV files that are ready to be imported into the RDS table. //---------------------------------------------------------------------------------------------------------------------- Service ImportWaferCounterFiles() hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') Lock hSysLists, ServiceKeyID then DataPath = Environment_Services('GetApplicationRootPath') : '\WaferCounter\' BackupPath = Environment_Services('GetApplicationRootPath') : '\WaferCounter\BackupFiles\' InitDir DataPath : '*.csv' FileList = DirList() For Each File in FileList using @FM OSRead WaferCounterData from DataPath : File then BackupDate = Oconv(Date(), 'D4/') BackupTime = Oconv(Time(), 'MTS') Convert ':' to '-' in BackupTime BackupFileName = BackupDate[7, 4] : '-' : BackupDate[1, 2] : '-' : BackupDate[4, 2] : '-' : BackupTime : ' ' : File If Count(File, '-') LE 1 then OSWrite WaferCounterData to BackupPath : BackupFileName end Swap CRLF$ with '' in WaferCounterData Swap ',' with @FM in WaferCounterData ToolID = Trim(WaferCounterData<2>) Operation = Trim(WaferCounterData<3>) Datetime = IConv(Trim(WaferCounterData<4>), 'DT') ReferenceKeyID = Trim(WaferCounterData<5>) CassetteNo = Trim(WaferCounterData<6>) WaferCount = Trim(WaferCounterData<7>) Result = False$ LogData = LoggingDTM LogData<2> = ToolID LogData<3> = Operation LogData<4> = Trim(WaferCounterData<4>) LogData<5> = ReferenceKeyID LogData<6> = CassetteNo LogData<7> = WaferCount If ReferenceKeyID[1, 2] EQ '1T' or ReferenceKeyID[1, 1] EQ 'O' then Convert 'O' to '' in ReferenceKeyID Swap '1T' with '' in ReferenceKeyID If Index(ReferenceKeyID, '.', 1) then // A dot means this is a WorkOrderNo.Cassette value. Need to create a WM_OUT Key ID. WorkOrderNo = ReferenceKeyID[1, '.'] WOStepKeyID = ReferenceKeyID[Col2() + 1, '.'] CassetteNo = ReferenceKeyID[Col2() + 1, '.'] WMOutKeyID = WorkOrderNo : '*' : WOStepKeyID : '*' : CassetteNo WMOutRow = Database_Services('ReadDataRow', 'WM_OUT', WMOutKeyID) If Error_Services('NoError') then WMOutRow = DateTime WMOutRow = WaferCount Database_Services('WriteDataRow', 'WM_OUT', WMOutKeyID, WMOutRow, True$, False$, True$) end end else // No dot in the reference key means this is an RDS Key ID. Transfer ReferenceKeyID to RDSKeyID If Num(RDSKeyID) then RDSKeyID = RDSKeyID + 0 RDSRow = Database_Services('ReadDataRow', 'RDS', RDSKeyID) If Error_Services('NoError') then RDSRow = DateTime RDSRow = WaferCount Database_Services('WriteDataRow', 'RDS', RDSKeyID, RDSRow, True$, False$, True$) end end If Error_Services('NoError') then Result = 'Success' end else Result = 'Failure: ':Error_Services('GetMessage') end end else // Throw error - either invalid barcode scanned or user manually entered data Result = 'Failure: ReferenceKeyID "':ReferenceKeyID:'" is invalid.' end LogData<8> = Result Logging_Services('AppendLog', objLog, LogData, @RM, @FM) OSDelete DataPath : File end Next File Unlock hSysLists, ServiceKeyID else Null end end service //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////