2011-11-17 01:06:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file eeschema/cross-probing.cpp
|
|
|
|
*/
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <eda_dde.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <lib_draw_item.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <sch_component.h>
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
2014-01-08 14:18:51 +00:00
|
|
|
* Execute a remote command sent by Pcbnew via a socket connection.
|
2011-11-17 01:06:08 +00:00
|
|
|
* <p>
|
|
|
|
* When user selects a module or pin in Pcbnew, Eeschema shows that same
|
|
|
|
* component or pin and moves cursor on the item. The socket port used
|
|
|
|
* is #KICAD_SCH_PORT_SERVICE_NUMBER which defaults to 4243.
|
|
|
|
*
|
|
|
|
* Valid commands are:
|
|
|
|
* \li \c \$PART: \c "reference" Put cursor on component.
|
|
|
|
* \li \c \$PART: \c "reference" \c \$REF: \c "ref" Put cursor on component reference.
|
|
|
|
* \li \c \$PART: \c "reference" \c \$VAL: \c "value" Put cursor on component value.
|
|
|
|
* \li \c \$PART: \c "reference" \c \$PAD: \c "pin name" Put cursor on the component pin.
|
|
|
|
* <p>
|
2011-09-30 18:15:37 +00:00
|
|
|
* @param cmdline = received command from Pcbnew
|
2007-10-08 16:14:16 +00:00
|
|
|
*/
|
2014-01-08 14:18:51 +00:00
|
|
|
void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
2007-10-08 16:14:16 +00:00
|
|
|
{
|
|
|
|
char line[1024];
|
|
|
|
char* idcmd;
|
|
|
|
char* text;
|
|
|
|
wxString part_ref, msg;
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME* frame;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
frame = (SCH_EDIT_FRAME*)wxGetApp().GetTopWindow();
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
strncpy( line, cmdline, sizeof(line) - 1 );
|
|
|
|
|
|
|
|
idcmd = strtok( line, " \n\r" );
|
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( (idcmd == NULL) || (text == NULL) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( strcmp( idcmd, "$PART:" ) != 0 )
|
|
|
|
return;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
part_ref = FROM_UTF8( text );
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
/* look for a complement */
|
|
|
|
idcmd = strtok( NULL, " \n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( idcmd == NULL ) // component only
|
|
|
|
{
|
2011-11-17 01:06:08 +00:00
|
|
|
frame->FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
|
2007-10-08 16:14:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( text == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
msg = FROM_UTF8( text );
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
if( strcmp( idcmd, "$REF:" ) == 0 )
|
|
|
|
{
|
2011-11-17 01:06:08 +00:00
|
|
|
frame->FindComponentAndItem( part_ref, true, FIND_REFERENCE, msg, false );
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( idcmd, "$VAL:" ) == 0 )
|
|
|
|
{
|
2011-11-17 01:06:08 +00:00
|
|
|
frame->FindComponentAndItem( part_ref, true, FIND_VALUE, msg, false );
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( idcmd, "$PAD:" ) == 0 )
|
|
|
|
{
|
2011-11-17 01:06:08 +00:00
|
|
|
frame->FindComponentAndItem( part_ref, true, FIND_PIN, msg, false );
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-11-17 01:06:08 +00:00
|
|
|
{
|
|
|
|
frame->FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
|
|
|
|
}
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem )
|
2007-10-08 16:14:16 +00:00
|
|
|
{
|
2007-10-09 13:10:58 +00:00
|
|
|
if( objectToSync == NULL )
|
|
|
|
return;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin = NULL;
|
|
|
|
char Line[1024];
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/* Cross probing to Pcbnew if a pin or a component is found */
|
2007-10-08 16:14:16 +00:00
|
|
|
switch( objectToSync->Type() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
|
|
|
case LIB_FIELD_T:
|
2008-12-08 15:27:13 +00:00
|
|
|
{
|
|
|
|
if( LibItem == NULL )
|
|
|
|
break;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
|
2008-12-08 15:27:13 +00:00
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
}
|
|
|
|
break;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2008-03-20 01:50:21 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) objectToSync;
|
2013-03-18 19:36:07 +00:00
|
|
|
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
|
2007-10-08 16:14:16 +00:00
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_PIN_T:
|
2007-10-09 13:10:58 +00:00
|
|
|
if( LibItem == NULL )
|
|
|
|
break;
|
2008-02-19 07:06:58 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
Pin = (LIB_PIN*) objectToSync;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
|
|
|
if( Pin->GetNumber() )
|
2007-10-08 16:14:16 +00:00
|
|
|
{
|
|
|
|
wxString pinnum;
|
|
|
|
Pin->ReturnPinStringNum( pinnum );
|
2011-02-28 18:36:19 +00:00
|
|
|
sprintf( Line, "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
|
2013-03-18 19:36:07 +00:00
|
|
|
TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
2007-10-09 13:10:58 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
|
2010-12-08 20:12:46 +00:00
|
|
|
}
|
2007-10-09 13:10:58 +00:00
|
|
|
|
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
break;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|