Added JSON body and response logging to CreateNewOrder service. Modified how reactor log comments are added for ABORT_ALARM NICA orders. Modified ABORT_ALARM solution to not trigger on WAITING_FOR_MAINTENANCE_UNSCHEDULED
This commit is contained in:
@ -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,6 +443,7 @@ Service CreateNewOrder(EntityType=ENTITY_TYPES, EntityID, OrderType=ORDER_TYPES,
|
||||
IsSuccessful = False$
|
||||
If ErrorMsg EQ '' then
|
||||
|
||||
AttemptNo = 0
|
||||
Retries = 3
|
||||
BackoffSeconds = 1
|
||||
OrderId = ''
|
||||
@ -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
|
||||
|
@ -2064,6 +2064,11 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force
|
||||
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)
|
||||
If Error_Services('HasError') then
|
||||
ErrorMsg = Error_Services('GetMessage')
|
||||
end else
|
||||
RlComment = 'ABORT/ALARM initiated for flow ':ModeSubCatFlowId:'.'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -2171,17 +2180,21 @@ Service CreateReactModeChange(UserID, ReactNo, Mode, ModeSubCat, ModeText, Force
|
||||
EntryId = UserID
|
||||
|
||||
RLRec = ''
|
||||
RLRec<reactor_log_start_date$> = CurDate
|
||||
RLRec<reactor_log_start_time$> = CurTime
|
||||
RLRec<reactor_log_reactor$> = ReactNo
|
||||
if NewModeCategory EQ 'MAINTENANCE' then
|
||||
RLRec<reactor_log_category$> = 'M' ;* for maintenance
|
||||
RLRec<REACTOR_LOG_START_DATE$> = CurDate
|
||||
RLRec<REACTOR_LOG_START_TIME$> = CurTime
|
||||
RLRec<REACTOR_LOG_REACTOR$> = ReactNo
|
||||
If NewModeCategory EQ 'MAINTENANCE' then
|
||||
RLRec<REACTOR_LOG_CATEGORY$> = 'M' ;* for maintenance
|
||||
end
|
||||
RLRec<REACTOR_LOG_ENTRY_ID$> = UserID
|
||||
RLRec<REACTOR_LOG_ENTRY_DATE$> = CurDate
|
||||
RLRec<REACTOR_LOG_REACT_UTIL_ID$> = NewRUKey
|
||||
RLRec<REACTOR_LOG_REACT_PROB_CAT_ID$> = ModeSubCatID
|
||||
If (RLComment NE '') then
|
||||
RLRec<REACTOR_LOG_NOTES$> = RLComment
|
||||
RLRec<REACTOR_LOG_NOTES_DTMS$> = CurDate + (CurTime / SECONDS_IN_DAY$)
|
||||
RLRec<REACTOR_LOG_NOTES_USERS$> = UserID
|
||||
end
|
||||
RLRec<reactor_log_entry_id$> = UserID
|
||||
RLRec<reactor_log_entry_date$> = CurDate
|
||||
RLRec<reactor_log_react_util_id$> = NewRUKey
|
||||
RLRec<reactor_log_react_prob_cat_id$> = ModeSubCatID
|
||||
|
||||
CurrWoNo = Xlate('CONFIG', 'WO_DAILY_SCHED':ReactNo, 'F2', 'X')
|
||||
CurrWoNo = CurrWoNo[1, 'F ']
|
||||
If CurrWoNo NE '' then
|
||||
@ -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
|
||||
|
Reference in New Issue
Block a user