Gerber UUID parameter calculation: refinements and more comments

This commit is contained in:
jean-pierre charras 2018-10-29 18:56:26 +01:00
parent c05ca469ae
commit 654dbbb44b
1 changed files with 11 additions and 8 deletions

View File

@ -278,9 +278,11 @@ static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMo
/** A helper function to build a project GUID using format RFC4122 Version 1 or 4
* from the project name, because a kicad project has no specific GUID
* RFC4122 is used only for its synthax, because fields have no meaning for Gerber files
* RFC4122 is used mainly for its syntax, because fields have no meaning for Gerber files
* and therefore the GUID generated has no meaning because it do not use any time and time stamp
* specific to the project.
* specific to the project, just a random pattern (random is here a pattern specific to a project).
*
* See en.wikipedia.org/wiki/Universally_unique_identifier
*/
static wxString makeProjectGUIDfromString( wxString& aText )
{
@ -289,9 +291,10 @@ static wxString makeProjectGUIDfromString( wxString& aText )
// with
// x = hexDigit lower/upper case
// and
// M = '1' or '4' (UID versiom 1 or 4) (we use 1)
// M = '1' or '4' (UUID version: 1 (basic) or 4 (random)) (we use 4: UUID random)
// and
// N = '8' or '9' or 'A|a' or 'B|b' (RFC4122 tag) (we use 9)
// N = '8' or '9' or 'A|a' or 'B|b' : UUID variant 1: 2 MSB bits have meaning) (we use N = 9)
// N = 1000 or 1001 or 1010 or 1011 : 10xx means Variant 1 (Variant2: 110x and 111x are reserved)
wxString guid;
@ -323,16 +326,16 @@ static wxString makeProjectGUIDfromString( wxString& aText )
guid << wxString::Format( "%2.2x", cc );
}
// Output the 4 next hex digits (UID version and 3 digits):
guid << "-1"; // first digit: UID version 1
// Output the 4 next hex digits (UUID version and 3 digits):
guid << "-4"; // first digit: UUID version 4 (M = 4)
{
int cc = int( bname[chr_idx++] ) << 4 & 0xFF0;
cc += int( bname[chr_idx] ) >> 4 & 0x0F;
guid << wxString::Format( "%3.3x", cc );
}
// Output the 4 next hex digits (UID tag and 3 digits):
guid << "-9"; // first digit: UID tag 9
// Output the 4 next hex digits (UUID variant and 3 digits):
guid << "-9"; // first digit: UUID variant 1 (N = 9)
{
int cc = (int( bname[chr_idx++] ) & 0x0F) << 8;
cc += int( bname[chr_idx++] ) & 0xFF;