Files
open-insight/LSL2/STPROC/REACT_MODE_CHG_NG_EVENTS.txt
2024-03-25 14:46:21 -07:00

428 lines
16 KiB
Plaintext

Compile function REACT_MODE_CHG_NG_EVENTS(CtrlEntId, Event, @PARAMS)
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
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
#pragma precomp SRP_PreCompiler
#window REACT_MODE_CHG_NG
$Insert EVENT_SETUP
$insert logical
$insert REACT_MODE_EQUATES
$Insert REACT_MODE_NG_EQUATES
$Insert REACTOR_MODES_EQUATES
$insert react_mode_equ ;* THESE ARE NOT THE SAME jch, Update 9/15/21. These are the equates for the CONFIG records
$insert msg_equates
$insert rlist_equates
$insert react_prob_cat_equates
$insert reactor_log_equ
$insert react_util_equ
$insert wo_log_equ
$insert REACTOR_CHILD_KEY_IDS_EQUATES
GoToEvent Event for CtrlEntId else
// Event not implemented
end
Return EventFlow or 1
//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------
Event WINDOW.CREATE(CreateParam)
//if @user4 eq 'JONATHAN_O' or @Username eq 'MESOUELLETTE' then debug
Reactor = CreateParam[1,'*']
Wo = CreateParam[COL2()+1,'*']
ForceModeChange = CreateParam[COL2()+1,'*']
FourthParm = CreateParam[COL2()+1,'*']
LeakLampAutoFlag = (FourthParm = 1 )
IF INDEX(CreateParam,'CENTER',1 ) THEN
void = center_window( @WINDOW )
END ELSE
Void = Set_Property( @WINDOW, 'VISIBLE', 1 )
END
EventFlow = 1
//Get List of Reactor Modes
Statement = 'SELECT REACTOR_MODES BY DESCRIPTION'
rlist( Statement, target_activelist$, '', '', '' )
ModeList = ''
IF @RecCount then
EoF = 0
NumKeys = @RecCount
Cnt = 0
Loop
ReadNext ReactorModeID Else EoF = 1
until EoF
ModeList<-1> = ReactorModeID
Repeat
end
Set_Property(@Window : '.MODE', 'LIST', ModeList)
//End of Get list of Reactor Modes
//Find the current REACT_MODE OR REACT_MODE_NG record.
OldGenReactModeKey = XLATE('REACTOR_CHILD_KEY_IDS', Reactor, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')
NewGenReactModeKey = XLATE('REACTOR_CHILD_KEY_IDS_NG', Reactor, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')
OldGenReactModeDTM = Field(OldGenReactModeKey, '*', 2)
NewGenReactModeDTM = Field(NewGenReactModeKey, '*', 2)
ReactModeKeyToUse = ''
If OldGenReactModeDTM GT NewGenReactModeDTM then
ReactModeKeyToUse = OldGenReactModeKey
GoSub TranslateOldCodes
end
If NewGenReactModeDTM GT OldGenReactModeDTM then
ReactModeKeyToUse = NewGenReactModeKey
end
//CurReactMode = Xlate('REACT_MODE', ReactModeKeyToUse, REACT_MODE_MODE$, 'X')
//End find the current REACT_MODE OR REACT_MODE_NG record.
Set_List_Box_Data( @WINDOW )
//check for Groups allowed to change
IF memberof( @USER4, 'DATA_ENTRY' ) OR memberof( @USER4, 'SUPERVISOR' ) OR memberof( @USER4, 'MAINTENANCE' ) OR @USER4 EQ 'JONATHAN_O' THEN
IF Reactor NE '' THEN
* called from status window and createparam is the reactor number
* so simply READ and lock
OPEN 'CONFIG' TO ConfigTable ELSE
Void = msg( '', 'Unable to open CONFIG table...' )
RETURN 0
END
LOCK ConfigTable, 'REACT_MODE':Reactor THEN
IF ForceModeChange THEN
Set_Property(@Window : '.CANCEL', 'ENABLED', 0)
Set_Property(@Window : '.APPLY', 'ENABLED', 1)
END
END ELSE
Set_Property(@Window : '.MODE', 'ENABLED', 0)
Set_Property(@Window : '.REACTMODESVC', 'ENABLED', 0)
Set_Property(@Window : '.CANCEL', 'TEXT', 'OK')
MsgInfo = ''
MsgInfo<mtext$> = 'Reactor ':Reactor:' is currently being set to another mode...'
MsgInfo<micon$> = '!'
NotSignedRL = 1
Void = msg( '', MsgInfo )
END
GOSUB DoRead
unlock ConfigTable, 'REACT_MODE':Reactor else NULL
END ELSE
* let them enter the reactor number and get a lock on the onchange event
Set_Property(@Window : '.reactor_no', 'ENABLED', 1)
END ;* End of check for Non-Null Reactor No
END ELSE
Set_Property(@Window : '.MODE', 'ENABLED', 0)
Set_Property(@Window : '.REACTMODESVC', 'ENABLED', 0)
Set_Property(@Window : '.CANCEL', 'TEXT', 'OK')
GOSUB DoRead
END ;* End of check for Groups allowed to change
OriginalCommentBackColor = Get_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR')
Set_Property(@Window, '@EDB_COMMENT_ORIG_BACK_COLOR', OriginalCommentBackColor)
Set_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR', 0)
OriginalCommentSize = Get_Property(@Window:'.EDB_COMMENT', 'SIZE')
Set_Property(@Window, '@EDB_COMMENT_ORIG_SIZE', OriginalCommentSize)
End Event
Event MODE.CHANGED()
Set_Property(@Window:'.EDB_COMMENT', 'TEXT', '')
OrigMode = Get_Property(@Window: '.CURRENT_MODE', 'TEXT')
NewMode = Get_Property(@Window : '.MODE', 'TEXT')
IF OrigMode NE NewMode then
Set_Property(@Window : '.APPLY', 'ENABLED', 1)
Set_Property(@Window : '.REACTMODESVC', 'TEXT', '')
end else
Set_Property(@Window : '.APPLY', 'ENABLED', 1)
//Set_Property(@Window : '.REACTMODESVC', 'TEXT', '')
end
CatDesc = Xlate('REACTOR_MODES', NewMode, REACTOR_MODES_SERVICE_CATEGORIES$, 'X')
Swap @VM with @FM in CatDesc
Set_Property(@Window : '.REACTMODESVC', 'VISIBLE', 1)
Set_Property(@Window : '.REACTMODESVC', 'ENABLED', 1)
Set_Property(@Window : '.REACTMODESVC', 'LIST', CatDesc)
Set_Property(@Window : '.SERV_LABEL', 'VISIBLE', 1)
IF NewMode EQ 'CHANGEOVER_SCHEDULED' then
//GoSub ChangeOverAutoSet
end
If (NewMode _NEC 'WAITING_FOR_MAINTENANCE_UNSCHEDULED') and (NewMode _NEC 'WAITING_FOR_ENGTECH_UNSCHEDULED') then
GoSub HideDropDownComments
end
end event
Event REACTMODESVC.CHANGED()
Set_Property(@Window:'.EDB_COMMENT', 'TEXT', '')
UseDropDownComments = 0
NewMode = Get_Property(@Window : '.MODE', 'TEXT')
SvcCat = Get_Property(@Window:'.REACTMODESVC', 'TEXT')
If NewMode _EQC 'WAITING_FOR_MAINTENANCE_UNSCHEDULED' then
AvailableMaintComments = Xlate('APP_INFO', 'REACT_MODE_CHANGE_MAINT_COMMENT_OPTIONS', 1, 'X')
Swap @VM with @FM in AvailableMaintComments
Set_Property(@Window:'.COB_COMMENT', 'LIST', AvailableMaintComments)
UseDropDownComments += 1
end
If NewMode _EQC 'WAITING_FOR_ENGTECH_UNSCHEDULED' then
AvailableEngrComments = Xlate('APP_INFO', 'REACT_MODE_CHANGE_ENGR_COMMENT_OPTIONS', 1, 'X')
Swap @VM with @FM in AvailableEngrComments
Set_Property(@Window:'.COB_COMMENT', 'LIST', AvailableEngrComments)
UseDropDownComments +=1
end
If SvcCat _EQC 'WF-PARTICLES' then
UseDropDownComments += 1
end
If UseDropDownComments GT 1 then
Set_Property(@Window:'.COB_COMMENT', 'ENABLED', True$)
Set_Property(@Window:'.COB_COMMENT', 'VISIBLE', True$)
OrigBackColor = Get_Property(@Window, '@EDB_COMMENT_ORIG_BACK_COLOR')
Set_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR', OrigBackColor)
OriginalCommentSize = Get_Property(@Window, '@EDB_COMMENT_ORIG_SIZE')
CommentSize = Get_Property(@Window, '@EDB_COMMENT_ORIG_SIZE')
CommentSize<2> = CommentSize<2> + 37
CommentSize<4> = 65
Set_Property(@Window:'.EDB_COMMENT', 'SIZE', CommentSize)
Set_Property(@Window:'.COB_COMMENT', 'TEXT', '')
end else
GoSub HideDropDownComments
end
end event
Event APPLY.CLICK()
//Initialize Logging
LogPath = Environment_Services('GetApplicationRootPath') : '\ReactMode\LogFiles'
Date = Oconv(Date(), 'D4/')
LogFileName = Date[7, 4] : '-' : Date[1, 2] : '-' : Date[4, 2] : ' ReactMode Log.csv'
Headers = 'Logging DTM' : @FM : 'Description'
ColumnWidths = 20 : @FM : 250
objLog = Logging_Services('NewLog', LogPath, LogFilename, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
ReactNo = Get_Property(@WINDOW:'.REACTOR_NO','TEXT')
NewMode = Get_Property(@Window : '.MODE', 'TEXT')
NewReactModeSvc = Get_Property(@WINDOW:'.REACTMODESVC','TEXT') ;* .reactmodesvc->text
NewNoteText = ''
CobCommentEnabled = Get_Property(@Window:'.COB_COMMENT', 'ENABLED')
If CobCommentEnabled then
SelectedComment = Get_Property(@Window:'.COB_COMMENT', 'TEXT')
If SelectedComment _EQC 'other' then
NewNoteText = Get_Property(@Window:'.EDB_COMMENT', 'TEXT')
end else
NewNoteText = SelectedComment
end
end else
NewNoteText = Get_Property(@Window:'.EDB_COMMENT', 'TEXT')
end
Reactor_Services('CreateReactModeChange', @User4, ReactNo, NewMode, NewReactModeSvc, NewNoteText)
If Error_Services('NoError') then
End_Dialog(@Window, NewMode)
end else
Error_Services('DisplayError')
end
RETURN 0
end event
Event RL_BUTTON.CLICK()
If Get_Property('NDW_MAIN', 'VISIBLE') then
AppMain = 'NDW_MAIN'
end else
AppMain = 'LSL_MAIN2'
end
ReactorLogID = Get_Property(@Window : '.RLID', 'TEXT')
//Void = start_window( 'REACTOR_LOG', AppMain, ReactorLogID:'*CENTER', '', '' )
Void = Dialog_Box('REACTOR_LOG', AppMain, ReactorLogID:'*CENTER')
void = Set_Property('REACTOR_LOG','@PARENT','REACT_MODE_CHG_NG')
If Reactor_Log_Services('IsMaint', ReactorLogID) AND Reactor_Log_Services('IsSigned', ReactorLogID) then
Set_Property(@Window : '.MODE', 'ENABLED', 1)
end
RETURN 0
end event
Event CANCEL.CLICK()
Reactor = Get_Property(@Window : '.REACTOR_NO', 'TEXT')
CurMode = Get_Property(@Window: '.CURRENT_MODE','TEXT')
End_Dialog(@Window, CurMode)
end event
Event COB_COMMENT.CHANGED()
Set_Property(@Window:'.EDB_COMMENT', 'TEXT', '')
Comment = Get_Property(@Window:'.COB_COMMENT', 'TEXT')
If Comment _EQC 'other' then
Set_Property(@Window:'.EDB_COMMENT', 'ENABLED', True$)
Set_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR', 0)
end else
Set_Property(@Window:'.EDB_COMMENT', 'ENABLED', False$)
OrigBackColor = Get_Property(@Window, '@EDB_COMMENT_ORIG_BACK_COLOR')
Set_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR', OrigBackColor)
end
end event
//-----------------------------------------------------------------------------
// INTERNAL GOSUBS
//-----------------------------------------------------------------------------
* * * * * * *
DoRead:
* * * * * * *
//Pull in the full REACT_MODE or REACT_MODE_NG record.
CurReactModeRec = XLATE('REACT_MODE', ReactModeKeyToUse, '','X')
If CurReactModeRec EQ '' then
//If CurReactModeRec is blank then check the NG table for that record.
CurReactModeRec = XLATE('REACT_MODE_NG', ReactModeKeyToUse, '','X')
end
//This basically pulls in redundant information from a config table
Rec = XLATE( 'CONFIG', 'REACT_MODE_NG':Reactor, '', 'X' )
If Rec = '' then
Rec = XLATE( 'CONFIG', 'REACT_MODE':Reactor, '', 'X' )
end
Service = Rec<Service$>
Note = Rec<Note$>
Mode = Rec<Mode$>
ReactLogID = Rec<ReactorLogID$>
ReactLogCat = XLATE('REACTOR_LOG', ReactLogID, 6, 'X')
//This determines if the current mode is a maint. mode and if so checks that the REACTOR_LOG has been signed off by a technician.
* IF Rec<ReactorLogID$> NE '' AND ReactLogCat EQ 'M' THEN
* debug
* Set_Property(@Window : '.RL_BUTTON', 'VISIBLE', 1)
* OPEN 'REACTOR_LOG' TO RLTable ELSE
* msg( '', 'Unable to open REACTOR_LOG...' )
* RETURN 0
* END
* READ RLRec from RLTable, ReactLogID THEN
* IF RLRec<reactor_log_tech_sig$> = '' THEN
* * DO NOT ALLOW A MODE CHANGE CAUSE THE REACTOR LOG IS STILL OPEN
* MsgInfo = ''
* MsgInfo<mtext$> = 'You are not allowed to change the mode because the maintenance tech has not signed off on the reactor log entry...'
* MsgInfo<micon$> = '!'
* Set_Property(@Window : '.MODE', 'ENABLED', 0);
* NotSignedRL = 1
* Void = msg( '', MsgInfo )
*
*
* END ELSE
* * ALLOW A MODE CHANGE CAUSE IT HAS BEEN SIGNED BY A MAINTENANCE TECHNICIAN
*
* END
* END ELSE
* * DO NOTHING CAUSE SOME MAINT GUY MUST HAVE DELETED THE ENTRY
* END
* END
IF ReactLogID NE '' then
IF Reactor_Log_Services('IsMaint', ReactLogID) then
Set_Property(@Window : '.RL_BUTTON', 'VISIBLE', 1)
IF NOT(Reactor_Log_Services('IsSigned', ReactLogID)) then
* DO NOT ALLOW A MODE CHANGE CAUSE THE REACTOR LOG IS STILL OPEN
MsgInfo = ''
MsgInfo<mtext$> = 'You are not allowed to change the mode because the maintenance tech has not signed off on the reactor log entry...'
MsgInfo<micon$> = '!'
Set_Property(@Window : '.MODE', 'ENABLED', 0);
NotSignedRL = 1
Void = msg( '', MsgInfo )
end
end else
* ALLOW A MODE CHANGE CAUSE IT HAS BEEN SIGNED BY A MAINTENANCE TECHNICIAN
end
end
Set_Property(@WINDOW:'.REACTOR_NO','TEXT', Reactor)
Set_Property(@WINDOW:'.USERNAME','TEXT', Rec<Username$>)
Set_Property(@WINDOW:'.DATE','TEXT', Rec<Date$>)
Set_Property(@WINDOW:'.TIME','TEXT', Rec<Time$>)
Set_Property(@WINDOW:'.CURRENT_MODE','TEXT', Mode)
Set_Property(@WINDOW:'.CURRENT_REACTMODESVC','TEXT', Service)
//Set_Property(@WINDOW, '@Mode', Rec<Mode$> )
Set_Property(@WINDOW:'.RUID','TEXT', Rec<ReactUtilID$>)
Set_Property(@WINDOW:'.RLID','TEXT', Rec<ReactorLogID$>)
Set_Property(@WINDOW:'.WO','TEXT', Wo)
IF Service THEN
Set_Property(@WINDOW:'.REACTMODESVC','VISIBLE',TRUE$)
Set_Property(@WINDOW:'.SERV_LABEL','VISIBLE',TRUE$)
//Set_Property(@WINDOW:'.REACTMODESVC','TEXT', Service)
Set_Property(@WINDOW:'.REACTMODESVC','ENABLED', 0) ;* Do not allow them to change the service until they change the mode
END
//Get Possible Modes here
ModeList = ''
ModeList = Reactor_Modes_Services('AvailableModes', Mode, @User4)
Set_Property(@Window : '.MODE', 'LIST', ModeList)
RETURN
* * * * * * * * * *
TranslateOldCodes:
* * * * * * * * * *
ReactorModeList = Xlate('SYSREPOSPOPUPS', @APPID<1>:'**':'REACTOR_MODE', PDISPLAY$, 'X')
ReactorModeArray = ReactorModeList<8>
Convert @VM to @FM in ReactorModeArray
Convert @SVM to @VM in ReactorModeArray
CurReactModeCode = XLATE('REACT_MODE', ReactModeKeyToUse, REACT_MODE_MODE$, 'X')
Locate CurReactModeCode in ReactorModeArray using @FM setting CodePos then
NewMode = ReactorModeArray<CodePos, 2>
end
return
* * * * * * * * * * *
CheckReactorLogStatus:
return
* * * * * * * * * * *
ChangeOverAutoSet:
* * * * * * * * * * *
LastWO = ''
NextWO = ''
return
HideDropDownComments:
Set_Property(@Window:'.COB_COMMENT', 'ENABLED', False$)
Set_Property(@Window:'.COB_COMMENT', 'VISIBLE', False$)
Set_Property(@Window:'.EDB_COMMENT', 'ENABLED', True$)
Set_Property(@Window:'.EDB_COMMENT', 'VISIBLE', True$)
Set_Property(@Window:'.EDB_COMMENT', 'BACKCOLOR', 0)
OriginalCommentSize = Get_Property(@Window, '@EDB_COMMENT_ORIG_SIZE')
Set_Property(@Window:'.EDB_COMMENT', 'SIZE', OriginalCommentSize)
Set_Property(@Window:'.COB_COMMENT', 'TEXT', '')
return