From ab8f9d3c24573dbe27c9feda3f373e3f6635674d Mon Sep 17 00:00:00 2001 From: "Infineon\\StieberD" Date: Thu, 12 Dec 2024 13:24:48 -0700 Subject: [PATCH] Alarm trigger with NICA_ORDERS table solution tested and ready for deployment updated SRP_Git_Services to handle creating local copies of inherited entities updated HgCV OCAP order trigger to also look for active prove-in orders moved error services common into sysprog to avoid compilation issues --- FRAMEWORKS/STPROC/ERROR_SERVICES.txt | 9 +- LSL2/STPROC/COMM_REACTOR_LOG.txt | 34 +- LSL2/STPROC/DEBUGGER_LOGGER.txt | 55 + LSL2/STPROC/ERROR_SERVICES.txt | 403 +++++ LSL2/STPROC/HTTPCLIENT_SERVICES.txt | 875 +++++++++++ LSL2/STPROC/METROLOGY_SERVICES.txt | 83 +- LSL2/STPROC/NICA_ORDERS_SERVICES.txt | 565 +++++++ LSL2/STPROC/PROVE_IN_OVERRIDE_EVENTS.txt | 187 +-- LSL2/STPROC/REACTORLOGS_API.txt | 17 +- LSL2/STPROC/REACTOR_ACTIONS.txt | 232 +++ LSL2/STPROC/REACTOR_LOG_ACTIONS.txt | 64 +- LSL2/STPROC/REACTOR_LOG_SERVICES.txt | 387 +---- LSL2/STPROC/REACTOR_MODES_SERVICES.txt | 21 +- LSL2/STPROC/REACTOR_SERVICES.txt | 1485 ++++++++----------- LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt | 115 +- LSL2/STPROC/SERVICE_SERVICES.txt | 59 +- LSL2/STPROC/WO_DAILY_SCHED_ALL_COMM.txt | 57 +- LSL2/STPROCINS/IQS_VIOL_DATA_EQUATES.txt | 13 + LSL2/STPROCINS/NICA_ORDERS_EQUATES.txt | 16 + LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt | 16 +- LSL2/STPROCINS/REACTOR_EQUATES.txt | 6 +- SYSPROG/STPROC/ERROR_SERVICES.txt | 9 +- SYSPROG/STPROC/SRP_GIT_SERVICES.txt | 26 +- SYSPROG/STPROCINS/ERROR_SERVICES_COMMON.txt | 4 + 24 files changed, 3167 insertions(+), 1571 deletions(-) create mode 100644 LSL2/STPROC/DEBUGGER_LOGGER.txt create mode 100644 LSL2/STPROC/ERROR_SERVICES.txt create mode 100644 LSL2/STPROC/HTTPCLIENT_SERVICES.txt create mode 100644 LSL2/STPROC/NICA_ORDERS_SERVICES.txt create mode 100644 LSL2/STPROC/REACTOR_ACTIONS.txt create mode 100644 LSL2/STPROCINS/IQS_VIOL_DATA_EQUATES.txt create mode 100644 LSL2/STPROCINS/NICA_ORDERS_EQUATES.txt create mode 100644 SYSPROG/STPROCINS/ERROR_SERVICES_COMMON.txt diff --git a/FRAMEWORKS/STPROC/ERROR_SERVICES.txt b/FRAMEWORKS/STPROC/ERROR_SERVICES.txt index 3dea632..65e0163 100644 --- a/FRAMEWORKS/STPROC/ERROR_SERVICES.txt +++ b/FRAMEWORKS/STPROC/ERROR_SERVICES.txt @@ -72,10 +72,11 @@ Function Error_Services(@Service, @Params) #pragma precomp SRP_PreCompiler -$insert LOGICAL +$Insert LOGICAL $Insert MSG_EQUATES -$insert RTI_DEBUG_COMMON -$insert SRPMail_Inserts +$Insert RTI_DEBUG_COMMON +$Insert SRPMail_Inserts +$Insert ERROR_SERVICES_COMMON Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 @@ -98,8 +99,6 @@ If Assigned(Response) else Response = '' AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display. -Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, Unused5@, Unused6@, Unused7@, Unused8@ - Declare function RetStack, Error_Services, SRPSendMail Declare subroutine Error_Services diff --git a/LSL2/STPROC/COMM_REACTOR_LOG.txt b/LSL2/STPROC/COMM_REACTOR_LOG.txt index 604aa97..82bb38a 100644 --- a/LSL2/STPROC/COMM_REACTOR_LOG.txt +++ b/LSL2/STPROC/COMM_REACTOR_LOG.txt @@ -14,12 +14,13 @@ Declare Subroutine obj_Tables, Print_RootCause_Analysis, Database_Services, obj_ Declare Subroutine ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, Dialog_Box, Yield Declare Subroutine obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, obj_Reactor_Log, obj_Post_Log Declare Subroutine Reactor_Log_Events, Reactor_Log_Services, Error_Services, React_Servs_Services, Reactor_Services -Declare Subroutine Override_Log_Services, SRP_List +Declare Subroutine Override_Log_Services, SRP_List, Nica_Orders_Services Declare Function Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, EntID, Repository, NextKey Declare Function Send_Message, Msg, Security_Check, obj_React_Item, Select_Into, MemberOf, Create_Dialog, obj_Calendar Declare Function GetAsyncKeyState, obj_Tables, MemberOf, Environment_Services, Database_Services, Rds_Services -Declare function Reactor_Services, Error_Services, React_Servs_Services, Reactor_Log_Services, Send_Event, SRP_List +Declare Function Reactor_Services, Error_Services, React_Servs_Services, Reactor_Log_Services, Send_Event, SRP_List +Declare Function Nica_Orders_Services $Insert MSG_EQUATES $Insert APPCOLORS @@ -676,8 +677,9 @@ TechSign: If Valid then SuccessfulSign = Reactor_Log_Services('SignReactorLog', ReactorLogNo, @USER4) If SuccessfulSign EQ 0 then - Error_Services('DisplayError') - ActiveChecklist = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_ACTIVE$, 'X') + Error_Services('DisplayError') + ActiveRlNicaOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', ReactorLogNo) + ActiveChecklist = (ActiveRlNicaOrderIds NE '') If ActiveChecklist then OverrideGroups = 'MAINTENANCE':@VM:'SUPERVISOR' UserMsg = "Reactor Log PM must be processed in NICA. Override required from a member of " @@ -685,22 +687,14 @@ TechSign: UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg) Override = UserVerification<1> If Override EQ True$ then - PmOrderIds = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_ORDER_ID$, 'X') - PmOrderList = SRP_List('Create', PmOrderIds, @VM) - PmTypes = Xlate('REACTOR_LOG', ReactorLogNo, REACTOR_LOG_CHECKLIST_TYPE$, 'X') - PmTypeList = SRP_List('Create', PmTypes, @VM) - ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2> - - ResponseComment = '' - For each PmType in PmTypes using @VM setting Idx - PmOrderId = SRP_List('GetAt', PmOrderList, Idx) - Reactor_Log_Services('CancelReactorLogPMOrder', ReactorLogNo, PmOrderId) - If ResponseComment NE '' then - ResponseComment := ', ' - end - ResponseComment := PmType - Next ProveInType + ResponseComment = '' + ActiveRlNicaOrderTypes = Xlate('NICA_ORDERS', ActiveRlNicaOrderIds, 'ORDER_TYPE', 'X') + For each ActiveRlNicaOrderId in ActiveRlNicaOrderIds using @VM setting Idx + Nica_Orders_Services('CancelOrder', ActiveRlNicaOrderId) + If ResponseComment NE '' then ResponseComment := ', ' + ResponseComment := ActiveRlNicaOrderTypes<0, Idx> + Next ActiveRlNicaOrderId Override_Log_Services('Create', 'REACTOR_LOG', ReactorLogNo, UserVerification<2>, ResponseComment, 'REACTOR_LOG_PM') @@ -732,7 +726,6 @@ TechSign: Error_Services('DisplayError') end end - end RETURN @@ -1666,3 +1659,4 @@ ColorRemRiTable: return + diff --git a/LSL2/STPROC/DEBUGGER_LOGGER.txt b/LSL2/STPROC/DEBUGGER_LOGGER.txt new file mode 100644 index 0000000..3d073e6 --- /dev/null +++ b/LSL2/STPROC/DEBUGGER_LOGGER.txt @@ -0,0 +1,55 @@ +Subroutine Debugger_Logger(Void) +/*********************************************************************************************************************** + + 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 Infineon Technologies. + + Name : Debugger_Logger + + Description : Handler program for the logging debug data. + + Notes : This is intended to be invoked by Error_Services("LogStack") (LSL2) so the current program, + Error_Services, is removed from the stack log. + + History : (Date, Initials, Notes) + 01/09/25 djs Original programmer. + +***********************************************************************************************************************/ + +#pragma precomp SRP_PreCompiler + +$insert LOGICAL +$insert RTI_DEBUG_COMMON +$insert ENVIRON_CONSTANTS +$insert ERROR_SERVICES_COMMON + +Equ CRLF$ to \0D0A\ + +Declare function Environment_Services, Logging_Services, GetSessionCallStack, Error_Services, RetStack +Declare subroutine Logging_Services, Get_Status, Set_Env + +Main: + + ErrorMessages = Error_Services('GetMessages') + LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\StackTrace' + LogDate = Oconv(Date(), 'D4/') + LogTime = Oconv(Time(), 'MTS') + LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Error Log.csv' + objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', '', '', False$, False$) + LogData = '' + LogData<1> = CRLF$:'Timestamp: ':LogDate:' ':LogTime + LogData<2> = 'Machine: ':Environment_Services('GetServer') + LogData<3> = 'Set_Status Code:':EsSpStatCode@ + LogData<4> = 'Set_Status Message:':EsSpStatMessage@ + Swap @FM with @VM in ErrorMessages + LogData<5> = 'Error_Services Messages:':ErrorMessages + LogData<6> = 'Call Depth: ':CallDepth@ + LogData<7> = 'Curr Program and line no: ':CallStack@<2,1>:@VM:CallStack@<2,2> + LogData<8> = 'Call Stack / Line Nos: ' + Stack = CallStack@ + Stack = Delete(Stack, 1, 0, 0) + LogData<9> = Stack:CRLF$ + Logging_Services('AppendLog', objLog, LogData, @FM, @VM, '', '', '') + +Return + diff --git a/LSL2/STPROC/ERROR_SERVICES.txt b/LSL2/STPROC/ERROR_SERVICES.txt new file mode 100644 index 0000000..85c96ee --- /dev/null +++ b/LSL2/STPROC/ERROR_SERVICES.txt @@ -0,0 +1,403 @@ +Function Error_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 : Error_Services + + Description : Handler program for all error 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. + + - The 'Set' service request is the equivelent to the various forms of setting an error within Basic+ + (e.g., Set_Status, Set_FSError, Set_EventStatus). This will clear out any pre-existing error(s) + first (see 'Clear' service request description below). In most cases the 'Add' service request + (see below) should be used since error conditions are intended to be automatically cleared by + service modules or properly managed stored procedures. + + - The 'Add' service request is similar to the 'Set' service request but it will not clear out any + pre-existing errors. Using 'Add', the error conditions can be stacked allowing the higher level + calling procedures the ability to contribute to the existing error or add additional errors. + + - The 'Clear' service request will reset all of the error condition flags. + + 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 + + History : (Date, Initials, Notes) + 12/28/12 dmb Original programmer. + 12/31/12 dmb Add hooks for various service requests. Add comments in the Notes section to explain the + theory of operation of Error Services. + 01/01/13 dmb Add functionality to the Set, Add, GetMessage, and GetMessages service requests. + 01/02/13 dmb Remove reference to SERVICES_SETUP and put the Assigned command lines directly into this + code to avoid infinite loop problem. + 01/05/13 dmb Added HasError service request. + 03/13/13 dmb [SRPFW-9] Added NoError service request. + 10/01/13 dmb [SRPFW-18] Replace APP_INSERTS with LOGICAL and declare Error_Services. + 10/06/13 dmb [SRPFW-17] Retrofit to use the default FrameWorks system font. + 03/20/17 fjt [SRPFW-160] Conversion to EB+; addition of justification parameter to display. + 10/09/17 dmb Add SendRuntimeAlert service to act as a debugger intercept process. + +***********************************************************************************************************************/ + +#pragma precomp SRP_PreCompiler + +$Insert LOGICAL +$Insert MSG_EQUATES +$Insert RTI_DEBUG_COMMON +$Insert SRPMail_Inserts +$Insert ERROR_SERVICES_COMMON +$Insert ENVIRON_CONSTANTS + +Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 + +// Make sure any request parameters which have not been assigned are nulled. +// Normally these would be referenced in the SERVICES_SETUP insert but there is a call to ERROR_SERVICES in that +// insert which causes an infinite loop to occur. +If Assigned(Service) else Service = '' +If Assigned(Error) else Error = '' +If Assigned(Param1) else Param1 = '' +If Assigned(Param2) else Param2 = '' +If Assigned(Param3) else Param3 = '' +If Assigned(Param4) else Param4 = '' +If Assigned(Param5) else Param5 = '' +If Assigned(Param6) else Param6 = '' +If Assigned(Param7) else Param7 = '' +If Assigned(Param8) else Param8 = '' +If Assigned(Param9) else Param9 = '' +If Assigned(Param10) else Param10 = '' +If Assigned(Response) else Response = '' + +AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display. + +Declare function RetStack, Error_Services, SRPSendMail, Get_Env +Declare subroutine Error_Services, Set_Env, Set_Status + +GoToService else + Error_Services('Set', Service : ' is not a valid service request within the Error services module.') +end + +Return Response else '' + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Service Parameter Options +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Options BOOLEAN = True$, False$ + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Services +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------------------------------------------------- +// Set +// +// Param1 - Error message. Messages should be fairly descriptive. +// +// Sets an error to the stack. This will automatically clear any existing error conditions first so this error will +// be the only one on the stack. +//---------------------------------------------------------------------------------------------------------------------- +Service Set(ErrorMessage) + + Error_Services('Clear') + Error_Services('Add', ErrorMessage) + + If AutoDisplayErrors then Error_Services('DisplayError') + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// Add +// +// Param1 - Error message. Messages should be fairly descriptive. +// +// Adds an error to the stack. This will not clear existing error conditions first. It is intended to allow higher level +// routines to add more information to an existing error condition or simply to maintain an ongoing error log for some +// troubleshooting or debugging purposes. +//---------------------------------------------------------------------------------------------------------------------- +Service Add(ErrorMessage) + + CurStack = RetStack() + AtSelf = CurStack[1, @FM] ; // AtSelf should be the name of this routine (e.g., ERROR_SERVICES) + Loop + CurRoutine = CurStack[1, @FM] ; // Get the next routine from the program call stack. + Until CurRoutine _NEC AtSelf + CurStack = Delete(CurStack, 1, 0, 0) ; // Remove any self-references from the program call stack. + Repeat + Convert @FM to @VM in CurStack ; // Convert the delimiter so it can be added to the global common. + + If Len(ErrorMessages@) then + ErrorMessages@ := @FM : ErrorMessage + RetStacks@ := @FM : CurStack + end else + ErrorMessages@ = ErrorMessage + RetStacks@ = CurStack + end + + If AutoDisplayErrors then Error_Services('DisplayError') + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// Clear +// +// Clears all error conditions and related information. +//---------------------------------------------------------------------------------------------------------------------- +Service Clear() + + ErrorMessages@ = '' + ErrorSources@ = '' + ErrorCodes@ = '' + RetStacks@ = '' + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetMessage +// +// Returns the most current error message. +//---------------------------------------------------------------------------------------------------------------------- +Service GetMessage() + + Response = ErrorMessages@[-1, 'B' : @FM] + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetMessages +// +// Returns the stack of error messages. This will be @FM delimited. +//---------------------------------------------------------------------------------------------------------------------- +Service GetMessages() + + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = ErrorMessages@ + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// HasError +// +// Returns True if there is an error condition, False if there is no error condition. Caller will still need to use +// the GetMessage or GetMessages service to determine what the error is. The HasError service allows the caller to +// embed the Error_Services service call inside of a conditional statement like this: +// +// If Error_Services('HasError') then +// * An error has occured. Proceed accordingly. +// ErrorMessage = Error_Services('GetMessage') +// end else +// * No error has occured. +// end +//---------------------------------------------------------------------------------------------------------------------- +Service HasError() + + If Len(ErrorMessages@) then + Response = True$ + end else + Response = False$ + end + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// NoError +// +// Returns True if there are no error conditions, False if there is an error condition. This is the opposite of the +// HasError service and exists for improved readability. +//---------------------------------------------------------------------------------------------------------------------- +Service NoError() + + If Len(ErrorMessages@) then + Response = False$ + end else + Response = True$ + end + +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// DisplayError +// +// Displays the current error message to the end user. +//---------------------------------------------------------------------------------------------------------------------- +Service DisplayError(Justification) + + ErrorMessage = Error_Services('GetMessage') + If Len(ErrorMessage) then + MsgStruct = '' + MsgStruct = ErrorMessage + MsgStruct = 'BO' + MsgStruct = 'W' + MsgStruct = '!' + MsgStruct = -1 + MsgStruct = -1 + MsgStruct = Justification + MsgStruct = 'Error Services' + MsgStruct = Segoe_UI$ + Msg(@Window, MsgStruct) + end + +End Service + + +Service GetSource() + + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = '' + +End Service + + +Service GetSources() + + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = '' + +End Service + + +Service GetCode() + + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = '' + +End Service + + +Service GetCodes() + + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = '' + +End Service + + +Service GetStackTrace() + // Business logic goes here. Data that needs to be returned should be assigned to the Response parameter. + Response = '' +End Service + + +//---------------------------------------------------------------------------------------------------------------------- +// LogStack +// +// Uses a custom debugger intercept to log the stack including line numbers to .../LogFiles/StackTrace. +//---------------------------------------------------------------------------------------------------------------------- +Service LogStack() + + DebuggerEnabled = Get_Env(ENV_DEBUGGER_ENABLED$) + DebuggerIntercept = Get_Env(ENV_DEBUGGER_INTERCEPT_PROC$) + Set_Env(ENV_DEBUGGER_ENABLED$, 2, 1) + Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, 'DEBUGGER_LOGGER', 1) + // Save the current status code and message before forcing runtime error + // to get OI to update stack variables in RTI_DEBUG_COMMON. + EsSpStatCode@ = Get_Status(EsSpStatMessage@) + ForceRuntimeError = 1/0 + Set_Env(ENV_DEBUGGER_ENABLED$, DebuggerEnabled, 1) + Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, DebuggerIntercept, 1) + // Restore OI status variables so we don't break any logic relying on it. + Set_Status(EsSpStatCode@, EsSpStatMessage@) + +end service + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Internal GoSubs +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////? + +//---------------------------------------------------------------------------------------------------------------------- +// SendRuntimeAlert +// +// Sends out an email alert when this service is called as a debugger intercept. +//---------------------------------------------------------------------------------------------------------------------- +SendRuntimeAlert: + + Done = False$ + Error = False$ + Program = Curr_Program@ + MsgSent = '' + + If Program EQ '' then Program = 'Error Services' + + ConfigFile = '' + ConfigFile<1> = SendUsing_Port$ + ConfigFile<2> = '' + ConfigFile<3> = '' ; // Server port + ConfigFile<4> = '' ; // Mail server + ConfigFile<5> = True$ ; // Authenticate + ConfigFile<6> = '' ; // Username + ConfigFile<7> = '' ; // Password + ConfigFile<8> = False$ ; // Use SSL + + Text = '' + Text<-1> = 'App: ' : @APPID<1> + Text<-1> = 'Window: ' : @WINDOW + Text<-1> = 'User: ' : @USERNAME + Text<-1> = 'Station: ' : @STATION + Text<-1> = ' ' + Text<-1> = 'SP Status: ' : SPStatus@ + Text<-1> = 'SP Stat Code: ' : SPStatCode@ + Text<-1> = 'Program: ' : Program + Text<-1> = 'Call Depth: ' : CallDepth@ + Text<-1> = 'Line No: ' : LineNo@ + Text<-1> = ' ' + Text<-1> = 'Stack: ' + Text<-1> = CallStack@ + Convert \00\ TO ',' in Text + Swap @VM with ':@VM:' IN Text + Swap @FM with Char(13) : Char(10) IN Text + Swap @TM with Char(13) : Char(10) IN Text + + SentFrom = '' + SentTo = '' + Message = '' + Message<1> = '' : Program ; // Subject + Message<2> = SentFrom ; // From (email address) + Message<3> = SentTo ; // Send to (email address) + Message<5> = '' ; // Blind Carbon Copy (email address) + Message<6> = '' ; // Reply To (email address) + Message<7> = 'TEXT' ; // Content Type (TEXT or HTML) + Message<8> = Text ; // Content / Body + Message<9> = '' ; // Attachment(s) (path to file name(s)) + + MsgSent = SRPSendMail(Message, ConfigFile) + +return diff --git a/LSL2/STPROC/HTTPCLIENT_SERVICES.txt b/LSL2/STPROC/HTTPCLIENT_SERVICES.txt new file mode 100644 index 0000000..4d6c849 --- /dev/null +++ b/LSL2/STPROC/HTTPCLIENT_SERVICES.txt @@ -0,0 +1,875 @@ +Function HTTPClient_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 : HTTPClient_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) + 03/28/16 dmb [SRPFW-120] Original programmer. + 07/01/17 dmb [SRPFW-184] Refactor using Enhanced BASIC+ syntax. + 05/19/18 dmb [SRPFW-235] Check for content in the HeaderList variable before calling the For Each loop. + 11/15/18 dmb [SRPFW-238] Add ClientCertPath argument to the SendHTTPRequest service to support + client-side certificates. + 02/28/19 dmb Change UseXMLHTTP argument to UseClientXMLHTTP in the SendHTTPRequest service to make it + easier to interpret. + 02/09/20 dmb [SRPFW-309] Fix a bug in the SendHTTPRequest service so that request headers are properly + parsed. All colons were erroneously being converted to @VM instead of the first colon (which + separated the header name from the header value). + 02/09/20 dmb [SRPFW-309] Update the SetResponseHeaderField service to better support Set-Cookie headers. + Allow multiple cookie names to be stored but only store the value of the last cookie name + if it is duplicated. + 02/09/20 dmb [SRPFW-309] Update the GetResponseHeaderField by adding a Delimiter argument so the caller + can specify an alternative delimiter for the values being returned. + 02/09/20 dmb [SRPFW-309] Add GetCookies service to make it easier to view all cookies returned in the + response. + 02/09/20 dmb [SRPFW-309] Add GetCookie service to make it easier to see the entire cookie string of a + specified cookie. + 02/10/20 dmb [SRPFW-309] Update the GetCookie service to include an IgnoreAttributes argument. If this + is True$, then only the cookie name and value will be returned. + 12/19/24 djs Created LSL version of service module. Added IgnoreCertErrors parameter to SendHttpRequest service. + +***********************************************************************************************************************/ + +#pragma precomp SRP_PreCompiler + +$insert LOGICAL +$insert SERVICE_SETUP + +Equ CRLF$ to \0D0A\ +// The readyState property will have this value when the request has returned from the server. +// http://msdn.microsoft.com/en-us/library/ms753800(v=vs.85).aspx +Equ HTTP_COMPLETED$ to 4 + +Equ SXH_SERVER_CERT_IGNORE_UNKNOWN_CA$ to 256 ; // Unknown certificate authority +Equ SXH_SERVER_CERT_IGNORE_WRONG_USAGE$ to 512 ; // Malformed certificate such as a certificate with no subject name. +Equ SXH_SERVER_CERT_IGNORE_CERT_CN_INVALID$ to 4096 ; // Mismatch between the visited hostname and the certificate name being used on the server. +Equ SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID$ to 8192 ; // The date in the certificate is invalid or has expired. +Equ SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS$ to 13056 ; // All certificate errors. + +Common /HTTPClientServices/ RequestHeaderFields@, RequestHeaderValues@, ResponseHeaderFields@, ResponseHeaderValues@, ResponseStatusCode@, ResponseStatusPhrase@, ResponseBody@, TimeoutDuration@ + +Declare function SRP_COM, HTTPClient_Services, GetTickCount, OLECreateInstance, OLEGetProperty, OLECallMethod, OLEStatus +Declare subroutine SRP_COM, HTTPClient_Services, OLEPutProperty + +GoToService else + Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' module.') +end + +Return Response OR '' + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Service Parameter Options +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Options BOOLEAN = True$, False$ +Options RESPONSEHEADERNAMES = 'Access-Control-Allow-Headers', 'Access-Control-Allow-Methods', 'Access-Control-Allow-Origin', 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-Location', 'Content-Disposition', 'Content-Type', 'Date', 'Expires', 'Last-Modified', 'Link', 'Location', 'Retry-After', 'Server', 'Set-Cookie', 'Transfer-Encoding', 'Vary', 'WWW-Authenticate', + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Services +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------------------------------------------------- +// SendHTTPRequest +// +// Method - The HTTP method to submit to the server. - [Required] +// URL - The URL receiving the HTTP request. - [Required] +// HeaderList - An @FM/@VM list of request header names and values. - [Optional] +// Body - The request body to be sent to the server. - [Optional] +// ProxyUser - Username needed to authenticate against a proxy server. - [Optional] +// ProxyPassword - Password needed to authenticate against a proxy server. - [Optional] +// UseAsynchronous - Flag to determine if the HTTP request should be processed asynchronously. Default is True. +// - [Optional] +// UseClientXMLHTTP - Flag to determine if client XMLHTTP or server XMLHTTP should be used. Default is server XMLHTTP. +// - [Optional] +// ClientCertPath - Path to a client-side certificate. This is usually in Location\Certificate Store\Subject format. +// - [Optional] +// +// Calls the indicated HTTP web service routine. +//---------------------------------------------------------------------------------------------------------------------- +Service SendHTTPRequestOLE(Method, URL, HeaderList, Body, ProxyUser, ProxyPassword, UseAsynchronous, UseClientXMLHTTP, ClientCertPath) + + // Defaults. + If UseAsynchronous NE False$ then UseAsynchronous = True$ + If UseClientXMLHTTP NE True$ then UseClientXMLHTTP = False$ + + If (Method NE '') AND (URL NE '') then + // Make sure all prior response settings are cleared before performing the next HTTP request. + HTTPClient_Services('ClearResponseSettings') + + // Attempt to get a handle for the best XMLHTTP object. + objXMLHTTP = '' + If UseClientXMLHTTP then + ServerPrefix = '' + end else + ServerPrefix = 'Server' + end + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.6.0' + objXMLHTTP = OLECreateInstance(XMLHTTPProgID) + Status = OLEStatus() + If Status then + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.3.0' + objXMLHTTP = OLECreateInstance(XMLHTTPProgID) + Status = OLEStatus() + If Status then + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP' + objXMLHTTP = OLECreateInstance(XMLHTTPProgID) + Status = OLEStatus() + If Status then + Error = 'Unable to create a handle to the XMLHTTP object in the ' : Service : ' service.' + Error := ' OLE Error: ' : Status + Error_Services('Add', Error) + end + end + end + + If Error_Services('NoError') then + // Invoke the XMLHTTP object's open method to initialize a request. + rv = OLECallMethod(objXMLHTTP, 'open', Method, URL, UseAsynchronous, ProxyUser, ProxyPassword) + Status = OLEStatus() + If Status then + Error = 'Error calling the open method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' OLE Error: ' : Status + Error_Services('Add', Error) + end + end + +* If Error_Services('NoError') then +* // Set the request header names and values. This will add or update any header fields passed in through this +* // service with those have may have been previously set using the SetRequestHeaderFields or +* // SetRequestHeaderField already. +* If Len(HeaderList) then HTTPClient_Services('SetRequestHeaderFields', HeaderList) +* // Now get all of the request header fields. +* HeaderList = HTTPClient_Services('GetRequestHeaderFields') +* If Error_Services('NoError') then +* If HeaderList NE '' then +* For Each HeaderPair in HeaderList using @FM +* HeaderName = HeaderPair<0, 1> +* HeaderValue = HeaderPair<0, 2> +* SRP_COM(objXMLHTTP, 'CALL', 'setRequestHeader', HeaderName, HeaderValue) +* If SRP_COM('', 'HASERROR') then +* Error = 'Error setting the setRequestHeader property for the ' : HeaderName : ' field in the XMLHTTP object in the ' : Service : ' service.' +* Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') +* Error_Services('Add', Error) +* end +* Next HeaderPair +* end +* end +* end + +* If ClientCertPath NE '' then +* If Error_Services('NoError') then +* // Invoke the XMLHTTP object's setOption method to invoke a certificate. +* rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 3, ClientCertPath) +* If SRP_COM('', 'HASERROR') then +* Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.' +* Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') +* Error_Services('Add', Error) +* end +* end +* end + + If Error_Services('NoError') then + // Invoke the XMLHTTP object's send method to submit the request to the server. + rv = OLECallMethod(objXMLHTTP, 'send', Body) + Status = OLEStatus() + If Status then + Error = 'Error calling the send method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' OLE Error: ' : Status + Error_Services('Add', Error) + end + end + + If Error_Services('NoError') then + If UseAsynchronous then + StartTime = GetTickCount() + TimeoutDuration = HTTPClient_Services('GetTimeoutDuration') + TimedOut = False$ + Loop + ReadyState = OLEGetProperty(objXMLHTTP, 'readyState') + CurrentTime = GetTickCount() + ElapsedTime = Int((CurrentTime - StartTime) / 1000) + TimedOut = ElapsedTime GE TimeoutDuration + While (ReadyState NE HTTP_COMPLETED$) AND Not(TimedOut) + Repeat + end + + // Check the XMLHTTP object's responseBody property to get the server's response. + Response = OLEGetProperty(objXMLHTTP, 'responseBody') + Response1 = OLEGetProperty(objXMLHTTP, 'responseText') + Response2 = objXMLHTTP->responseBody + Response3 = objXMLHTTP->responseText + + Status = OLEStatus() + If Status then + Error = 'Error getting the responseBody property for the XMLHTTP object in the ' : Service : ' service.' + Error := ' OLE Error: ' : Status + Error_Services('Add', Error) + Response = '' + end else + HTTPClient_Services('SetResponseBody', Response) + end + end + + If Error_Services('NoError') then + // If the request was successful, get the response status code, phrase, and response headers and set them + // using HTTPClient_Services so the caller can retrieve is desired. + Code = OLEGetProperty(objXMLHTTP, 'status') + Phrase = Trim(OLEGetProperty(objXMLHTTP, 'statusText')) + HTTPClient_Services('SetResponseStatusCode', Code) + HTTPClient_Services('SetResponseStatusPhrase', Phrase) + + ResponseHeaders = OLECallMethod(objXMLHTTP, 'getAllResponseHeaders') + Swap CRLF$ with @FM in ResponseHeaders + For Each ResponseHeader in ResponseHeaders using @FM + Name = ResponseHeader[1, 'F:'] + Value = Trim(ResponseHeader[Col2() + 1, 9999]) + If (Name NE '') AND (Value NE '') then + HTTPClient_Services('SetResponseHeaderField', Name, Value) + end + Next ResponseHeader + end + + // Make sure all prior request settings are cleared so future HTTP request won't be affected. + Error = Error_Services('GetMessage') ; // Get any pre-existing errors so they can be preserved. + HTTPClient_Services('ClearRequestSettings') ; // This will automatically clear the error stack. + Error_Services('Set', Error) ; // Restore any errors so the caller can check for them. + end else + Error_Services('Add', 'Method or URL argument was missing from the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SendHTTPRequest +// +// Method - The HTTP method to submit to the server. - [Required] +// URL - The URL receiving the HTTP request. - [Required] +// HeaderList - An @FM/@VM list of request header names and values. - [Optional] +// Body - The request body to be sent to the server. - [Optional] +// ProxyUser - Username needed to authenticate against a proxy server. - [Optional] +// ProxyPassword - Password needed to authenticate against a proxy server. - [Optional] +// UseAsynchronous - Flag to determine if the HTTP request should be processed asynchronously. Default is True. +// - [Optional] +// UseClientXMLHTTP - Flag to determine if client XMLHTTP or server XMLHTTP should be used. Default is server XMLHTTP. +// - [Optional] +// ClientCertPath - Path to a client-side certificate. This is usually in Location\Certificate Store\Subject format. +// - [Optional] +// +// Calls the indicated HTTP web service routine. +//---------------------------------------------------------------------------------------------------------------------- +Service SendHTTPRequest(Method, URL, HeaderList, Body, ProxyUser, ProxyPassword, UseAsynchronous, UseClientXMLHTTP, ClientCertPath, IgnoreCertErrors) + + // Defaults. + If UseAsynchronous NE False$ then UseAsynchronous = True$ + If UseClientXMLHTTP NE True$ then UseClientXMLHTTP = False$ + If IgnoreCertErrors NE True$ then IngoreCertErrors = False$ + + If (Method NE '') AND (URL NE '') then + // Make sure all prior response settings are cleared before performing the next HTTP request. + HTTPClient_Services('ClearResponseSettings') + + // Attempt to get a handle for the best XMLHTTP object. + objXMLHTTP = '' + If UseClientXMLHTTP then + ServerPrefix = '' + end else + ServerPrefix = 'Server' + end + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.6.0' + If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP.3.0' + If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else + XMLHTTPProgID = 'Msxml2.' : ServerPrefix : 'XMLHTTP' + If SRP_COM(objXMLHTTP, 'CREATE', XMLHTTPProgID) else + Error = 'Unable to create a handle to the XMLHTTP object in the ' : Service : ' service.' + If SRP_COM('', 'HASERROR') then + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + end + Error_Services('Add', Error) + end + end + end + + If Error_Services('NoError') then + // Invoke the XMLHTTP object's open method to initialize a request. + SRP_COM(objXMLHTTP, 'CALL', 'open', Method, URL, UseAsynchronous, ProxyUser, ProxyPassword) + If SRP_COM('', 'HASERROR') then + Error = 'Error calling the open method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + end + end + + If Error_Services('NoError') then + // Set the request header names and values. This will add or update any header fields passed in through this + // service with those have may have been previously set using the SetRequestHeaderFields or + // SetRequestHeaderField already. + If Len(HeaderList) then HTTPClient_Services('SetRequestHeaderFields', HeaderList) + // Now get all of the request header fields. + HeaderList = HTTPClient_Services('GetRequestHeaderFields') + If Error_Services('NoError') then + If HeaderList NE '' then + For Each HeaderPair in HeaderList using @FM + HeaderName = HeaderPair<0, 1> + HeaderValue = HeaderPair<0, 2> + SRP_COM(objXMLHTTP, 'CALL', 'setRequestHeader', HeaderName, HeaderValue) + If SRP_COM('', 'HASERROR') then + Error = 'Error setting the setRequestHeader property for the ' : HeaderName : ' field in the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + end + Next HeaderPair + end + end + end + + If IgnoreCertErrors then + If Error_Services('NoError') then + rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS$) + If SRP_COM('', 'HASERROR') then + Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + end + end + end + + If ClientCertPath NE '' then + If Error_Services('NoError') then + // Invoke the XMLHTTP object's setOption method to invoke a certificate. + rv = SRP_COM(objXMLHTTP, 'CALL', 'setOption', 3, ClientCertPath) + If SRP_COM('', 'HASERROR') then + Error = 'Error calling the setOption method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + end + end + end + + If Error_Services('NoError') then + // Invoke the XMLHTTP object's send method to submit the request to the server. + rv = SRP_COM(objXMLHTTP, 'CALL', 'send', Body) + If SRP_COM('', 'HASERROR') then + Error = 'Error calling the send method for the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + end + end + + If Error_Services('NoError') then + If UseAsynchronous then + StartTime = GetTickCount() + TimeoutDuration = HTTPClient_Services('GetTimeoutDuration') + TimedOut = False$ + Loop + ReadyState = SRP_COM(objXMLHTTP, 'GET', 'readyState') + CurrentTime = GetTickCount() + ElapsedTime = Int((CurrentTime - StartTime) / 1000) + TimedOut = ElapsedTime GE TimeoutDuration + While (ReadyState NE HTTP_COMPLETED$) AND Not(TimedOut) + Repeat + end + + // Check the XMLHTTP object's responseBody property to get the server's response. +* Response = SRP_COM(objXMLHTTP, 'GET', 'responseBody') + Response = SRP_COM(objXMLHTTP, 'GET', 'responseText') + + If SRP_COM('', 'HASERROR') then + Error = 'Error getting the responseBody property for the XMLHTTP object in the ' : Service : ' service.' + Error := ' SRP_COM Error: ' : SRP_COM('', 'ERROR') + Error_Services('Add', Error) + Response = '' + end else + HTTPClient_Services('SetResponseBody', Response) + end + end + + If Error_Services('NoError') then + // If the request was successful, get the response status code, phrase, and response headers and set them + // using HTTPClient_Services so the caller can retrieve is desired. + Code = SRP_COM(objXMLHTTP, 'GET', 'status') + Phrase = Trim(SRP_COM(objXMLHTTP, 'GET', 'statusText')) + HTTPClient_Services('SetResponseStatusCode', Code) + HTTPClient_Services('SetResponseStatusPhrase', Phrase) + + ResponseHeaders = SRP_COM(objXMLHTTP, 'CALL', 'getAllResponseHeaders') + Swap CRLF$ with @FM in ResponseHeaders + For Each ResponseHeader in ResponseHeaders using @FM + Name = ResponseHeader[1, 'F:'] + Value = Trim(ResponseHeader[Col2() + 1, 9999]) + If (Name NE '') AND (Value NE '') then + HTTPClient_Services('SetResponseHeaderField', Name, Value) + end + Next ResponseHeader + end + + // Release the handle to the XMLHTTP object in case it was created. + SRP_COM(objXMLHTTP, 'RELEASE') + + // Make sure all prior request settings are cleared so future HTTP request won't be affected. + Error = Error_Services('GetMessage') ; // Get any pre-existing errors so they can be preserved. + HTTPClient_Services('ClearRequestSettings') ; // This will automatically clear the error stack. + Error_Services('Set', Error) ; // Restore any errors so the caller can check for them. + end else + Error_Services('Add', 'Method or URL argument was missing from the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetRequestHeaderFields +// +// HeaderList - An @FM/@VM list of request header fields and their values. - [Required] +// +// Sets the Request Header Fields as indicated by the HeaderList argument. The HeaderList should not be formatted as a +// list rather than an associated multivalue array. This is easier for the developer to manage in the code that calls +// this service. +//---------------------------------------------------------------------------------------------------------------------- +Service SetRequestHeaderFields(HeaderList) + + If HeaderList NE '' then + For Each HeaderPair in HeaderList using @FM + HeaderName = HeaderPair<0, 1> + HeaderValue = HeaderPair<0, 2> + HTTPClient_Services('SetRequestHeaderField', HeaderName, HeaderValue) + Next HeaderPair + end else + Error_Services('Add', 'HeaderList argument was missing from the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetRequestHeaderField +// +// Name - Header Field Name to set. - [Required] +// Value - Value for the header field. This will be Trimmed to enforce proper formatting. - [Required] +// +// Sets the indicated Request Header Field with the indicated value. +//---------------------------------------------------------------------------------------------------------------------- +Service SetRequestHeaderField(Name, Value) + + If (Name NE '') AND (Value NE '') then + SearchName = Name + Convert @Lower_Case to @Upper_Case in SearchName + SearchFields = RequestHeaderFields@ + Convert @Lower_Case to @Upper_Case in SearchFields + Locate SearchName in SearchFields using @FM setting fPos else + fPos = Count(RequestHeaderFields@, @FM) + (RequestHeaderFields@ NE '') + 1 + end + RequestHeaderFields@ = Name + RequestHeaderValues@ = Trim(Value) + end else + Error_Services('Add', 'The Name or Value argument is missing in the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetRequestHeaderFields +// +// Returns all of the Request Header Field names and values. This returns an @FM/@VM list of names and values. +//---------------------------------------------------------------------------------------------------------------------- +Service GetRequestHeaderFields() + + HeaderFieldBlock = '' + + If RequestHeaderFields@ NE '' then + NumFields = Count(RequestHeaderFields@, @FM) + (RequestHeaderFields@ NE '') + For FieldCnt = 1 to NumFields + HeaderFieldBlock := RequestHeaderFields@ : @VM : RequestHeaderValues@ : @FM + Next FieldCnt + HeaderFieldBlock[-1, 1] = '' + end + + Response = HeaderFieldBlock + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetRequestHeaderField +// +// Name - Header Field Name to get. - [Required] +// +// Returns the value previously set for the indicated Request Header Field. +//---------------------------------------------------------------------------------------------------------------------- +Service GetRequestHeaderField(Name) + + Value = '' + + If Name NE '' then + SearchName = Name + Convert @Lower_Case to @Upper_Case in SearchName + SearchFields = RequestHeaderFields@ + Convert @Lower_Case to @Upper_Case in SearchFields + Locate SearchName in SearchFields using @FM setting fPos then + Value = RequestHeaderValues@ + end else + Error_Services('Add', Name : ' is not a header field in the request.') + end + end else + Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.') + end + + Response = Value + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetResponseHeaderField +// +// Name - Header Field Name to set. - [Required] +// Value - Value for the header field. This will be Trimmed to enforce proper formatting. - [Required] +// +// Sets the indicated Response Header Field with the indicated value. +//---------------------------------------------------------------------------------------------------------------------- +Service SetResponseHeaderField(Name, Value) + + If (Name NE '') AND (Value NE '') then + SearchName = Name + Convert @Lower_Case to @Upper_Case in SearchName + SearchFields = ResponseHeaderFields@ + Convert @Lower_Case to @Upper_Case in SearchFields + Locate SearchName in SearchFields using @FM setting fPos else + fPos = Count(ResponseHeaderFields@, @FM) + (ResponseHeaderFields@ NE '') + 1 + end + ResponseHeaderFields@ = Name + PreviousValue = ResponseHeaderValues@ + If PreviousValue EQ '' then + ResponseHeaderValues@ = Trim(Value) + end else + If Name EQ 'Set-Cookie' then + // Unlike other response headers, Set-Cookie can have multiple entries. However, if more than one + // cookie of a particular name exists then only store the last entry. + SetCookieFound = False$ + CookieName = Value[1, 'F='][1, 'F '][1, 'F;'] + For Each HeaderField in ResponseHeaderFields@ using @FM setting fPos + If HeaderField EQ 'Set-Cookie' then + SetCookieFound = True$ + end + Until SetCookieFound EQ True$ + Next HeaderField + If SetCookieFound EQ True$ then + // Set-Cookie was found. Check to see if the cookie name has already been added. + CookieNameFound = False$ + CookieValues = ResponseHeaderValues@ + For Each CookieValue in CookieValues using @VM setting vPos + MatchCookieName = CookieValue[1, 'F='][1, 'F '][1, 'F;'] + If CookieName EQ MatchCookieName then + CookieNameFound = True$ + end + Until CookieNameFound EQ True$ + Next CookieValue + If CookieNameFound EQ True$ then + // Cookie name already exists. Replace the old value with the new one. + ResponseHeaderValues@ = Trim(Value) + end else + // This is a new cookie name. Append the Set-Cookie value to the list. + ResponseHeaderValues@ = Trim(Value) + end + end else + // No cookies have been set yet. + ResponseHeaderValues@ = Trim(Value) + end + end else + ResponseHeaderValues@ = PreviousValue : ' ;' : Trim(Value) + end + end + end else + Error_Services('Add', 'The Name or Value argument is missing in the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetResponseHeaderFields +// +// Returns all of the Response Header Field names and values. This returns an @FM/@VM list of names and values. +//---------------------------------------------------------------------------------------------------------------------- +Service GetResponseHeaderFields() + + HeaderFieldBlock = '' + + If ResponseHeaderFields@ NE '' then + NumFields = Count(ResponseHeaderFields@, @FM) + (ResponseHeaderFields@ NE '') + For FieldCnt = 1 to NumFields + HeaderFieldBlock := ResponseHeaderFields@ : @VM : ResponseHeaderValues@ : @FM + Next FieldCnt + HeaderFieldBlock[-1, 1] = '' + end else + Error_Services('Add', 'There are no response header fields get.') + end + + Response = HeaderFieldBlock + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetResponseHeaderField +// +// Name - Header Field Name to get. - [Required] +// Delimiter - Delimiter to use for multiple values. Default is '; ' for all header fields except for Set-Cookie. +// Set-Cookie defaults to @VM. - [Optional] +// +// Returns the value previously set for the indicated Response Header Field. The Name argument is case-insensitive but +// if the indicated Response Header Field has not been set then an error condition will be set. +//---------------------------------------------------------------------------------------------------------------------- +Service GetResponseHeaderField(Name=RESPONSEHEADERNAMES, Delimiter) + + Value = '' + + If Name NE '' then + SearchName = Name + Convert @Lower_Case to @Upper_Case in SearchName + SearchFields = ResponseHeaderFields@ + Convert @Lower_Case to @Upper_Case in SearchFields + Locate SearchName in SearchFields using @FM setting fPos then + Value = ResponseHeaderValues@ + If Delimiter NE '' then + If Name EQ 'Set-Cookie' then + Convert @VM to Delimiter in Value + end else + Swap '; ' with Delimiter in Value + end + end + end else + Error_Services('Add', Name : ' is not a header field in the response.') + end + end else + Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.') + end + + Response = Value + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetCookies +// +// Delimiter - Delimiter to use for multiple cookies. Default is @FM - [Optional] +// +// Returns all cookie strings from the response headers. +//---------------------------------------------------------------------------------------------------------------------- +Service GetCookies(Delimiter) + + If Delimiter EQ '' then Delimiter = @FM + + Cookies = HTTPClient_Services('GetResponseHeaderField', 'Set-Cookie', Delimiter) + + Response = Cookies + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetCookie +// +// Name - Name of the cookie to get. - [Required] +// IgnoreAttributes - Boolean flag to indicate if the cookie's attributes should be removed when returning the cookie. +// Default value is False$. - [Optional] +// +// Returns the value for the indicated cookie name. +//---------------------------------------------------------------------------------------------------------------------- +Service GetCookie(Name, IgnoreAttributes=BOOLEAN) + + If IgnoreAttributes NE True$ then IgnoreAttributes = False$ + + Cookie = '' + + If Name NE '' then + CookieNameFound = False$ + Cookies = HTTPClient_Services('GetCookies') + For Each CookieString in Cookies using @FM + MatchCookieName = CookieString[1, 'F='][1, 'F '][1, 'F;'] + If Name EQ MatchCookieName then + CookieNameFound = True$ + end + Until CookieNameFound EQ True$ + Next CookieValue + If CookieNameFound EQ True$ then + If IgnoreAttributes EQ True$ then + CookieString = Trim(CookieString[1, ';']) + end + Transfer CookieString to Cookie + end + end else + Error_Services('Add', 'The Name argument is missing in the ' : Service : ' service.') + end + + Response = Cookie + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetResponseStatusCode +// +// Code - HTTP status code to set. - [Required] +// +// Sets the response status code generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service SetResponseStatusCode(Code) + + If Code NE '' then + ResponseStatusCode@ = Code + end else + Error_Services('Add', 'The Code argument is missing in the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetResponseStatusCode +// +// Gets the response status code generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service GetResponseStatusCode() + + Response = ResponseStatusCode@ + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetResponseStatusPhrase +// +// Phrase - HTTP status phrase to set. - [Required] +// +// Sets the response status phrase generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service SetResponseStatusPhrase(Phrase) + + If Phrase NE '' then + ResponseStatusPhrase@ = Phrase + end else + Error_Services('Add', 'The Phrase argument is missing in the ' : Service : ' service.') + end + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetResponseStatusPhrase +// +// Gets the response status phrase generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service GetResponseStatusPhrase() + + Response = ResponseStatusPhrase@ + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetResponseBody +// +// Body - The response body which would have been generated by an XMLHTTP call. +// +// Sets the response body generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service SetResponseBody(Body) + + ResponseBody@ = Body + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetResponseBody +// +// Gets the response body generated by the most recent HTTP request. +//---------------------------------------------------------------------------------------------------------------------- +Service GetResponseBody() + + Response = ResponseBody@ + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// SetTimeoutDuration +// +// TimeoutDuration - The length of time (in seconds) before an HTTP request will abort. +// +// Sets the timeout duration that will be used before an HTTP request will abort. This is only applicable if the +// request is asynchronous. If the timeout duration is empty, a default setting of 30 minutes (1800 seconds) will be +// set. +//---------------------------------------------------------------------------------------------------------------------- +Service SetTimeoutDuration(TimeoutDuration) + + If TimeoutDuration EQ '' then TimeoutDuration = 1800 + + TimeoutDuration@ = TimeoutDuration + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// GetTimeoutDuration +// +// Returns the timeout duration that will be used before an HTTP request will abort. This is only applicable if the +// request is asynchronous. If the timeout duration is empty, a default setting of 30 minutes (1800) seconds) will be +// returned. +//---------------------------------------------------------------------------------------------------------------------- +Service GetTimeoutDuration() + + If TimeoutDuration@ EQ '' then TimeoutDuration@ = 1800 + + Response = TimeoutDuration@ + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// ClearResponseSettings +// +// Clears all of the global common variables used for responses. +//---------------------------------------------------------------------------------------------------------------------- +Service ClearResponseSettings() + + ResponseHeaderFields@ = '' + ResponseHeaderValues@ = '' + ResponseStatusCode@ = '' + ResponseStatusPhrase@ = '' + ResponseBody@ = '' + +end service + + +//---------------------------------------------------------------------------------------------------------------------- +// ClearRequestSettings +// +// Clears all of the global common variables used for requests. +//---------------------------------------------------------------------------------------------------------------------- +Service ClearRequestSettings() + + RequestHeaderFields@ = '' + RequestHeaderValues@ = '' + TimeoutDuration@ = 1800 + +end service diff --git a/LSL2/STPROC/METROLOGY_SERVICES.txt b/LSL2/STPROC/METROLOGY_SERVICES.txt index 0944961..6087095 100644 --- a/LSL2/STPROC/METROLOGY_SERVICES.txt +++ b/LSL2/STPROC/METROLOGY_SERVICES.txt @@ -43,6 +43,7 @@ Function Metrology_Services(@Service, @Params) 09/18/18 djs Added code within the ImportTencorData service to post wafer image pdfs to a staging table where they will be stored locally on the App server. 09/11/19 fdr Add new service "ImportStratusData" + 12/05/24 djs Updated GetIQSViolations service to store reactor violations in the respective reactor record. ***********************************************************************************************************************/ @@ -67,6 +68,7 @@ $insert WO_MAT_EQUATES $Insert NOTIFICATION_EQUATES $Insert RLIST_EQUATES $Insert WM_OUT_EQUATES +$Insert IQS_VIOL_DATA_EQUATES Common /MetrologyServices/ MachineType@, RDSNo@ @@ -91,7 +93,7 @@ Equ Comma$ to ',' Declare subroutine SRP_Stopwatch, Error_Services, obj_Tables, Metrology_Services, obj_RDS_Test, SRP_JSON Declare subroutine RTI_Set_Debugger, Database_Services, Btree.Extract, Set_Status, QA_Services, obj_Notes Declare subroutine Logging_Services, SRP_Send_Mail, SRP_Run_Command, PM_Services, Httpclient_Services -Declare subroutine Tool_Services, Mona_Services +Declare subroutine Tool_Services, Mona_Services, Reactor_Services Declare function SRP_Sort_Array, Metrology_Services, obj_RDS_Test, obj_Test_Point_Map, Database_Services, UCase 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 @@ -2039,6 +2041,7 @@ end service Service GetCalculatedLayer(RDSKeyID, Machine, RunDataZone, WoIsEpiPro, ScannedLayer) + CalculatedLayer = '' If (RDSKeyID NE '') AND (Machine NE '') then @@ -2223,7 +2226,9 @@ Service RemoveOldMetrology() end service + Service ImportBioRadEPPFQAData(RunData, FileName) + Timestamp = RunData<2> WMOKeyID = RunData<6> Swap '.' with '*' in WMOKeyID @@ -2303,8 +2308,10 @@ Service ImportBioRadEPPFQAData(RunData, FileName) end else Metrology_Services('LogResults', RDSNo@, Machine, 'UID001', Service : ' : ' : Error_Services('GetMessage')) end + end service + //---------------------------------------------------------------------------------------------------------------------- // CleanRepository // @@ -2349,61 +2356,23 @@ Service MonitorQueue(NumFiles) // Enable manual entry restriction - check current status to avoid unnecessary writes. CurrLockStatus = Database_Services('ReadDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK') If CurrLockStatus EQ False$ then - Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', True$) - // Add message to OI Admins' Inbox - * OIAdmins = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X') - * Recipients = OIAdmins - * SentFrom = 'ADMIN_OI' - * Subject = 'ROTR Manual Entry Restriction Re-enabled' - * Message = 'Metrology run data queue currently has ':CurrFileCount:' files. ' | - * : 'ROTR manual entry lock has been re-enabled.' - * AttachWindow = '' - * AttachKey = '' - * SendToGroup = '' - * Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup - * Set_Status(0) - * obj_Notes('Create',Parms) - * + Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', True$) end end else // Lift manual entry restriction - check current status to avoid unnecessary writes. CurrLockStatus = Database_Services('ReadDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK') If CurrLockStatus EQ True$ then Database_Services('WriteDataRow', 'APP_INFO', 'ROTR_DATA_ENTRY_LOCK', False$) - // Add message to OI Admins' Inbox - * OIAdmins = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X') - * Recipients = OIAdmins - * SentFrom = 'ADMIN_OI' - * Subject = 'ROTR Manual Entry Restriction Disabled' - * Message = 'Metrology run data queue currently has ':CurrFileCount:' files. ' | - * : 'ROTR manual entry lock has been temporarily disabled.' - * AttachWindow = '' - * AttachKey = '' - * SendToGroup = '' - * Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup - * Set_Status(0) - * obj_Notes('Create',Parms) - end end end service + Service GetIQSViolations() + hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') Lock hSysLists, ServiceKeyID then - Equ ViolReactorCol$ To 1 - Equ ViolTestCol$ To 2 - Equ ViolUSLCol$ To 3 - Equ ViolTARCol$ To 4 - Equ ViolLSLCol$ To 5 - Equ ViolLastEntryCol$ To 6 - Equ ViolLastAlarmCol$ To 7 - Equ ViolAlarmCol$ To 8 - Equ ViolSubGroupCol$ To 9 - Equ ViolMeanCol$ To 10 - Equ LastWriteTimeCol$ To 11 - Response = 0 ParsedIQSData = '' Pass = 1 @@ -2445,21 +2414,21 @@ Service GetIQSViolations() //Delete useuless Entire Database column FilteredData = Delete(FilteredData, i,1,0) - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData swap '>' with '>' in FilteredData swap '<' with '<' in FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData - ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData + ParsedIQSData = FilteredData Next i - LastWriteTime = IConv(PublishDate, 'DT') - ParsedIQSData = LastWriteTime + LastWriteTime = IConv(PublishDate, 'DT') + ParsedIQSData = LastWriteTime Database_Services('WriteDataRow', 'CONFIG', 'IQS_VIOL_DATA', ParsedIQSData, True$, False$, True$) //Send status of last write time @@ -2469,8 +2438,11 @@ Service GetIQSViolations() Mona_Services('SendBufferedStatus', 'IQS_VIOLATION_DATA', 'LastDataTimestamp', 'OK') end + Reactor_Services('UpdateReactorIQSViolations') + Unlock hSysLists, ServiceKeyID else Null end + end service Service ScanRecipeMatchesRdsTestSpecThickMrecipe(RdsNo, RecipeLayer, RecipeInScan, RdsTestKeysFromRdsLayer, Zone='') @@ -2555,6 +2527,7 @@ Service ScanNumDataPointsMatchesRdsTestSpecThickMPattern(RdsNo, RecipeLayer, Sca Response = MatchFound end service + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3015,5 +2988,3 @@ LoadRunDataToDatabase: return - - diff --git a/LSL2/STPROC/NICA_ORDERS_SERVICES.txt b/LSL2/STPROC/NICA_ORDERS_SERVICES.txt new file mode 100644 index 0000000..9dae517 --- /dev/null +++ b/LSL2/STPROC/NICA_ORDERS_SERVICES.txt @@ -0,0 +1,565 @@ +Compile function Nica_Orders_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 Infineon Technologies. + + Name : Nica_Orders_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 + + History : (Date, Initials, Notes) + 12/05/24 djs Original programmer. + +***********************************************************************************************************************/ +#pragma precomp SRP_PreCompiler + +$Insert APP_INSERTS +$Insert SERVICE_SETUP +$Insert REACTOR_EQUATES +$Insert REACTOR_LOG_EQUATES +$Insert NICA_ORDERS_EQUATES + +Declare function Environment_Services, Database_Services, Error_Services, Logging_Services, Nica_Orders_Services +Declare function Httpclient_Services, SRP_JSON +Declare subroutine Error_Services, Btree.Extract, Database_Services, Logging_Services, Nica_Orders_Services, Delay +Declare subroutine Httpclient_Services, SRP_JSON, Mona_Services, Service_Services + +Machine = Environment_Services('GetServer') +LogDate = Oconv(Date(), 'D4/') +LogTime = Oconv(Time(), 'MTS') +LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM + +GoToService + +Return Response or "" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Service Parameter Options +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Options BOOLEAN = True$, False$ +Options ENTITY_TYPES = 'REACTOR','REACTOR_LOG' +Options ORDER_TYPES = 'INTRUSIVE_MAINT','CHANGEOVER','INITIATE_IDLE','IDLE','ASM_HTR_TUBE_CHANGE','ASM_HTR_ANNUAL_PM','ASM_HTR_SEMIANNUAL_PM','ASM_HTR_FIVE_AND_TEN_YEAR_PM','IQS_HGCV_ALARM' +Options ORDER_STATUSES = 'new','creating','not-started','in-progress','cancelled','done' + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// SERVICES +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +Service GetOrderIds(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, OrderStatus=ORDER_STATUSES, IsComplete=BOOLEAN) + + OrderKeys = '' + ErrorMsg = '' + If ( (EntityType NE '') or (EntityID NE '') or (OrderType NE '') or (OrderStatus NE '') or (IsComplete NE '') ) then + Open 'DICT.NICA_ORDERS' to hDict then + Query = '' + Table = 'NICA_ORDERS' + Option = 'E' + Flag = '' + If EntityType NE '' then Query := 'ENTITY_TYPE' : @VM : EntityType : @FM + If EntityID NE '' then Query := 'ENTITY_ID' : @VM : EntityID : @FM + If OrderType NE '' then Query := 'ORDER_TYPE' : @VM : OrderType : @FM + If OrderStatus NE '' then Query := 'ORDER_STATUS' : @VM : OrderStatus : @FM + If IsComplete NE '' then Query := 'IS_COMPLETE' : @VM : IsComplete : @FM + Btree.Extract(Query, Table, hDict, OrderKeys, Option, Flag) + If Flag NE 0 then + ErrorMsg = 'Error in ':Service:' service. Btree.Extract call failed.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Failed to open DICT.NICA_ORDERS.' + end + end else + ErrorMsg = 'Error in ':Service:' service. At least one search parameter must be provided.' + end + + If ErrorMsg EQ '' then + Response = OrderKeys + end else + Error_Services('Add', ErrorMsg) + end + +End Service + + +Service GetOrderUpdates() + + hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') + Lock hSysLists, ServiceKeyID then + ActiveOrderIds = Nica_Orders_Services('GetActiveOrders') + For each OrderId in ActiveOrderIds using @VM + Nica_Orders_Services('GetOrderStatusUpdate', OrderId) + Next OrderId + Unlock hSysLists, ServiceKeyID else Null + end + +end service + + +Service GetActiveOrders(EntityType=ENTITY_TYPES, EntityId, OrderType=ORDER_TYPES) + + Response = Nica_Orders_Services('GetOrderIds', EntityType, EntityID, OrderType, '#cancelled', False$) + +end service + + +Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES) + + ErrorMsg = '' + EntityTypes = 'REACTOR,REACTOR_LOG' + OrderTypes = 'INTRUSIVE_MAINT,CHANGEOVER,INITIATE_IDLE,IDLE,ASM_HTR_TUBE_CHANGE,ASM_HTR_ANNUAL_PM,' + OrderTypes := 'ASM_HTR_SEMIANNUAL_PM,ASM_HTR_FIVE_AND_TEN_YEAR_PM,IQS_HGCV_ALARM' + + Machine = Environment_Services('GetServer') + Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' + ColumnWidths = 20 : @FM : 15 : @FM : 300 + LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders' + makeDirSuccess = Utility("MAKEDIR", LogPath) + LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : LogTime : '_CreateNicaOrder.csv' + objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) + + Prod = Environment_Services('IsProd') + IgnoreCertErrors = Not(Prod) + + If ( (EntityType NE '') and (EntityID NE '') and (OrderType NE '') ) then + + Begin Case + Case Not(InList(EntityTypes, EntityType, ',')) + ErrorMsg = 'Error in ':Service:' service. Unsupported entity type' + Case Not(InList(OrderTypes, OrderType, ',')) + ErrorMsg = 'Error in ':Service:' service. Unsupported order type' + End Case + + If ErrorMsg EQ '' then + + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Attempting to create NICA order for entity ':EntityType:' ' :EntityID:' of type ':OrderType + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + CurrActiveOrders = Nica_Orders_Services('GetActiveOrders', EntityType, EntityID, OrderType) + OrderTypeAlreadyActive = (CurrActiveOrders NE '') + + If OrderTypeAlreadyActive EQ False$ then + + Begin Case + Case EntityType EQ 'REACTOR' + ReactNo = EntityID + + Case EntityType EQ 'REACTOR_LOG' + ReactNo = Xlate(EntityType, EntityID, REACTOR_LOG_REACTOR$, 'X') + End Case + + // Call the API + NicaURL = Environment_Services("GetProveInApiUrl"):'/checklists?' + NicaURL := 'checklistType=':OrderType + NicaURL := '&reactorNumber=':ReactNo + + Retries = 3 + BackoffSeconds = 1 + IsSuccessful = False$ + + OrderId = '' + + Loop + while (IsSuccessful EQ False$ and Retries GT 0) + WaitSeconds = (3 - retries) * BackoffSeconds + Delay(WaitSeconds) + + Retries = Retries - 1 + + HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors) + If HttpResponseJson NE '' then + ObjResponseJson = '' + If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then + OrderId = SRP_JSON(ObjResponseJson, 'GetValue', 'id') + If OrderId NE '' then + Convert @Lower.Case to @Upper.Case in OrderId + NicaOrderRec = '' + NicaOrderRec = OrderType + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'state') + NicaOrderRec = EntityType + NicaOrderRec = EntityID + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete') + Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$) + If Error_Services('NoError') then + If ( (OrderType _EQC 'INITIATE_IDLE') and (EntityType _EQC 'REACTOR') ) then + Open 'REACTOR' to hReactor then + WriteV True$ to hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else + ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.' + end + end + end + If ErrorMsg EQ '' then + IsSuccessful = True$ + Response = OrderId + end + end else + ErrorMsg = Error_Services('GetMessage') + end + end else + ErrorMsg = 'Error in ':Service:' service. Null OrderId returned from MesaProveInAPI.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Error parsing JSON response from MesaProveInAPI.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Null JSON response returned from MesaProveInAPI.' + end + SRP_JSON(ObjResponseJson, 'Release') + Repeat + + If Environment_Services('IsProd') then + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' + end else + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' + end + StatusName = 'CreateNicaOrder' + If IsSuccessful then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Successfully created Nica order for entity ':EntityType:' ':EntityID:' of type ':OrderType + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok') + end else + ErrorMsg = 'Error encountered when attempting to create Nica in order for reactor ':ReactNo:' of type ':OrderType + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical') + end + end else + ErrorMsg = 'Error encountered when attempting to create Nica order for entity ':EntityType:' ' :EntityID:' of type ':OrderType:'. Active order already exists.' + end + end + end else + ErrorMsg = 'Error in ':Service:' service. Null EntityType, EntityID, or OrderType passed in.' + end + + If ErrorMsg NE '' then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = ErrorMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + Error_Services('Add', ErrorMsg) + Response = 'error' + end + +end service + + +Service CancelOrder(OrderId) + + ErrorMsg = '' + Machine = Environment_Services('GetServer') + Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' + ColumnWidths = 20 : @FM : 15 : @FM : 300 + LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders' + makeDirSuccess = Utility("MAKEDIR", LogPath) + LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_CancelNicaOrder.csv' + objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) + + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Attempting to cancel Nica order ' : OrderId :'.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + Prod = Environment_Services('IsProd') + IgnoreCertErrors = Not(Prod) + + If OrderId NE '' then + LockRetries = 3 + LockBackoffSeconds = 1 + HaveLock = False$ + Loop + While (HaveLock EQ False$ and LockRetries GT 0) + WaitSeconds = (3 - LockRetries) * LockBackoffSeconds + Delay(WaitSeconds) + LockRetries = LockRetries - 1 + HaveLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS', OrderId, True$) + Repeat + + If HaveLock then + NicaOrderRec = Database_Services('ReadDataRow', 'NICA_ORDERS', OrderId) + If Error_Services('NoError') then + EntityType = NicaOrderRec + EntityId = NicaOrderRec + Begin Case + Case EntityType EQ 'REACTOR' + ReactNo = EntityId + + Case EntityType EQ 'REACTOR_LOG' + ReactNo = Xlate(EntityType, EntityId, REACTOR_LOG_REACTOR$, 'X') + + Case Otherwise$ + ErrorMsg = 'Error in ':Service:' service. Unsupported entity type.' + End Case + + If ErrorMsg EQ '' then + + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Sending cancel request for Nica order ' : OrderId : ' for reactor ' : ReactNo + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + Response = False$ + BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' + UrlOrderId = OrderId + Convert @Upper.Case to @Lower.Case in UrlOrderId + ProveInUrl = BaseProveInUrl:'checklistOrderId=':UrlOrderId + ProveInUrl = ProveInUrl:'&checklistState=cancelled' + + Retries = 3 + BackoffSeconds = 1 + IsSuccessful = False$ + + Loop + while (IsSuccessful EQ False$ and Retries GT 0) + WaitSeconds = (3 - Retries) * BackoffSeconds + Delay(WaitSeconds) + Retries = Retries - 1 + HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors) + If HttpResponseJson NE '' then + ObjResponseJson = '' + If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then + IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'pendingUpdate') + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'state') + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete') + Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$) + If Error_Services('NoError') then + OrderType = NicaOrderRec + If ( (OrderType _EQC 'IDLE') and (EntityType EQ 'REACTOR') ) then + Open 'REACTOR' to hReactor then + WriteV False$ on hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else + ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.' + end + end + end + If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$ + end else + ErrorMsg = Error_Services('GetMessage') + end + If IsComplete EQ True$ then + Response = True$ + end else + Response = False$ + end + end + end + SRP_JSON(ObjResponseJson, 'Release') + Repeat + + If Environment_Services('IsProd') then + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' + end else + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' + end + StatusName = 'CancelNicaOrder' + If ( (IsSuccessful EQ True$) and (Response NE 'error') and (ErrorMsg EQ '') ) then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Successfully cancelled Nica order ' : OrderId : ' for reactor ' : ReactNo + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok') + end else + ErrorMsg = 'Error encountered cancelling Nica order ' : OrderId : ' for reactor ' : ReactNo + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical') + end + end else + ErrorMsg = Error_Services('GetMessage') + Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId) + end + end else + ErrorMsg = 'Error in ':Service:' service. Failed to lock NICA_ORDERS ':OrderId:' for cancellation.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Null OrderID passed in.' + end + end else + ErrorMsg = Error_Services('GetMessage') + end + + If ErrorMsg NE '' then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = ErrorMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + Error_Services('Add', ErrorMsg) + Response = 'error' + end + +end service + + +Service GetOrderStatus(OrderId) + + If OrderId NE '' then + If RowExists('NICA_ORDERS', OrderId) then + Response = Xlate('NICA_ORDERS', OrderId, 'ORDER_STATUS', 'X') + end else + Error_Services('Add', 'Error in ':Service:' service. Nica order ':OrderId:' does not exist.') + end + end else + Error_Services('Add', 'Error in ':Service:' service. Null OrderId passed in.') + end + +end service + + +Service GetOrderStatusUpdate(OrderId) + + ErrorMsg = '' + Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' + ColumnWidths = 20 : @FM : 15 : @FM : 300 + LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders' + makeDirSuccess = Utility("MAKEDIR", LogPath) + LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_GetOrderStatusUpdate.csv' + objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) + + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Attempting to update Nica order ' : OrderId :'.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + Prod = Environment_Services('IsProd') + IgnoreCertErrors = Not(Prod) + + If OrderId NE '' then + HaveLock = Database_Services('GetKeyIDLock', 'NICA_ORDERS', OrderId, True$) + If HaveLock then + NicaOrderRec = Database_Services('ReadDataRow', 'NICA_ORDERS', OrderId) + If Error_Services('NoError') then + EntityType = NicaOrderRec + EntityId = NicaOrderRec + Begin Case + Case EntityType EQ 'REACTOR' + ReactNo = EntityId + + Case EntityType EQ 'REACTOR_LOG' + ReactNo = Xlate(EntityType, EntityId, REACTOR_LOG_REACTOR$, 'X') + + Case Otherwise$ + ErrorMsg = 'Error in ':Service:' service. Unsupported entity type.' + End Case + + If ErrorMsg EQ '' then + + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Attempting to fetch Nica order ':OrderId:' for reactor ':ReactNo + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + Response = True$ + IsSuccessful = True$ + BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' + UrlOrderId = OrderId + Convert @Upper.Case to @Lower.Case in UrlOrderId + ProveInUrl = BaseProveInUrl:'checklistOrderId=':UrlOrderId + + Retries = 3 + BackoffSeconds = 1 + IsSuccessful = False$ + + Loop + while (IsSuccessful EQ False$ and Retries GT 0) + WaitSeconds = (3 - Retries) * BackoffSeconds + + Delay(WaitSeconds) + + Retries = Retries - 1 + + HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '', IgnoreCertErrors) + + If HttpResponseJson NE '' then + ObjResponseJson = '' + If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then + IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete') + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'type') + NicaOrderRec = SRP_JSON(ObjResponseJson, 'GetValue', 'state') + NicaOrderRec = IsComplete + Database_Services('WriteDataRow', 'NICA_ORDERS', OrderId, NicaOrderRec, True$, False$, False$) + If Error_Services('NoError') then + If IsComplete EQ True$ then + OrderType = NicaOrderRec + If ( (OrderType _EQC 'IDLE') and (EntityType _EQC 'REACTOR') ) then + Open 'REACTOR' to hReactor then + WriteV False$ on hReactor, ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$ else + ErrorMsg = 'Error in ':Service:' service. Error setting IDLE_STARTUP_REQUIRED flag in REACTOR record.' + end + end + end + If ErrorMsg EQ '' then Response = True$ + end else + Response = False$ + end + If ( (Response EQ True$) or (Response EQ False$) ) then IsSuccessful = True$ + end else + ErrorMsg = Error_Services('GetMessage') + end + end + end + SRP_JSON(ObjResponseJson, 'Release') + Repeat + + If Environment_Services('IsProd') then + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' + end else + MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' + end + + StatusName = 'GetNicaOrderUpdate' + If IsSuccessful and Response NE 'error' then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Successfully updated Nica order ':OrderId:' for reactor ':ReactNo:'.' + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok') + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + end else + Database_Services('ReleaseKeyIDLock', 'NICA_ORDERS', OrderId) + ErrorMsg = 'Error encountered updating Nica order ':OrderId:' for reactor ':ReactNo:'.' + Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical') + end + end + end else + ErrorMsg = Error_Services('GetMessage') + end + end else + ErrorMsg = 'Error in ':Service:' service. Failed to lock NICA_ORDERS ':OrderId:'.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Null OrderId passed in.' + end + + If ErrorMsg NE '' then + LogData = '' + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = ErrorMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + Error_Services('Add', ErrorMsg) + Response = 'error' + end + +end service + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Internal GoSubs +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + diff --git a/LSL2/STPROC/PROVE_IN_OVERRIDE_EVENTS.txt b/LSL2/STPROC/PROVE_IN_OVERRIDE_EVENTS.txt index 20bf87a..ebdf20a 100644 --- a/LSL2/STPROC/PROVE_IN_OVERRIDE_EVENTS.txt +++ b/LSL2/STPROC/PROVE_IN_OVERRIDE_EVENTS.txt @@ -1,90 +1,97 @@ -Compile function PROVE_IN_OVERRIDE_EVENTS(CtrlEntId, Event, @PARAMS) -#pragma precomp SRP_PreCompiler -#window PROVE_IN_OVERRIDE - -$Insert APP_INSERTS -$Insert REACTOR_EQUATES -$insert Message_Box_Equates - -Declare subroutine Placedialog, Message_Box - -GoToEvent Event for CtrlEntId else - // Event not implemented -end - -Return EventFlow or 1 - -//----------------------------------------------------------------------------- -// EVENT HANDLERS -//----------------------------------------------------------------------------- - -Event WINDOW.CREATE(CreateParam) - ReactNo = CreateParam - - Placedialog(-2, -2) - - ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X') - for each ProveInType in ProveInTypes using @VM setting dummy - Begin Case - Case ProveInType _EQC 'changeover' - Set_Property(@Window:'.CHB_CHANGEOVER', 'ENABLED', True$) - Case ProveInType _EQC 'initiate_idle' - Set_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'ENABLED', True$) - Case ProveInType _EQC 'idle' - Set_Property(@Window:'.CHB_IDLE_STARTUP', 'ENABLED', True$) - Case ProveInType _EQC 'intrusive_maint' - Set_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'ENABLED', True$) - Case Otherwise$ - Null - End Case - Next ProveInType -End Event - -Event PUB_SUBMIT.CLICK() - OverrideData = '' - - SelectedTypes = '' - If Get_Property(@Window:'.CHB_CHANGEOVER', 'CHECK') then - SelectedTypes = "CHANGEOVER" - end - If Get_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'CHECK') then - If SelectedTypes NE '' then - SelectedTypes := @VM - end - SelectedTypes := 'INITIATE_IDLE' - end - If Get_Property(@Window:'.CHB_IDLE_STARTUP', 'CHECK') then - If SelectedTypes NE '' then - SelectedTypes := @VM - end - SelectedTypes := 'IDLE' - end - If Get_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'CHECK') then - If SelectedTypes NE '' then - SelectedTypes := @VM - end - SelectedTypes := 'INTRUSIVE_MAINT' - end - - If SelectedTypes EQ '' then - Message_Box(@Window, "You must select at least one prove in type!", "Error", MSG_ICON_EXCLAM$) - return - end else - OverrideData<1, 1> = SelectedTypes - end - - OverrideData<2, 1> = Get_Property(@Window:'.EDB_COMMENT', 'TEXT') - - If OverrideData<2, 1> EQ '' or Len(OverrideData<2, 1>) LT 4 then - Message_Box(@Window, "Your comment must be at least 4 characters!", "Error", MSG_ICON_EXCLAM$) - return - end - - End_Dialog(@Window, OverrideData) -end event - -Event PUB_CANCEL.CLICK() - End_Dialog(@Window, '') -end event - - +Compile function PROVE_IN_OVERRIDE_EVENTS(CtrlEntId, Event, @PARAMS) +#pragma precomp SRP_PreCompiler +#window PROVE_IN_OVERRIDE + +$Insert APP_INSERTS +$insert Message_Box_Equates + +Declare subroutine Placedialog, Message_Box +Declare function Nica_Orders_Services + +GoToEvent Event for CtrlEntId else + // Event not implemented +end + +Return EventFlow or 1 + +//----------------------------------------------------------------------------- +// EVENT HANDLERS +//----------------------------------------------------------------------------- + +Event WINDOW.CREATE(CreateParam) + + ReactNo = CreateParam + + Placedialog(-2, -2) + + ActiveOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo) + For each OrderType in ActiveOrders using @VM setting dummy + Begin Case + Case OrderType _EQC 'changeover' + Set_Property(@Window:'.CHB_CHANGEOVER', 'ENABLED', True$) + Case OrderType _EQC 'initiate_idle' + Set_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'ENABLED', True$) + Case OrderType _EQC 'idle' + Set_Property(@Window:'.CHB_IDLE_STARTUP', 'ENABLED', True$) + Case OrderType _EQC 'intrusive_maint' + Set_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'ENABLED', True$) + Case Otherwise$ + Null + End Case + Next OrderType + +End Event + + +Event PUB_SUBMIT.CLICK() + + OverrideData = '' + + SelectedTypes = '' + If Get_Property(@Window:'.CHB_CHANGEOVER', 'CHECK') then + SelectedTypes = "CHANGEOVER" + end + If Get_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'CHECK') then + If SelectedTypes NE '' then + SelectedTypes := @VM + end + SelectedTypes := 'INITIATE_IDLE' + end + If Get_Property(@Window:'.CHB_IDLE_STARTUP', 'CHECK') then + If SelectedTypes NE '' then + SelectedTypes := @VM + end + SelectedTypes := 'IDLE' + end + If Get_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'CHECK') then + If SelectedTypes NE '' then + SelectedTypes := @VM + end + SelectedTypes := 'INTRUSIVE_MAINT' + end + + If SelectedTypes EQ '' then + Message_Box(@Window, "You must select at least one prove in type!", "Error", MSG_ICON_EXCLAM$) + return + end else + OverrideData<1, 1> = SelectedTypes + end + + OverrideData<2, 1> = Get_Property(@Window:'.EDB_COMMENT', 'TEXT') + + If OverrideData<2, 1> EQ '' or Len(OverrideData<2, 1>) LT 4 then + Message_Box(@Window, "Your comment must be at least 4 characters!", "Error", MSG_ICON_EXCLAM$) + return + end + + End_Dialog(@Window, OverrideData) + +end event + + +Event PUB_CANCEL.CLICK() + + End_Dialog(@Window, '') + +end event + diff --git a/LSL2/STPROC/REACTORLOGS_API.txt b/LSL2/STPROC/REACTORLOGS_API.txt index 959a8fb..de0f2d5 100644 --- a/LSL2/STPROC/REACTORLOGS_API.txt +++ b/LSL2/STPROC/REACTORLOGS_API.txt @@ -44,8 +44,8 @@ $insert HTTP_INSERTS $insert REACTOR_LOG_EQUATES $insert OI_WIZARD_EQUATES -Declare function Reactor_Log_Services, OI_Wizard_Services, MemberOf -Declare subroutine Database_Services, Reactor_Log_Services, Override_Log_Services +Declare function Reactor_Log_Services, OI_Wizard_Services, MemberOf, Nica_Orders_Services +Declare subroutine Database_Services, Reactor_Log_Services, Override_Log_Services, Nica_Orders_Services GoToAPI else // The specific resource endpoint doesn't have a API handler yet. @@ -185,13 +185,13 @@ API ReactorLogs.ID.nicaOverride.POST If OverrideComment NE '' then Override_Log_Services('Create', 'REACTOR_LOG', RLKey, OverrideUser, OverrideComment, 'REACTOR_LOG_PM', '') If Error_Services('NoError') then - // Cancel all ReactorLog PMs - ActivePMKeys = Xlate('REACTOR_LOG', RLKey, REACTOR_LOG_CHECKLIST_ORDER_ID$, 'X') - If ActivePMKeys NE '' then - For each ActivePMKey in ActivePMKeys using @VM setting vPos - Reactor_Log_Services('CancelReactorLogPMOrder', RLKey, ActivePMKey) + // Cancel all ReactorLog NICA Orders + ActiveRlNicaOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey) + If ActiveRlNicaOrderIds NE '' then + For each ActiveRlNicaOrderId in ActiveRlNicaOrderIds using @VM setting vPos + Nica_Orders_Services('CancelOrder', ActiveRlNicaOrderId) Until Error_Services('HasError') - Next ActivePMKey + Next ActiveRlNicaOrderId end If Error_Services('NoError') then HTTP_Services('SetResponseStatus', 200, 'Nica orders canceled for REACTOR_LOG "':RLKey:'".') @@ -261,3 +261,4 @@ API reactorlogs.ID.nicaoverride.PUT end api + diff --git a/LSL2/STPROC/REACTOR_ACTIONS.txt b/LSL2/STPROC/REACTOR_ACTIONS.txt new file mode 100644 index 0000000..7a2f302 --- /dev/null +++ b/LSL2/STPROC/REACTOR_ACTIONS.txt @@ -0,0 +1,232 @@ +Function Reactor_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10) +/*********************************************************************************************************************** + + 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 Infineon. + + Name : Reactor_Actions + + Description : Handles calculated columns and MFS calls for the current table. + + Notes : This function uses @ID, @RECORD, and @DICT to make sure {ColumnName} references work correctly. + If called from outside of a calculated column these will need to be set and restored. + + Parameters : + Action [in] -- Name of the action to be taken + CalcColName [in] -- Name of the calculated column that needs to be processed. Normally this should only be + populated when the CalcField action is being used. + FSList [in] -- The list of MFSs and the BFS name for the current file or volume. This is an @SVM + delimited array, with the current MFS name as the first value in the array, and the BFS + name as the last value. Normally set by a calling MFS. + Handle [in] -- The file handle of the file or media map being accessed. Note, this does contain the + entire handle structure that the Basic+ Open statement would provide. Normally set by a + calling MFS. + Name [in] -- The name (key) of the record or file being accessed. Normally set by a calling MFS. + FMC [in] -- Various functions. Normally set by a calling MFS. + Record [in] -- The entire record (for record-oriented functions) or a newly-created handle (for + "get handle" functions). Normally set by a calling MFS. + Status [in/out] -- Indicator of the success or failure of an action. Normally set by the calling MFS but + for some actions can be set by the action handler to indicate failure. + OrigRecord [in] -- Original content of the record being processed by the current action. This is + automatically being assigned by the WRITE_RECORD and DELETE_RECORD actions within + BASE_MFS. + Param1-10 [in/out] -- Additional request parameter holders + ActionFlow [out] -- Used to control the action chain (see the ACTION_SETUP insert for more information.) + Can also be used to return a special value, such as the results of the CalcField + method. + + History : (Date, Initials, Notes) + 12/05/24 djs Original programmer. + +***********************************************************************************************************************/ + +#pragma precomp SRP_PreCompiler + +$Insert LOGICAL +$Insert FILE.SYSTEM.EQUATES +$Insert ACTION_SETUP +$Insert REACTOR_EQUATES +$Insert IQS_VIOL_DATA_EQUATES + +Declare function Error_Services, Database_Services, Logging_Services, Environment_Services, Nica_Orders_Services +Declare subroutine Error_Services, Database_Services, Logging_Services, Set_Status, Reactor_Services + +If KeyID then GoSub Initialize_System_Variables + +Begin Case + + Case Action _EQC 'CalculateColumn' ; GoSub CalculateColumn + Case Action _EQC 'READ_RECORD_PRE' ; GoSub READ_RECORD_PRE + Case Action _EQC 'READ_RECORD' ; GoSub READ_RECORD + Case Action _EQC 'READONLY_RECORD_PRE' ; GoSub READONLY_RECORD_PRE + Case Action _EQC 'READONLY_RECORD' ; GoSub READONLY_RECORD + Case Action _EQC 'WRITE_RECORD_PRE' ; GoSub WRITE_RECORD_PRE + Case Action _EQC 'WRITE_RECORD' ; GoSub WRITE_RECORD + Case Action _EQC 'DELETE_RECORD_PRE' ; GoSub DELETE_RECORD_PRE + Case Action _EQC 'DELETE_RECORD' ; GoSub DELETE_RECORD + Case Otherwise$ ; Status = 'Invalid Action' + +End Case + +If KeyID then GoSub Restore_System_Variables + +If Assigned(ActionFlow) else ActionFlow = ACTION_CONTINUE$ + +Return ActionFlow + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Calculated Columns +// +// The typical structure of a calculated column will look like this: +// +// Declare function Database_Services +// +// @ANS = Database_Services('CalculateColumn') +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +CalculateColumn: + + // Make sure the ActionFlow return variable is cleared in case nothing is calculated. + ActionFlow = '' + +return + + +// ----- MFS calls ----------------------------------------------------------------------------------------------------- + +READ_RECORD_PRE: + // In order to stop a record from being read in this action these lines of code must be used: + // + // OrigFileError = 100 : @FM : KeyID + // Status = 0 + // Record = '' + // ActionFlow = ACTION_STOP$ +return + +READ_RECORD: + // In order to stop a record from being read in this action these lines of code must be used: + // + // OrigFileError = 100 : @FM : KeyID + // Status = 0 + // Record = '' +return + +READONLY_RECORD_PRE: + // In order to stop a record from being read in this action these lines of code must be used: + // + // OrigFileError = 100 : @FM : KeyID + // Status = 0 + // Record = '' + // ActionFlow = ACTION_STOP$ +return + +READONLY_RECORD: + // In order to stop a record from being read in this action these lines of code must be used: + // + // OrigFileError = 100 : @FM : KeyID + // Status = 0 + // Record = '' +return + +WRITE_RECORD_PRE: + +return + +WRITE_RECORD: + + OrigIqsAlarmDtm = OrigRecord + NewIqsAlarmDtm = Record + Begin Case + Case ( ( (OrigIqsAlarmDtm EQ '') and (NewIqsAlarmDtm NE '') ) or (OrigIqsAlarmDtm LT NewIqsAlarmDtm) ) + // New alarm + NewIqsAlarmTest = Record + If IndexC(NewIqsAlarmTest, 'HgCV', 1) then + // New HgCV alarm -> Create NICA order + If @User4 EQ '' then + ModeUser = 'OI_ADMIN' + end else + ModeUser = @User4 + end + CurrActiveHgCVOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', Name, 'IQS_HGCV_ALARM') + CurrActiveProveInOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', Name, 'CHANGEOVER') + OrderTypeAlreadyActive = ( (CurrActiveHgCVOrders NE '') or (CurrActiveProveInOrders NE '') ) + If Not(OrderTypeAlreadyActive) then + // Only create an order and change the mode if there is not already an active IQS_HGCV_ALARM order + OrderResponse = Nica_Orders_Services('CreateNewOrder', 'REACTOR', Name, 'IQS_HGCV_ALARM') + Reactor_Services('CreateReactModeChange', ModeUser, Name, 'TROUBLESHOOT_OPERATOR', 'WF-Product HgCV', 'IQS SPC HgCV Alarm Detected', False$) + end + end + Case NewIqsAlarmDtm EQ '' and OrigIqsAlarmDtm NE '' + // Alarm cleared + Null + Case Otherwise$ + // No change to alarm state + Null + + End Case + +return + +DELETE_RECORD_PRE: +return + +DELETE_RECORD: +return + + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Internal GoSubs +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +Initialize_System_Variables: + + // Save these for restoration later + SaveDict = @DICT + SaveID = @ID + SaveRecord = @RECORD + OrigFileError = @FILE.ERROR + + // Now make sure @DICT, ID, and @RECORD are populated + CurrentDictName = '' + If @DICT then + DictHandle = @DICT<1, 2> + Locate DictHandle in @TABLES(5) Using @FM Setting fPos then + CurrentDictName = Field(@TABLES(0), @FM, fPos, 1) + end + end + + If CurrentDictName NE DictName then + Open DictName to @DICT else Status = 'Unable to initialize @DICT' + end + + @ID = KeyID + If Record else + // Record might not have been passed in. Read the record from the database table just to make sure. + @FILE.ERROR = '' + Open TableName to hTable then + FullFSList = hTable[1, 'F' : @VM] + BFS = FullFSList[-1, 'B' : @SVM] + LastHandle = hTable[-1, 'B' : \0D\] + FileHandle = \0D\ : LastHandle[1, @VM] + + Call @BFS(READO.RECORD, BFS, FileHandle, KeyID, FMC, Record, ReadOStatus) + end + end + @RECORD = Record + +return + + +Restore_System_Variables: + + Transfer SaveDict to @DICT + Transfer SaveID to @ID + Transfer SaveRecord to @RECORD + @FILE.ERROR = OrigFileError + +return + + + diff --git a/LSL2/STPROC/REACTOR_LOG_ACTIONS.txt b/LSL2/STPROC/REACTOR_LOG_ACTIONS.txt index b57470d..c48e89f 100644 --- a/LSL2/STPROC/REACTOR_LOG_ACTIONS.txt +++ b/LSL2/STPROC/REACTOR_LOG_ACTIONS.txt @@ -59,8 +59,9 @@ $Insert WO_MAT_QA_EQUATES Equ WOCust$ to 2 Equ Comma$ to ',' -Declare function Error_Services, Database_Services, Logging_Services, Environment_Services +Declare function Error_Services, Database_Services, Logging_Services, Environment_Services, Nica_Orders_Services Declare subroutine Error_Services, Database_Services, Logging_Services, Set_Status, Reactor_Log_Services, Rds_Services +Declare subroutine Nica_Orders_Services If KeyID then GoSub Initialize_System_Variables @@ -100,10 +101,6 @@ CalculateColumn: // Make sure the ActionFlow return variable is cleared in case nothing is calculated. ActionFlow = '' - -* Begin Case -* Case CalcColName EQ 'ROTR_ACTION' ; GoSub ROTR_ACTION -* End Case return @@ -234,18 +231,18 @@ WRITE_RECORD: If (FiveYearAdded or TenYearAdded) then // Create NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM') + Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM') end end If (FiveYearRemoved or TenYearRemoved) then // Cancel NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - ChecklistTypes = Record - ChecklistOrderIds = Record - Locate 'ASM_HTR_FIVE_AND_TEN_YEAR_PM' in ChecklistTypes using @VM setting vPos then - OrderId = ChecklistOrderIds<0, vPos> - Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId) + OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM') + If OrderIds NE '' then + For each OrderId in OrderIds + Nica_Orders_Services('CancelOrder', OrderId) + Next OrderId end end end @@ -253,57 +250,57 @@ WRITE_RECORD: If (AsmTubeChangeAdded or HtrTubeChangeAdded) then // Create NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_TUBE_CHANGE') + Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_TUBE_CHANGE') end end If (AsmTubeChangeRemoved or HtrTubeChangeRemoved) then // Cancel NICA order - If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - ChecklistTypes = Record - ChecklistOrderIds = Record - Locate 'ASM_HTR_TUBE_CHANGE' in ChecklistTypes using @VM setting vPos then - OrderId = ChecklistOrderIds<0, vPos> - Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId) - end + If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then + OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_TUBE_CHANGE') + If OrderIds NE '' then + For each OrderId in OrderIds + Nica_Orders_Services('CancelOrder', OrderId) + Next OrderId + end end end If SemiannualAdded then // Create NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_SEMIANNUAL_PM') + Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_SEMIANNUAL_PM') end end If SemiannualRemoved then // Cancel NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - ChecklistTypes = Record - ChecklistOrderIds = Record - Locate 'ASM_HTR_SEMIANNUAL_PM' in ChecklistTypes using @VM setting vPos then - OrderId = ChecklistOrderIds<0, vPos> - Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId) - end + OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_SEMIANNUAL_PM') + If OrderIds NE '' then + For each OrderId in OrderIds + Nica_Orders_Services('CancelOrder', OrderId) + Next OrderId + end end end If AnnualAdded then // Create NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - Reactor_Log_Services('CreateReactorLogPMOrder', Name, 'ASM_HTR_ANNUAL_PM') + Nica_Orders_Services('CreateNewOrder', 'REACTOR_LOG', Name, 'ASM_HTR_ANNUAL_PM') end end If AnnualRemoved then // Cancel NICA order If ( (ReactType EQ 'ASM') or (ReactType EQ 'ASM+') or (ReactType EQ 'HTR') ) then - ChecklistTypes = Record - ChecklistOrderIds = Record - Locate 'ASM_HTR_ANNUAL_PM' in ChecklistTypes using @VM setting vPos then - OrderId = ChecklistOrderIds<0, vPos> - Reactor_Log_Services('CancelReactorLogPMOrder', Name, OrderId) - end + OrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', Name, 'ASM_HTR_ANNUAL_PM') + If OrderIds NE '' then + For each OrderId in OrderIds + Nica_Orders_Services('CancelOrder', OrderId) + Next OrderId + end end end end @@ -379,3 +376,4 @@ Restore_System_Variables: return + diff --git a/LSL2/STPROC/REACTOR_LOG_SERVICES.txt b/LSL2/STPROC/REACTOR_LOG_SERVICES.txt index adc3688..f17a1f7 100644 --- a/LSL2/STPROC/REACTOR_LOG_SERVICES.txt +++ b/LSL2/STPROC/REACTOR_LOG_SERVICES.txt @@ -20,8 +20,6 @@ Compile function Reactor_Log_Services(@Service, @Params) ??/??/?? jro Original programmer. ***********************************************************************************************************************/ - - #pragma precomp SRP_PreCompiler $Insert APP_INSERTS @@ -37,10 +35,10 @@ $Insert REACTOR_EQUATES Declare function Database_Services, Reactor_Log_Services, Obj_React_Item, Set_Status, Errmsg, Error_Services, Utility Declare function obj_Calendar, NextKey, SRP_JSON, Datetime, Reactor_Services, React_Servs_Services, Logging_Services -Declare function Environment_Services, HttpClient_Services, SRP_List +Declare function Environment_Services, HttpClient_Services, SRP_List, Nica_Orders_Services Declare subroutine Set_Status, RList, Errmsg, Database_Services, Error_Services, obj_React_Reads, obj_Post_Log, Delay Declare subroutine obj_Reactor_Log, Btree.Extract, SRP_JSON, Reactor_Services, Logging_Services, Mona_Services, SRP_List -Declare subroutine Reactor_Log_Services +Declare subroutine Reactor_Log_Services, Nica_Orders_Services GoToService @@ -89,13 +87,14 @@ Service SignReactorLog(ReactorLogID, UserID) ErrorMsg = '' If RowExists('REACTOR_LOG', ReactorLogID) then // Update any NICA checklist order statuses - Reactor_Log_Services('GetReactorLogPMStatus', ReactorLogID) + Nica_Orders_Services('GetOrderUpdates') If Error_Services('NoError') then If RowExists('LSL_USERS', UserID) then ReactorLogRec = Database_Services('ReadDataRow', 'REACTOR_LOG', ReactorLogID) If Error_Services('NoError') then // Verify NICA checklists are complete - If Sum(ReactorLogRec) EQ 0 then + ActiveRlNicaOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', ReactorLogID) + If ActiveRLNicaOrders EQ '' then // Verify reactor number is populated ReactorNo = ReactorLogRec If ReactorNo NE '' then @@ -135,6 +134,7 @@ Service SignReactorLog(ReactorLogID, UserID) Until ErrorMsg NE '' Next ServiceID end + // Check if any react items are missing disposition codes If ErrorMsg EQ '' then RemRINos = Xlate('REACTOR_LOG', ReactorLogID, 'REM_RI_NO', 'X') @@ -159,7 +159,6 @@ Service SignReactorLog(ReactorLogID, UserID) end end - If ErrorMsg EQ '' then // Check if we need to "post" any items that are being installed InstRINo = ReactorLogRec @@ -301,16 +300,10 @@ Service SignReactorLog(ReactorLogID, UserID) ErrorMsg = 'Error in ':Service:' service. Reactor number is missing.' end end else - ActiveCheckLists = '' - CheckListTypes = ReactorLogRec - CheckListActives = ReactorLogRec - For each CheckListType in CheckListTypes using @VM setting vPos - If CheckListActives<0, vPos> EQ True$ then - ActiveCheckLists := CheckListType:',' - end - Next CheckListType - If ActiveCheckLists NE '' then ActiveCheckLists[-1, 1] = '' - ErrorMsg = 'Error in ':Service:' service. NICA order(s) ':ActiveCheckLists:' must be completed prior to signing reactor log.' + ActiveChecklistTypes = Xlate('NICA_ORDERS', ActiveRlNicaOrders, 'ORDER_TYPE', 'X') + Swap @VM with ',' in ActiveChecklistTypes + ErrorMsg = 'Error in ':Service:' service. NICA order(s) ':ActiveChecklistTypes + ErrorMsg := ' must be completed prior to signing reactor log.' end end else ErrorMsg = Error_Services('GetMessage') @@ -907,6 +900,21 @@ Service ConvertJSONToRecord(JSON) end service +Service GetRlChecklistActive(RLKey) + + If RLKey NE '' then + ActiveTubeChangeIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_TUBE_CHANGE') + ActiveAnnualPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_ANNUAL_PM') + ActiveSemiannualPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_SEMIANNUAL_PM') + ActiveFiveAndTenPmIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', RLKey, 'ASM_HTR_FIVE_AND_TEN_YEAR_PM') + Response = ( (ActiveTubeChangeIds NE '') or (ActiveAnnualPmIds NE '') or (ActiveSemiannualPmIds NE '') or (ActiveFiveAndTenPmIds NE '') ) + end else + Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.') + end + +end service + + Service AddComment(Reactor, NewNote, User) ReactModeNGKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', Reactor, 'REACT_MODE_KEY_IDS', 'X') @@ -928,348 +936,6 @@ Service AddComment(Reactor, NewNote, User) end service -Service CreateReactorLogPMOrder(RLNo, PmType=PM_TYPES) - - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPM' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogDate = Oconv(Date(), 'D4/') - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPM.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RLNo) - ReactNo = RlRec - Machine = Environment_Services('GetServer') - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Attempting to create PM order for reactor ':ReactNo:' of type ':PMType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - CurrentPmTypes = RlRec - PmTypeAlreadyActive = False$ - - For each ActivePmType in CurrentPmTypes using @VM setting dummy - If ActivePmType EQ PmType then PmTypeAlreadyActive = True$ - Next ActivePmType - - If PmTypeAlreadyActive EQ False$ then - - RlRec = True$ - RlRec = PmType - - // Call the API - NicaURL = Environment_Services("GetProveInApiUrl"):'/checklists?' - NicaURL := 'checklistType=':PmType - NicaURL := '&reactorNumber=':ReactNo - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - OrderId = '' - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - retries) * BackoffSeconds - Delay(WaitSeconds) - - Retries = Retries - 1 - - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - OrderId = SRP_JSON(ObjResponseJson, 'GetValue', 'id') - If orderId NE '' then - IsSuccessful = True$ - Response = OrderId - end - end - end - SRP_JSON(ObjResponseJson, 'Release') - Repeat - - RlRec = OrderId - - Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$) - - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'CreateReactorLogPmOrder' - If IsSuccessful then - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully created PM order for reactor ':ReactNo:' and reactor log ':RlNo:' of type ':PmType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok') - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered when attempting to create PM order for reactor ':ReactNo:' and reactor log ':RlNo:' of type ':PmType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical') - - Error_Services('Add', 'Error in ' : Service : ' service. Could not create NICA order.') - end - end - -end service - - -Service CancelReactorLogPMOrder(RlNo, OrderId) - - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPM' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogDate = Oconv(Date(), 'D4/') - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPM.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RlNo) - ReactNo = RlRec - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - Machine = Environment_Services('GetServer') - LogData<2> = Machine - LogData<3> = 'Attempting to cancel PM order ' : OrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Response = False$ - - BaseNicaUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' - NicaUrl = BaseNicaUrl:'checklistOrderId=':OrderId - NicaUrl := '&checklistState=cancelled' - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - Retries) * BackoffSeconds - Delay(WaitSeconds) - - Retries = Retries - 1 - - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', NicaUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'pendingUpdate') - Response = (IsComplete EQ True$) - end - end - SRP_JSON(ObjResponseJson, 'Release') - IsSuccessful = ( (Response EQ True$) or (Response EQ False$) ) - Repeat - - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'UpdateReactorLogPmOrderState' - If IsSuccessful and Response NE 'error' then - PmOrderIds = RlRec - PmOrderIdList = SRP_List('Create', PmOrderIds, @VM) - PmTypes = RlRec - PmTypeList = SRP_List('Create', PmTypes, @VM) - - For each PmOrderId in PmOrderIds using @VM setting Idx - If OrderId EQ PmOrderId then - SRP_List('RemoveAt', PmOrderIdList, Idx) - SRP_List('RemoveAt', PmTypeList, Idx) - end - Next ProveInOrderId - - RlRec = SRP_List("GetVariable", PmOrderIdList, @VM) - RlRec = SRP_List("GetVariable", PmTypeList, @VM) - SRP_List('Release', PmTypeList) - - OrderIdCount = SRP_List("Count", PmOrderIdList) - SRP_List("Release", PmOrderIdList) - // remove flag if pm passed - If OrderIdCount EQ 0 then RlRec = False$ - - Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$) - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully cancelled PM order ' : PmOrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok') - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered cancelling PM order ' : PmOrderId : ' for reactor ' : ReactNo : ' and reactor log ' : RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical') - - Error_Services('Add', 'Error in ' : Service : ' service. Could not cancel NICA order') - end - -end service - - -Service GetReactorLogPMStatus(RlNo) - - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorLogPm' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogDate = Oconv(Date(), 'D4/') - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorLogPm.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - RlRec = Database_Services('ReadDataRow', 'REACTOR_LOG', RlNo) - ReactNo = RlRec - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - Machine = Environment_Services('GetServer') - LogData<2> = Machine - LogData<3> = 'Attempting to fetch pm order for reactor ':ReactNo:' and reactor log ':RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Response = True$ - IsSuccessful = True$ - - // Check flag on reactor first, then call api if necessary - - PmActive = RlRec - If PmActive then - - PmOrderIds = RlRec - PmOrderIdList = SRP_List("Create", PmOrderIds, @VM) - PmTypes = RlRec - PmTypeList = SRP_List("Create", PmTypes, @VM) - - For each PmOrderId in PmOrderIds using @VM setting Idx - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Fetching pm order ':PmOrderId - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - BaseNicaUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' - NicaUrl = BaseNicaUrl:'checklistOrderId=':PmOrderId - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - Retries) * BackoffSeconds - Delay(WaitSeconds) - - Retries = Retries - 1 - - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', NicaUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete') - If IsComplete EQ True$ then - SRP_List('RemoveAt', PmOrderIdList, Idx) - SRP_List('RemoveAt', PmTypeList, Idx) - Response = True$ - end else - Response = False$ - end - end - end - SRP_JSON(ObjResponseJson, 'Release') - IsSuccessful = ( (Response EQ True$) or (Response EQ False$) ) - Repeat - Next PmOrderId - - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'GetReactorLogPmOrderStatus' - If IsSuccessful and Response NE 'error' then - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully fetched pm order for reactor ':ReactNo:' and reactor log ':RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'ok') - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered when fetching pm order for reactor ':RlNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'critical') - - Error_Services('Add', 'Error in ' : Service : ' service. Could not retrieve NICA order status.') - end - - RlRec = SRP_List("GetVariable", PmOrderIdList, @VM) - RlRec = SRP_List("GetVariable", PmTypeList, @VM) - SRP_List('Release', PmTypeList) - - OrderIdCount = SRP_List("Count", PmOrderIdList) - SRP_List("Release", PmOrderIdList) - // remove flag if prove in passed - If OrderIdCount EQ 0 then RlRec = False$ - - Database_Services('WriteDataRow', 'REACTOR_LOG', RlNo, RlRec, True$, False$, True$) - end - -end service - - -Service UpdateReactorLogPMStatuses() - - hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') - Lock hSysLists, ServiceKeyID then - Open 'DICT.REACTOR_LOG' to hDict then - RLKeys = '' - Query = 'CHECKLIST_ACTIVE':@VM:True$:@FM - Flag = '' - Btree.Extract(Query, 'REACTOR_LOG', hDict, RLKeys, '', Flag) - If Flag EQ 0 then - // Btree.Extract successful - If RLKeys NE '' then - For each RLKey in RLKeys using @VM - Reactor_Log_Services("GetReactorLogPMStatus", RLKey) - Next RLKey - end - end else - Error_Services('Add', 'Error in ':Service:' service. Btree.Extract call failed.') - end - end - Unlock hSysLists, ServiceKeyID else Null - end - -end service - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1282,6 +948,3 @@ ClearCursors: return - - - diff --git a/LSL2/STPROC/REACTOR_MODES_SERVICES.txt b/LSL2/STPROC/REACTOR_MODES_SERVICES.txt index 9bf4e95..8c72033 100644 --- a/LSL2/STPROC/REACTOR_MODES_SERVICES.txt +++ b/LSL2/STPROC/REACTOR_MODES_SERVICES.txt @@ -31,7 +31,8 @@ $Insert REACT_PROB_CAT_EQUATES $Insert REACTOR_EQUATES $Insert RLIST_EQUATES -Declare function Database_Services, React_Prob_Cat_Services, Reactor_Modes_Services, Memberof, Error_Services +Declare function Database_Services, React_Prob_Cat_Services, Reactor_Modes_Services, Memberof, Error_Services +Declare function Nica_Orders_Services, Reactor_Services Declare subroutine Error_Services, Database_Services, delete, RList, Reactor_Services GoToService @@ -223,17 +224,9 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo) CurModeReleaseGroups = XLATE('REACTOR_MODES', ReactorModesKey, REACTOR_MODES_GROUPS_RELEASE$, 'X') CanRelease = 0 - IdleStartupRequired = False$ - If ReactNo NE '' then - IdleStartupRequired = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X') - If IdleStartupRequired EQ True$ then - Reactor_Services('GetReactorProveInStatus', ReactNo) - end - IdleStartupRequired = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X') - If IdleStartupRequired EQ '' then IdleStartupRequired = False$ - end + IdleStartupRequired = Reactor_Services('GetIdleStartupRequired', ReactNo) - //Check can release from current mode + // Check can release from current mode for each ReleaseGroup in CurModeReleaseGroups using @VM if Memberof(CurrUser, ReleaseGroup) then CanRelease = 1 @@ -267,8 +260,10 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo) Next mode end - for each PossibleMode in PossibleModes using @FM + + For each PossibleMode in PossibleModes using @FM AllowMode = True$ + If PossibleMode EQ 'IDLE_STARTUP' and IdleStartupRequired EQ False$ then AllowMode = False$ end @@ -299,5 +294,3 @@ Service AvailableModes(ReactorModesKey, CurrUser, ReactNo) end service - - diff --git a/LSL2/STPROC/REACTOR_SERVICES.txt b/LSL2/STPROC/REACTOR_SERVICES.txt index 41cb2a4..8c5ede8 100644 --- a/LSL2/STPROC/REACTOR_SERVICES.txt +++ b/LSL2/STPROC/REACTOR_SERVICES.txt @@ -32,7 +32,6 @@ Function Reactor_Services(@Service, @Params) 12/06/23 djm Add MD3 conversion to TargetThickness in metric increment and decrement services. ***********************************************************************************************************************/ - #pragma precomp SRP_PreCompiler $insert APP_INSERTS @@ -52,36 +51,38 @@ $Insert REACT_STATUS_EQUATES $Insert WO_LOG_EQUATES $Insert REACTOR_DAILY_UPTIME_EQUATES $Insert REACT_LL_EQUATES -equ WOCust$ to 2 +$Insert IQS_VIOL_DATA_EQUATES -//Uptime Percentage Equates -EQU PRODUCTIVE$ to 1 -EQU UNSCHED$ to 2 -EQU SCHED$ to 3 -EQU NONSCHED$ to 4 -EQU ENG$ to 5 +Equ WOCust$ to 2 +// Uptime Percentage Equates +Equ PRODUCTIVE$ to 1 +Equ UNSCHED$ to 2 +Equ SCHED$ to 3 +Equ NONSCHED$ to 4 +Equ ENG$ to 5 -Declare subroutine Error_Services, Reactor_Services, Memory_Services, RList, Database_Services, SRP_JSON, obj_React_Mode -Declare subroutine Excel_Services, Schedule_Services, Logging_Services, Set_Status, obj_React_Status, Errmsg,React_Assign_Conv +Declare subroutine Error_Services, Reactor_Services, Memory_Services, RList, Database_Services, SRP_JSON +Declare subroutine Excel_Services, Schedule_Services, Logging_Services, Set_Status, obj_React_Status, Errmsg Declare subroutine Obj_Notes, Btree.Extract, SRP_Fastarray, Delay, Mona_Services, SRP_List, Msg, Rds_Services +Declare subroutine React_Assign_Conv, Nica_Orders_Services, obj_React_Mode Declare function SRP_Array, Reactor_Services, Memory_Services, Database_Services, SRP_Sort_Array, Excel_Services Declare function SRP_Math, SRP_Hash, SRP_JSON, Epi_Part_Services, Schedule_Services, Date_Services, Environment_Services Declare function Logging_Services, GetCommandLine, NextKey, Reactor_Log_Services, SRP_DateTime, ole_getwebpage Declare function Datetime, Reactor_Modes_Services, Work_Order_Services, React_Mode_NG_Services, Lsl_Users_Services Declare function SRP_Time, Rds_Services, SRP_Fastarray, Httpclient_Services, SRP_List, Utility, Memberof, Error_Services +Declare function Nica_Orders_Services // Report paths for various performance report services. TemplatesFolder = Environment_Services('GetApplicationRootPath') : '\Reports\Scheduler\Templates\' DailyReportsFolder = Environment_Services('GetApplicationRootPath') : '\Reports\Scheduler\Daily\' WeeklyReportsFolder = Environment_Services('GetApplicationRootPath') : '\Reports\Scheduler\Weekly\' -CommandLine = GetCommandLine() -Machine = Environment_Services('GetServer') - -LogDate = Oconv(Date(), 'D4/') -LogTime = Oconv(Time(), 'MTS') -LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM +CommandLine = GetCommandLine() +Machine = Environment_Services('GetServer') +LogDate = Oconv(Date(), 'D4/') +LogTime = Oconv(Time(), 'MTS') +LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM GoToService else @@ -95,7 +96,6 @@ Return Response else '' Options BOOLEAN = True$, False$ Options REACTORMETRIC = 'TUBE_BELL_JAR_THK', 'TUBE_BELL_JAR_WFR_CNT', 'SUSC_THK', 'SUSC_WFR_CNT', 'LOWER_QUARTZ_THK', 'LOWER_QUARTZ_WFR', 'ARMS_WFR_CNT' - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Services //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -132,8 +132,8 @@ Service IncrementWfrMetrics(RDSNo) // Arms are not used for EPP If ReactorType NE 'EPP' then - CurrArmsWfrCnt = OldReactorRec - If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 + CurrArmsWfrCnt = OldReactorRec + If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 end // Set values to 0 if blank @@ -206,67 +206,71 @@ Service IncrementWfrMetrics(RDSNo) end service + Service GetWaferCntMetricsByReactorID(ReactorID) - If ReactorID NE '' then - If RowExists('REACTOR', ReactorID) then - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactorID) - ReactorType = ReactorRec - ResponseData = '' - Begin Case - Case ReactorType EQ 'ASM' OR ReactorType EQ 'ASM+' - ResponseData<1, 1> = ReactorID - ResponseData<1, 2> = ReactorRec - ResponseData<1, 3> = ReactorRec - ResponseData<1, 4> = ReactorRec - ResponseData<1, 5> = ReactorRec - ResponseData<1, 6> = ReactorRec - //These are the column titles to help us with API Responses - ResponseData<2, 1> = 'ReactorID' - ResponseData<2, 2> = 'SusceptorWaferCount' - ResponseData<2, 3> = 'SusceptorThickness' - ResponseData<2, 4> = 'TubeWaferCount' - ResponseData<2, 5> = 'TubeThickness' - ResponseData<2, 6> = 'ArmsWaferCount' - Case ReactorType EQ 'HTR' - ResponseData<1, 1> = ReactorID - ResponseData<1, 2> = ReactorRec - ResponseData<1, 3> = ReactorRec - ResponseData<1, 4> = ReactorRec - ResponseData<1, 5> = ReactorRec - ResponseData<1, 6> = ReactorRec - //These are the column titles to help us with API Responses - ResponseData<2, 1> = 'ReactorID' - ResponseData<2, 2> = 'SusceptorWaferCount' - ResponseData<2, 3> = 'SusceptorThickness' - ResponseData<2, 4> = 'TubeWaferCount' - ResponseData<2, 5> = 'TubeThickness' - ResponseData<2, 6> = 'ArmsWaferCount' - Case ReactorType EQ 'EPP' - ResponseData<1, 1> = ReactorID - ResponseData<1, 2> = ReactorRec - ResponseData<1, 3> = ReactorRec - ResponseData<1, 4> = ReactorRec - ResponseData<1, 5> = ReactorRec - ResponseData<1, 6> = ReactorRec - ResponseData<1, 7> = ReactorRec - //These are the column titles to help us with API Responses - ResponseData<2, 1> = 'ReactorID' - ResponseData<2, 2> = 'SusceptorWaferCount' - ResponseData<2, 3> = 'SusceptorThickness' - ResponseData<2, 4> = 'BellJarWaferCount' - ResponseData<2, 5> = 'BellJarThickness' - ResponseData<2, 6> = 'LowerQuartzWaferCount' - ResponseData<2, 7> = 'LowerQuartzThickness' - End Case - Response = ResponseData - end else - Error_Services('Add', 'Error: Invalid Reactor ID passed to REACTOR_SERVICES("GetWaferMetricsByReactorID"') - end - end else - Error_Services('Add', 'Error: Null Reactor ID passed to REACTOR_SERVICES("GetWaferMetricsByReactorID"') - end + + If ReactorID NE '' then + If RowExists('REACTOR', ReactorID) then + ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactorID) + ReactorType = ReactorRec + ResponseData = '' + Begin Case + Case ReactorType EQ 'ASM' OR ReactorType EQ 'ASM+' + ResponseData<1, 1> = ReactorID + ResponseData<1, 2> = ReactorRec + ResponseData<1, 3> = ReactorRec + ResponseData<1, 4> = ReactorRec + ResponseData<1, 5> = ReactorRec + ResponseData<1, 6> = ReactorRec + //These are the column titles to help us with API Responses + ResponseData<2, 1> = 'ReactorID' + ResponseData<2, 2> = 'SusceptorWaferCount' + ResponseData<2, 3> = 'SusceptorThickness' + ResponseData<2, 4> = 'TubeWaferCount' + ResponseData<2, 5> = 'TubeThickness' + ResponseData<2, 6> = 'ArmsWaferCount' + Case ReactorType EQ 'HTR' + ResponseData<1, 1> = ReactorID + ResponseData<1, 2> = ReactorRec + ResponseData<1, 3> = ReactorRec + ResponseData<1, 4> = ReactorRec + ResponseData<1, 5> = ReactorRec + ResponseData<1, 6> = ReactorRec + //These are the column titles to help us with API Responses + ResponseData<2, 1> = 'ReactorID' + ResponseData<2, 2> = 'SusceptorWaferCount' + ResponseData<2, 3> = 'SusceptorThickness' + ResponseData<2, 4> = 'TubeWaferCount' + ResponseData<2, 5> = 'TubeThickness' + ResponseData<2, 6> = 'ArmsWaferCount' + Case ReactorType EQ 'EPP' + ResponseData<1, 1> = ReactorID + ResponseData<1, 2> = ReactorRec + ResponseData<1, 3> = ReactorRec + ResponseData<1, 4> = ReactorRec + ResponseData<1, 5> = ReactorRec + ResponseData<1, 6> = ReactorRec + ResponseData<1, 7> = ReactorRec + //These are the column titles to help us with API Responses + ResponseData<2, 1> = 'ReactorID' + ResponseData<2, 2> = 'SusceptorWaferCount' + ResponseData<2, 3> = 'SusceptorThickness' + ResponseData<2, 4> = 'BellJarWaferCount' + ResponseData<2, 5> = 'BellJarThickness' + ResponseData<2, 6> = 'LowerQuartzWaferCount' + ResponseData<2, 7> = 'LowerQuartzThickness' + End Case + Response = ResponseData + end else + Error_Services('Add', 'Error: Invalid Reactor ID passed to REACTOR_SERVICES("GetWaferMetricsByReactorID"') + end + end else + Error_Services('Add', 'Error: Null Reactor ID passed to REACTOR_SERVICES("GetWaferMetricsByReactorID"') + end + end service + //---------------------------------------------------------------------------------------------------------------------- // DecrementWfrMetrics // @@ -299,8 +303,8 @@ Service DecrementWfrMetrics(RDSNo) // Arms are not used for EPP If ReactorType NE 'EPP' then - CurrArmsWfrCnt = OldReactorRec - If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 + CurrArmsWfrCnt = OldReactorRec + If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 end // Set values to 0 if blank @@ -374,7 +378,6 @@ Service DecrementWfrMetrics(RDSNo) end service - //---------------------------------------------------------------------------------------------------------------------- // IncrementTestWfrMetrics // @@ -403,8 +406,8 @@ Service IncrementTestWfrMetrics(TargetThickness, WaferCount, ReactorNo) // Arms are not used for EPP If ReactorType NE 'EPP' then - CurrArmsWfrCnt = OldReactorRec - If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 + CurrArmsWfrCnt = OldReactorRec + If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 end // Set values to 0 if blank @@ -477,6 +480,7 @@ Service IncrementTestWfrMetrics(TargetThickness, WaferCount, ReactorNo) end service + //---------------------------------------------------------------------------------------------------------------------- // DecrementTestWfrMetrics // @@ -505,8 +509,8 @@ Service DecrementTestWfrMetrics(TargetThickness, WaferCount, ReactorNo) // Arms are not used for EPP If ReactorType NE 'EPP' then - CurrArmsWfrCnt = OldReactorRec - If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 + CurrArmsWfrCnt = OldReactorRec + If CurrArmsWfrCnt = '' then CurrArmsWfrCnt = 0 end // Set values to 0 if blank @@ -594,35 +598,36 @@ Service ResetWfrMetric(ReactorNo, MetricType = REACTORMETRIC) ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactorNo) - Begin Case - - Case MetricType = 'TUBE_BELL_JAR_THK' - ReactorRec = 0 - - Case MetricType = 'TUBE_BELL_JAR_WFR_CNT' - ReactorRec = 0 - - Case MetricType = 'SUSC_THK' - ReactorRec = 0 - - Case MetricType = 'SUSC_WFR_CNT' - ReactorRec = 0 - - Case MetricType = 'LOWER_QUARTZ_THK' - ReactorRec = 0 - - Case MetricType = 'LOWER_QUARTZ_WFR' - ReactorRec = 0 - - Case MetricType = 'ARMS_WFR_CNT' - ReactorRec = 0 - - End Case + Begin Case + + Case MetricType = 'TUBE_BELL_JAR_THK' + ReactorRec = 0 + + Case MetricType = 'TUBE_BELL_JAR_WFR_CNT' + ReactorRec = 0 + + Case MetricType = 'SUSC_THK' + ReactorRec = 0 + + Case MetricType = 'SUSC_WFR_CNT' + ReactorRec = 0 + + Case MetricType = 'LOWER_QUARTZ_THK' + ReactorRec = 0 + + Case MetricType = 'LOWER_QUARTZ_WFR' + ReactorRec = 0 + + Case MetricType = 'ARMS_WFR_CNT' + ReactorRec = 0 + + End Case Database_Services('WriteDataRow', 'REACTOR', ReactorNo, ReactorRec, 1, 0, 0) end service + //---------------------------------------------------------------------------------------------------------------------- // GetReactors // @@ -767,6 +772,7 @@ Service GetReactorNumbers(MatchType, MatchSize) end service + //---------------------------------------------------------------------------------------------------------------------- // GetReactor // @@ -1120,6 +1126,7 @@ Service ClearWafersProcessed(ScheduleDate) end service + //---------------------------------------------------------------------------------------------------------------------- // CreateDailyPerformanceReport // @@ -1448,6 +1455,7 @@ Service UpdateWeeklyPerformanceReport(YearWeekNo) end service + Service GetReactorCurrLoad(ReactNo) Response = '' @@ -1457,6 +1465,7 @@ Service GetReactorCurrLoad(ReactNo) end service + Service GetReactorCurrLoadRDS(ReactNo) Response = '' @@ -1464,37 +1473,47 @@ Service GetReactorCurrLoadRDS(ReactNo) LoadedCassettes = ReactStatusRec Response = LoadedCassettes + + Response = '' + ReactStatusRec = Database_Services('ReadDataRow', 'REACT_STATUS', ReactNo) + LoadedCassettes = ReactStatusRec + Response = LoadedCassettes + end service + Service GetReactCurrModeRec(ReactNo) - - Response = '' - ReactModeRecKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') - ReactModeRec = Database_Services('ReadDataRow', 'REACT_MODE_NG', ReactModeRecKey) - Response = ReactModeRec - + + Response = '' + ReactModeRecKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') + ReactModeRec = Database_Services('ReadDataRow', 'REACT_MODE_NG', ReactModeRecKey) + Response = ReactModeRec + end service + Service GetReactCurrModeId(ReactNo) - - Response = '' - ReactModeRecKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') - Response = ReactModeRecKey - + + Response = '' + ReactModeRecKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') + Response = ReactModeRecKey + end service + Service GetReactCurrModeName(ReactNo) - Response = '' - ReactModeRec = Reactor_Services('GetReactCurrModeRec', ReactNo) - Response = ReactModeRec - + Response = '' + ReactModeRec = Reactor_Services('GetReactCurrModeRec', ReactNo) + Response = ReactModeRec + end service + Service GetReactModeHistory(ReactNo, DaysToReport) StartDt = Date() - DaysToReport @@ -1786,6 +1805,7 @@ Service GetReactorCassLoadHistory(ReactNo, DaysToReport) end service + Service GetReactorCassLoadHistoryRange(ReactNo, StartDTM, StopDTM) Response = '' @@ -1864,12 +1884,12 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force ErrorMsg = '' IF ForceModeChange NE True$ then ForceModeChange = False$ If ( (UserID NE '') and (ReactNo NE '') and (Mode NE '') and (ModeSubCat NE '')) then - CurTime = time() CurDate = date() NGPrevModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')<1, 1> PrevModeRec = Reactor_Services('GetReactCurrModeRec', ReactNo) SelectedModeRec = Database_Services('ReadDataRow', 'REACTOR_MODES', Mode) + SelE10State = SelectedModeRec CommentException = False$ @@ -1911,31 +1931,31 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force ErrorMsg = 'Failed to locate ModeSubCat.' end - CurrentMode = PrevModeRec - ActiveProveInPreventsModeChange = Reactor_Services('ActiveProveInPreventsModeChange', ReactNo, Mode, CurrentMode) - - If Error_Services('HasError') then - ErrorMsg = Error_Services('GetMessage') - end else - If ActiveProveInPreventsModeChange EQ True$ then - ErrorMsg = 'A reactor prove in is required before changing the mode. Active prove in types: ' - - TypeList = '' - ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X') - for each ProveInType in ProveInTypes using @VM setting Idx - If Idx GT 1 then - TypeList := ', ' - end - TypeList := ProveInType - Next ProveInType - - ErrorMsg := TypeList - end - end - - IdleStartupRequired = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X') + CurrentMode = PrevModeRec + ActiveProveInPreventsModeChange = Reactor_Services('ActiveProveInPreventsModeChange', ReactNo, Mode, CurrentMode) + + If Error_Services('HasError') then + ErrorMsg = Error_Services('GetMessage') + end else + If ActiveProveInPreventsModeChange EQ True$ then + ErrorMsg = 'A reactor prove in is required before changing the mode. Active prove in types: ' + + TypeList = '' + ProveInTypes = Reactor_Services('GetActiveProveInTypes', ReactNo) + for each ProveInType in ProveInTypes using @VM setting Idx + If Idx GT 1 then + TypeList := ', ' + end + TypeList := ProveInType + Next ProveInType + + ErrorMsg := TypeList + end + end + + IdleStartupRequired = Reactor_Services('GetIdleStartupRequired', ReactNo) If ErrorMsg EQ '' and IdleStartupRequired and Mode[1, 2] EQ 'UP' then - ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X') + ProveInTypes = Reactor_Services('GetActiveProveInTypes', ReactNo) IdleStartupActive = False$ for each ProveInType in ProveInTypes using @VM setting Idx If ProveInType EQ 'IDLE' then @@ -1949,18 +1969,26 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force ErrorMsg = "An IDLE_STARTUP prove in checklist is required before putting the reactor UP. Change the mode to IDLE_STARTUP, then complete the checklist." end end - - If ErrorMsg EQ '' then - If Len(Mode) GT 10 and Mode[1, 10] EQ 'CHANGEOVER' then - Reactor_Services('CreateReactorProveInOrder', ReactNo, 'CHANGEOVER') + + If ErrorMsg EQ '' then + ActiveHgCVChecklists = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'IQS_HGCV_ALARM') + HgCVChecklistActive = (ActiveHgCVChecklists NE '') + If ( HgCVChecklistActive and (SelE10State _EQC 'Productive') ) then + ErrorMsg = "An HgCV OCAP Checklist is active for this reactor and must be completed or overridden in order to change to a productive state." + end + end + + If ErrorMsg EQ '' then + If Len(Mode) GT 10 and Mode[1, 10] EQ 'CHANGEOVER' then + Nica_Orders_Services('CreateNewOrder', 'REACTOR', ReactNo, 'CHANGEOVER') end If Mode EQ 'INITIATE_IDLE' then - Reactor_Services('CreateReactorProveInOrder', ReactNo, 'INITIATE_IDLE') + Nica_Orders_Services('CreateNewOrder', 'REACTOR', ReactNo, 'INITIATE_IDLE') end If Mode EQ 'IDLE_STARTUP' then - Reactor_Services('CreateReactorProveInOrder', ReactNo, 'IDLE') + Nica_Orders_Services('CreateNewOrder', 'REACTOR', ReactNo, 'IDLE') end end @@ -2396,16 +2424,16 @@ end service Service FormatReactStatusSingle(ReactNo) - - Response = '' - CurrModeRec = Reactor_Services('GetReactCurrModeRec', ReactNo) - CurrLoadings = Reactor_Services('GetReactorCurrLoad', ReactNo) - - ReactStatusArray = CurrModeRec - ReactStatusArray<12> = CurrLoadings; *Currently loaded cassettes - - Response = ReactStatusArray - + + Response = '' + CurrModeRec = Reactor_Services('GetReactCurrModeRec', ReactNo) + CurrLoadings = Reactor_Services('GetReactorCurrLoad', ReactNo) + + ReactStatusArray = CurrModeRec + ReactStatusArray<12> = CurrLoadings; *Currently loaded cassettes + + Response = ReactStatusArray + end service @@ -2507,24 +2535,24 @@ end service Service IsReactorLoaded(ReactNo) - - ErrorMsg = '' - Response = False$ - If ReactNo NE '' then - LoadedRDS = Xlate('REACT_STATUS', ReactNo, 'LOAD_RDS', 'X') - If LoadedRDS NE '' then Response = True$ - end else - ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed in.' - end - If ErrorMsg NE '' then - Error_Services('Add', ErrorMsg) - end - + + ErrorMsg = '' + Response = False$ + If ReactNo NE '' then + LoadedRDS = Xlate('REACT_STATUS', ReactNo, 'LOAD_RDS', 'X') + If LoadedRDS NE '' then Response = True$ + end else + ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed in.' + end + If ErrorMsg NE '' then + Error_Services('Add', ErrorMsg) + end + end service Service GetReactorTimeSinceUnload(ReactNo) - + ErrorMsg = '' Response = 0 @@ -2544,145 +2572,145 @@ end service Service ConvertRecordToJSON(ReactorNo, ItemURL, CurrUser, FullObject=BOOLEAN) - - If FullObject EQ '' then FullObject = True$ - ErrorMsg = '' - JSON = '' - If ReactorNo then - objJSON = '' - If SRP_JSON(objJSON, 'New', 'Object') then - // Add in reactor current mode, available modes, and available sub categories. - CurrModeKey = Reactor_Services('GetReactCurrModeId', ReactorNo) - CurrMode = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_MODE$, 'X') - ServiceDesc = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_SERVICE_DESC$, 'X') - If (CurrUser NE '') then AvailModes = Reactor_Modes_Services('AvailableModes', CurrMode, CurrUser) - CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$ , 'X') - ReactorType = Xlate('REACTOR', ReactorNo, 'REACT_TYPE', 'X') - ReactAssign = Xlate('REACTOR', ReactorNo, 'REACT_ASSIGNMENT', 'X') - React_Assign_Conv('OCONV', ReactAssign, '', ReactAssign) - // Create reactor object - If SRP_JSON(objReactor, 'New', 'Object') then - SRP_JSON(objReactor, 'SetValue', 'reactorNo', ReactorNo) - SRP_JSON(objReactor, 'SetValue', 'reactType', ReactorType) - SRP_JSON(objReactor, 'SetValue', 'reactAssignment', ReactAssign) - PickPlace = Xlate('REACTOR', ReactorNo, 'PICK_PLACE', 'X') - SRP_JSON(objReactor, 'SetValue', 'pickPlace', PickPlace, 'Boolean') - LLDisabledKey = Xlate('REACTOR', ReactorNo, 'ACTIVE_LL_DISABLED', 'X') - LoadLockDisabled = Xlate('REACT_LL', LLDisabledKey, 'DISABLED', 'X') - SRP_JSON(objReactor, 'SetValue', 'loadLockDown', LoadLockDisabled) - SRP_JSON(objReactor, 'SetValue', '0311Active', Xlate('REACTOR', ReactorNo, '0311_ACTIVE', 'X'), 'Boolean') - SRP_JSON(objReactor, 'SetValue', 'active0311Checklist', Xlate('REACTOR', ReactorNo, '0311_ACTIVE', 'X'), 'Boolean') - SRP_JSON(objReactor, 'SetValue', 'TubeBellJarCnt', Xlate('REACTOR', ReactorNo, REACTOR_TUBE_BELL_JAR_THK$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'TubeBellJarThk', Xlate('REACTOR', ReactorNo, REACTOR_TUBE_BELL_JAR_WFR_CNT$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'SusceptorCnt', Xlate('REACTOR', ReactorNo, REACTOR_SUSC_WFR_CNT$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'SusceptorThk', Xlate('REACTOR', ReactorNo, REACTOR_SUSC_THK$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'LowerQuartzCnt', Xlate('REACTOR', ReactorNo, REACTOR_LOWER_QUARTZ_WFR$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'LowerQuartzThk', Xlate('REACTOR', ReactorNo, REACTOR_LOWER_QUARTZ_THK$, 'X')) - SRP_JSON(objReactor, 'SetValue', 'ArmsCnt', Xlate('REACTOR', ReactorNo, REACTOR_ARMS_WFR_CNT$, 'X')) - - // Add Current Run Status (Current Loaded Cassettes) - LoadedRDS = Xlate('REACT_STATUS', ReactorNo, 'LOAD_RDS', 'X') - If LoadedRDS NE '' then - objLoadedRDS = '' - If SRP_JSON(objLoadedRDS, 'New', 'Array') then - For each RDS in LoadedRDS using @VM setting vPos - SRP_JSON(objLoadedRDS, 'AddValue', RDS) - Next RDS - SRP_JSON(objReactor, 'Set', 'loadedRDS', objLoadedRDS) - SRP_JSON(objLoadedRDS, 'Release') - end - end else - SRP_JSON(objReactor, 'SetValue', 'loadedRDS', '') - end - - // Add new reactor items here - InstItems = Xlate('REACTOR', ReactorNo, REACTOR_CURR_INST_ITEMS$, 'X') - If InstItems NE '' then - objInstItems = '' - If SRP_JSON(objInstItems, 'New', 'Array') then - For each Item in InstItems using @VM setting vPos - swap '*' with @VM in Item - SRP_JSON(objInstItems, 'AddValue', Item<1, 2>) - Next Item - SRP_JSON(objReactor, 'Set', 'installedReactItems', objInstItems) - SRP_JSON(objInstItems, 'Release') - end - end else - SRP_JSON(objReactor, 'SetValue', 'installedReactItems', '') - end - - // Add Current Run Status (Is running) - ReactorRunning = (LoadedRDS NE '') - SRP_JSON(objReactor, 'SetValue', 'isRunning', ReactorRunning, 'Boolean') - - // Add Out of prod time - OutofProdDTM = Xlate('REACT_STATUS', ReactorNo, 'OUT_OF_PROD_DTM', 'X') - SRP_JSON(objReactor, 'SetValue', 'outOfProdDTM', OConv(OutofProdDTM, 'DT2/^H')) - - If FullObject then - // Add Last Unload Time - LastUnloadDTM = Xlate('REACT_STATUS', ReactorNo, 'UNLOAD_RDS_DTM', 'X') - SRP_JSON(objReactor, 'SetValue', 'unloadDTM', OConv(LastUnloadDTM, 'DT2/^H')) - - // Add Last Load Time - LastLoadDTM = Xlate('REACT_STATUS', ReactorNo, 'LOAD_RDS_DTM', 'X') - LastLoadDTM = LastLoadDTM[-1, 'B':@VM] - SRP_JSON(objReactor, 'SetValue', 'loadDTM', OConv(LastLoadDTM, 'DT2/^H')) - - // Add Last Reactor Readings - LastReadWfrsDTM = Xlate('REACTOR', ReactorNo, 'LAST_READ_WFRS_DTM', 'X') - LastReadWfrs = Xlate('REACT_READS', ReactorNo:'*':LastReadWfrsDTM, 'WAFER_CNT', 'X') - SRP_JSON(objReactor, 'SetValue', 'lastReadWafersDTM', OConv(LastReadWfrsDTM, 'DT2/^H')) - SRP_JSON(objReactor, 'SetValue', 'lastReadWafers', LastReadWfrs) - end - - // Add work order object - SchedConfigRec = Database_Services('ReadDataRow', 'CONFIG', 'WO_DAILY_SCHED':ReactorNo) - WorkOrderCust = SchedConfigRec - CurrWorkOrder = Field(WorkOrderCust, ' ', 1) - SRP_JSON(objReactor, 'SetValue', 'workOrder', CurrWorkOrder) - WOHotStatus = Xlate('WO_LOG', CurrWorkOrder, 'HOT_FLAG', 'X') - SRP_JSON(objReactor, 'SetValue', 'workOrderHotStatus', WOHotStatus) - WOCustomer = Field(WorkOrderCust, ' ', 2) - SRP_JSON(objReactor, 'SetValue', 'workOrderCustomer', WOCustomer) - If FullObject then - JSONWorkOrder = Work_Order_Services('ConvertRecordToJSON', CurrWorkOrder) - objWorkOrder = '' - If SRP_JSON(objWorkOrder, 'Parse', JSONWorkOrder) EQ '' then - objTemp = SRP_JSON(objWorkOrder, 'Get', 'workOrder') - SRP_JSON(objReactor, 'Set', 'workOrder', objTemp) - SRP_JSON(objTemp, 'Release') - SRP_JSON(objWorkOrder, 'Release') - end - end - - // Reactor Mode object/properties - If FullObject then - // Add reactor mode object - JSONReactorMode = React_Mode_NG_Services('ConvertRecordToJSON', CurrModeKey, '', CurrUser) - objReactorMode = '' - If SRP_JSON(objReactorMode, 'Parse', JSONReactorMode) EQ '' then - objTemp = SRP_JSON(objReactorMode, 'Get', 'reactorMode') - SRP_JSON(objReactor, 'Set', 'reactorMode', objTemp) - SRP_JSON(objTemp, 'Release') - SRP_JSON(objReactorMode, 'Release') - end - end else - CurrMode = Xlate('REACT_MODE_NG', CurrModeKey, 'MODE', 'X') - SubCat = Xlate('REACT_MODE_NG', CurrModeKey, 'SERVICE_DESC', 'X') - E10State = Xlate('REACTOR_MODES', CurrMode, 'E10_STATE', 'X') - SRP_JSON(objReactor, 'SetValue', 'currMode', CurrMode) - SRP_JSON(objReactor, 'SetValue', 'serviceDesc', SubCat) - SRP_JSON(objReactor, 'SetValue', 'e10State', E10State) - end - - If Not(FullObject) then - // Add reactor log properties - CurrRlKey = Xlate('REACTOR', ReactorNo, 'CURR_MODE_RL_ID', 'X') - If CurrRLKey NE '' then - RlChecklistActive = Xlate('REACTOR_LOG', CurrRlKey, 'CHECKLIST_ACTIVE', 'X') - SRP_JSON(objReactor, 'SetValue', 'reactorLogChecklistActive', RlChecklistActive, 'Boolean') - If RlChecklistActive then + + If FullObject EQ '' then FullObject = True$ + ErrorMsg = '' + JSON = '' + If ReactorNo then + objJSON = '' + If SRP_JSON(objJSON, 'New', 'Object') then + // Add in reactor current mode, available modes, and available sub categories. + CurrModeKey = Reactor_Services('GetReactCurrModeId', ReactorNo) + CurrMode = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_MODE$, 'X') + ServiceDesc = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_SERVICE_DESC$, 'X') + If (CurrUser NE '') then AvailModes = Reactor_Modes_Services('AvailableModes', CurrMode, CurrUser) + CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$ , 'X') + ReactorType = Xlate('REACTOR', ReactorNo, 'REACT_TYPE', 'X') + ReactAssign = Xlate('REACTOR', ReactorNo, 'REACT_ASSIGNMENT', 'X') + React_Assign_Conv('OCONV', ReactAssign, '', ReactAssign) + // Create reactor object + If SRP_JSON(objReactor, 'New', 'Object') then + SRP_JSON(objReactor, 'SetValue', 'reactorNo', ReactorNo) + SRP_JSON(objReactor, 'SetValue', 'reactType', ReactorType) + SRP_JSON(objReactor, 'SetValue', 'reactAssignment', ReactAssign) + PickPlace = Xlate('REACTOR', ReactorNo, 'PICK_PLACE', 'X') + SRP_JSON(objReactor, 'SetValue', 'pickPlace', PickPlace, 'Boolean') + LLDisabledKey = Xlate('REACTOR', ReactorNo, 'ACTIVE_LL_DISABLED', 'X') + LoadLockDisabled = Xlate('REACT_LL', LLDisabledKey, 'DISABLED', 'X') + SRP_JSON(objReactor, 'SetValue', 'loadLockDown', LoadLockDisabled) + SRP_JSON(objReactor, 'SetValue', '0311Active', Xlate('REACTOR', ReactorNo, '0311_ACTIVE', 'X'), 'Boolean') + SRP_JSON(objReactor, 'SetValue', 'active0311Checklist', Xlate('REACTOR', ReactorNo, '0311_ACTIVE', 'X'), 'Boolean') + SRP_JSON(objReactor, 'SetValue', 'TubeBellJarCnt', Xlate('REACTOR', ReactorNo, REACTOR_TUBE_BELL_JAR_THK$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'TubeBellJarThk', Xlate('REACTOR', ReactorNo, REACTOR_TUBE_BELL_JAR_WFR_CNT$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'SusceptorCnt', Xlate('REACTOR', ReactorNo, REACTOR_SUSC_WFR_CNT$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'SusceptorThk', Xlate('REACTOR', ReactorNo, REACTOR_SUSC_THK$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'LowerQuartzCnt', Xlate('REACTOR', ReactorNo, REACTOR_LOWER_QUARTZ_WFR$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'LowerQuartzThk', Xlate('REACTOR', ReactorNo, REACTOR_LOWER_QUARTZ_THK$, 'X')) + SRP_JSON(objReactor, 'SetValue', 'ArmsCnt', Xlate('REACTOR', ReactorNo, REACTOR_ARMS_WFR_CNT$, 'X')) + + // Add Current Run Status (Current Loaded Cassettes) + LoadedRDS = Xlate('REACT_STATUS', ReactorNo, 'LOAD_RDS', 'X') + If LoadedRDS NE '' then + objLoadedRDS = '' + If SRP_JSON(objLoadedRDS, 'New', 'Array') then + For each RDS in LoadedRDS using @VM setting vPos + SRP_JSON(objLoadedRDS, 'AddValue', RDS) + Next RDS + SRP_JSON(objReactor, 'Set', 'loadedRDS', objLoadedRDS) + SRP_JSON(objLoadedRDS, 'Release') + end + end else + SRP_JSON(objReactor, 'SetValue', 'loadedRDS', '') + end + + // Add new reactor items here + InstItems = Xlate('REACTOR', ReactorNo, REACTOR_CURR_INST_ITEMS$, 'X') + If InstItems NE '' then + objInstItems = '' + If SRP_JSON(objInstItems, 'New', 'Array') then + For each Item in InstItems using @VM setting vPos + swap '*' with @VM in Item + SRP_JSON(objInstItems, 'AddValue', Item<1, 2>) + Next Item + SRP_JSON(objReactor, 'Set', 'installedReactItems', objInstItems) + SRP_JSON(objInstItems, 'Release') + end + end else + SRP_JSON(objReactor, 'SetValue', 'installedReactItems', '') + end + + // Add Current Run Status (Is running) + ReactorRunning = (LoadedRDS NE '') + SRP_JSON(objReactor, 'SetValue', 'isRunning', ReactorRunning, 'Boolean') + + // Add Out of prod time + OutofProdDTM = Xlate('REACT_STATUS', ReactorNo, 'OUT_OF_PROD_DTM', 'X') + SRP_JSON(objReactor, 'SetValue', 'outOfProdDTM', OConv(OutofProdDTM, 'DT2/^H')) + + If FullObject then + // Add Last Unload Time + LastUnloadDTM = Xlate('REACT_STATUS', ReactorNo, 'UNLOAD_RDS_DTM', 'X') + SRP_JSON(objReactor, 'SetValue', 'unloadDTM', OConv(LastUnloadDTM, 'DT2/^H')) + + // Add Last Load Time + LastLoadDTM = Xlate('REACT_STATUS', ReactorNo, 'LOAD_RDS_DTM', 'X') + LastLoadDTM = LastLoadDTM[-1, 'B':@VM] + SRP_JSON(objReactor, 'SetValue', 'loadDTM', OConv(LastLoadDTM, 'DT2/^H')) + + // Add Last Reactor Readings + LastReadWfrsDTM = Xlate('REACTOR', ReactorNo, 'LAST_READ_WFRS_DTM', 'X') + LastReadWfrs = Xlate('REACT_READS', ReactorNo:'*':LastReadWfrsDTM, 'WAFER_CNT', 'X') + SRP_JSON(objReactor, 'SetValue', 'lastReadWafersDTM', OConv(LastReadWfrsDTM, 'DT2/^H')) + SRP_JSON(objReactor, 'SetValue', 'lastReadWafers', LastReadWfrs) + end + + // Add work order object + SchedConfigRec = Database_Services('ReadDataRow', 'CONFIG', 'WO_DAILY_SCHED':ReactorNo) + WorkOrderCust = SchedConfigRec + CurrWorkOrder = Field(WorkOrderCust, ' ', 1) + SRP_JSON(objReactor, 'SetValue', 'workOrder', CurrWorkOrder) + WOHotStatus = Xlate('WO_LOG', CurrWorkOrder, 'HOT_FLAG', 'X') + SRP_JSON(objReactor, 'SetValue', 'workOrderHotStatus', WOHotStatus) + WOCustomer = Field(WorkOrderCust, ' ', 2) + SRP_JSON(objReactor, 'SetValue', 'workOrderCustomer', WOCustomer) + If FullObject then + JSONWorkOrder = Work_Order_Services('ConvertRecordToJSON', CurrWorkOrder) + objWorkOrder = '' + If SRP_JSON(objWorkOrder, 'Parse', JSONWorkOrder) EQ '' then + objTemp = SRP_JSON(objWorkOrder, 'Get', 'workOrder') + SRP_JSON(objReactor, 'Set', 'workOrder', objTemp) + SRP_JSON(objTemp, 'Release') + SRP_JSON(objWorkOrder, 'Release') + end + end + + // Reactor Mode object/properties + If FullObject then + // Add reactor mode object + JSONReactorMode = React_Mode_NG_Services('ConvertRecordToJSON', CurrModeKey, '', CurrUser) + objReactorMode = '' + If SRP_JSON(objReactorMode, 'Parse', JSONReactorMode) EQ '' then + objTemp = SRP_JSON(objReactorMode, 'Get', 'reactorMode') + SRP_JSON(objReactor, 'Set', 'reactorMode', objTemp) + SRP_JSON(objTemp, 'Release') + SRP_JSON(objReactorMode, 'Release') + end + end else + CurrMode = Xlate('REACT_MODE_NG', CurrModeKey, 'MODE', 'X') + SubCat = Xlate('REACT_MODE_NG', CurrModeKey, 'SERVICE_DESC', 'X') + E10State = Xlate('REACTOR_MODES', CurrMode, 'E10_STATE', 'X') + SRP_JSON(objReactor, 'SetValue', 'currMode', CurrMode) + SRP_JSON(objReactor, 'SetValue', 'serviceDesc', SubCat) + SRP_JSON(objReactor, 'SetValue', 'e10State', E10State) + end + + If Not(FullObject) then + // Add reactor log properties + CurrRlKey = Xlate('REACTOR', ReactorNo, 'CURR_MODE_RL_ID', 'X') + If CurrRLKey NE '' then + RlChecklistActive = Xlate('REACTOR_LOG', CurrRlKey, 'CHECKLIST_ACTIVE', 'X') + SRP_JSON(objReactor, 'SetValue', 'reactorLogChecklistActive', RlChecklistActive, 'Boolean') + If RlChecklistActive then RlChecklistTypes = Xlate('REACTOR_LOG', CurrRlKey, 'CHECKLIST_TYPE', 'X') RlChecklistOrderIds = Xlate('REACTOR_LOG', CurrRlKey, 'CHECKLIST_ORDER_ID', 'X') objRlChecklistArray = '' @@ -2700,134 +2728,134 @@ Service ConvertRecordToJSON(ReactorNo, ItemURL, CurrUser, FullObject=BOOLEAN) SRP_JSON(objReactor, 'Set', 'reactorLogChecklists', objRlChecklistArray) SRP_JSON(objRlChecklistArray, 'Release') end - end - end - // Add prove in checklist properties - PiChecklistActive = Xlate('REACTOR', ReactorNo, 'PROVE_IN_ACTIVE', 'X') - SRP_JSON(objReactor, 'SetValue', 'proveInChecklistActive', PiChecklistActive, 'Boolean') - If PiChecklistActive then - PiTypes = Xlate('REACTOR', ReactorNo, 'PROVE_IN_TYPE', 'X') - PiChecklistOrderIds = Xlate('REACTOR', ReactorNo, 'PROVE_IN_ORDER_ID', 'X') - objPiChecklistArray = '' - If SRP_JSON(objPiChecklistArray, 'New', 'Array') then - objProveIn = '' - For each PiType in PiTypes using @VM setting vPos - If SRP_JSON(objProveIn, 'New', 'Object') then - SRP_JSON(objProveIn, 'SetValue', 'proveInType', PiType) - PiChecklistOrderId = PiCheckListOrderIds<0, vPos> - SRP_JSON(objProveIn, 'SetValue', 'proveInOrderId', PiChecklistOrderId) - SRP_JSON(objPiChecklistArray, 'Add', objProveIn) - SRP_JSON(objProveIn, 'Release') - end - Next PiType - SRP_JSON(objReactor, 'Set', 'proveInChecklists', objPiChecklistArray) - SRP_JSON(objPiChecklistArray) - end - end - end - - If itemURL NE '' then - // The itemURL was passed in so add HAL+JSON properties. - objLinks = '' - // Create the _links property and then all link objects needed for this resource. - 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(objReactor, 'Set', '_links', objLinks) - SRP_JSON(objLinks, 'Release') - end - // Create the _class property for this resource. - SRP_JSON(objReactor, 'SetValue', '_class', 'resource') - end - SRP_JSON(objJSON, 'Set', 'reactor', objReactor) - SRP_JSON(objReactor, 'Release') - end - JSON = SRP_JSON(objJSON, 'Stringify', 'Styled') - SRP_JSON(objJSON, 'Release') - end else - ErrorMsg = 'Error in ':Service:' service. Error creating JSON object.' - end - end else - ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed in.' - end - - If ErrorMsg EQ '' then - Response = JSON - end else - Error_Services('Add', ErrorMsg) - end - + end + end + // Add prove in checklist properties + PiChecklistActive = Xlate('REACTOR', ReactorNo, 'PROVE_IN_ACTIVE', 'X') + SRP_JSON(objReactor, 'SetValue', 'proveInChecklistActive', PiChecklistActive, 'Boolean') + If PiChecklistActive then + PiTypes = Xlate('REACTOR', ReactorNo, 'PROVE_IN_TYPE', 'X') + PiChecklistOrderIds = Xlate('REACTOR', ReactorNo, 'PROVE_IN_ORDER_ID', 'X') + objPiChecklistArray = '' + If SRP_JSON(objPiChecklistArray, 'New', 'Array') then + objProveIn = '' + For each PiType in PiTypes using @VM setting vPos + If SRP_JSON(objProveIn, 'New', 'Object') then + SRP_JSON(objProveIn, 'SetValue', 'proveInType', PiType) + PiChecklistOrderId = PiCheckListOrderIds<0, vPos> + SRP_JSON(objProveIn, 'SetValue', 'proveInOrderId', PiChecklistOrderId) + SRP_JSON(objPiChecklistArray, 'Add', objProveIn) + SRP_JSON(objProveIn, 'Release') + end + Next PiType + SRP_JSON(objReactor, 'Set', 'proveInChecklists', objPiChecklistArray) + SRP_JSON(objPiChecklistArray) + end + end + end + + If itemURL NE '' then + // The itemURL was passed in so add HAL+JSON properties. + objLinks = '' + // Create the _links property and then all link objects needed for this resource. + 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(objReactor, 'Set', '_links', objLinks) + SRP_JSON(objLinks, 'Release') + end + // Create the _class property for this resource. + SRP_JSON(objReactor, 'SetValue', '_class', 'resource') + end + SRP_JSON(objJSON, 'Set', 'reactor', objReactor) + SRP_JSON(objReactor, 'Release') + end + JSON = SRP_JSON(objJSON, 'Stringify', 'Styled') + SRP_JSON(objJSON, 'Release') + end else + ErrorMsg = 'Error in ':Service:' service. Error creating JSON object.' + end + end else + ErrorMsg = 'Error in ':Service:' service. Null ReactNo passed in.' + end + + If ErrorMsg EQ '' then + Response = JSON + end else + Error_Services('Add', ErrorMsg) + end + end service Service ConvertJSONToRecord(KeyID, JSON) - - Record = '' - If JSON NE '' then - If SRP_JSON(objJSON, 'Parse', JSON) EQ '' then - objReactor = SRP_JSON(objJSON, 'Get', 'reactor') - Record = Database_Services('ReadDataRow', 'REACTOR', KeyID) - If Error_Services('NoError') then - // Add code to update additional columns as needed. - // If property is "" then clear the field. - // If property is null then do not update it. - NewVal = SRP_JSON(objReactor, 'GetValue', '0311Active') - If NewVal NE 'null' then - Record = NewVal - end - end - SRP_JSON(objReactor, 'Release') - SRP_JSON(objJSON, 'Release') - end else - Error_Services('Add', 'Error in ':Service:' service. Unable to parse JSON payload.') - end - end else - Error_Services('Add', 'Error in ':Service:' service. Null JSON passed in.') - end - - Response = Record - + + Record = '' + If JSON NE '' then + If SRP_JSON(objJSON, 'Parse', JSON) EQ '' then + objReactor = SRP_JSON(objJSON, 'Get', 'reactor') + Record = Database_Services('ReadDataRow', 'REACTOR', KeyID) + If Error_Services('NoError') then + // Add code to update additional columns as needed. + // If property is "" then clear the field. + // If property is null then do not update it. + NewVal = SRP_JSON(objReactor, 'GetValue', '0311Active') + If NewVal NE 'null' then + Record = NewVal + end + end + SRP_JSON(objReactor, 'Release') + SRP_JSON(objJSON, 'Release') + end else + Error_Services('Add', 'Error in ':Service:' service. Unable to parse JSON payload.') + end + end else + Error_Services('Add', 'Error in ':Service:' service. Null JSON passed in.') + end + + Response = Record + end service Service CleanReactStatus() - - hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') + + hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') Lock hSysLists, ServiceKeyID then - ReactNos = Reactor_Services('GetReactorNumbers') - For each ReactNo in ReactNos using @FM - HaveLock = Database_Services('GetKeyIDLock', 'REACT_STATUS', ReactNo) - If HaveLock then - OrigReactStatRec = Database_Services('ReadDataRow', 'REACT_STATUS', ReactNo) - ReactStatRec = OrigReactStatRec - If Error_Services('NoError') then - For Col = 1 to 9 - OrigList = OrigReactStatRec - If OrigList NE '' then - CleanList = '' - For each Val in OrigList using @VM - If Val NE 1 then CleanList<0, -1> = Val - Next Val - ReactStatRec = CleanList - end - Next Col - If OrigReactStatRec NE ReactStatRec then - Database_Services('WriteDataRow', 'REACT_STATUS', ReactNo, ReactStatRec, True$, False$, False$) - end else - Database_Services('ReleaseKeyIDLock', 'REACT_STATUS', ReactNo) - end - end - end - Next ReactNo - Unlock hSysLists, ServiceKeyID else Null - end - + ReactNos = Reactor_Services('GetReactorNumbers') + For each ReactNo in ReactNos using @FM + HaveLock = Database_Services('GetKeyIDLock', 'REACT_STATUS', ReactNo) + If HaveLock then + OrigReactStatRec = Database_Services('ReadDataRow', 'REACT_STATUS', ReactNo) + ReactStatRec = OrigReactStatRec + If Error_Services('NoError') then + For Col = 1 to 9 + OrigList = OrigReactStatRec + If OrigList NE '' then + CleanList = '' + For each Val in OrigList using @VM + If Val NE 1 then CleanList<0, -1> = Val + Next Val + ReactStatRec = CleanList + end + Next Col + If OrigReactStatRec NE ReactStatRec then + Database_Services('WriteDataRow', 'REACT_STATUS', ReactNo, ReactStatRec, True$, False$, False$) + end else + Database_Services('ReleaseKeyIDLock', 'REACT_STATUS', ReactNo) + end + end + end + Next ReactNo + Unlock hSysLists, ServiceKeyID else Null + end + end service @@ -2892,6 +2920,7 @@ Service GetReactModeKeysByTimeSpan(ReactorNo, StartDtm, StopDtm) end service + Service GetReactorUptimeMetricsByTimeSpan(ReactorNo, StartDtm, StopDtm) ToolData = '' @@ -3172,8 +3201,8 @@ Service GetReactorUptimeMetricsByTypeAndTimeSpan(startDtm, endDtm, reactType) If reactType EQ '' then reactType = 'ALL' If Error_Services('NoError') then If endDtm GT Date() then - //This sets the current report end time to the current time. - endDtm = Datetime() + //This sets the current report end time to the current time. + endDtm = Datetime() end reportMinutes = SRP_Datetime('MinuteSpan', startDtm, endDtm) if num(reportMinutes) then @@ -3287,7 +3316,7 @@ end service Service GetLoadedRds(ReactNo) StopRDS = Xlate('REACT_STATE', ReactNo, 'LAST_RDS_NO', 'X') - + // Get list of RDS on current reactor that are not FQA ReactorConfigKey = 'WO_DAILY_SCHED':ReactNo WoNo = Field(Xlate('CONFIG', ReactorConfigKey, WOCust$, 'X'), ' ', 1) @@ -3325,383 +3354,40 @@ Service GetLoadedRds(ReactNo) end service -Service CreateReactorProveInOrder(ReactNo, ProveInType) +Service ActiveProveInPreventsModeChange(ReactNo, NewMode, CurrentMode) - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorProveIn' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorProveIn.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Attempting to craete prove in order for reactor ':ReactNo:' of type ':ProveInType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) - - CurrentProveInTypes = ReactorRec - ProveInTypeAlreadyActive = False$ - for each ActiveProveInType in CurrentProveInTypes using @VM setting dummy - If ActiveProveInType EQ ProveInType then - ProveInTypeAlreadyActive = True$ - end - Next ActiveProveInType - - If ProveInTypeAlreadyActive EQ False$ then - ReactorRec = True$ - - If CurrentProveInTypes NE '' then - ReactorRec = CurrentProveInTypes : @VM : ProveInType - end else - ReactorRec = ProveInType - end - If ProveInType EQ 'INITIATE_IDLE' then - ReactorRec = True$ - end - - // Call the API - ProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' - ProveInUrl = ProveInUrl:'checklistType=':ProveInType - ProveInUrl = ProveInUrl:'&reactorNumber=':ReactNo - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - OrderId = '' - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - retries) * BackoffSeconds - Delay(WaitSeconds) - - Retries = Retries - 1 - - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - OrderId = SRP_JSON(ObjResponseJson, 'GetValue', 'id') - If orderId NE '' then - IsSuccessful = True$ - Response = OrderId - end - end - end - SRP_JSON(ObjResponseJson, 'Release') - Repeat - - CurrentOrderIds = ReactorRec - If CurrentOrderIds NE '' then - ReactorRec = CurrentOrderIds : @VM : OrderId - end else - ReactorRec = OrderId - end - - Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec) - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'CreateReactorProveInOrder' - If IsSuccessful then - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully created prove in order for reactor ':ReactNo:' of type ':ProveInType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok') - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered when attempting to create prove in order for reactor ':ReactNo:' of type ':ProveInType - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical') - - Error_Services('Add', 'Error in ' : Service : ' service. Could not create NICA order.') - end - end - -end service - - -Service GetReactorProveInStatus(ReactNo) - - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorProveIn' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorProveIn.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Attempting to fetch prove in order for reactor ':ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Response = True$ - IsSuccessful = True$ - - // Check flag on reactor first, then call api if necessary - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) - ProveInActive = ReactorRec - If ProveInActive then - BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' - - ProveInOrderIds = ReactorRec - ProveInOrderIdList = SRP_List("Create", ProveInOrderIds, @VM) - ProveInTypes = ReactorRec - ProveInTypeList = SRP_List("Create", ProveInTypes, @VM) - for each ProveInOrderId in ProveInOrderIds using @VM setting Idx - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Fetching prove in order ':ProveInOrderId - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - ProveInUrl = BaseProveInUrl:'checklistOrderId=':ProveInOrderId - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - Retries) * BackoffSeconds - Delay(WaitSeconds) - Retries = Retries - 1 - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'GET', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'isComplete') - If IsComplete EQ True$ then - SRP_List('RemoveAt', ProveInOrderIdList, Idx) - ProveInType = SRP_List("GetAt", ProveInTypeList, Idx) - If ProveInType _EQC 'IDLE' then - ReactorRec = False$ - end - SRP_List('RemoveAt', ProveInTypeList, Idx) + If (ReactNo NE '') then + If (NewMode NE '') then + ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) + ActiveProveIn = Reactor_Services('GetProveInActive', ReactNo) + If ActiveProveIn EQ True$ then + Nica_Orders_Services('GetOrderUpdates') + ActiveProveIn = Reactor_Services('GetProveInActive', ReactNo) + If ActiveProveIn EQ True$ then + Begin Case + Case CurrentMode EQ 'INITIATE_IDLE' + IdleStartupActive = Reactor_Services('GetIdleStartupRequired', ReactNo) + If IdleStartupActive EQ True$ then Response = True$ end else Response = False$ end - end - end - SRP_JSON(ObjResponseJson, 'Release') - - If Response EQ True$ or Response EQ False$ then - IsSuccessful = True$ - end - Repeat - Next ProveInOrderId - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'GetReactorProveInOrderStatus' - If IsSuccessful and Response NE 'error' then - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully fetched prove in order for reactor ':ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered when fetching prove in order for reactor ':ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - Error_Services('Add', 'Error in ' : Service : ' service. Could not retrieve NICA order status.') - end - ReactorRec = SRP_List("GetVariable", ProveInOrderIdList, @VM) - ReactorRec = SRP_List("GetVariable", ProveInTypeList, @VM) - SRP_List('Release', ProveInTypeList) - - OrderIdCount = SRP_List("Count", ProveInOrderIdList) - SRP_List("Release", ProveInOrderIdList) - // remove flag if prove in passed - If OrderIdCount EQ 0 then - ReactorRec = False$ - end - - Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec) - end - -end service - - -Service CancelReactorProveIn(ReactNo, OrderId) - - Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log' - ColumnWidths = 20 : @FM : 15 : @FM : 300 - LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ReactorProveIn' - makeDirSuccess = Utility("MAKEDIR", LogPath) - LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_ReactorProveIn.csv' - objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$) - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Attempting to cancel prove in order ' : OrderId : ' for reactor ' : ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Response = False$ - - BaseProveInUrl = Environment_Services("GetProveInApiUrl"):'/checklists?' - - ProveInUrl = BaseProveInUrl:'checklistOrderId=':OrderId - ProveInUrl = ProveInUrl:'&checklistState=cancelled' - - Retries = 3 - BackoffSeconds = 1 - IsSuccessful = False$ - - Loop - while (IsSuccessful EQ False$ and Retries GT 0) - WaitSeconds = (3 - Retries) * BackoffSeconds - Delay(WaitSeconds) - Retries = Retries - 1 - - HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'PUT', ProveInUrl, 'Accept':@VM:'*/*', '', '', '', False$, False$, '') - If HttpResponseJson NE '' then - ObjResponseJson = '' - If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then - IsComplete = SRP_JSON(ObjResponseJson, 'GetValue', 'pendingUpdate') - If IsComplete EQ True$ then - Response = True$ - end else - Response = False$ - end - end - end - SRP_JSON(ObjResponseJson, 'Release') - - If Response EQ True$ or Response EQ False$ then - IsSuccessful = True$ - end - Repeat - - If Environment_Services('IsProd') then - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_MESAPROVEINAPI' - end else - MonAResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_MESAPROVEINAPI_DEV' - end - StatusName = 'UpdateReactorProveInOrderState' - If IsSuccessful and Response NE 'error' then - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) - ProveInOrderIds = ReactorRec - ProveInOrderIdList = SRP_List('Create', ProveInOrderIds, @VM) - ProveInTypes = ReactorRec - ProveInTypeList = SRP_List('Create', ProveInTypes, @VM) - - for each ProveInOrderId in ProveInOrderIds using @VM setting Idx - If OrderId EQ ProveInOrderId then - ProveInType = SRP_List('GetAt', ProveInTypeList, Idx) - If ProveInType EQ 'IDLE' then - ReactorRec = False$ - end - - SRP_List('RemoveAt', ProveInOrderIdList, Idx) - SRP_List('RemoveAt', ProveInTypeList, Idx) - end - Next ProveInOrderId - - ReactorRec = SRP_List("GetVariable", ProveInOrderIdList, @VM) - ReactorRec = SRP_List("GetVariable", ProveInTypeList, @VM) - SRP_List('Release', ProveInTypeList) - - OrderIdCount = SRP_List("Count", ProveInOrderIdList) - SRP_List("Release", ProveInOrderIdList) - // remove flag if prove in passed - If OrderIdCount EQ 0 then - ReactorRec = False$ - end - - Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec) - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Successfully cancelled prove in order ' : ProveInOrderId : ' for reactor ' : ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Ok') - end else - Response = 'error' - - LogData = '' - LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM - LogData<2> = Machine - LogData<3> = 'Error encountered cancelling prove in order ' : ProveInOrderId : ' for reactor ' : ReactNo - Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) - - Mona_Services('SendBufferedStatus', MonAResource, StatusName, 'Critical') - - Error_Services('Add', 'Error in ' : Service : ' service. Could not cancel NICA order') - end - -end service - - -Service ActiveProveInPreventsModeChange(ReactNo, NewMode, CurrentMode) - - If (ReactNo EQ '') then - Error_Services('Add', 'Error in ' : Service : ' service. ReactNo was empty') - end - - If (NewMode EQ '') then - Error_Services('Add', 'Error in ' : Service : ' service. NewMode was empty') - end - - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) - ActiveProveIn = ReactorRec - If ActiveProveIn EQ True$ then - Reactor_Services('GetReactorProveInStatus', ReactNo) - If Error_Services('HasError') then - ErrMsg = Error_Services('GetMessage') - Error_Services('Add', ErrMsg) - end else - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) - ActiveProveIn = ReactorRec - If ActiveProveIn EQ True$ then - Begin Case - Case CurrentMode EQ 'INITIATE_IDLE' - IdleStartupActive = False$ - CurrentProveInTypes = ReactorRec - for each ProveInType in CurrentProveInTypes using @VM setting dummy - If ProveInType EQ 'INITIATE_IDLE' then IdleStartupActive = True$ - Next ProveInType - If IdleStartupActive EQ True$ then + Case Len(NewMode) GE 2 and NewMode[1, 2] EQ 'UP' Response = True$ - end else + Case Otherwise$ Response = False$ - end - Case Len(NewMode) GE 2 and NewMode[1, 2] EQ 'UP' - Response = True$ - Case Otherwise$ - Response = False$ - End Case + End Case + end else + Response = False$ + end end else Response = False$ end + end else + Error_Services('Add', 'Error in ' : Service : ' service. NewMode was empty') end end else - Response = False$ + Error_Services('Add', 'Error in ' : Service : ' service. ReactNo was empty') end end service @@ -3724,7 +3410,7 @@ end service Service GetReactorLoadCountLimit(ReactNo) - + ErrMsg = 'Error in ReactorServices -> GetReactorLoadCountLimit: ' MaxLoadCount = 999 If ReactNo NE '' then @@ -3800,35 +3486,35 @@ Service RemoveRDSFromReactorLoad(RDSNo, ReactorNo, User) Response = 0 If User NE '' then - If RDSNo NE '' then - If ReactorNo NE '' then - ReactStatusRec = Database_Services('ReadDataRow', 'REACT_STATUS', ReactorNo) - If Error_Services('NoError') then - Locate RDSNo in ReactStatusRec setting RDSPos then - ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_RDS$, RDSPos, 0) - ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_RDS_DTM$, RDSPos, 0) - ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_CASS_ID$, RDSPos, 0) - ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_DTM$, RDSPos, 0) - Database_Services('WriteDataRow', 'REACT_STATUS', ReactorNo, ReactStatusRec, 1, 0, 1) - If Error_Services('NoError') then - Response = 1 + If RDSNo NE '' then + If ReactorNo NE '' then + ReactStatusRec = Database_Services('ReadDataRow', 'REACT_STATUS', ReactorNo) + If Error_Services('NoError') then + Locate RDSNo in ReactStatusRec setting RDSPos then + ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_RDS$, RDSPos, 0) + ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_RDS_DTM$, RDSPos, 0) + ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_CASS_ID$, RDSPos, 0) + ReactStatusRec = Delete(ReactStatusREc, REACT_STATUS_LOAD_DTM$, RDSPos, 0) + Database_Services('WriteDataRow', 'REACT_STATUS', ReactorNo, ReactStatusRec, 1, 0, 1) + If Error_Services('NoError') then + Response = 1 + end else + ErrMsg = Error_Services('GetMessage') + Error_Services('Add', ErrMsg) + end end else - ErrMsg = Error_Services('GetMessage') - Error_Services('Add', ErrMsg) + Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: RDS was not found as a loaded lot.') end - end else - Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: RDS was not found as a loaded lot.') - end + end else + ErrMsg = Error_Services('GetMessage') + Error_Services('Add', ErrMsg) + end end else - ErrMsg = Error_Services('GetMessage') - Error_Services('Add', ErrMsg) + Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: No Reactor No was supplied.') end end else - Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: No Reactor No was supplied.') + Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: No RDS No was supplied.') end - end else - Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: No RDS No was supplied.') - end end else Error_Services('Add', 'Error in Reactor Services -> RemoveRDSFromReactorLoad: No Username was supplied.') end @@ -3867,29 +3553,142 @@ Service AddRDSToReactorLoad(RDSNo, ReactorNo) end service + +Service UpdateReactorIQSViolations() + + ReactNos = Reactor_Services('GetReactorNumbers') + If Error_Services('NoError') then + CurrViols = Database_Services('ReadDataRow', 'CONFIG', 'IQS_VIOL_DATA') + If Error_Services('NoError') then + ViolatingReactors = CurrViols + ViolationDtms = CurrViols + ViolationTests = CurrViols + Swap ' AM' with 'AM' in ViolationDtms + Swap ' PM' with 'PM' in ViolationDtms + ViolationDtms = IConv(ViolationDtms, 'DT') + For each ReactNo in ReactNos + ActiveAlarm = False$ + For each ViolReactor in ViolatingReactors using @VM setting vPos + If ViolReactor EQ ReactNo then + ActiveAlarm = True$ + ThisAlarmDtm = ViolationDtms<0, vPos> + ThisAlarmTest = ViolationTests<0, vPos> + // Check if a new alarm and update if necessary + LastAlarmDtm = Xlate('REACTOR', ReactNo, REACTOR_IQS_ALARM_DTM$, 'X') + If LastAlarmDtm LT ThisAlarmDtm then + // New alarm + HaveLock = Database_Services('GetKeyIDLock', 'REACTOR', ReactNo, True$) + If HaveLock then + ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) + If Error_Services('NoError') then + ReactorRec = ThisAlarmDtm + ReactorRec = ThisAlarmTest + // WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false + // REACTOR_ACTIONS will be triggered, which will generate a NICA order if a new HgCV alarm is detected + Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$) + end + end + end + end + Next ViolReactor + + If Not(ActiveAlarm) then + // Clear last active alarm + HaveLock = Database_Services('GetKeyIDLock', 'REACTOR', ReactNo, True$) + If HaveLock then + ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) + If Error_Services('NoError') then + ReactorRec = '' + ReactorRec = '' + // WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false + Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$) + end + end + end + Next ReactNo + end + end + +end service + + +Service GetProveInActive(ReactNo) + + If ReactNo NE '' then + ActiveChangeoverIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'CHANGEOVER') + ActiveInitIdleIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'INITIATE_IDLE') + ActiveIdleIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'IDLE') + Response = ( (ActiveChangeoverIds NE '') or (ActiveInitIdleIds NE '') or (ActiveIdleIds NE '') ) + end else + Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.') + end + +end service + + +Service GetActiveProveInTypes(ReactNo) + + If ReactNo NE '' then + ActiveProveInOrderIds = Reactor_Services('GetActiveProveInOrderIds', ReactNo) + If ActiveProveInOrderIds NE '' then + Response = Xlate('NICA_ORDERS', ActiveProveInOrderIds, 'ORDER_TYPE', 'X') + end + end else + Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.') + end + +end service + + +Service GetActiveProveInOrderIds(ReactNo) + + If ReactNo NE '' then + ActiveChangeoverIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'CHANGEOVER') + ActiveInitIdleIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'INITIATE_IDLE') + ActiveIdlesIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'IDLE') + If (ActiveChangeoverIds NE '') then Response<0, -1> = ActiveChangeoverIds + If (ActiveInitIdleIds NE '') then Response<0, -1> = ActiveInitIdleIds + If (ActiveIdlesIds NE '') then Response<0, -1> = ActiveInitIdleIds + end else + Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.') + end + +end service + + +Service GetIdleStartupRequired(ReactNo) + + If ReactNo NE '' then + Response = Xlate('REACTOR', ReactNo, REACTOR_IDLE_STARTUP_REQUIRED$, 'X') + end else + Error_Services('Add', 'Error in ':Service:' service. Null ReactNo passed into service.') + end + +end service + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RollbackReactUtil: - - // Reopen previous REACT_UTIL record - If OldReactUtilID NE '' then - OldReactUtilRec = Database_Services('ReadDataRow', 'REACT_UTIL', OldReactUtilID) - OldReactUtilRec = '' - OldReactUtilRec = '' - OldReactUtilRec = '' - Database_Services('WriteDataRow', 'REACT_UTIL', OldReactUtilID, OldReactUtilRec) - end - + + // Reopen previous REACT_UTIL record + If OldReactUtilID NE '' then + OldReactUtilRec = Database_Services('ReadDataRow', 'REACT_UTIL', OldReactUtilID) + OldReactUtilRec = '' + OldReactUtilRec = '' + OldReactUtilRec = '' + Database_Services('WriteDataRow', 'REACT_UTIL', OldReactUtilID, OldReactUtilRec) + end + return ClearCursors: - - For counter = 0 to 8 - ClearSelect counter - Next counter - + + For counter = 0 to 8 + ClearSelect counter + Next counter + return diff --git a/LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt b/LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt index 4792c31..f4b1d8a 100644 --- a/LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt +++ b/LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt @@ -54,10 +54,11 @@ $insert Message_Box_Equates Declare function center_window, msg, Memberof, Get_Property, NextKey, next_key, rowexists, Get_Status Declare function SRP_Array, start_window, Dialog_Box, Reactor_Log_Services, Reactor_Modes_Services, GetTickCount Declare function Reactor_Services, Error_Services, Logging_Services, Environment_Services, Database_Services -Declare function SRP_List +Declare function SRP_List, Nica_Orders_Services Declare subroutine RList, Set_Property, Set_List_Box_Data, end_dialog, record_lock, obj_React_Mode, ErrMsg Declare subroutine Mona_Services, Reactor_Services, Error_Services, obj_React_Status, Logging_Services Declare subroutine Database_Services, Override_Log_Services, SRP_List, Message_Box, Reactor_Log_Services +Declare subroutine Nica_Orders_Services GoToEvent Event for CtrlEntId else // Event not implemented @@ -281,52 +282,73 @@ Event APPLY.CLICK() If Error_Services('NoError') then Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText) If Error_Services('NoError') then + End_Dialog(@Window, NewMode) + end else + Error_Services('DisplayError') - ActiveProveIn = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_ACTIVE$, 'X') - If ActiveProveIn then - OverrideGroups = 'LEAD':@VM:'SUPERVISOR' - UserMsg = "Reactor prove in must be processed in NICA. Override required from a lead or supervisor to bypass NICA." - UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg) - Override = UserVerification<1> - If Override EQ True$ then - ProveInOrderIds = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_ORDER_ID$, 'X') - ProveInOrderList = SRP_List('Create', ProveInOrderIds, @VM) - ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X') - ProveInTypeList = SRP_List('Create', ProveInTypes, @VM) - If SRP_List('Count', ProveInOrderList) GT 1 then - OverrideData = Dialog_Box('PROVE_IN_OVERRIDE', @Window, ReactNo) - - ProveInTypesToCancel = OverrideData<1, 1> - ProveInTypesToCancelList = SRP_List('Create', ProveInTypesToCancel, @VM) - - ResponseComment = '' - for each ProveInType in ProveInTypes using @VM setting Idx - If SRP_List('Locate', ProveInTypesToCancelList, ProveInType) GT 0 then - ProveInOrderId = SRP_List('GetAt', ProveInOrderList, Idx) - Reactor_Services('CancelReactorProveIn', ReactNo, ProveInOrderId) - If ResponseComment NE '' then - ResponseComment := ', ' + ActiveProveIn = Reactor_Services('GetProveInActive', ReactNo) + ActiveHgCVChecklists = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactNo, 'IQS_HGCV_ALARM') + HgCVChecklistActive = (ActiveHgCVChecklists NE '') + + Begin Case + + Case ActiveProveIn + + OverrideGroups = 'LEAD':@VM:'SUPERVISOR' + UserMsg = "Reactor prove in must be processed in NICA. Override required from a lead or supervisor to bypass NICA." + UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg) + Override = UserVerification<1> + If Override EQ True$ then + ProveInOrderIds = Reactor_Services('GetActiveProveInOrderIds', ReactNo) + If (DCount(ProveInOrderIds, @VM) GT 1) then + ProveInTypes = Xlate('NICA_ORDERS', ProveInOrderIds, 'ORDER_TYPE', 'X') + OverrideData = Dialog_Box('PROVE_IN_OVERRIDE', @Window, ReactNo) + ProveInTypesToCancel = OverrideData<1, 1> + ResponseComment = '' + For each ProveInType in ProveInTypes using @VM setting Idx + Locate ProveInType in ProveInTypesToCancel using @VM setting Unused then + ProveInOrderId = ProveInOrderIds<0, Idx> + Nica_Orders_Services('CancelOrder', ProveInOrderId) + If ResponseComment NE '' then ResponseComment := ', ' + ResponseComment := ProveInType end - ResponseComment := ProveInType - end - Next ProveInType - - ResponseComment := ': ' - ResponseComment := OverrideData<2, 1> - - Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN') - - SRP_List('Release', ProveInTypesToCancelList) - end else - ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2> - - If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then - ProveInOrderId = SRP_List('GetAt', ProveInOrderList, 1) - Reactor_Services('CancelReactorProveIn', ReactNo, ProveInOrderId) - + Next ProveInType + ResponseComment := ': ' + ResponseComment := OverrideData<2, 1> Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN') + Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText) + If Error_Services('NoError') then End_Dialog(@Window, NewMode) + end else + ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2> + If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then + Nica_Orders_Services('CancelOrder', ProveInOrderIds<0, 1>) + Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'REACTOR_PROVE_IN') + Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText) + If Error_Services('NoError') then End_Dialog(@Window, NewMode) + end else + Message_Box(@Window, 'You must enter a comment greater than 4 letters!', 'Error', MSG_ICON_EXCLAM$) + end + end + end + + Case HgCVChecklistActive + + OverrideGroups = 'LEAD':@VM:'SUPERVISOR' + UserMsg = "HgCV OCAP Checklist must be completed in NICA. Override required from a lead or supervisor to bypass NICA." + UserVerification = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:OverrideGroups:@FM:'':@FM:UserMsg) + Override = UserVerification<1> + If Override then + + ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @WINDOW)<2> + If Assigned(ResponseComment) and Len(ResponseComment) GT 4 then + + For each ActiveHgCVOrderId in ActiveHgCVChecklists using @VM + Nica_Orders_Services('CancelOrder', ActiveHgCVOrderId) + Next ActiveHgCVChecklistId + + Override_Log_Services('Create', 'REACTOR', ReactNo, UserVerification<2>, ResponseComment, 'HGCV_OCAP_CHECKLIST') Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText) If Error_Services('NoError') then @@ -335,11 +357,9 @@ Event APPLY.CLICK() end else Message_Box(@Window, 'You must enter a comment greater than 4 letters!', 'Error', MSG_ICON_EXCLAM$) end - end - SRP_List('Release', ProveInOrderList) - SRP_List('Release', ProveInTypeList) - end - end + end + End Case + end end @@ -504,3 +524,4 @@ return + diff --git a/LSL2/STPROC/SERVICE_SERVICES.txt b/LSL2/STPROC/SERVICE_SERVICES.txt index c0a7c37..7848d14 100644 --- a/LSL2/STPROC/SERVICE_SERVICES.txt +++ b/LSL2/STPROC/SERVICE_SERVICES.txt @@ -32,6 +32,7 @@ $insert SERVICE_SETUP $insert SERVICES_EQUATES $insert RLIST_EQUATES $insert SQL_REQUESTS_EQUATES +$Insert PROC_QUEUE_EQUATES Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@ @@ -154,20 +155,17 @@ end service Service ProcessProcedureQueue() - hValidationRequests = Database_Services('GetTableHandle', 'PROC_QUEUE') - If Error_Services('NoError') then - Sentence = "SELECT PROC_QUEUE WITH COMP_DTM NE ''" - Set_Status(0) - RList(Sentence, TARGET_ACTIVELIST$, '', '', '') + Open 'PROC_QUEUE' to hProcQueue then + Select hProcQueue EOF = False$ Loop ReadNext RequestKeyID else EOF = True$ Until EOF - Lock hValidationRequests, RequestKeyID then + Lock hProcQueue, RequestKeyID then RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID) If RequestRow NE '' then - Procedure = RequestRow<1> - Params = RequestRow<2> + Procedure = RequestRow + Params = RequestRow If Procedure NE '' then Dim ProcParams(10) For each Param in Params using @VM setting pPos @@ -190,13 +188,13 @@ Service ProcessProcedureQueue() end end If Error_Services('NoError') then - RequestRow<3> = DateTime() + Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) end else - RequestRow<3> = DateTime() - RequestRow<4> = Error_Services('GetMessage') + RequestRow = DateTime() + RequestRow = Error_Services('GetMessage') + Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, True$) end - Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, True$) - Unlock hValidationRequests, RequestKeyID else Null + Unlock hProcQueue, RequestKeyID else Null end Repeat end @@ -208,35 +206,13 @@ Service PostProcecure(ProcedureName, Params) Response = '' If (ProcedureName NE '') then - RequestKeyID = RTI_CreateGUID() - RequestRow = '' - RequestRow = '' - RequestRow = '' - Database_Services('WriteDataRow', 'SQL_REQUESTS', RequestKeyID, RequestRow, False$, False$, False$) - If Error_Services('NoError') then - TimeExpired = False$ - Start = GetTickCount() - Loop - RequestRow = Database_Services('ReadDataRow', 'SQL_REQUESTS', RequestKeyID) - ResponseDate = RequestRow - If ResponseDate NE '' then - Response = RequestRow - Response = SRP_Decode(Response) - end - // Time will expire after 30 seconds. - If GetTickCount() - Start GE 30000 then TimeExpired = True$ - Until (ResponseDate NE '') OR TimeExpired - Sleepery(10) - WinYield() - Yield();Yield();Yield();Yield();Yield();Yield();Yield();Yield() - Repeat - If TimeExpired then - Error_Services('Add', 'Timed out attempting to retrieve wafer image.') - end - Database_Services('DeleteDataRow', 'SQL_REQUESTS', RequestKeyID, True$) - end + RequestKeyID = RTI_CreateGUID() + RequestRow = '' + RequestRow = ProcedureName + RequestRow = Params + Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$) end else - Error_Services('Add', 'Null parameter passed into service call. All parameters are required.') + Error_Services('Add', 'Error in ':Service:' service. Null ProcedureName passed in.') end return @@ -247,3 +223,4 @@ return //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + diff --git a/LSL2/STPROC/WO_DAILY_SCHED_ALL_COMM.txt b/LSL2/STPROC/WO_DAILY_SCHED_ALL_COMM.txt index 5e4642d..75aea75 100644 --- a/LSL2/STPROC/WO_DAILY_SCHED_ALL_COMM.txt +++ b/LSL2/STPROC/WO_DAILY_SCHED_ALL_COMM.txt @@ -10,8 +10,8 @@ function wo_daily_sched_all_comm(Branch,CurrParm) ***********************************************************************************************************************/ #pragma precomp SRP_PreCompiler -declare function set_property, fieldcount, get_property, msg, dialog_box, security_check -declare function send_message, utility, key_sort, start_window, entid, repository +declare function set_property, fieldcount, get_property, msg, dialog_box, security_check, Reactor_Log_Services +declare function send_message, utility, key_sort, start_window, entid, repository, Nica_Orders_Services declare function relational_call, memberof, get_mode_icon, Database_Services, Reactor_Services declare subroutine extract_si_keys, end_dialog, make.list, security_err_msg, Set_Property, SRP_Stopwatch, Dialog_Box Declare subroutine Send_Message @@ -67,24 +67,21 @@ ChecklistButton: Message = '' ReactorNo = CurrParm[-1, 'B_'] - Status_ProveIn = XLATE('REACTOR', ReactorNo, REACTOR_PROVE_IN_ACTIVE$, 'X') - - If Status_ProveIn EQ '' Then Status_ProveIn = False$ + Status_ProveIn = Reactor_Services('GetProveInActive', ReactorNo) Status_0311 = XLATE('REACTOR', ReactorNo, REACTOR_0311_ACTIVE$, 'X') If Status_0311 EQ '' then Status_0311 = False$ - CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactorNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') - CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$, 'X') - Status_ReactorPM = Xlate('REACTOR_LOG', CurrRLKey, REACTOR_LOG_CHECKLIST_ACTIVE$, 'X') - - If Status_ReactorPM EQ '' then Status_ReactorPM = False$ + CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactorNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X') + CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$, 'X') + ReactorPmOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', CurrRlKey) + HgCVAlarmOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR', I, 'IQS_HGCV_ALARM') ChecklistInfo = 'The following checklist(s) are active: ' If Status_ProveIn then // Add each active prove in order - ProveInOrderTypes = Xlate('REACTOR', ReactorNo, REACTOR_PROVE_IN_TYPE$, 'X') + ProveInOrderTypes = Reactor_Services('GetActiveProveInTypes', ReactorNo) For each ProveInOrderType in ProveInOrderTypes using @VM setting vPos ChecklistInfo<-1> = ProveInOrderType Next ProveInOrderType @@ -92,13 +89,18 @@ ChecklistButton: If Status_0311 then ChecklistInfo<-1> = '0311 OCAP' - If Status_ReactorPM then - // Add each active reactor PM order - RlPmTypes = Xlate('REACTOR_LOG', CurrRLKey, REACTOR_LOG_CHECKLIST_TYPE$, 'X') - For each RlPmType in RlPmTypes using @VM setting vPos - ChecklistInfo<-1> = RlPmType + If ReactorPmOrderIds NE '' then + // Add each active reactor PM checklist order + For each ReactorPmOrderId in ReactorPmOrderIds using @VM setting vPos + ChecklistInfo<-1> = Xlate('NICA_ORDERS', ReactorPmOrderId, 'ORDER_TYPE', 'X') Next RlPmType end + + If HgCVAlarmOrderIds NE '' then + For each HgCVAlarmOrderId in HgCVAlarmOrderIds using @VM + ChecklistInfo<-1> = Xlate('NICA_ORDERS', HgCVAlarmOrderId, 'ORDER_TYPE', 'X') + Next HgCVAlarmOrder + end Swap @FM with CRLF$ in ChecklistInfo @@ -246,17 +248,11 @@ FORM_CREATE: RPanelTitle := ' - PP' END - Status_ProveIn = XLATE('REACTOR', I, REACTOR_PROVE_IN_ACTIVE$, 'X') - - IF Status_ProveIn EQ '' THEN - Status_ProveIn = FALSE$ - END + Status_ProveIn = Reactor_Services('GetProveInActive', I) Status_0311 = XLATE('REACTOR', I, REACTOR_0311_ACTIVE$, 'X') - IF Status_0311 EQ '' THEN - Status_0311 = FALSE$ - END + IF Status_0311 EQ '' THEN Status_0311 = FALSE$ Set_Property(Window:'.RPANEL':I, 'TEXT', RpanelTitle ) ;* Display Wafer Size in inches Set_Property(Window:'.RWO':I, 'TEXT', WO ) ;* Display WO # @@ -271,8 +267,8 @@ FORM_CREATE: end CurrModeKey = Xlate('REACTOR_CHILD_KEY_IDS_NG', I, 'REACT_MODE_KEY_IDS', 'X') - CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, 'START_RL_ID', 'X') - Status_ReactorPM = Xlate('REACTOR_LOG', CurrRLKey, 'CHECKLIST_ACTIVE', 'X') + CurrRLKey = Xlate('REACT_MODE_NG', CurrModeKey, 'START_RL_ID', 'X') + Status_ReactorPM = Reactor_Log_Services('GetRlChecklistActive', CurrRLKey) If Status_ReactorPM EQ '' then Status_ReactorPM = False$ @@ -280,7 +276,13 @@ FORM_CREATE: Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveReactorPM.png') end - OlePicVisible = ( (Status_ProveIn EQ True$) or (Status_0311 EQ True$) or (Status_ReactorPM EQ True$) ) + Status_HgCV_Alarm = (Nica_Orders_Services('GetActiveOrders', 'REACTOR', I, 'IQS_HGCV_ALARM') NE '') + + If Status_HgCV_Alarm EQ True$ then + Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveProveIn.png') + end + + OlePicVisible = ( Status_ProveIn or Status_0311 or Status_ReactorPM or Status_HgCV_Alarm) Set_Property(Window:'.OLE_PIC_':I,'VISIBLE', OlePicVisible) IQSPicControl = @Window : '.OLE_PIC_IQS_': i @@ -329,3 +331,4 @@ return *===============================================================================================* + diff --git a/LSL2/STPROCINS/IQS_VIOL_DATA_EQUATES.txt b/LSL2/STPROCINS/IQS_VIOL_DATA_EQUATES.txt new file mode 100644 index 0000000..c932011 --- /dev/null +++ b/LSL2/STPROCINS/IQS_VIOL_DATA_EQUATES.txt @@ -0,0 +1,13 @@ +Compile Insert IQS_VIOL_DATA_EQUATES + +Equ IQS_VIOL_DATA.REACTOR$ to 1 +Equ IQS_VIOL_DATA.TEST$ to 2 +Equ IQS_VIOL_DATA.USL$ to 3 +Equ IQS_VIOL_DATA.TAR$ to 4 +Equ IQS_VIOL_DATA.LSL$ to 5 +Equ IQS_VIOL_DATA.LAST_ENTRY$ to 6 +Equ IQS_VIOL_DATA.LAST_ALARM$ to 7 +Equ IQS_VIOL_DATA.ALARM$ to 8 +Equ IQS_VIOL_DATA.SUBGROUPS$ to 9 +Equ IQS_VIOL_DATA.MEAN$ to 10 +Equ IQS_VIOL_DATA.LAST_WRITE_TIME$ to 11 diff --git a/LSL2/STPROCINS/NICA_ORDERS_EQUATES.txt b/LSL2/STPROCINS/NICA_ORDERS_EQUATES.txt new file mode 100644 index 0000000..3caf46a --- /dev/null +++ b/LSL2/STPROCINS/NICA_ORDERS_EQUATES.txt @@ -0,0 +1,16 @@ +compile insert NICA_ORDERS_EQUATES +/*---------------------------------------- + Author : Table Create Insert Routine + Written : 05/12/2024 + Description : Insert for Table NICA_ORDERS +----------------------------------------*/ +#ifndef __NICA_ORDERS_EQUATES__ +#define __NICA_ORDERS_EQUATES__ + + equ NICA_ORDERS.ORDER_TYPE$ to 1 + equ NICA_ORDERS.ORDER_STATUS$ to 2 + equ NICA_ORDERS.ENTITY_TYPE$ to 3 + equ NICA_ORDERS.ENTITY_ID$ to 4 + equ NICA_ORDERS.IS_COMPLETE$ to 5 + +#endif diff --git a/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt b/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt index 90776fe..725f52a 100644 --- a/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt +++ b/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt @@ -1,13 +1,15 @@ compile insert PROC_QUEUE_EQUATES /*---------------------------------------- - Author : Table Create Insert Routine - Written : 15/01/2020 + Author : Table Create Insert Routine + Written : 09/12/2024 Description : Insert for Table PROC_QUEUE ----------------------------------------*/ +#ifndef __PROC_QUEUE_EQUATES__ +#define __PROC_QUEUE_EQUATES__ + equ PROC_QUEUE.PROC_NAME$ to 1 + equ PROC_QUEUE.PARAMS$ to 2 + equ PROC_QUEUE.LAST_ATTEMPT_DTM$ to 3 + equ PROC_QUEUE.ERROR$ to 4 -Equ PROC_QUEUE.REQ_ID$ To 0 -Equ PROC_QUEUE.PROC_NAME$ To 1 -Equ PROC_QUEUE.PARAMS$ To 2 -Equ PROC_QUEUE.COMP_DTM$ To 3 -Equ PROC_QUEUE.ERROR$ To 4 +#endif diff --git a/LSL2/STPROCINS/REACTOR_EQUATES.txt b/LSL2/STPROCINS/REACTOR_EQUATES.txt index 35f239a..c622625 100644 --- a/LSL2/STPROCINS/REACTOR_EQUATES.txt +++ b/LSL2/STPROCINS/REACTOR_EQUATES.txt @@ -77,7 +77,5 @@ Equ REACTOR_PROVE_IN_ACTIVE$ To 65 Equ REACTOR_PROVE_IN_TYPE$ To 66 Equ REACTOR_PROVE_IN_ORDER_ID$ To 67 Equ REACTOR_IDLE_STARTUP_REQUIRED$ To 68 - - - - +Equ REACTOR_IQS_ALARM_DTM$ To 69 +Equ REACTOR_IQS_ALARM_TEST$ To 70 diff --git a/SYSPROG/STPROC/ERROR_SERVICES.txt b/SYSPROG/STPROC/ERROR_SERVICES.txt index 3dea632..65e0163 100644 --- a/SYSPROG/STPROC/ERROR_SERVICES.txt +++ b/SYSPROG/STPROC/ERROR_SERVICES.txt @@ -72,10 +72,11 @@ Function Error_Services(@Service, @Params) #pragma precomp SRP_PreCompiler -$insert LOGICAL +$Insert LOGICAL $Insert MSG_EQUATES -$insert RTI_DEBUG_COMMON -$insert SRPMail_Inserts +$Insert RTI_DEBUG_COMMON +$Insert SRPMail_Inserts +$Insert ERROR_SERVICES_COMMON Equ Segoe_UI$ to 'Segoe UI' : @SVM : -12 : @SVM : 400 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 34 : @SVM : 0 : @SVM : 3 : @SVM : 2 : @SVM : 1 : @SVM : 0 : @SVM : 0 : @SVM : 0 : @SVM : 0 @@ -98,8 +99,6 @@ If Assigned(Response) else Response = '' AutoDisplayErrors = False$ ; // Set this to True$ when debugging so all errors will automatically display. -Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, Unused5@, Unused6@, Unused7@, Unused8@ - Declare function RetStack, Error_Services, SRPSendMail Declare subroutine Error_Services diff --git a/SYSPROG/STPROC/SRP_GIT_SERVICES.txt b/SYSPROG/STPROC/SRP_GIT_SERVICES.txt index b81a457..aa374d0 100644 --- a/SYSPROG/STPROC/SRP_GIT_SERVICES.txt +++ b/SYSPROG/STPROC/SRP_GIT_SERVICES.txt @@ -468,15 +468,23 @@ Service PullEntities(EntityList, StatusList, StatusCtrl, CommitId) If Get_Status(ErrCode) then SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n Locked!\n", "", LogPos) end else - Set_Status(0) - Repository("WRITE", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record) - If Get_Status(ErrCode) then - SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n", ErrCode, LogPos) - end else - SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos) - Get_Status(ErrCode) - If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM - end + Set_Status(0) + Repository("WRITE", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record) + If Get_Status(ErrCode) then + Set_Status(0) + Repository("NEW", EntityId, "", 1, 1, "", "", "", "", "", EntityId[-1, "B*"], Record) + If Get_Status(ErrCode) then + SRP_Git_Services("SendStatus", StatusCtrl, " -- Save Failed\n", ErrCode, LogPos) + end else + SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos) + Get_Status(ErrCode) + If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM + end + end else + SRP_Git_Services("SendStatus", StatusCtrl, " -- Saved\n", "", LogPos) + Get_Status(ErrCode) + If Type EQ "STPROC" OR Type EQ "OIWIN" OR Type EQ "OIEVENT" then EntitiesToCompile := EntityId:@FM + end Set_Status(0) Repository("UNLOCK", EntityId) end diff --git a/SYSPROG/STPROCINS/ERROR_SERVICES_COMMON.txt b/SYSPROG/STPROCINS/ERROR_SERVICES_COMMON.txt new file mode 100644 index 0000000..442af5e --- /dev/null +++ b/SYSPROG/STPROCINS/ERROR_SERVICES_COMMON.txt @@ -0,0 +1,4 @@ +Compile Insert ERROR_SERVICES_COMMON + +Common /ErrorServices/ ErrorMessages@, ErrorSources@, ErrorCodes@, RetStacks@, EsSpStatCode@, EsSpStatMessage@, Unused7@, Unused8@ +