open-insight/LSL2/STPROC/LABELING_SERVICES.txt
2024-12-13 02:23:42 +01:00

177 lines
7.9 KiB
Plaintext

Compile function Labeling_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
Declare Function Database_Services, Environment_Services, Set_Printer, Direct_Print, Printer_Select, Error_Services
Declare Function Logging_Services, Datetime
Declare subroutine Error_Services, Labeling_Services, Lot_Services
$insert LOGICAL
$Insert LOT_EQUATES
$Insert TEST_WAFER_PROD_EQUATES
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\LabelPrinting'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' TestWaferLabelPrinting.csv'
Headers = 'Logging DTM' : @FM : 'Lot Id' : @FM : 'Username' : @FM : 'PrinterID' : @FM : 'Message'
objTWLabelPrinting = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
GoToService
Return Response or ""
//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------
Service PrintLabel(ZPLString, PrinterId)
SuccessfulPrint = False$
ErrorMessage = ''
If PrinterId EQ '' then
PrinterId = Printer_Select(PrinterID)
end
If PrinterID NE '' then
stat = Direct_Print('START', PrinterId, '', '')
If Stat GE 0 then
stat = Direct_Print('PRINT', ZPLString)
If Stat GE 0 then
stat = Direct_Print('STOP')
end
end
If Stat LT 0 then
Begin Case
Case Stat EQ -1
ErrorMessage = "A subsequent START message was sent prior to a previous report's STOP message was invoked."
Case Stat EQ -2
ErrorMessage = 'Unable to initialize printer. The printer name may be incorrect or the printer is not avaible'
Case Stat EQ -3 OR Stat EQ -4
ErrorMessage = 'Problems starting the report.'
Case Stat EQ -5 OR Stat EQ -6
ErrorMessage = 'Problems stopping the report.'
Case Stat EQ -7
ErrorMessage = 'Error with printing data - fatal error sending data to the printer.'
Case Stat EQ -8
ErrorMessage = 'Error with printing data - wrong number of bytes sent to the printer.'
Case Stat EQ -9 OR Stat EQ -10
ErrorMessage = 'Error occurred sending the PAGE message'
Case Stat EQ -11
ErrorMessage = 'Problems aborting the report.'
Case Stat EQ -12
ErrorMessage = 'The Direct_Print function was called prior to the START message being invoked.'
End Case
end
end
If ErrorMessage NE '' then
Error_Services('Add', ErrorMessage)
end
end service
Service PrintTestWaferLotLabel(LotId, Username, PrinterId)
ErrorMessage = ''
If Username EQ '' then
Username = @User4
If Username EQ '' then Username = @USERNAME
end
If RowExists('LOT', LotId) then
ZPLStringLabel = ''
LotRec = Database_Services('ReadDataRow', 'LOT', LotId)
PartNoId = LotRec<LOT_PROD_ID$>
PartNo = Xlate('TEST_WAFER_PROD', PartNoId, TEST_WAFER_PROD_PART_NAME$, 'X')
VendorPartNo = LotRec<LOT_VENDOR_PART_NO$>
VendorLotNo = LotRec<LOT_VENDOR_LOT_NO$>
VendorCode = LotRec<LOT_VENDOR_CODE$>
LotQty = LotRec<LOT_WAFER_QTY$>
For LabelCnt = 1 to 2
ZPLStringLabel := '^XA'
ZPLStringLabel := '^LH0,0'
ZPLStringLabel := '^PR1'
ZPLStringLabel := '^LL406'
ZPLStringLabel := '^PW900'
ZPLStringLabel := '^MD22'
ZPLStringLabel := '^MMT'
ZPLStringLabel := '^FO25,25^A045,70,40^FD(1T)Lot Number: ^FS^FX(Lot Number Title)^FS'
ZPLStringLabel := '^FO320,25^A045,70,40^FD':LotId:'^FS^FX(Lot Number Text)^FS'
ZPLStringLabel := '^FO25,200^A070,40^FD':PartNo:'^FS^FX(Part Number Text)^FS'
ZPLStringLabel := '^FO60,300^BY7^B3,,50,N^FD1T':LotId:'^FS^FX(Lot Number 1D Barcode)^FS'
ZPLStringLabel := "^FO25,370^A045,28^FDWe do what we promise. That's quality made by Infineon.^FS^FX(Infineon Quality Statement)^FS"
ZPLStringLabel := '^FO500,105^CI28'
ZPLStringLabel := '^BXN,5,200^FDP':PartNo:'|S':VendorPartNo:'|1T':LotId:'|2T':VendorLotNo:'|(PSN)|Q':LotQty:'|1V':VendorCode:'|SEQ':LabelCnt:'^FS^FX(2DBarcode)^FS'
ZPLStringLabel := '^XZ'
Next LabelCnt
If ZPLStringLabel NE '' then
Labeling_Services('PrintLabel', ZPLStringLabel, PrinterId)
If Error_Services('NoError') then
//Log Event for lot.
end else
//Log Error for lot
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = 'Error printing label for lot ' : LotId : '. LotId was null or did not exist in database.'
end
If ErrorMessage EQ '' then
Lot_Services('CreateLotEvent', LotId, 'TW', Datetime(), 'COMMENT', 'Lot Labels Printed', '', 0, 0, '', Username)
end else
Error_Services('Add', ErrorMessage)
end
End Service
Service GetTestWaferLotZPL(LotId, Username)
ZPLStringLabel = ''
LotRec = Database_Services('ReadDataRow', 'LOT', LotId)
PartNoId = LotRec<LOT_PROD_ID$>
PartNo = Xlate('TEST_WAFER_PROD', PartNoId, TEST_WAFER_PROD_PART_NAME$, 'X')
VendorPartNo = LotRec<LOT_VENDOR_PART_NO$>
VendorLotNo = LotRec<LOT_VENDOR_LOT_NO$>
VendorCode = LotRec<LOT_VENDOR_CODE$>
LotQty = LotRec<LOT_WAFER_QTY$>
For LabelCnt = 1 to 2
ZPLStringLabel := '^XA'
ZPLStringLabel := '^LH0,0'
ZPLStringLabel := '^PR1'
ZPLStringLabel := '^LL406'
ZPLStringLabel := '^PW900'
ZPLStringLabel := '^MD22'
ZPLStringLabel := '^MMT'
ZPLStringLabel := '^FO25,25^A045,70,40^FD(1T)Lot Number: ^FS^FX(Lot Number Title)^FS'
ZPLStringLabel := '^FO320,25^A045,70,40^FD':LotId:'^FS^FX(Lot Number Text)^FS'
ZPLStringLabel := '^FO25,175^A070,75^FD':PartNo:'^FS^FX(Part Number Text)^FS'
ZPLStringLabel := '^FO60,300^BY2^B3,,50,N^FD1T':LotId:'^FS^FX(Lot Number 1D Barcode)^FS'
ZPLStringLabel := "^FO25,370^A045,28^FDWe do what we promise. That's quality made by Infineon.^FS^FX(Infineon Quality Statement)^FS"
ZPLStringLabel := '^FO500,105^CI28'
ZPLStringLabel := '^XZ'
Next LabelCnt
Response = ZPLStringLabel
end service
Service GetAllZebraPrinters()
Server = Environment_Services('GetServer')
ZebraPrinterList = ''
ZebraPrinterList<1> = 'MESZBRPRT002' : @VM : '10.95.30.247' : @VM : 9100
ZebraPrinterList<2> = 'MESZBRPRT003' : @VM : '10.95.1.27' : @VM : 9100
ZebraPrinterList<3> = 'MESZBRPRT004' : @VM : '10.95.15.252' : @VM : 9100
ZebraPrinterList<4> = 'MESZBRPRT005' : @VM : '10.95.30.42' : @VM : 9100
ZebraPrinterList<5> = 'MESZBRPRT006' : @VM : '10.95.25.25' : @VM : 9100
ZebraPrinterList<6> = 'MESZBRPRT007' : @VM : '10.95.1.13' : @VM : 9100
ZebraPrinterList<7> = 'MESZBRPRT008' : @VM : '10.95.164.24' : @VM : 9100
ZebraPrinterList<8> = 'MESZBRPRT0011' : @VM : '10.95.13.33' : @VM : 9100
ZebraPrinterList<9> = 'FI_ZEBRA_PRINTER' : @VM : '10.95.164.55' : @VM : 9100
If Server EQ 'MESTSA01EC' OR Server EQ 'MESSA01EC' then
ZebraPrinterList<10> = 'JONATHAN_HOME_TEST' : @VM : '192.168.0.123' : @VM : 9100
end
Response = ZebraPrinterList
end service