Gerber UUID parameter calculation: refinements and more comments
This commit is contained in:
parent
c05ca469ae
commit
654dbbb44b
|
@ -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
|
/** 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
|
* 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
|
* 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 )
|
static wxString makeProjectGUIDfromString( wxString& aText )
|
||||||
{
|
{
|
||||||
|
@ -289,9 +291,10 @@ static wxString makeProjectGUIDfromString( wxString& aText )
|
||||||
// with
|
// with
|
||||||
// x = hexDigit lower/upper case
|
// x = hexDigit lower/upper case
|
||||||
// and
|
// 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
|
// 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;
|
wxString guid;
|
||||||
|
|
||||||
|
@ -323,16 +326,16 @@ static wxString makeProjectGUIDfromString( wxString& aText )
|
||||||
guid << wxString::Format( "%2.2x", cc );
|
guid << wxString::Format( "%2.2x", cc );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the 4 next hex digits (UID version and 3 digits):
|
// Output the 4 next hex digits (UUID version and 3 digits):
|
||||||
guid << "-1"; // first digit: UID version 1
|
guid << "-4"; // first digit: UUID version 4 (M = 4)
|
||||||
{
|
{
|
||||||
int cc = int( bname[chr_idx++] ) << 4 & 0xFF0;
|
int cc = int( bname[chr_idx++] ) << 4 & 0xFF0;
|
||||||
cc += int( bname[chr_idx] ) >> 4 & 0x0F;
|
cc += int( bname[chr_idx] ) >> 4 & 0x0F;
|
||||||
guid << wxString::Format( "%3.3x", cc );
|
guid << wxString::Format( "%3.3x", cc );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the 4 next hex digits (UID tag and 3 digits):
|
// Output the 4 next hex digits (UUID variant and 3 digits):
|
||||||
guid << "-9"; // first digit: UID tag 9
|
guid << "-9"; // first digit: UUID variant 1 (N = 9)
|
||||||
{
|
{
|
||||||
int cc = (int( bname[chr_idx++] ) & 0x0F) << 8;
|
int cc = (int( bname[chr_idx++] ) & 0x0F) << 8;
|
||||||
cc += int( bname[chr_idx++] ) & 0xFF;
|
cc += int( bname[chr_idx++] ) & 0xFF;
|
||||||
|
|
Loading…
Reference in New Issue