DacoTaco / BarcodeParserBuilder

BarcodeParserBuilder is a .Net ( standard 2.0 & 2.1 ) nuget package to help parse & build barcode strings
https://www.nuget.org/packages/BarcodeParserBuilder
GNU Lesser General Public License v2.1
11 stars 4 forks source link

Parsing Code39 barcodes. Methods to get AIM identifier and modifier #12

Closed neemevool closed 11 months ago

neemevool commented 11 months ago

Parsing Code39 barcodes. Recognizes and interprets barcode scanner AIM modifiers for Code39. AimParser introduces methods to get the AIM identifier and identifier modifier from the raw reading. Possibility to extend other barcode types by reader modifier.

About AIM identifier

AIM identifier (now actually ISO/IEC 15424:2008(E) standard) specifies a preamble message generated by the reader and interpretable by the receiving system, which indicates the bar code symbology or other origin of transmitted data, together with details of certain specified optional processing features associated with the data message.

The AIM identifer is 3 character preamble in the reading, where ] is the "flag character" and indicates to the host that it and the characters following are the symbology identifier characters. Code character is second character in the symbology identifier string, which usually indicates to the host the bar code symbology of the symbol which has been read. Modifier character(s) are one or more characters following the code character in the symbology identifier string, indicating optional features or processing applied to the symbol.

The precise interpretation of the modifier character should be obtained by reference to the relevant symbology specification. The modifier characters define the options available for the code character. The number of modifier characters and their meaning is defined for each of the code characters. The first modifier character shall be from the set {0 to 9, A to Z, a to z}; in some instances the character may represent a hexadecimal value (0 to F) corresponding to the sum of active processing options.

DacoTaco commented 11 months ago

hey, thanks for the emails/Pull Request!

generally, this is an awesome improvement that i think is very good to have! this would also improve the GS1(28) parsing, incase the FUNC1 is defined differently in the scanner.

however, i have a general question why it would be important to have the AimReaderModifier available in the barcode. once you have the barcode, this information is no longer relevant, correct?

can't we have this info be passed to the parse function of the barcodeparserbuilder, so that when its parsing it can use it to parse the barcode in a specific way and/or save it to the specific barcode ïf it's needed ?

neemevool commented 11 months ago

Hello!

Yes, I considered it to not pass the modifier but the problem is that it may be needed when using the barcode data.

This is because how real scanners work. Scanners have for each barcode type configurable modifier options and these affect the final outcome.

For example the same A – Code39. It is possible to tell the scanner just alone for that Code39 settings:

Sometimes software developer can, sometimes cannot dictate what are the scanner settings applied. So in some circumstances you must be able to strip the checksum yourself, sometimes you want to have it not passed at all.

It gets even more complex for other barcode types. So thereby I thought that this information would be needed to be passed with the reading.

From: DacoTaco @.> Sent: Sunday, November 26, 2023 12:01 PM To: DacoTaco/BarcodeParserBuilder @.> Cc: neemevool @.>; Author @.> Subject: Re: [DacoTaco/BarcodeParserBuilder] Parsing Code39 barcodes. Methods to get AIM identifier and modifier (PR #12)

hey, thanks for the emails/Pull Request!

generally, this is an awesome improvement that i think is very good to have! this would also improve the GS1(28) parsing, incase the FUNC1 is defined differently in the scanner.

however, i have a general question why it would be important to have the AimReaderModifier available in the barcode. once you have the barcode, this information is no longer relevant, correct?

can't we have this info be passed to the parse function of the barcodeparserbuilder, so that when its parsing it can use it to parse the barcode in a specific way and/or save it to the specific barcode ïf needed ?

— Reply to this email directly, view it on GitHub https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#issuecomment-1826740072 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRAIU6X6DCCS6JI7RVAM2DYGMHNXAVCNFSM6AAAAAA7Z267N2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWG42DAMBXGI . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AJRAIU5FOFCA5NP6FCX6DDLYGMHNXA5CNFSM6AAAAAA7Z267N2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTM4HLWQ.gif Message ID: @. @.> >

neemevool commented 11 months ago

Yes, I will do changes. But please view some questions below

From: DacoTaco @.> Sent: Sunday, November 26, 2023 12:26 PM To: DacoTaco/BarcodeParserBuilder @.> Cc: neemevool @.>; Author @.> Subject: Re: [DacoTaco/BarcodeParserBuilder] Parsing Code39 barcodes. Methods to get AIM identifier and modifier (PR #12)

@DacoTaco requested changes on this pull request.

overal great addition. just some comments i'd like to see changed :) ^^


In BarcodeParserBuilder/BarcodeParserBuilder.cs https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#discussion_r1405369328 :

@@ -35,6 +35,7 @@ public bool TryParse(string? barcodeString, out Barcode? barcode, out string? fe

                 //retrieve output parameter and return true
                 barcode = (Barcode?)tryParseParameters[1];

why are you setting the feedback? don't you know what parser builder parsed it based on the type of barcode youre getting back?

NEEME: yes, I can remove it. I added it to just have also human readable feedback or for consistent logging without the need to add extra processing. It just felt quite “silent” when the parser does not say anything when everything is fine but talks only when something is wrong.


In BarcodeParserBuilder/Infrastructure/AimReaderModifier.cs https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#discussion_r1405369789 :

  • .Select(f => f.GetValue(null))
  • .Cast();
  • public static IEnumerable GetAllValues() where T : AimReaderModifier =>
  • typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static)
  • .Select(f => f.GetValue(f).ToString());
  • public override bool Equals(object obj)
  • {
  • return obj is AimReaderModifier aimModifier && aimModifier.Value == this.Value;
  • }
  • public int CompareTo(object other) => Value.CompareTo(((AimReaderModifier)other).Value);
  • //public AimReaderModifier(string readerModifierValue) { Value = readerModifierValue ?? throw new ArgumentNullException(nameof(readerModifierValue)); }

commented code -> delete

NEEME: I will


In BarcodeParserBuilder/Infrastructure/AimParser.cs https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#discussion_r1405370228 :

@@ -59,6 +60,31 @@ internal static string StripBarcodePrefix(string barcodeString) return barcodeString[3..]; }

why not create a class called AimInformation and just return that info in 1 go? no need to call both functions if you always want the full information anyway

NEEME: Yes, I can do it.


In BarcodeParserBuilder/Barcodes/CODE39/Code39Barcode.cs https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#discussion_r1405370641 :

  • get => throw new UnusedFieldException(nameof(SerialNumber));
  • set => throw new UnusedFieldException(nameof(SerialNumber));
  • }
  • public static Code39ReaderModifier ParseReaderModifier(string readerModifierValue)
  • {
  • if (Code39ReaderModifier.GetAllValues().Contains(readerModifierValue))
  • {
  • return new Code39ReaderModifier(readerModifierValue);
  • }
  • throw new Code39ParseException("Invalid reader modifier");
  • }
  • public static string StripCheckCharacter(string inputString, Code39ReaderModifier readerModifier)

what is the use of this?

NEEME: you mean the purpose of StripCheckCharacter? The scanner can be set to pass the check character or not to pass it. And sometimes you just cannot say to the customer how they must configure the scanner. This method encapsulates the logic when you want to safely remove the check character, but without knowing whether the scanner passed it or not. Or how it is calculated etc.

— Reply to this email directly, view it on GitHub https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#pullrequestreview-1749316875 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRAIU2DUSETSUPAO5LF5CLYGMKKTAVCNFSM6AAAAAA7Z267N2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTONBZGMYTMOBXGU . You are receiving this because you authored the thread.Message ID: @.***>

DacoTaco commented 11 months ago

ye, that looks better already. i am going to go through it somewhere this week. i might request some more minor changes or do them after this (because GS128 can use the aim information too).

i assume you need the aim information in your application? do you need the product code with, or without the check character?

neemevool commented 11 months ago

You mean to change GS128 to support AIM modifier like following?

]C0 Code128 Standard. No FNC1 in first or second symbol character position after start character.

]C1 Code128 Function code 1 in first character position or GS1 Databar Expanded

]C2 Code128 Function code 2 in second character position. Concatenation according to ISBT

]C4 Code128 Concatenation according to ISBT (International Society for Blood Transfusion)

I can add the support to parse these and submit another pull request. But I can add real barcode parsing support difference for C1 and C0, but C2 and C4 should be also looked into.

I need urgently support for C0 and C1, because it is currently a showstopper if C0 barcodes cannot be parsed.

From: DacoTaco @.> Sent: Monday, November 27, 2023 9:26 PM To: DacoTaco/BarcodeParserBuilder @.> Cc: neemevool @.>; Author @.> Subject: Re: [DacoTaco/BarcodeParserBuilder] Parsing Code39 barcodes. Methods to get AIM identifier and modifier (PR #12)

ye, that looks better already. i am going to go through it already somewhere this week. i might request some more minor changes or do them after this (because GS128 can use the aim information too).

— Reply to this email directly, view it on GitHub https://github.com/DacoTaco/BarcodeParserBuilder/pull/12#issuecomment-1828472900 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRAIU7LOU37EEN6Q7UZ2JTYGTSLLAVCNFSM6AAAAAA7Z267N2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRYGQ3TEOJQGA . You are receiving this because you authored the thread.Message ID: @.***>

DacoTaco commented 11 months ago

yes, i think GS1/GS128 needs to have the aim information as well, as it will need it to parse the barcode correctly, as it now only supports ]C1 :)

if adding this will help you in your application, feel free to add it! the code looks good so far :)

DacoTaco commented 11 months ago

@neemevool : sorry for the wait, i expected the other change to follow! ill merge it :)