diff --git a/LSL2/STPROC/ENVIRONMENT_SERVICES.txt b/LSL2/STPROC/ENVIRONMENT_SERVICES.txt index af0965e..10a01f7 100644 --- a/LSL2/STPROC/ENVIRONMENT_SERVICES.txt +++ b/LSL2/STPROC/ENVIRONMENT_SERVICES.txt @@ -36,7 +36,7 @@ Function Environment_Services(@Service, @Params) #pragma precomp SRP_PreCompiler -$insert LOGICAL +$insert APP_INSERTS $insert SERVICE_SETUP $insert SRPMail_Inserts @@ -553,7 +553,20 @@ Service GetEnvironmentVariable(VariableName) end service + +Service GetServiceManagerPort() + + FilePath = Drive():'\SRPEngineServer.ini' + OSRead IniFile from FilePath then + CharIndex = Index(IniFile, 'Port', 1) + Line = IniFile[CharIndex, 'F':CRLF$] + Response = Trim(Line[-1, 'B=']) + end + +end service + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + diff --git a/LSL2/STPROC/METROLOGY_SERVICES.txt b/LSL2/STPROC/METROLOGY_SERVICES.txt index 616e8b8..e8b688e 100644 --- a/LSL2/STPROC/METROLOGY_SERVICES.txt +++ b/LSL2/STPROC/METROLOGY_SERVICES.txt @@ -1259,7 +1259,6 @@ end service Service ImportCDEQualData(RunData, ResourceID, PSN) Machine = 'CDE' - ResourceID = Field(FileName, ' ', 1, 1) URL = "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV3/":ResourceID:"/header" TimeoutDuration = HTTPClient_Services('GetTimeoutDuration') If TimeoutDuration NE 30 then Httpclient_Services('SetTimeoutDuration', 30) @@ -3273,3 +3272,4 @@ LoadRunDataToDatabase: return + diff --git a/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt b/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt index 9241002..470bdca 100644 --- a/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt +++ b/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt @@ -300,18 +300,10 @@ return SendCommand: // Call the SRPEngineService and pass it the command - Server = Environment_Services('GetServer') - TCPServerSettings@ = Environment_Services('GetApplicationRootIP') - Convert '\\' to '' in TCPServerSettings@ - // Get the port from the SRPEngineServer.ini file instead. - FilePath = Drive():'\SRPEngineServer.ini' - OSRead IniFile from FilePath then - CharIndex = Index(IniFile, 'Port', 1) - Line = IniFile[CharIndex, 'F':CRLF$] - Port = Trim(Line[-1, 'B=']) - TCPServerSettings@<2> = Port - end - + Server = Environment_Services('GetServer') + TCPServerSettings@ = Environment_Services('GetApplicationRootIP') + Convert '\\' to '' in TCPServerSettings@ + TCPServerSettings@<2> = Environment_Services('GetServiceManagerPort') TcpClientHandle = 0 If SRP_TcpClient(TcpClientHandle, 'CONNECT', TCPServerSettings@<1>, TCPServerSettings@<2>) then SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command) diff --git a/LSL2/STPROC/SERVICE_SERVICES.txt b/LSL2/STPROC/SERVICE_SERVICES.txt index cdd1902..dabd46a 100644 --- a/LSL2/STPROC/SERVICE_SERVICES.txt +++ b/LSL2/STPROC/SERVICE_SERVICES.txt @@ -40,9 +40,10 @@ Equ Comma$ to ',' Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@ Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime -Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services +Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services, +Declare function SRP_TCPClient Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services -Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes +Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes, SRP_TCPClient LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ProcQueue' LogDate = Oconv(Date(), 'D4/') @@ -166,104 +167,145 @@ end service Service ProcessProcedureQueue() - // Loop through the procedure queue until we can find a process request that is not yet locked - // (i.e., already being crunched on by another engine). Process that one request and then end. - Open 'PROC_QUEUE' to hProcQueue then - Select hProcQueue - EOF = False$ - Done = False$ - Loop - ReadNext RequestKeyID else EOF = True$ - Until EOF or Done - Lock hProcQueue, RequestKeyID then - DeleteRequest = True$ - Server = Environment_Services('GetServer') - Done = True$ - Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId) - RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID) - If RequestRow NE '' then - Procedure = RequestRow - Procedure = UCase(Procedure) - Params = RequestRow - If Procedure NE '' then - Dim ProcParams(12) - For each Param in Params using @VM setting pPos - ProcParams(pPos) = Param - Next Param - NumArguments = DCount(Params, @VM) - - Begin Case - Case NumArguments EQ 0 ; Call @Procedure() - Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1)) - Case NumArguments EQ 2 ; Call @Procedure(ProcParams(1), ProcParams(2)) - Case NumArguments EQ 3 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3)) - Case NumArguments EQ 4 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4)) - Case NumArguments EQ 5 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5)) - Case NumArguments EQ 6 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6)) - Case NumArguments EQ 7 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7)) - Case NumArguments EQ 8 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8)) - Case NumArguments EQ 9 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9)) - Case NumArguments EQ 10 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10)) - Case NumArguments EQ 11 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10), ProcParams(11)) - Case Otherwise$ - Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.') - End Case - end - - Swap @VM with ',' in Params - LogData = LoggingDTM - LogData<2> = Server - LogData<3> = RequestKeyId - LogData<4> = Procedure - LogData<5> = Params - ErrCode = '' - If ( Get_Status(ErrCode) or Error_Services('HasError') ) then - NumAttempts = RequestRow + 1 - ErrorMessage = Error_Services('GetMessage') - If NumAttempts LT 3 then - DeleteRequest = False$ - RequestRow = NumAttempts - RequestRow = Datetime() - RequestRow = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode - Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyId, RequestRow, True$, False$, False$) - end else - // Notify OI_SYSADMIN group - Recipients = '' - SentFrom = 'SYSTEM' - Subject = 'Background Procedure Queue Error' - Message = OConv(Datetime(), 'DT2/^H') - Message<2> = 'Error on server ':Server - Message<3> = 'Stored Procedure: ':Procedure - StatCodes = 'Parameters: ':Params - Message<4> = 'Error_Services error message: ':ErrorMessage - Message<5> = 'Get_Status error code: ':ErrCode - Swap @FM with \0D0A\ in Message - AttachWindow = '' - AttachKey = '' - SendToGroup = 'OI_SYSADMIN' - Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup - obj_Notes('Create',Parms) - - // Move request to PROC_QUEUE_FAILED - RequestRow = NumAttempts - RequestRow = Datetime() - RequestRow = 'Error_Services error message: ':ErrorMessage:'Get_Status error code: ':ErrCode - Database_Services('WriteDataRow', 'PROC_QUEUE_FAILED', RequestKeyId, RequestRow, True$, False$, False$) - end - LogData<6> = 'Failed' - LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode - end else - LogData<6> = 'Success' - end - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - end - If DeleteRequest then - Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) + hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') + Lock hSysLists, ServiceKeyID then + ServerIP = Environment_Services('GetApplicationRootIP') + ServerPort = Environment_Services('GetServiceManagerPort') + Convert '\' to '' in ServerIP + Open 'PROC_QUEUE' to hProcQueue then + Select hProcQueue + EOF = False$ + Loop + ReadNext RequestKeyID else EOF = True$ + Until EOF + TcpClientHandle = 0 + If SRP_TcpClient(TcpClientHandle, 'CONNECT', ServerIP, ServerPort) then + Command = 'RUN SERVICE_SERVICES "ProcessRequest", ':Quote(RequestKeyID) + SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command) + SRP_TcpClient(TcpClientHandle, 'CLOSE_SES') end - Unlock hProcQueue, RequestKeyID else Null - end - Repeat - end + Repeat + end + Unlock hSysLists, ServiceKeyID else Null + end + +end service + + +Service ProcessRequest(RequestKeyID) + + If RequestKeyID NE '' then + DeleteRequest = True$ + Server = Environment_Services('GetServer') + Done = True$ + If RowExists('PROC_QUEUE', RequestKeyID) then + RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID) + If RequestRow NE '' then + Procedure = RequestRow + Procedure = UCase(Procedure) + Params = RequestRow + If Procedure NE '' then + Dim ProcParams(12) + For each Param in Params using @VM setting pPos + ProcParams(pPos) = Param + Next Param + NumArguments = DCount(Params, @VM) + + Begin Case + Case NumArguments EQ 0 ; Call @Procedure() + Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1)) + Case NumArguments EQ 2 ; Call @Procedure(ProcParams(1), ProcParams(2)) + Case NumArguments EQ 3 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3)) + Case NumArguments EQ 4 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4)) + Case NumArguments EQ 5 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5)) + Case NumArguments EQ 6 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6)) + Case NumArguments EQ 7 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7)) + Case NumArguments EQ 8 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8)) + Case NumArguments EQ 9 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9)) + Case NumArguments EQ 10 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10)) + Case NumArguments EQ 11 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10), ProcParams(11)) + Case Otherwise$ + Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.') + End Case + end + + Swap @VM with ',' in Params + LogData = LoggingDTM + LogData<2> = Server + LogData<3> = RequestKeyId + LogData<4> = Procedure + LogData<5> = Params + ErrCode = '' + If ( Get_Status(ErrCode) or Error_Services('HasError') ) then + NumAttempts = RequestRow + 1 + ErrorMessage = Error_Services('GetMessage') + If NumAttempts LT 3 then + DeleteRequest = False$ + RequestRow = NumAttempts + RequestRow = Datetime() + RequestRow = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode + Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyId, RequestRow, True$, False$, False$) + end else + // Notify OI_SYSADMIN group + Recipients = '' + SentFrom = 'SYSTEM' + Subject = 'Background Procedure Queue Error' + Message = OConv(Datetime(), 'DT2/^H') + Message<2> = 'Error on server ':Server + Message<3> = 'Stored Procedure: ':Procedure + StatCodes = 'Parameters: ':Params + Message<4> = 'Error_Services error message: ':ErrorMessage + Message<5> = 'Get_Status error code: ':ErrCode + Swap @FM with \0D0A\ in Message + AttachWindow = '' + AttachKey = '' + SendToGroup = 'OI_SYSADMIN' + Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup + obj_Notes('Create',Parms) + // Move request to PROC_QUEUE_FAILED + RequestRow = NumAttempts + RequestRow = Datetime() + RequestRow = 'Error_Services error message: ':ErrorMessage:'Get_Status error code: ':ErrCode + Database_Services('WriteDataRow', 'PROC_QUEUE_FAILED', RequestKeyId, RequestRow, True$, False$, False$) + end + LogData<6> = 'Failed' + LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode + end else + LogData<6> = 'Success' + end + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end else + DeleteRequest = False$ + // Failed to read request record. + ErrorMessage = Error_Services('GetMessage') + LogData = LoggingDTM + LogData<2> = Server + LogData<3> = RequestKeyId + LogData<4> = '' + LogData<5> = '' + LogData<6> = 'Failed' + LogData<7> = 'Failed to read request record. Error_Services error message: ':ErrorMessage + ErrCode = '' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + // Notify OI_SYSADMIN group + Recipients = '' + SentFrom = 'SYSTEM' + Subject = 'Background Procedure Queue Error' + Message = OConv(Datetime(), 'DT2/^H') + Message<2> = 'Error on server ':Server + Message<3> = 'Failed to read request record. Error_Services error message: ':ErrorMessage + Swap @FM with \0D0A\ in Message + AttachWindow = '' + AttachKey = '' + SendToGroup = 'OI_SYSADMIN' + Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup + obj_Notes('Create',Parms) + end + If DeleteRequest then + Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) + end + end + end end service