Files
open-insight/LSL2/OIEVENT/CLICK/REACT_MODE_CHG.APPLY.json
2024-03-25 15:12:53 -07:00

11 lines
12 KiB
JSON

{
"header": {
"version": 1,
"type": "record"
},
"body": {
"record1": {
"<1>": "declare function msg, NextKey, next_key, rowexists, Get_Status, Logging_Services, Environment_Services\r\ndeclare subroutine end_dialog, record_lock, obj_React_Mode, ErrMsg, obj_React_Status, Logging_Services\r\n\r\n$insert logical\r\n$insert react_mode_equ\r\n$INSERT REACTOR_EQUATES\r\n$insert reactor_log_equ\r\n$insert react_util_equ\r\n$insert wo_log_equ\r\n$insert msg_equates\r\n$insert REACTOR_CHILD_KEY_IDS_EQUATES\r\n\r\nCurTime = time()\r\nCurDate = date()\r\n\r\nLogPath = Environment_Services('GetApplicationRootPath') : '\\ReactMode\\LogFiles'\r\n\r\nDate = Oconv(Date(), 'D4/')\r\nLogFileName = Date[7, 4] : '-' : Date[1, 2] : '-' : Date[4, 2] : ' ReactMode Log.csv'\r\nHeaders = 'Logging DTM' : @FM : 'Description'\r\nColumnWidths = 20 : @FM : 250\r\nobjLog = Logging_Services('NewLog', LogPath, LogFilename, CRLF$, ' ', Headers, ColumnWidths, False$, False$)\r\n\r\nLeakLampAutoFlag\t= ( Get_Property( @window, '@LeakLampAutoFlag' ) = 1 )\r\n\r\nCurReactModeSvc\t\t= Get_Property(@WINDOW:'.REACTMODESVC','TEXT')\t;* .reactmodesvc->text\r\n\r\nReactProbCat = trim( field( CurReactModeSvc, '|', 1 ) )\r\n\r\nif ReactProbCat <> '' then\r\n\tif rowexists( 'REACT_PROB_CAT', ReactProbCat ) else\r\n\t MsgInfo = ''\r\n\t MsgInfo<mtext$> = 'You must choose a VALID Reactor Problem Category.'\r\n\t MsgInfo<micon$> = 'H'\r\n\t Void = msg( '', MsgInfo )\r\n\t return 0 \r\n\tend\r\nend\r\n\r\nCurMode = Get_Property(@WINDOW:'.MODE','DEFPROP')\t\t;*.mode->text\r\nNoteText = Get_Property(@WINDOW:'.NOTE','DEFPROP')\t\t;*Note contents\r\nCurReactor = .reactor_no->text\r\n\r\nLogData = ''\r\nLogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM\r\nLogData<2> = 'Reactor No: ' : CurReactor : ' - Requested Mode Change: ' : CurMode\r\nLogging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)\r\n\r\n\r\nIF Get_Property( @WINDOW, '@Mode' )[1,11] NE 'Maintenance' THEN\r\n\tIF NoteText = '' AND LEN(NoteText) < 3 THEN\r\n\t\t* Note Text appears to be null\r\n\t\tErrMsg('Note / Reason for Change must be filled in.')\t\t;* Reason not required coming out of maintenance\r\n\t\tRETURN 0\r\n\tEND\r\nEND\r\n\r\nif CurMode[1,11] = ( 'Maintenance' ) and ( CurReactModeSvc = '' ) then\r\n MsgInfo = ''\r\n MsgInfo<mtext$> = 'You must choose a Reactor Problem Category.'\r\n MsgInfo<micon$> = 'H'\r\n Void = msg( '', MsgInfo )\r\n return 0\r\nend\r\n\r\n* IF THERE IS AN RUID THEN WE NEED TO CLOSE OUT THE PRIOR MODE\r\n\r\n\r\nopen 'REACT_UTIL' to ReactUtilTable else\r\n void = msg( '', 'Unable to open REACT_UTIL table...' )\r\n return 0\r\nend\r\n\r\n* ReactUtilID as found in the 'REACT_MODE':ReactNo record in the CONFIG table\r\n\r\nTReactUtilID = .ruid->text\r\n\r\nif TReactUtilID then\r\n * CHECK TO SEE IF THEY HAVE ENTERED THE REACTOR LOG INFO IF IT IS MAINTENANCE MODE\r\n ReactorLogID = ''\r\n \r\n if get_property( @window, '@Mode' )[1,11] = 'Maintenance' then \r\n CurMaintID = xlate( 'REACT_UTIL', TReactUtilID, react_util_reactor_log_id$, 'X' )\r\n if ( CurMaintID <> '' ) then\r\n CurMaintRec = xlate( 'REACTOR_LOG', CurMaintID, '', 'X' )\r\n end\r\n end\r\n\r\n\r\n record_lock( ReactUtilTable, 'REACT_UTIL', TReactUtilID )\r\n \r\n RUtilRec = ''\r\n RUtilRec = xlate( 'REACT_UTIL', TReactUtilID, '', 'X' )\r\n RUtilRec<react_util_end_date$> = CurDate\r\n RUtilRec<react_util_end_time$> = CurTime\r\n RUtilRec<react_util_mode_finish_user$> = @user4\r\n \r\n write RUtilRec on ReactUtilTable, TReactUtilID else\r\n* Void = msg( '', 'Unable to write ':TReactUtilID:' on REACT_UTIL...' )\r\n* return 0\r\n end\r\n \r\n unlock ReactUtilTable, TReactUtilID else\r\n* Void = msg( '', 'Unable to unlock REACT_UTIL ':TReactUtilID:'...' )\r\n* return 0\r\n end\r\n \r\nend\r\n\r\n**********************************************************************************\r\n* WRITE OUT NEW MODE INFORMATION\r\n\r\nKeyToUse = next_key( 'REACT_UTIL', ReactUtilTable, 'NEXT', '' )\r\nRUtilRec = ''\r\nRUtilRec<react_util_reactor$> = CurReactor\r\nRUtilRec<REACT_UTIL_NOTES$> = NoteText\r\n\r\n \r\nRMode = ''\r\n\r\nReactorLogID = ''\r\n\r\n* * * * * Added 3/27/2004 by John C. Henry, J.C. Henry, Inc. - Added popup for maintenance of Mode Codes\r\n\r\nPopupData = XLATE('SYSREPOSPOPUPS','LSL2**REACTOR_MODE',8,'X')\r\n\r\nFOR I = 1 TO COUNT(PopupData,@VM) + (@VM NE '')\r\n\tStatusDesc = PopupData<1,I,2>\r\nUNTIL StatusDesc = CurMode\r\nNEXT I\r\n\r\nRMode = PopupData<1,I,1>\r\n\r\nIF RMode = 'M' OR RMode = 'J' THEN ReactorLogID = 'CreateAReactorLogEntry'\r\n\r\n* * * * * End of changes.\r\n\r\n\r\nRUtilRec<react_util_mode$> = RMode\r\nRUtilRec<react_util_start_date$> = CurDate\r\nRUtilRec<react_util_start_time$> = CurTime\r\nRUtilRec<react_util_mode_start_user$> = @user4\r\n\r\n\r\nTwo = .wo->text\r\nif Two <> '' then\r\n * called from processing windows\r\n RUtilRec<react_util_wo$> = Two\r\nend else\r\n * called from main menu so work order not passed \r\n * we do have a lock so we can use the previous \r\n * work order---in other words it has not changed\r\n Two = xlate( 'REACT_UTIL', .ruid->text, react_util_wo$, 'X' ) \r\n RUtilRec<react_util_wo$> = Two\r\nend\r\n\r\nRUtilRec<react_util_cust_no$> = xlate( 'WO_LOG', Two[1,6], wo_log_cust_no$, 'X' )\t\t\t;* Added [1,6] for WO Step mods 7/28/2005 JCH\r\n\r\n********************************************************************************************************\r\n\r\n* NOW IF IT IS MAINTENANCE MODE, CREATE A REACTOR LOG ENTRY AND ASSIGN TO REACT_UTIL_REACTOR_LOG_ID$\r\n\r\nif ( ReactorLogID <> '' ) then\r\n ReactorLogID = ''\r\n\topen 'REACTOR_LOG' to RLTable else\r\n*\t Void = msg( '', 'Unable to open REACTOR_LOG...' )\r\n*\t return 0\r\n\tend\r\n\t// Already set at top of event handler. No need to set this again.\r\n * CurDate = date()\r\n * CurTime = time()\r\n EntryId = @user4\r\n\tReactorLogID = NextKey( 'REACTOR_LOG' )\r\n\tRLRec = ''\r\n\tRLRec<reactor_log_start_date$> = CurDate\r\n\tRLRec<reactor_log_start_time$> = CurTime\r\n\tRLRec<reactor_log_reactor$> = CurReactor\r\n\tRLRec<reactor_log_category$> = 'M' ;* for maintenance\r\n\tRLRec<reactor_log_entry_id$> = EntryId\t\t\r\n\tRLRec<reactor_log_entry_date$> = CurDate\r\n\tRLRec<reactor_log_react_util_id$> = KeyToUse\r\n\tRLRec<reactor_log_react_prob_cat_id$> = trim( field( .reactmodesvc->text, '|', 1 ) )\r\n\t\r\n\tif LeakLampAutoFlag then\r\n\t RLRec<reactor_log_react_serv_id$> = 188\r\n\t RLRec<reactor_log_scheduled$> = 1\r\n\t RLRec<reactor_log_react_serv_cat_id$> = 25\r\n\tend\r\n\t\r\n\twrite RLRec on RLTable, ReactorLogID else\r\n*\t void = msg( '', 'Unable to write ':ReactorLogID:' on REACTOR_LOG...' )\r\n*\t return 0\r\n\tend\r\n\t\r\nend\r\n\r\nRUtilRec<react_util_reactor_log_id$> = ReactorLogID\r\n\r\nwrite RUtilRec on ReactUtilTable, KeyToUse else\r\n* Void = msg( '', 'Unable to write ':KeyToUse:' on REACT_UTIL...' )\r\n* return 0\r\nend\r\n\r\nunlock ReactUtilTable, KeyToUse else\r\n* Void = msg( '', 'Unable to unlock REACT_UTIL ':KeyToUse:'...' )\r\n* return 0\r\nend\r\nVoid = next_key( 'REACT_UTIL', ReactUtilTable, 'UPDATE', KeyToUse )\r\n\r\nopen 'CONFIG' to ConfigTable else\r\n* Void = msg( '', 'Unable to open CONFIG table...' )\r\n* return 0\r\nend\r\nRec = ''\r\nRec<Mode$> = .mode->text\r\nRec<Username$> = oconv( @user4, '[XLATE_CONV,LSL_USERS*FIRST_LAST]' )\r\nRec<Date$> = oconv( date(), 'D4/' )\r\nRec<Time$> = oconv( time(), 'MTH' )\r\nRec<ReactUtilID$> = KeyToUse\r\nRec<ReactorLogID$> = ReactorLogID\r\n\r\nif .reactmodesvc->visible then\r\n Rec<Service$> = .reactmodesvc->text\r\nend else\r\n Rec<Service$> = ''\r\nend\r\n\r\nif .note->visible then\r\n Rec<Note$> = .note->text\r\nend else\r\n Rec<Note$> = ''\r\nend\r\n\r\nReactNo = Get_Property(@WINDOW:'.REACTOR_NO','TEXT')\r\nCurrDTM = Rec<Date$>:\" \":Rec<Time$>\r\n\r\n*PrevModeKey = XLATE('REACTOR',ReactNo,REACTOR_CURR_MODE_KEY$,'X')<1,1>\t;* This gets to MV'd if there are problems in the data JCH\r\nPrevModeKey = Xlate('REACTOR_CHILD_KEY_IDS', ReactNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')<1, 1>\r\nOpenDTM\t= FIELD(PrevModeKey,'*',2)\r\nOpenDTM = OCONV(OpenDTM,'DT4/^S')\r\n\r\nMode\t= Rec<Mode$>\r\n\r\nRecName = 'REACT_MODE':ReactNo\r\n\r\n\r\n* * * * * Changes by JCH on 11/5/2007 * * * * *\r\n\r\nCurrMode = OCONV(XLATE('REACTOR',ReactNo,'CURR_MODE','X'),'[REACT_MODE_CONV]')\r\nNewMode\t = Get_Property(@WINDOW:'.MODE','TEXT')\r\nProdModes = 'Production':@VM\r\nProdModes := 'Production (incr sampling)'\r\n\r\nLogData = ''\r\nLogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM\r\nLogData<2> = 'Reactor No: ' : CurReactor : ' - Current Mode: ' : CurrMode : ' - New Mode: ' : NewMode\r\nLogging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)\r\n\r\n*IF NewMode NE CurrMode AND NewMode NE '' THEN\r\n\r\n\tLOCATE CurrMode IN ProdModes USING @VM SETTING DUMMY THEN\r\n\t\r\n\t\tLOCATE NewMode IN ProdModes USING @VM SETTING DUMMY ELSE\r\n\t\t\r\n\t\t\tOutOfProdDTM = Rec<Date$>:' ':Rec<Time$>\r\n\t\t\t\r\n\t\t\tobj_React_Status('SetOutOfProdDTM',ReactNo:@RM:OutOfProdDTM)\r\n\t\t\t\r\n\t\t\tIF Get_Status(errCode) THEN\r\n\t\t\t\tErrMsg(errCode)\r\n\t\t\tEND\r\n\t\tEND\t\t;* End of check on New Mode\r\n\tEND\t\t;* End of check on Current Mode\r\n*END\t\t;* End of check for a CHANGE in Mode\r\n\r\n* * * End of changes * * * * *\r\n\r\n\r\nWRITE Rec ON ConfigTable,RecName THEN\r\n\r\n\r\n*\tIF NewMode NE CurrMode AND NewMode NE '' THEN\r\n\r\n\r\n\t\tIF CurrMode NE '' THEN\r\n\t\t\tcrParms = ReactNo\r\n\t\t\tcrParms := @RM:OpenDTM\r\n\t\t\tcrParms := @RM:CurrDTM\r\n\t\t\tcrParms := @RM:@USER4\r\n\t\t\tcrParms := @RM:Rec<Note$>\r\n\t\t\tcrParms := @RM:Rec<ReactUtilID$>\r\n\t\t\tcrParms := @RM:Rec<ReactorLogID$>\r\n\r\n LogData = ''\r\n LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM\r\n LogData<2> = 'Reactor No: ' : ReactNo : ' - obj_React_Mode(\"Close\") - Key ID: ' : ReactNo : '*' : Iconv(OpenDTM, 'DT')\r\n Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)\r\n\r\n\t\t\tobj_React_Mode('Close',crParms)\t\t\t\t;* Close the currently active mode\r\n\t\t\t\r\n\t\t\tIF Get_Status(errCode) THEN\r\n\t\t\t\tErrMsg(errCode)\r\n\t\t\tEND\r\n\t\tEND\r\n\t\t\t\r\n\t\tcrParms = ReactNo\r\n\t\tcrParms := @RM:CurrDTM\r\n\t\tcrParms := @RM:@USER4\r\n\t\tcrParms := @RM:Rec<Mode$>\r\n\t\tcrParms := @RM:Rec<Note$>\r\n\t\tcrParms := @RM:Rec<ReactUtilID$>\r\n\t\tcrParms := @RM:Rec<ReactorLogID$>\r\n\r\n LogData = ''\r\n LogData<1> = Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTS') ; // Logging DTM\r\n LogData<2> = 'Reactor No: ' : ReactNo : ' - obj_React_Mode(\"Create\") - Key ID: ' : ReactNo : '*' : Iconv(CurrDTM, 'DT')\r\n Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)\r\n\r\n\t\tobj_React_Mode('Create',crParms)\t\t;* Create new active mode record\r\n\t\t\r\n\t\tIF Get_Status(errCode) THEN\r\n\t\t\tErrMsg(errCode)\r\n\t\tEND\r\n\t\r\n*\tEND\r\n\t\t\r\nEND ELSE\r\n* Void = msg( '', 'Unable to write ':RecName:' on CONFIG table...' )\r\n* return 0\r\nend\r\n\r\nunlock ConfigTable, RecName else NULL\r\n\r\nNewMode = Get_Property(@WINDOW:'.MODE','TEXT')\r\n\r\nWriteFinishTime = Time()\r\n\r\nif LeakLampAutoFlag then\r\n end_dialog( @window, ReactorLogID )\r\nend else\r\n end_dialog( @window, NewMode )\r\nend\r\nRETURN 0"
}
}
}