diff --git a/LSL2/STPROC/NICA_ORDERS_SERVICES.txt b/LSL2/STPROC/NICA_ORDERS_SERVICES.txt index 210ea5e..fbced53 100644 --- a/LSL2/STPROC/NICA_ORDERS_SERVICES.txt +++ b/LSL2/STPROC/NICA_ORDERS_SERVICES.txt @@ -425,7 +425,7 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, SRP_JSON(objJson, 'SetValue', 'reactorNumber', ReactNo) NewChecklistInstIds = Xlate('NICA_CHECKLISTS', NewSortedChecklistIds, 'NICA_BASE_INSTRUCTION_ID', 'X') SRP_JSON(objJson, 'SetValueArray', 'baseInstructionIds', NewChecklistInstIds, @VM) - Body = SRP_JSON(objJson, 'Stringify', 'Styled') + Body = SRP_JSON(objJson, 'Stringify', 'Fast') Convert @FM to '' in Body SRP_JSON(objJson, 'Release') end else @@ -443,11 +443,12 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, IsSuccessful = False$ If ErrorMsg EQ '' then + AttemptNo = 0 Retries = 3 BackoffSeconds = 1 OrderId = '' - Loop + Loop while (IsSuccessful EQ False$ and Retries GT 0) WaitSeconds = (3 - retries) * BackoffSeconds Delay(WaitSeconds) @@ -458,7 +459,32 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES, end else Headers = 'Accept':@VM:'*/*' end + + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + AttemptNo += 1 + LogData<3> = 'Attempt number ':AttemptNo:' to send HTTP POST request to ':NicaURL + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + // Write directly to the log file to avoid mangling the JSON + OSRead LogBytes from LogPath:'\':LogFileName then + LogBytes := CRLF$:Body + OSWrite LogBytes to LogPath:'\':LogFileName + end + HttpResponseJson = Httpclient_Services('SendHTTPRequest', 'POST', NicaURL, Headers, Body, '', '', False$, False$, '', IgnoreCertErrors) + + LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM + LogData<2> = Machine + LogData<3> = 'Attempt number ':AttemptNo:' HttpResponse from ':NicaURL:':' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$) + + // Write directly to the log file to avoid mangling the JSON + OSRead LogBytes from LogPath:'\':LogFileName then + LogBytes := CRLF$:HttpResponseJson + OSWrite LogBytes to LogPath:'\':LogFileName + end + If HttpResponseJson NE '' then ObjResponseJson = '' If SRP_JSON(ObjResponseJson, 'Parse', HttpResponseJson) EQ '' then diff --git a/LSL2/STPROC/REACTOR_SERVICES.txt b/LSL2/STPROC/REACTOR_SERVICES.txt index 52c2b6d..7eba107 100644 --- a/LSL2/STPROC/REACTOR_SERVICES.txt +++ b/LSL2/STPROC/REACTOR_SERVICES.txt @@ -2063,7 +2063,12 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force Begin Case Case ( AbortAlarmOrderActive and (SelE10State _EQC 'Productive') ) ErrorMsg = "An ABORT/ALARM Checklist is active for this reactor and must be completed or overridden in order to change to a productive state." - + + Case ( (Mode _EQC 'WAITING_FOR_MAINTENANCE_UNSCHEDULED') and IndexC(ModeSubCat, 'ABORT/ALARM', 1) ) + // Do not create an ABORT/ALARM NICA order yet as maintenance may determine the appropriate ABORT/ALARM sub mode to be different than + // the operator. This avoids creating a NICA order for the wrong flow. + CreateAbortAlarmOrder = False$ + Case ( AbortAlarmFromIntrusiveMaintRequired and IndexC(ModeSubCat, 'ABORT/ALARM', 1) and (ModeSubCatFlowId NE '') and (ChecklistIds NE '') ) // INTRUSIVE_MAINT FIRST_PRODUCT_RUN_THICK or FIRST_PRODUCT_RUN_HGCV checklist started and // ABORT/ALARM mode entered, so create an ABORT/ALARM order to contain product in reactor. @@ -2099,7 +2104,11 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force If CreateAbortAlarmOrder then Nica_Orders_Services('CreateNewOrder', 'REACTOR', ReactNo, 'ABORT_ALARM', ModeSubCatFlowId, ModeSubCatRespLvl, ChecklistIds, Intrusive) - RlComment = 'ABORT/ALARM initiated for flow ':ModeSubCatFlowId:'.' + If Error_Services('HasError') then + ErrorMsg = Error_Services('GetMessage') + end else + RlComment = 'ABORT/ALARM initiated for flow ':ModeSubCatFlowId:'.' + end end end @@ -2171,19 +2180,23 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force EntryId = UserID RLRec = '' - RLRec = CurDate - RLRec = CurTime - RLRec = ReactNo - if NewModeCategory EQ 'MAINTENANCE' then - RLRec = 'M' ;* for maintenance + RLRec = CurDate + RLRec = CurTime + RLRec = ReactNo + If NewModeCategory EQ 'MAINTENANCE' then + RLRec = 'M' ;* for maintenance end - RLRec = UserID - RLRec = CurDate - RLRec = NewRUKey - RLRec = ModeSubCatID - - CurrWoNo = Xlate('CONFIG', 'WO_DAILY_SCHED':ReactNo, 'F2', 'X') - CurrWoNo = CurrWoNo[1, 'F '] + RLRec = UserID + RLRec = CurDate + RLRec = NewRUKey + RLRec = ModeSubCatID + If (RLComment NE '') then + RLRec = RLComment + RLRec = CurDate + (CurTime / SECONDS_IN_DAY$) + RLRec = UserID + end + CurrWoNo = Xlate('CONFIG', 'WO_DAILY_SCHED':ReactNo, 'F2', 'X') + CurrWoNo = CurrWoNo[1, 'F '] If CurrWoNo NE '' then CurrPSNo = Xlate('WO_LOG', CurrWoNo, 'PS_NO', 'X') end else @@ -2292,7 +2305,6 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force // Reopen previous react mode Database_Services('WriteDataRow', 'REACT_MODE_NG', NGPrevModeKey, PrevModeRec) end else - If RlComment NE '' then Reactor_Log_Services('AddComment', ReactNo, RlComment, UserID) If SelE10State _EQC 'Productive' then // Reset ABORT/ALARM flag Open 'REACTOR' to hReactor then