------------------------------------------------------------------ -- -- NAME: SEGMENTS - BODY -- DISCREPANCY REPORTS: ------------------------------------------------------------------ -- file: SEGS_B.ADA -- level: 1a, 2a with GKS_STATE_LIST; with CGI_SUBTYPES_A; with WSM; with GKS_OPERATING_STATE_LIST; with ERROR_HANDLING; with GKS_ERRORS; with OUTPUT_ATTRIBUTES_TYPE; with GET_OUTPUT_ATTRIBUTES; with GKS_ERROR_STATE_LIST; use CGI_SUBTYPES_A; use WSM; use GKS_OPERATING_STATE_LIST; use GKS_ERRORS; use GKS_ERROR_STATE_LIST; package body SEGMENTS is -- The package SEGMENTS contains procedures that perform various -- operations on segments. procedure CREATE_SEGMENT (SEGMENT : in SEGMENT_NAME) is -- The procedure CREATE_SEGMENT checks the operating state. -- If there are no workstations active, (error #3) the procedure -- ERROR_HANDLING is called. Otherwise the Workstation Manager is -- called. It can detect error 121. If error 121 occurs, procedure -- ERROR_HANDLING is called. Otherwise the Operating State is set -- to SGOP. -- -- SEGMENT - This is the identifier to associate with the -- segment about to be created. GKS_INSTR : CGI_CREATE_SEGMENT; OUTPUT_ATTRIBUTES_AT_CREATE : OUTPUT_ATTRIBUTES_TYPE. OUTPUT_ATTRIBUTES; begin -- Check the GKS_ERROR_STATE_LIST to see that the ERROR_STATE -- is not ON before continuing. if GKS_ERROR_STATE_LIST.ERROR_STATE = ON then return; end if; -- The following if inquires the GKS_OPERATING_STATE_LIST to -- see if GKS is in the proper state before proceeding with the -- call to the WS_MANAGER. if (CURRENT_OPERATING_STATE /= WSAC) then -- error 3 -- The state must be active workstation. -- Otherwise an error exists and must be logged. GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(NOT_WSAC,"CREATE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Call WS_MANAGER with segment parameters. GKS_INSTR.SEGMENT_TO_CREATE := SEGMENT; GET_OUTPUT_ATTRIBUTES.GET_ATTRIBUTES (OUTPUT_ATTRIBUTES_AT_CREATE); GKS_INSTR.ATTRIBUTES_AT_CREATE := OUTPUT_ATTRIBUTES_AT_CREATE; WS_MANAGER(GKS_INSTR); -- Check for a successful call. if GKS_INSTR.ERROR_INDICATOR = SEGMENT_IN_USE then -- error 121 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(SEGMENT_IN_USE,"CREATE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Segment was successfully created therefore the state -- is changed to segment open. CURRENT_OPERATING_STATE := SGOP; end if; end if; exception when GKS_ERROR => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; when OTHERS => begin GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(UNKNOWN,"CREATE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; exception when OTHERS => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; end; end CREATE_SEGMENT; procedure CLOSE_SEGMENT is -- The procedure CLOSE_SEGMENT checks the operating state. -- If no segments are open, (error #4) the procedure ERROR_HANDLING -- is called. Otherwise the Workstation Manager is called. -- Then, the Operating State is set to WSAC. GKS_INSTR : CGI_CLOSE_SEGMENT; begin -- Check the GKS_ERROR_STATE_LIST to see that the ERROR_STATE -- is not ON before continuing. if GKS_ERROR_STATE_LIST.ERROR_STATE = ON then return; end if; -- The following if inquires the GKS_OPERATING_STATE_LIST to -- see if GKS is in the proper state before proceeding with the -- call to the WS_MANAGER. if (CURRENT_OPERATING_STATE /= SGOP) then -- error 4 -- The state must be segment open. -- Otherwise an error exists and must be logged. GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(NOT_SGOP,"CLOSE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Call WS_MANAGER. WS_MANAGER(GKS_INSTR); -- Check for a successful call. if GKS_INSTR.ERROR_INDICATOR = SUCCESSFUL then -- error 0 CURRENT_OPERATING_STATE := WSAC; end if; end if; exception when GKS_ERROR => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; when OTHERS => begin GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(UNKNOWN,"CLOSE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; exception when OTHERS => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; end; end CLOSE_SEGMENT; procedure RENAME_SEGMENT (OLD_NAME : in SEGMENT_NAME; NEW_NAME : in SEGMENT_NAME) is -- The procedure RENAME_SEGMENT checks the operating state. -- If there are no workstations open, (error #7) the procedure -- ERROR_HANDLING is called. Otherwise the Workstation Manager is -- called. It can detect errors 121 or 122 which will cause -- the procedure ERROR_HANDLING to be called. -- -- OLD_NAME - This is the identifier of the segment that -- is to change. -- -- NEW_NAME - This is the new identifier that is to be -- associated with this segment. GKS_INSTR : CGI_RENAME_SEGMENT; ERROR_INDICATOR : ERROR_NUMBER := SUCCESSFUL; begin -- Check the GKS_ERROR_STATE_LIST to see that the ERROR_STATE -- is not ON before continuing. if GKS_ERROR_STATE_LIST.ERROR_STATE = ON then return; end if; -- The following if inquires the GKS_OPERATING_STATE_LIST to -- see if GKS is in the proper state before proceeding with the -- call to the WS_MANAGER. if (CURRENT_OPERATING_STATE = GKOP) or (CURRENT_OPERATING_STATE = GKCL) then -- The state must indicate there is an open workstation. -- Otherwise an error exists and must be logged. -- error 7 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(NOT_WSOP_WSAC_SGOP,"RENAME_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Call WS_MANAGER with segment parameters. GKS_INSTR.OLD_NAME := OLD_NAME; GKS_INSTR.NEW_NAME := NEW_NAME; WS_MANAGER(GKS_INSTR); ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; -- Check for a successful call. If not, only SEGMENT_IN_USE -- and SEGMENT_DOES_NOT_EXIST should be returned. Anything -- else is unknown. Whatever the error, it must be logged. if ERROR_INDICATOR /= SUCCESSFUL then -- error 0 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(ERROR_INDICATOR,"RENAME_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; end if; end if; exception when GKS_ERROR => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; when OTHERS => begin GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(UNKNOWN,"CREATE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; exception when OTHERS => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; end; end RENAME_SEGMENT; procedure DELETE_SEGMENT (SEGMENT : in SEGMENT_NAME) is -- The procedure DELETE_SEGMENT checks the operating state. -- If there are no workstations open, (error #7) the procedure -- ERROR_HANDLING is called. Otherwise the Workstation Manager -- is called. It can detect errors 122 or 125. If either -- error occurs, the procedure ERROR_HANDLING is called. -- -- SEGMENT - This is the identifier of the segment that is -- to be deleted. GKS_INSTR : CGI_DELETE_SEGMENT; ERROR_INDICATOR : ERROR_NUMBER := SUCCESSFUL; begin -- Check the GKS_ERROR_STATE_LIST to see that the ERROR_STATE -- is not ON before continuing. if GKS_ERROR_STATE_LIST.ERROR_STATE = ON then return; end if; -- The following if inquires the GKS_OPERATING_STATE_LIST to -- see if GKS is in the proper state before proceeding with the -- call to the WS_MANAGER. if (CURRENT_OPERATING_STATE = GKOP) or (CURRENT_OPERATING_STATE = GKCL) then -- The state must indicate there is an open workstation, -- Otherwise an error exists and must be logged. -- error 7 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(NOT_WSOP_WSAC_SGOP,"DELETE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Call WS_MANAGER with segment parameters. GKS_INSTR.SEGMENT_TO_DELETE := SEGMENT; WS_MANAGER(GKS_INSTR); ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; -- Check for a successful call. If not, only -- SEGMENT_DOES_NOT_EXIST and SEGMENT_IS_OPEN errors -- should be returned. Anything else is UNKNOWN. -- Whatever the error, it must be logged. if ERROR_INDICATOR /= SUCCESSFUL then -- error 0 if (ERROR_INDICATOR = SEGMENT_DOES_NOT_EXIST) or -- error 122 (ERROR_INDICATOR = SEGMENT_IS_OPEN) then -- error 125 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(ERROR_INDICATOR,"DELETE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; end if; end if; end if; exception when GKS_ERROR => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; when OTHERS => begin GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(UNKNOWN,"DELETE_SEGMENT"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; exception when OTHERS => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; end; end DELETE_SEGMENT; procedure DELETE_SEGMENT_FROM_WS (WS : in WS_ID; SEGMENT : in SEGMENT_NAME) is -- The procedure DELETE_SEGMENT_FROM_WS checks the operating state. -- If there are no workstations open, (error #7) the procedure -- ERROR_HANDLING is called. It also checks the specified workstation -- and if it is not open, causes (error 25) the procedure -- ERROR_HANDLING to be called. Otherwise WS_MANAGER is called. -- It can detect errors 123 and 125. If either error occurs, the -- procedure ERROR_HANDLING is called. It can also detect errors 33 -- and 35 which causes the procedure ERROR_HANDLING to be called. -- -- WS - The identifier of the workstation in which the -- segment is to be deleted. -- -- SEGMENT - The identifier of the segment to be deleted from -- the workstation. GKS_INSTR : CGI_DELETE_SEGMENT_FROM_WS; ERROR_INDICATOR : ERROR_NUMBER := SUCCESSFUL; begin -- Check the GKS_ERROR_STATE_LIST to see that the ERROR_STATE -- is not ON before continuing. if GKS_ERROR_STATE_LIST.ERROR_STATE = ON then return; end if; -- The following if inquires the GKS_OPERATING_STATE_LIST to -- see if GKS is in the proper state before proceeding with the -- call to the WS_MANAGER. if (CURRENT_OPERATING_STATE = GKOP) or (CURRENT_OPERATING_STATE = GKCL) then -- The state must indicate there is an open workstation. -- Otherwise, an error exists and must be logged. -- error 7 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(NOT_WSOP_WSAC_SGOP,"DELETE_SEGMENT_FROM_WS"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; -- Check if the workstation is open. elsif not WS_IDS.IS_IN_LIST (WS, GKS_STATE_LIST.LIST_OF_OPEN_WS) then -- The indicated workstation must be open. Otherwise, -- an error exists and must be logged. GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(WS_NOT_OPEN,"DELETE_SEGMENT_FROM_WS"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; else -- Call the WS_MANAGER with the segment and workstation -- parameters. GKS_INSTR.WS_TO_DELETE_SEGMENT_FROM := WS; GKS_INSTR.SEGMENT_TO_DELETE_FROM_WS := SEGMENT; WS_MANAGER(GKS_INSTR); ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; -- Check for a successful call. if ERROR_INDICATOR /= SUCCESSFUL then -- error 0 if (ERROR_INDICATOR = SEGMENT_NOT_ON_WS) or -- error 123 (ERROR_INDICATOR = SEGMENT_IS_OPEN) then -- error 125 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(ERROR_INDICATOR,"DELETE_SEGMENT_FROM_WS"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; elsif (ERROR_INDICATOR = WS_CATEGORY_IS_MI) or -- error 33 (ERROR_INDICATOR = WS_CATEGORY_IS_INPUT) then -- error 35 GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(ERROR_INDICATOR,"DELETE_SEGMENT_FROM_WS"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; end if; end if; end if; exception when GKS_ERROR => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; when OTHERS => begin GKS_ERROR_STATE_LIST.ERROR_STATE := ON; ERROR_HANDLING(UNKNOWN,"DELETE_SEGMENT_FROM_WS"); GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; exception when OTHERS => GKS_ERROR_STATE_LIST.ERROR_STATE := OFF; raise; end; end DELETE_SEGMENT_FROM_WS; end SEGMENTS;