Eeschema Eagle Import: generate unique timestamps for multiunit parts

This commit is contained in:
Maciej Suminski 2017-08-18 10:57:09 +02:00
parent a8e800f571
commit 08907d4fe8
3 changed files with 10 additions and 7 deletions

View File

@ -171,20 +171,23 @@ unsigned long timeStamp( wxXmlNode* aTree )
} }
time_t moduleTstamp( const string& aName, const string& aValue ) time_t moduleTstamp( const string& aName, const string& aValue, int aUnit )
{ {
std::size_t h1 = std::hash<string>{}( aName ); std::size_t h1 = std::hash<string>{}( aName );
std::size_t h2 = std::hash<string>{}( aValue ); std::size_t h2 = std::hash<string>{}( aValue );
return ((h1 ^ h2 << 1) & 0xffffffff); std::size_t h3 = std::hash<int>{}( aUnit );
return h1 ^ (h2 << 1) ^ (h3 << 2);
} }
string modulePath( const string& aName, const string& aValue ) string modulePath( const string& aName, const string& aValue )
{ {
// TODO handle subsheet
std::ostringstream s; std::ostringstream s;
s << '/' << std::setfill('0') << std::uppercase << std::hex << std::setw(8) s << '/' << std::setfill( '0' ) << std::uppercase << std::hex << std::setw( 8 )
<< moduleTstamp( aName, aValue ); << moduleTstamp( aName, aValue, 0 );
return s.str(); return s.str();
} }

View File

@ -1050,7 +1050,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
component->SetConvert( 0 ); component->SetConvert( 0 );
component->SetPosition( wxPoint( einstance.x * EUNIT_TO_MIL, -einstance.y * EUNIT_TO_MIL ) ); component->SetPosition( wxPoint( einstance.x * EUNIT_TO_MIL, -einstance.y * EUNIT_TO_MIL ) );
component->GetField( FOOTPRINT )->SetText( wxString( package ) ); component->GetField( FOOTPRINT )->SetText( wxString( package ) );
component->SetTimeStamp( moduleTstamp( einstance.part, epart->value ? *epart->value : "" ) ); component->SetTimeStamp( moduleTstamp( einstance.part, epart->value ? *epart->value : "", unit ) );
// component->AddHierarchicalReference( path, reference, (int)tmp ); // TODO ?? // component->AddHierarchicalReference( path, reference, (int)tmp ); // TODO ??
if( einstance.rot ) if( einstance.rot )

View File

@ -364,8 +364,8 @@ string makeKey( const string& aFirst, const string& aSecond );
/// Make a unique time stamp /// Make a unique time stamp
unsigned long timeStamp( wxXmlNode* aTree ); unsigned long timeStamp( wxXmlNode* aTree );
/// Computes module path basing on its name and value /// Computes module timestamp basing on its name, value and unit
time_t moduleTstamp( const string& aName, const string& aValue ); time_t moduleTstamp( const string& aName, const string& aValue, int aUnit );
/// Returns module path using the module timestamp /// Returns module path using the module timestamp
// TODO does not handle multisheet schematics correctly // TODO does not handle multisheet schematics correctly