Compile function OBJ_GAN_CYCLE_TIME(Method, Parms)

/*
	Methods for GAN_CYCLE_TIME table
    
	08/25/2020 JRO - Initial Coding
     
    Properties:
     
    Methods:
    
    Create(DataStruct)		;* Create new record
	
	
*/


DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, NextKey,  obj_Prod_Spec, Send_Dyn
DECLARE FUNCTION obj_RDS_Test, Environment_Services, Logging_Services
DECLARE SUBROUTINE  Set_Status, Msg, obj_Tables, Send_Dyn, obj_WO_Step, obj_RDS_Layer, obj_RDS_Test, obj_WM_In,obj_WO_Mat
DECLARE SUBROUTINE ErrMsg, Logging_Services

$INSERT MSG_EQUATES
$INSERT DICT_EQUATES
$Insert REACT_RUN_EQUATES
$Insert RUN_STAGE_WFR_EQUATES
$Insert GAN_CYCLE_TIME_EQUATES
$Insert WO_LOG_EQUATES
$Insert PROD_VER_EQUATES
$Insert WO_WFR_EQUATES

ErrTitle = 'Error in Stored Procedure "obj_gan_cycle_time"'
ErrorMsg = ''

LogPath     = Environment_Services('GetApplicationRootPath') : '\LogFiles\GAN_CYCLE_TIME'
LogDate     = Oconv(Date(), 'D4/')
LogTime     = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' GAN_CYCLE_TIME.csv'
Headers     = 'Logging DTM' : @FM : 'User' : @FM : 'Notes'
objLog      = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$)
LoggingDTM  = LogDate : ' ' : LogTime   ; // Logging DTM 

IF NOT(ASSIGNED(Method))	THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms))		THEN Parms = ''

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
		
	CASE 1
		
		
END CASE

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
END

RETURN Result



* * * * * * *
Create:
* * * * * * *
	LogData       = ''
	LogData<1>    = '*** Form Contents ***'
	LogData<2, 1> = LoggingDTM
	LogData<2, 2> = @User4
	LogData<3>    = 'Writing GAN_CYCLE_TIME record from OBJ_GAN_CYCLE_TIME' : @ID
	Logging_Services('AppendLog', objLog, LogData, @FM, @VM)
	RecKey = Parms[1,@RM]
	Record = Parms[COL2()+1,@RM]
	
	Swap '*' with @VM in RecKey
	RDSNo = RecKey<1,1>
	WaferNo = RecKey<1,3>
	
	ReactRunRec = Xlate('REACT_RUN',RDSNo, '', 'X')
	WO_NO = ReactRunRec<REACT_RUN_WO_NO$>
	RunID = ReactRunRec<REACT_RUN_GAN_RUN_ID$>
	ReactorNo = 'R':RunID[1,2]
	PartNo = XLATE('WO_LOG', WO_NO,WO_LOG_WAFER_TRACK_PART$,'X')
	ProdVerNo = XLATE('WO_LOG', WO_NO, WO_LOG_PROD_VER_NO$,'X')
	PSNo = Xlate('PROD_VER',ProdVerNo,PROD_VER_PROC_STEP_PSN$,'X')
	WfrStg = RecKey<1,2>
	ToolClass = Record<RUN_STAGE_WFR_SPEC_TOOL_CLASS$>
	Tool = Record<RUN_STAGE_WFR_TOOL_ID$>
	StartDTM = Record<RUN_STAGE_WFR_SIA_COMP_DTM$, 1>
	StopDTM = Record<RUN_STAGE_WFR_SIA_COMP_DTM$, 2>
	OperatorStart = Record<RUN_STAGE_WFR_SIA_COMP_BY$, 1>
	OperatorStop =  Record<RUN_STAGE_WFR_SIA_COMP_BY$, 2>
	IF WfrStg EQ 'UV' OR WfrStg EQ 'WARP' OR WfrStg EQ 'CAN' OR WfrStg EQ 'CAN_PRE' OR WfrStg EQ 'CAN_PST' then
		WfrScribe = ''
	end else
		WOWfrKey = WaferNo
		Swap '.' with '*' in WOWfrKey
		WfrScribe = XLATE('WO_WFR', WOWfrKey, 26, 'X')
	end
	IF WfrStg EQ 'EPI_DEPOSITION' then
		Recipe = ReactRunRec<103>
	end else
		Recipe = ''
	end
	
	IF Record<RUN_STAGE_WFR_SIA_COMP_DTM$, 2> EQ '' then
		RETURN Result
	end
	
	RecToWrite = ''
	RecToWrite<GAN_CYCLE_TIME_WO_NO$> =            WO_NO
	RecToWrite<GAN_CYCLE_TIME_RUN_ID$> =           RunID
	RecToWrite<GAN_CYCLE_TIME_RDS_No$> =           RDSNo
	RecToWrite<GAN_CYCLE_TIME_RECIPE$> =           Recipe
	RecToWrite<GAN_CYCLE_TIME_Part_NO$> =          PartNo
	RecToWrite<GAN_CYCLE_TIME_PSN_NO$> =           PSNo
	RecToWrite<GAN_CYCLE_TIME_STAGE_NAME$> =       WfrStg
	RecToWrite<GAN_CYCLE_TIME_TOOL_CLASS$> =       ToolClass
	RecToWrite<GAN_CYCLE_TIME_TOOL$> =             Tool
	RecToWrite<GAN_CYCLE_TIME_START_DTM$> =        StartDTM
	RecToWrite<GAN_CYCLE_TIME_STOP_DTM$> =         StopDTM
	RecToWrite<GAN_CYCLE_TIME_OPERATOR_START$> =   OperatorStart
	RecToWrite<GAN_CYCLE_TIME_OPERATOR_STOP$> =    OperatorStop
	RecToWrite<GAN_CYCLE_TIME_WFR_SCRIBE$> = WfrScribe
	RecToWrite<GAN_CYCLE_TIME_REACTOR$> = ReactorNo
	NewRecKey = RDSNo : '-' : WfrStg: '-' : Record<RUN_STAGE_WFR_SIA_COMP_DTM$, 2>
	
	Obj_Tables('WriteRec', 'GAN_CYCLE_TIME':@RM:NewRecKey:@RM:@RM:RecToWrite)
	
RETURN Result

