qa/drc_proto: updated DRC rule file format to the last version, post-rebase fixes too
This commit is contained in:
parent
e0ffdc8fe7
commit
f582783b27
|
@ -37,6 +37,17 @@
|
|||
#include <drc_proto/drc_test_provider.h>
|
||||
|
||||
|
||||
void drcPrintDebugMessage( int level, wxString msg, const char *function, int line )
|
||||
{
|
||||
wxString valueStr;
|
||||
if( wxGetEnv( "DRC_DEBUG", &valueStr ) )
|
||||
{
|
||||
int setLevel = wxAtoi( valueStr );
|
||||
if( level <= setLevel )
|
||||
fprintf(stderr,"[%-30s:%-5d] %s", function, line, (const char *) msg.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
test::DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
|
||||
m_board( aBoard ),
|
||||
m_designSettings ( aSettings ),
|
||||
|
@ -125,29 +136,32 @@ bool test::DRC_ENGINE::CompileRules()
|
|||
for( auto provider : m_testProviders )
|
||||
{
|
||||
ReportAux( wxString::Format( "- Provider: '%s': ", provider->GetName() ) );
|
||||
drc_dbg(11, "do prov %s", provider->GetName() );
|
||||
|
||||
for ( auto id : provider->GetMatchingConstraintIds() )
|
||||
{
|
||||
if( m_ruleMap.find(id) == m_ruleMap.end() )
|
||||
m_ruleMap[id] = new RULE_SET;
|
||||
drc_dbg(11, "do id %d", id);
|
||||
if( m_constraintMap.find(id) == m_constraintMap.end() )
|
||||
m_constraintMap[id] = new CONSTRAINT_SET;
|
||||
|
||||
m_ruleMap[ id ]->provider = provider;
|
||||
m_constraintMap[ id ]->provider = provider;
|
||||
|
||||
for( auto rule : m_rules )
|
||||
{
|
||||
drc_dbg(10, "Scan provider %s rule %s", provider->GetName() );
|
||||
drc_dbg(11, "Scan provider %s, rule %s", provider->GetName(), rule->GetName() );
|
||||
|
||||
if( ! rule->IsEnabled() )
|
||||
continue;
|
||||
|
||||
for( auto& constraint : rule->Constraints() )
|
||||
{
|
||||
drc_dbg(11, "scan constraint id %d\n", constraint.GetType() );
|
||||
if( constraint.GetType() != id )
|
||||
continue;
|
||||
|
||||
ReportAux( wxString::Format( " |- Rule: '%s' ", rule->m_Name ) );
|
||||
ReportAux( wxString::Format( " |- Rule: '%s' ", rule->GetName() ) );
|
||||
|
||||
auto rcons = new RULE_WITH_CONDITIONS;
|
||||
auto rcons = new CONSTRAINT_WITH_CONDITIONS;
|
||||
|
||||
if( rule->IsConditional() )
|
||||
{
|
||||
|
@ -159,8 +173,9 @@ bool test::DRC_ENGINE::CompileRules()
|
|||
ReportAux( wxString::Format( " |- condition: '%s' compile: %s", condition->GetExpression(), compileOk ? "OK" : "ERROR") );
|
||||
}
|
||||
|
||||
rcons->rule = rule;
|
||||
m_ruleMap[ id ]->sortedRules.push_back( rcons );
|
||||
rcons->constraint = constraint;
|
||||
rcons->parentRule = rule;
|
||||
m_constraintMap[ id ]->sortedConstraints.push_back( rcons );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -215,10 +230,17 @@ void test::DRC_ENGINE::RunTests( )
|
|||
const test::DRC_CONSTRAINT& test::DRC_ENGINE::EvalRulesForItems( test::DRC_CONSTRAINT_TYPE_T aConstraintId, BOARD_ITEM* a, BOARD_ITEM* b, PCB_LAYER_ID aLayer )
|
||||
{
|
||||
test::DRC_RULE* rv;
|
||||
auto ruleset = m_ruleMap[ aConstraintId ];
|
||||
auto ruleset = m_constraintMap[ aConstraintId ];
|
||||
|
||||
for( auto rcond : ruleset->sortedRules )
|
||||
for( auto rcond : ruleset->sortedConstraints )
|
||||
{
|
||||
if( rcond->conditions.size() == 0 ) // uconditional
|
||||
{
|
||||
drc_dbg( 8, " -> rule '%s' matches (unconditional)\n",
|
||||
rcond->constraint.GetParentRule()->GetName()
|
||||
);
|
||||
return rcond->constraint;
|
||||
}
|
||||
for( auto condition : rcond->conditions )
|
||||
{
|
||||
drc_dbg( 8, " -> check condition '%s'\n",
|
||||
|
@ -228,13 +250,10 @@ const test::DRC_CONSTRAINT& test::DRC_ENGINE::EvalRulesForItems( test::DRC_CONST
|
|||
if( result )
|
||||
{
|
||||
drc_dbg( 8, " -> rule '%s' matches, triggered by condition '%s'\n",
|
||||
rcond->rule->GetName(),
|
||||
rcond->constraint.GetParentRule()->GetName(),
|
||||
condition->GetExpression() );
|
||||
for( const DRC_CONSTRAINT& c : rcond->rule->Constraints() )
|
||||
{
|
||||
if( c.GetType() == aConstraintId )
|
||||
return c;
|
||||
}
|
||||
|
||||
return rcond->constraint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,24 +332,16 @@ test::DRC_CONSTRAINT test::DRC_ENGINE::GetWorstGlobalConstraint( test::DRC_CONST
|
|||
std::vector<test::DRC_CONSTRAINT> test::DRC_ENGINE::QueryConstraintsById( test::DRC_CONSTRAINT_TYPE_T constraintID )
|
||||
{
|
||||
std::vector<test::DRC_CONSTRAINT> rv;
|
||||
|
||||
for( auto rule : m_ruleMap[constraintID]->sortedRules )
|
||||
{
|
||||
assert( rule );
|
||||
assert( rule->rule );
|
||||
|
||||
for( const DRC_CONSTRAINT& c : rule->constraints )
|
||||
if( c.GetType() == constraintID )
|
||||
rv.push_back( c );
|
||||
}
|
||||
|
||||
for ( auto c : m_constraintMap[constraintID]->sortedConstraints )
|
||||
rv.push_back(c->constraint);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
bool test::DRC_ENGINE::HasCorrectRulesForId( test::DRC_CONSTRAINT_TYPE_T ruleID )
|
||||
bool test::DRC_ENGINE::HasCorrectRulesForId( test::DRC_CONSTRAINT_TYPE_T constraintID )
|
||||
{
|
||||
return m_ruleMap[ruleID]->sortedRules.size() != 0;
|
||||
//drc_dbg(10,"hascorrect id %d size %d\n", ruleID, m_ruleMap[ruleID]->sortedRules.size( ) );
|
||||
return m_constraintMap[constraintID]->sortedConstraints.size() != 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,12 +53,11 @@ class NETLIST;
|
|||
class PROGRESS_REPORTER;
|
||||
class REPORTER;
|
||||
|
||||
//#ifdef DEBUG
|
||||
|
||||
void drcPrintDebugMessage( int level, wxString msg, const char *function, int line );
|
||||
|
||||
#define drc_dbg(level, fmt, ...) \
|
||||
wxLogTrace( "drc_proto", fmt, __VA_ARGS__ );
|
||||
//#else
|
||||
//#define drc_dbg(level, fmt, ...)
|
||||
//#endif
|
||||
drcPrintDebugMessage(level, wxString::Format( fmt, __VA_ARGS__ ), __FUNCTION__, __LINE__ );
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
@ -213,20 +212,20 @@ private:
|
|||
|
||||
void freeCompiledRules();
|
||||
|
||||
struct RULE_WITH_CONDITIONS
|
||||
struct CONSTRAINT_WITH_CONDITIONS
|
||||
{
|
||||
std::vector<test::DRC_RULE_CONDITION*> conditions;
|
||||
test::DRC_RULE* rule;
|
||||
std::vector<test::DRC_CONSTRAINT> constraints;
|
||||
test::DRC_RULE* parentRule;
|
||||
test::DRC_CONSTRAINT constraint;
|
||||
};
|
||||
|
||||
struct RULE_SET
|
||||
struct CONSTRAINT_SET
|
||||
{
|
||||
std::vector<RULE_WITH_CONDITIONS*> sortedRules;
|
||||
std::vector<CONSTRAINT_WITH_CONDITIONS*> sortedConstraints;
|
||||
DRC_TEST_PROVIDER* provider;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<test::DRC_CONSTRAINT_TYPE_T, RULE_SET*> RULE_MAP;
|
||||
typedef std::unordered_map<test::DRC_CONSTRAINT_TYPE_T, CONSTRAINT_SET*> CONSTRAINT_MAP;
|
||||
|
||||
|
||||
void inferImplicitRules();
|
||||
|
@ -240,8 +239,8 @@ private:
|
|||
std::vector<DRC_RULE_CONDITION*> m_ruleConditions;
|
||||
std::vector<DRC_RULE*> m_rules;
|
||||
std::vector<DRC_TEST_PROVIDER*> m_testProviders;
|
||||
std::unordered_map<EDA_ITEM*, RULE_SET*> m_implicitRules;
|
||||
RULE_MAP m_ruleMap;
|
||||
std::unordered_map<EDA_ITEM*, CONSTRAINT_SET*> m_implicitRules;
|
||||
CONSTRAINT_MAP m_constraintMap;
|
||||
REPORTER* m_reporter;
|
||||
PROGRESS_REPORTER* m_progressReporter;
|
||||
|
||||
|
|
|
@ -44,8 +44,9 @@ test::DRC_RULE::~DRC_RULE()
|
|||
{
|
||||
}
|
||||
|
||||
void test::DRC_RULE::AddConstraint( const DRC_CONSTRAINT& aConstraint )
|
||||
void test::DRC_RULE::AddConstraint( DRC_CONSTRAINT& aConstraint )
|
||||
{
|
||||
aConstraint.SetParentRule( this );
|
||||
m_constraints.push_back( aConstraint );
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ class DRC_CONSTRAINT
|
|||
|
||||
// fixme: needed?
|
||||
bool Allowed() const { return m_Allow; }
|
||||
void SetParentRule( DRC_RULE *aParentRule ) { m_parentRule = aParentRule; }
|
||||
DRC_RULE* GetParentRule() const { return m_parentRule; }
|
||||
|
||||
DRC_CONSTRAINT_TYPE_T GetType() const { return m_Type; }
|
||||
|
@ -160,7 +161,7 @@ public:
|
|||
return m_constraints;
|
||||
}
|
||||
|
||||
void AddConstraint( const DRC_CONSTRAINT& aConstraint );
|
||||
void AddConstraint( DRC_CONSTRAINT& aConstraint );
|
||||
|
||||
bool IsConditional() const
|
||||
{
|
||||
|
|
|
@ -401,6 +401,8 @@ void test::DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
|
|||
parseUnknown();
|
||||
}
|
||||
}
|
||||
|
||||
aRule->AddConstraint( constraint );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,12 +126,12 @@ bool test::DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
|
|||
|
||||
for( auto outlineItem : boardOutline )
|
||||
{
|
||||
//printf("RefT %d\n", outlineItem->Type() );
|
||||
drc_dbg(12, "RefT %d %p\n", outlineItem->Type(), outlineItem );
|
||||
auto refShape = outlineItem->GetEffectiveShape();
|
||||
|
||||
for( auto boardItem : boardItems )
|
||||
{
|
||||
// printf("BoardT %d\n", boardItem->Type() );
|
||||
drc_dbg(12, "BoardT %d %p\n", boardItem->Type(), boardItem );
|
||||
|
||||
auto shape = boardItem->GetEffectiveShape();
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
(version 20200610)
|
||||
|
||||
(condition (expression "A.type == 'Pad' && B.type == 'Pad' && (A.onlayer('B.Cu'))") (rule "pad2pad_clearance_back") )
|
||||
|
||||
(rule "pad2pad_clearance_back" (type "clearance") (priority 1) (severity error) (min "1mm") )
|
||||
(rule "default" (type "clearance") (priority 0) (severity error) (min "0.2mm") )
|
||||
(rule "pad2pad_clearance_back"
|
||||
(condition "A.type == 'Pad' && B.type == 'Pad' && (A.onlayer('B.Cu'))" )
|
||||
(constraint clearance (min "1mm") )
|
||||
)
|
||||
|
||||
(rule "default"
|
||||
(constraint clearance (min "0.2mm") )
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue