Commit 7a129e16 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Functional

*) void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, const std::string& aPayload, wxWindow* aSource=NULL );
*) virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent );
*) enum MAIL_T expansion into the brave new world if cross KIWAY_PLAYER communications.

Let the KIWAY_PLAYING begin.....
through well conceived mail from one KIWAY_PLAYER to another.
Get thinking now.  Add a new MAIL_T value, then send ExpressMail(), 
and receive it in KiwayMailIn(), it's that easy.
parent 1648d7fd
......@@ -37,6 +37,7 @@ KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ):
m_program( aProgram ),
m_top( 0 )
......@@ -317,8 +318,7 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent )
if( alive )
{
#if 0
// This is still broken, but is the way to go.
#if 1
return alive->ProcessEvent( aEvent );
#else
alive->KiwayMailIn( *mail );
......
......@@ -27,7 +27,18 @@
//IMPLEMENT_DYNAMIC_CLASS( KIWAY_EXPRESS, wxEvent )
#if 0 // requires that this code reside in only a single link image, rather than
// in each of kicad.exe, _pcbnew.kiface, and _eeschema.kiface as now.
// In the current case wxEVENT_ID will get a different value in each link
// image. We need to put this into a shared library for common utilization,
// I think that library should be libki.so. I am reluctant to do that now
// because the cost will be finding libki.so at runtime, and we need infrastructure
// to set our LIB_ENV_VAR to the proper place so libki.so can be reliably found.
// All things in due course.
const wxEventType KIWAY_EXPRESS::wxEVENT_ID = wxNewEventType();
#else
const wxEventType KIWAY_EXPRESS::wxEVENT_ID = 30000; // commmon accross all link images, hopefully unique.
#endif
KIWAY_EXPRESS::KIWAY_EXPRESS( const KIWAY_EXPRESS& anOther ) :
......
......@@ -8,7 +8,9 @@
BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME )
/* have not been able to get this to work yet:
EVT_KIWAY_EXPRESS( KIWAY_PLAYER::kiway_express )
Use Connect() in constructor until this can be sorted out
Use Connect() in constructor until this can be sorted out.
OK the problem is KIWAY_PLAYER::wxEVENT_ID not being unique accross all link images.
*/
END_EVENT_TABLE()
......
......@@ -30,6 +30,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiway_express.h>
#include <macros.h>
#include <eda_dde.h>
#include <wxEeschemaStruct.h>
......@@ -176,19 +177,27 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aComponent, SCH_COMPONENT* a
SendCommand( MSG_TO_PCB, packet.c_str() );
else
{
Kiway().ExpressMail( FRAME_PCB, 0, packet, this );
// Typically ExpressMail is going to be s-expression packets, but since
// we have existing interpreter of the cross probe packet on the other
// side in place, we use that here.
Kiway().ExpressMail( FRAME_PCB, MAIL_CROSS_PROBE, packet, this );
}
}
}
#include <kiway_express.h>
void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
// @todo switch on command type
std::string payload = mail.GetPayload();
const std::string& payload = mail.GetPayload();
switch( mail.Command() )
{
case MAIL_CROSS_PROBE:
ExecuteRemoteCommand( payload.c_str() );
break;
ExecuteRemoteCommand( payload.c_str() );
// many many others.
}
}
......@@ -29,6 +29,20 @@
#include <wx/wx.h>
#include <frame_type.h>
/**
* Enum MAIL_T
* is the set of mail types sendable via KIWAY::ExpressMail() and supplied as
* the @a aCommand parameter to that function. Such mail will be received in
* KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent ) and aEvent.Command() will
* match aCommand to ExpressMail().
*/
enum MAIL_T
{
MAIL_CROSS_PROBE,
};
/**
* Class KIWAY_EXPRESS
* carries a payload from one KIWAY_PLAYER to anothing within a PROJECT.
......@@ -42,6 +56,15 @@ public:
*/
FRAME_T Dest() { return m_destination; }
/**
* Function Command
* returns the EXPRESS_MAIL_T associated with this mail.
*/
MAIL_T Command()
{
return (MAIL_T) GetId(); // re-purposed control id.
}
/**
* Function Payload
* returns the payload, which can be any text but it typicall self
......
......@@ -13,6 +13,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiway_express.h>
#include <wxPcbStruct.h>
#include <eda_dde.h>
#include <macros.h>
......@@ -206,19 +207,27 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem )
SendCommand( MSG_TO_SCH, packet.c_str() );
else
{
Kiway().ExpressMail( FRAME_SCH, 0, packet, this );
// Typically ExpressMail is going to be s-expression packets, but since
// we have existing interpreter of the cross probe packet on the other
// side in place, we use that here.
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
}
}
}
#include <kiway_express.h>
void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
// @todo switch on command type
std::string payload = mail.GetPayload();
const std::string& payload = mail.GetPayload();
switch( mail.Command() )
{
case MAIL_CROSS_PROBE:
ExecuteRemoteCommand( payload.c_str() );
break;
ExecuteRemoteCommand( payload.c_str() );
// many many others.
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment