So we're slowly updating our barcodes over the next couple of months to a different manufacturer, who inconveniently uses a very different decoded format.See example image. With the first row being our current format, and the second and third being the updated. We will need to be able to read all 3. This is our current decoding SCL script: Example
TYPE UDT_Decoded_Bearing:STRUCTCompany_ID : byte;Component_ID : STRING[10];Mfg_Year : byte;Mfg_Month : byte;Serial : STRING[8];END_STRUCTEND_TYPEDATA_BLOCK DecodedBearingSTRUCTdataUDT: UDT_Decoded_Bearing;Element: STRING[20];Data: String[20];END_STRUCTBEGINEND_DATA_BLOCKFUNCTION FC_Decode_Bearing : WORDVAR_INPUTRaw_Barcode: ARRAY[1..512] OF CHAR;END_VARVAR_OUTPUTDecodedData: UDT_Decoded_Bearing;END_VARVAR_TEMPi: INT;iStartChar: INT;iEndChar: INT;iFoundChar: INT;// Element: STRING[20];// Data: STRING[20];Source: ARRAY[1..512] OF CHAR;END_VARSource:= Raw_Barcode;iStartChar:= 3; // skip over the initial open tagDecodedBearing.Element:= '';DecodedBearing.Data:= '';DecodedData.Company_ID := 0;DecodedData.Component_ID := '';DecodedData.Mfg_Year := 0;DecodedData.Mfg_Month := 0;DecodedData.Serial := '';FOR i:= 0 TO 20 DOiStartChar:= FIND_CHAR(IN1:= Source, START_CHAR:= iStartChar, SEARCH_CHAR:= '<') + 1; //Finding Start of opening TagiFoundChar:= FIND_CHAR(IN1:= Source, START_CHAR:= iStartChar, SEARCH_CHAR:= '>'); //Finding End of opening TagDecodedBearing.Element:= CHAR_TO_STR (IN1:= Source, START_CHAR:= iStartChar, Length := iFoundChar - iStartChar); //reading opening tagiFoundChar:= FIND_CHAR(IN1:= Source, START_CHAR:= iStartChar, SEARCH_CHAR:= '<'); //Finding Start of closing tagiStartChar:= iStartChar + 1;DecodedBearing.Data:= CHAR_TO_STR (IN1 := Source, START_CHAR := iStartChar, Length := iFoundChar - iStartChar); //reading tag dataiStartChar:= iStartChar + 1;IF DecodedBearing.Element = 'companyCode' THENIF DecodedBearing.Data = '8AMS' THEN // Brenco - To Be TestedDecodedData.Company_ID := 1;ELSIF DecodedBearing.Data = '8FAS' THEN // FAG - To Be TestedDecodedData.Company_ID := 2;ELSIF DecodedBearing.Data = 'KOYO' THEN // Guess!!!DecodedData.Company_ID := 3;ELSIF DecodedBearing.Data = '8SKF' THEN // To Be TestedDecodedData.Company_ID := 4;ELSIF DecodedBearing.Data = '8TIM' THEN // Proven Working - 2D BarcodeDecodedData.Company_ID := 5;ELSIF DecodedBearing.Data = '8NTN' THEN // Guess - Added 20160410 JCPDecodedData.Company_ID := 6;END_IF;ELSIF DecodedBearing.Element = 'idNumber' THENDecodedData.Component_ID := DecodedBearing.Data;ELSIF DecodedBearing.Element = 'C205' THENDecodedData.Serial := DecodedBearing.Data;ELSIF DecodedBearing.Element = 'C206' THENDecodedData.Mfg_Year := INT_TO_BYTE(STRNG_I(DecodedBearing.Data));ELSIF DecodedBearing.Element = 'C207' THENDecodedData.Mfg_Month := INT_TO_BYTE(STRNG_I(DecodedBearing.Data));END_IF;END_FOR;//END_WHILE;FC_Decode_Bearing:= 0;END_FUNCTION
I'm a bit stuck getting it to read one between the brackets and another outside of them and to be able to get the same data from them. The 8th, 9th and 10th section in the 3rd example will need to be added in as variables, as they are the refurbed month and year. Any assistance with any of this is highly appreciated. Thanks!
Follow us on