Updated CreateLotEvent to use Transaction Queue instead of Proc Queue to avoid locking errors.

This commit is contained in:
Infineon\StieberD
2025-07-01 10:41:54 -07:00
parent ff0036d4c2
commit b796060529

View File

@ -1,16 +1,64 @@
Compile function Lot_Event_Services(@Service, @Params) Compile function Lot_Event_Services(@Service, @Params)
/***********************************************************************************************************************
Name : Lot_Event_Services
Description : Handler program for all LOT_EVENT services.
Notes : Application errors should be logged using the Error Services module. There are a few methodological
assumptions built into way errors are managed which are important to understand in order to properly
work with Error Services:
- The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to
the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger
this will appear backwards since the originating procedure always appears at the bottom of the
list and the current routine appears at the top of the list. We are using this orientation because
it is common to refer to the process of calling other procedures as 'drilling down'.
- The reason for defining the orientation of the call stack is because Error_Services allows for
multiple error conditions to be appended to an original error. In most cases this will happen when
a procedure at the bottom of the stack generates an error condition and then returns to its
calling procedure. This higher level procedure can optionally add more information relevant to
itself. This continues as the call stack 'bubbles' its way back to the top to where the
originating procedure is waiting.
- Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus)
preserve their error state until explicitly cleared. This can hinder the normal execution of code
since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists.
Our philosophy is that error conditions should automatically be cleared before a new procedure
is executed to avoid this problem. However, the nature of Basic+ does not make this easy to
automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our
philosophy then it should include a call into the 'Clear' service request at the top of the
program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.)
- Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any
error conditions that were set before.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
Metadata :
History : (Date, Initials, Notes)
07/01/25 djs Modified CreateLotEvent to use Transaction Queue instead of Proc Queue to avoid locking
errors on LOT table. Updated error throwing.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler #pragma precomp SRP_PreCompiler
Declare function Error_Services, Logging_Services, Environment_Services, Database_Services, RTI_CreateGUID, Lot_Services $Insert SERVICE_SETUP
Declare function Lot_Event_Services $insert APP_INSERTS
Declare subroutine Error_Services, Logging_Services, Database_Services, Lot_Services, Service_Services
$insert LOGICAL
$Insert LOT_EVENT_EQUATES $Insert LOT_EVENT_EQUATES
$Insert LOT_EQUATES $Insert LOT_EQUATES
$Insert LOT_OPERATION_EQUATES $Insert LOT_OPERATION_EQUATES
Declare function Error_Services, Logging_Services, Environment_Services, Database_Services, RTI_CreateGUID
Declare function Lot_Event_Services, Lot_Services
Declare subroutine Error_Services, Logging_Services, Database_Services, Lot_Services, Service_Services
Declare subroutine Transaction_Services
Options EVENT_TYPES = 'MOVE_IN', 'MOVE_OUT', 'HOLD_ON', 'HOLD_OFF', 'REDUCE_WAFER_QTY', 'BONUS_WAFER_QTY', 'COMMENT', 'LOCATION', 'LOAD', 'UNSIGN_LOAD', 'TW_USE', 'CLOSE', 'SIGN_FQA', 'UNSIGN_FQA' Options EVENT_TYPES = 'MOVE_IN', 'MOVE_OUT', 'HOLD_ON', 'HOLD_OFF', 'REDUCE_WAFER_QTY', 'BONUS_WAFER_QTY', 'COMMENT', 'LOCATION', 'LOAD', 'UNSIGN_LOAD', 'TW_USE', 'CLOSE', 'SIGN_FQA', 'UNSIGN_FQA'
Options LOT_TYPES = 'TW', 'RDS', 'WM_OUT', 'WM_IN', 'WO_MAT', 'LOT' Options LOT_TYPES = 'TW', 'RDS', 'WM_OUT', 'WM_IN', 'WO_MAT', 'LOT'
Options LEGACY_LOT_TYPES = 'RDS', 'WM_OUT', 'WM_IN' Options LEGACY_LOT_TYPES = 'RDS', 'WM_OUT', 'WM_IN'
@ -20,152 +68,165 @@ GoToService
Return Response or "" Return Response or ""
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// SERVICES // Services
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
Service CreateLotEvent(LotId, EventDateTime, EventType=EVENT_TYPES, EventNote, EventEquipmentId, OperatorId, IsLegacyLotId=BOOLEAN, LegacyLotType=LEGACY_LOT_TYPES) Service CreateLotEvent(LotId, EventDateTime, EventType=EVENT_TYPES, EventNote, EventEquipmentId, OperatorId, IsLegacyLotId=BOOLEAN, LegacyLotType=LEGACY_LOT_TYPES)
GoSub InitEventLog GoSub InitEventLog
ErrorMessage = '' ErrorMessage = ''
//Handle Legacy Lots // Handle Legacy Lots
If IsLegacyLotId then If IsLegacyLotId then
If LegacyLotType NE '' then If LegacyLotType NE '' then
LegacyLotId = LotId LegacyLotId = LotId
LotId = Lot_Services('GetLotIdByLegacyLotIdAndType', LotId, LegacyLotType) LotId = Lot_Services('GetLotIdByLegacyLotIdAndType', LotId, LegacyLotType)
If LotID EQ '' then If LotID EQ '' then
LotId = Lot_Services('CreateNewLot', LegacyLotType, '', '', '', '', '', OperatorId, '', LegacyLotId) LotId = Lot_Services('CreateNewLot', LegacyLotType, '', '', '', '', '', OperatorId, '', LegacyLotId)
end end
end else end else
LotId = '' LotId = ''
end end
end end
If RowExists('LOT', LotId) then If RowExists('LOT', LotId) then
NewEventId = RTI_CreateGUID() NewEventId = RTI_CreateGUID()
If NewEventId NE '' then If NewEventId NE '' then
NewEventSequence = Lot_Event_Services('GetLotEventNextSequence', LotId) NewEventSequence = Lot_Event_Services('GetLotEventNextSequence', LotId)
If Error_Services('NoError') then If Error_Services('NoError') then
NewEventRec = '' NewEventRec = ''
NewEventRec<LOT_EVENT_LOT_ID$> = LotId NewEventRec<LOT_EVENT_LOT_ID$> = LotId
NewEventRec<LOT_EVENT_LOT_EVENT_TYPE$> = EventType NewEventRec<LOT_EVENT_LOT_EVENT_TYPE$> = EventType
NewEventRec<LOT_EVENT_EVENT_DATETIME$> = EventDatetime NewEventRec<LOT_EVENT_EVENT_DATETIME$> = EventDatetime
NewEventRec<LOT_EVENT_EVENT_NOTE$> = EventNote NewEventRec<LOT_EVENT_EVENT_NOTE$> = EventNote
NewEventRec<LOT_EVENT_EQUIPMENT_ID$> = EventEquipmentId NewEventRec<LOT_EVENT_EQUIPMENT_ID$> = EventEquipmentId
NewEventRec<LOT_EVENT_EVENT_OPERATOR_ID$> = OperatorId NewEventRec<LOT_EVENT_EVENT_OPERATOR_ID$> = OperatorId
NewEventRec<LOT_EVENT_SEQUENCE$> = NewEventSequence NewEventRec<LOT_EVENT_SEQUENCE$> = NewEventSequence
Database_Services('WriteDataRow', 'LOT_EVENT', NewEventId, NewEventRec) Database_Services('WriteDataRow', 'LOT_EVENT', NewEventId, NewEventRec)
If Error_Services('NoError') then If Error_Services('NoError') then
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', 'SetLatestLotEvent':@VM:LotId:@VM:NewEventId) Transaction_Services('PostWriteFieldTransaction', 'LOT', LotId, LOT_MOST_RECENT_LOT_EVENT_ID$, NewEventId)
end else If Error_Services('HasError') then ErrorMessage = Error_Services('GetMessage')
ErrorMessage = 'Error creating new event : ' : Error_Services('GetMessage') end else
end ErrorMessage = 'Error creating new event : ' : Error_Services('GetMessage')
end else end
ErrorMessage = Error_Services('GetMessage') end else
end ErrorMessage = Error_Services('GetMessage')
end else end
ErrorMessage = 'Error creating an event Id.' end else
end ErrorMessage = 'Error creating an event Id.'
end else end
ErrorMessage = 'Error in Create Lot Event routine, Lot id was not found.' end else
end ErrorMessage = 'Error in Create Lot Event routine, Lot id was not found.'
If ErrorMessage EQ '' then end
LogData = '' If ErrorMessage EQ '' then
LogData<1> = LoggingDTM LogData = ''
LogData<2> = LotId LogData<1> = LoggingDTM
LogData<3> = EventType LogData<2> = LotId
LogData<4> = OperatorId LogData<3> = EventType
LogData<9> = 'Successfully logged event.' LogData<4> = OperatorId
Logging_Services('AppendLog', objLotEventLog, LogData, @RM, @FM, False$) LogData<9> = 'Successfully logged event.'
end else Logging_Services('AppendLog', objLotEventLog, LogData, @RM, @FM, False$)
LogData = '' end else
LogData<1> = LoggingDTM LogData = ''
LogData<2> = LotId LogData<1> = LoggingDTM
LogData<3> = EventType LogData<2> = LotId
LogData<4> = OperatorId LogData<3> = EventType
LogData<9> = ErrorMessage LogData<4> = OperatorId
Logging_Services('AppendLog', objLotEventLog, LogData, @RM, @FM, False$) LogData<9> = ErrorMessage
Error_Services('Add', ErrorMessage) Logging_Services('AppendLog', objLotEventLog, LogData, @RM, @FM, False$)
end Error_Services('Add', ErrorMessage)
end
end service end service
Service GetLotEventNextSequence(LotId) Service GetLotEventNextSequence(LotId)
ErrorMessage = '' ErrorMessage = ''
NextSequence = 1 NextSequence = 1
If LotID NE '' then If LotID NE '' then
If RowExists('LOT', LotId) then If RowExists('LOT', LotId) then
LotEvents = XLATE('LOT', LotId, LOT_LOT_EVENTS$, 'X') LotEvents = XLATE('LOT', LotId, LOT_LOT_EVENTS$, 'X')
for each LotEvent in LotEvents using @VM for each LotEvent in LotEvents using @VM
ThisEventSequence = XLATE('LOT_EVENT', LotEvent, LOT_EVENT_SEQUENCE$, 'X') ThisEventSequence = XLATE('LOT_EVENT', LotEvent, LOT_EVENT_SEQUENCE$, 'X')
If ThisEventSequence GE NextSequence then NextSequence = ThisEventSequence + 1 If ThisEventSequence GE NextSequence then NextSequence = ThisEventSequence + 1
Next LotEvent Next LotEvent
end else end else
ErrorMessage = 'Unable to get lot event sequence: Lot ID not found.' ErrorMessage = 'Unable to get lot event sequence: Lot ID not found.'
end end
end else end else
ErrorMessage = 'Unable to get lot event sequence: Lot ID was null.' ErrorMessage = 'Unable to get lot event sequence: Lot ID was null.'
end end
If ErrorMessage EQ '' then If ErrorMessage EQ '' then
Response = NextSequence Response = NextSequence
end else end else
Error_Services('Add', ErrorMessage) Error_Services('Add', ErrorMessage)
end end
end service end service
//Returns a @FM delimited list of events in sequence
// Returns a @FM delimited list of events in sequence
Service GetLotEventsInSequence(LotId) Service GetLotEventsInSequence(LotId)
LotEventsUnsorted = ''
LotEventsSorted = '' ErrorMsg = ''
LotEventsToReturn = '' LotEventsUnsorted = ''
If LotID NE '' then LotEventsSorted = ''
//Get Operations LotEventsToReturn = ''
LotEvents = Xlate('LOT', LotId, LOT_LOT_EVENTS$, 'X') If LotID NE '' then
for each LotEvent in LotEvents using @VM // Get Operations
ThisEventSequence = XLATE('LOT_EVENT', LotEvent, LOT_EVENT_SEQUENCE$, 'X') LotEvents = Xlate('LOT', LotId, LOT_LOT_EVENTS$, 'X')
LotEventsToReturn<ThisEventSequence> = LotEvent for each LotEvent in LotEvents using @VM
Next LotOperation ThisEventSequence = XLATE('LOT_EVENT', LotEvent, LOT_EVENT_SEQUENCE$, 'X')
end else LotEventsToReturn<ThisEventSequence> = LotEvent
//error: lot id was null Next LotOperation
end end else
Response = LotEventsToReturn ErrorMsg = 'Error in ':Service:' service. Null LotID passed into service.'
end
If ErrorMsg EQ '' then
Response = LotEventsToReturn
end else
Error_Services('Add', ErrorMsg)
end
end service end service
Service SetLatestLotEvent(LotId, LotEventId) Service SetLatestLotEvent(LotId, LotEventId)
ErrorMessage = '' ErrorMessage = ''
If RowExists('LOT', LotId) then If RowExists('LOT', LotId) then
If RowExists('LOT_EVENT', LotEventId) then If RowExists('LOT_EVENT', LotEventId) then
LotRec = Database_Services('ReadDataRow', 'LOT', LotId, True$, 0, False$) LotRec = Database_Services('ReadDataRow', 'LOT', LotId, True$, 0, False$)
LotRec<LOT_MOST_RECENT_LOT_EVENT_ID$> = LotEventId LotRec<LOT_MOST_RECENT_LOT_EVENT_ID$> = LotEventId
Database_Services('WriteDataRow', 'LOT', LotId, LotRec) Database_Services('WriteDataRow', 'LOT', LotId, LotRec)
If Error_Services('HasError') then If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage') ErrorMessage = Error_Services('GetMessage')
end end
end else end else
ErrorMessage = 'Lot event ' : LotEventId : ' for lot ' : LotId : ' not found in LOT_EVENT table' ErrorMessage = 'Lot event ' : LotEventId : ' for lot ' : LotId : ' not found in LOT_EVENT table'
end end
end else end else
ErrorMessage = 'Lot Id ' : LotId : ' not found in LOT table.' ErrorMessage = 'Lot Id ' : LotId : ' not found in LOT table.'
end end
If ErrorMessage NE '' then If ErrorMessage NE '' then Error_Services('Add', ErrorMessage)
Error_Services('Add', ErrorMessage)
end
end service end service
/* * * * * * * * * *
* INTERNAL GOSUBS //----------------------------------------------------------------------------------------------------------------------
* * * * * * * * * */ // Internal GoSubs
//----------------------------------------------------------------------------------------------------------------------
InitEventLog: InitEventLog:
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Lot' LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Lot'
LogDate = Oconv(Date(), 'D4/') LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS') LogTime = Oconv(Time(), 'MTS')
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' LotEvent.csv' LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' LotEvent.csv'
Headers = 'Logging DTM' : @FM : 'Lot Id' : @FM : 'Event Type' : @FM : 'Operator' : @FM : 'Begin Wafer Qty' : @FM : 'End Wafer Qty' : @FM : 'Bonus Wafer Qty' : @FM : 'Reduce Wafer Qty' : @FM : 'Message' Headers = 'Logging DTM' : @FM : 'Lot Id' : @FM : 'Event Type' : @FM : 'Operator' : @FM : 'Begin Wafer Qty' : @FM : 'End Wafer Qty' : @FM : 'Bonus Wafer Qty' : @FM : 'Reduce Wafer Qty' : @FM : 'Message'
objLotEventLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$) objLotEventLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
return return