⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propaux.cpp

📁 Source code for cnc controlling three dimentioal machine
💻 CPP
字号:
// PropAux.cpp : implementation file
//

#include "stdafx.h"
#include "mastercontrol.h"
#include "PropAux.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// PropAux property page

IMPLEMENT_DYNCREATE(PropAux, CPropertyPage)

PropAux::PropAux() : CPropertyPage(PropAux::IDD)
{
	//{{AFX_DATA_INIT(PropAux)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
    Limits =     (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "Limits" , 0 ) == 1; // false by default
	AuxPins[0] = AfxGetApp( )->GetProfileInt("Preferences", "Pin1" , 1 );
	AuxPins[1] = AfxGetApp( )->GetProfileInt("Preferences", "Pin14" , 2 );
	AuxPins[2] = AfxGetApp( )->GetProfileInt("Preferences", "Pin16" , 3 );
    AuxPins[3] = AfxGetApp( )->GetProfileInt("Preferences", "Pin17" , 4 );
    InPins[0] = AfxGetApp( )->GetProfileInt("Preferences", "Pin10" , 1 );
    InPins[1] = AfxGetApp( )->GetProfileInt("Preferences", "Pin11" , 2 );
    InPins[2] = AfxGetApp( )->GetProfileInt("Preferences", "Pin12" , 3 );
    InPins[3] = AfxGetApp( )->GetProfileInt("Preferences", "Pin13" , 4 );
	InPins[4] = AfxGetApp( )->GetProfileInt("Preferences", "Pin15" , 5 );

	Function = 0;
	Function1 = 0;
	 
     

}

PropAux::~PropAux()
{
}

void PropAux::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(PropAux)
	DDX_Control(pDX, IDC_LIMITSON, m_LimitsOn);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(PropAux, CPropertyPage)
	//{{AFX_MSG_MAP(PropAux)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_AUX1, OnAux1)
	ON_BN_CLICKED(IDC_AUX2, OnAux2)
	ON_BN_CLICKED(IDC_AUX3, OnAux3)
	ON_BN_CLICKED(IDC_ELEVEN, OnEleven)
	ON_BN_CLICKED(IDC_ENABLE, OnEnable)
	ON_BN_CLICKED(IDC_ESTOP, OnEstop)
	ON_BN_CLICKED(IDC_FIFTEEN, OnFifteen)
	ON_BN_CLICKED(IDC_FOURTEEN, OnFourteen)
	ON_BN_CLICKED(IDC_HOMEA, OnHomea)
	ON_BN_CLICKED(IDC_HOMEX, OnHomex)
	ON_BN_CLICKED(IDC_HOMEY, OnHomey)
	ON_BN_CLICKED(IDC_HOMEZ, OnHomez)
	ON_BN_CLICKED(IDC_ONE, OnOne)
	ON_BN_CLICKED(IDC_SEVENTEEN, OnSeventeen)
	ON_BN_CLICKED(IDC_SIXTEEN, OnSixteen)
	ON_BN_CLICKED(IDC_TEN, OnTen)
	ON_BN_CLICKED(IDC_THIRTEEN, OnThirteen)
	ON_BN_CLICKED(IDC_TWELVE, OnTwelve)
	ON_BN_CLICKED(IDC_LIMITSON, OnLimitson)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// PropAux message handlers
void PropAux::DrawAuxPin()
{
    
	CStatic *plugs = (CStatic*) GetDlgItem(IDC_PLUGAUX);
	CDC *dc = plugs->GetDC();
	COLORREF bk = 0x000;
	CSize size = dc->GetWindowExt();
	RECT bounds;
	plugs->GetClientRect(&bounds);
	bounds.bottom -=3;
	bounds.right -= 3;
	bounds.top 	+= 3;
	bounds.left += 3;
	
	dc->FillSolidRect(&bounds, bk);
	dc->SelectStockObject(WHITE_PEN);
 
	for(int x = 1; x< 5; x++)
	{
	  dc->MoveTo( (x*23)-9 , 3 );		   // goto each function
	  dc->LineTo( (x*23)-9, (AuxPins[x-1]*18)-5); // line to under pin
	  dc->LineTo( 3 , (AuxPins[x-1]*18)-5 );  // line to pin
	 
	}
	
	
}

void PropAux::DrawInPin()
{

	CStatic *plugs = (CStatic*) GetDlgItem(IDC_PLUGINS);
	CDC *dc = plugs->GetDC();
	COLORREF bk = 0x000;
	CSize size = dc->GetWindowExt();
	RECT bounds;
	plugs->GetClientRect(&bounds);
	bounds.bottom -=3;
	bounds.right -= 3;
	bounds.top 	+= 3;
	bounds.left += 3;
	
	dc->FillSolidRect(&bounds, bk);
	dc->SelectStockObject(WHITE_PEN);
 
	for(int x = 1; x<6; x++)
	{
	  dc->MoveTo( (x*23)-9 , 3 );		   // goto each function
	  dc->LineTo( (x*23)-9, (InPins[x-1]*18)-5); // line to under pin
	  dc->LineTo( 3 , (InPins[x-1]*18)-5 );  // line to pin
	 
	}
	if( Limits ) 
	{
		m_LimitsOn.SetCheck(1);
	}
	else m_LimitsOn.SetCheck(0);
	
}

void PropAux::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
    DrawInPin();
    DrawAuxPin();	
	// Do not call CPropertyPage::OnPaint() for painting messages
}

void PropAux::OnAux1() 
{
	SetModified(TRUE);
	Function1 = 1;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
    stat->SetWindowText( "Aux 1 Drive -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnAux2() 
{
	SetModified(TRUE);
	Function1 = 2;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
    stat->SetWindowText( "Aux 2 Drive -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnAux3() 
{
	SetModified(TRUE);
	Function1 = 3;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
    stat->SetWindowText( "Aux 3 Drive -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnEleven() 
{
	SetModified(TRUE);
	if( !Function ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = InPins[1];
	for(int y=0; y<5; y++) if( InPins[y] == Function) InPins[y] = temp;
 
	InPins[1] = Function;
	DrawInPin();
    Function = 0;
	SetModified(TRUE);
	
}

void PropAux::OnEnable() 
{
	SetModified(TRUE);
    Function1 = 4;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
    stat->SetWindowText( "Motor Enable -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnEstop() 
{
	SetModified(TRUE);
	Function = 1;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
    stat->SetWindowText( "E-Stop -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnFifteen() 
{
	if( !Function ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = InPins[4];
	for(int y=0; y<5; y++) if( InPins[y] == Function) InPins[y] = temp;
 
	InPins[4] = Function;
	DrawInPin();
    Function = 0;
	SetModified(TRUE);
	
}

void PropAux::OnFourteen() 
{
	if( !Function1 ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = AuxPins[1];
	for(int y=0; y<4; y++) if( AuxPins[y] == Function1) AuxPins[y] = temp;
 
	AuxPins[1] = Function1;
	DrawAuxPin();
    Function1 = 0;
	SetModified(TRUE);
	
}

void PropAux::OnHomea() 
{
	Function = 5;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
    stat->SetWindowText( "Not Used -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnHomex() 
{
	Function = 2;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
    stat->SetWindowText( "Limit X -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnHomey() 
{
	Function = 3;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
    stat->SetWindowText( "Limit Y -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnHomez() 
{
	Function = 4;
    CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
    stat->SetWindowText( "Limit Z -- Select Pin");
    stat->Invalidate(TRUE);
	
}

void PropAux::OnOne() 
{
	if( !Function1 ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = AuxPins[0];
	for(int y=0; y<4; y++) if( AuxPins[y] == Function1) AuxPins[y] = temp;
 
	AuxPins[0] = Function1;
	DrawAuxPin();
    Function1 = 0;
	SetModified(TRUE);
	
}

void PropAux::OnSeventeen() 
{
	if( !Function1 ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = AuxPins[3];
	for(int y=0; y<4; y++) if( AuxPins[y] == Function1) AuxPins[y] = temp;
 
	AuxPins[3] = Function1;
	DrawAuxPin();
    Function1 = 0;
	SetModified(TRUE);
	
}

void PropAux::OnSixteen() 
{
	if( !Function1 ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT2);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = AuxPins[2];
	for(int y=0; y<4; y++) if( AuxPins[y] == Function1) AuxPins[y] = temp;
 
	AuxPins[2] = Function1;
	DrawAuxPin();
    Function1 = 0;
	SetModified(TRUE);
	
}

void PropAux::OnTen() 
{
	if( !Function ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = InPins[0];
	for(int y=0; y<5; y++) if( InPins[y] == Function) InPins[y] = temp;
 
	InPins[0] = Function;
	DrawInPin();
    Function = 0;
	SetModified(TRUE);
	
}

void PropAux::OnThirteen() 
{
	if( !Function ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = InPins[3];
	for(int y=0; y<5; y++) if( InPins[y] == Function) InPins[y] = temp;
 
	InPins[3] = Function;
	DrawInPin();
    Function = 0;
	SetModified(TRUE);
	
}

void PropAux::OnTwelve() 
{
	if( !Function ) 
	{ CStatic	*stat = (CStatic*) GetDlgItem(IDC_PROMPT1);
      stat->SetWindowText( "Select Function to Map ");
      stat->Invalidate(TRUE);
      return;
	}
	int temp = InPins[2];
	for(int y=0; y<5; y++) if( InPins[y] == Function) InPins[y] = temp;
 
	InPins[2] = Function;
	DrawInPin();
    Function = 0;
	SetModified(TRUE);
	
}

BOOL PropAux::OnKillActive() 
{

	AfxGetApp( )->WriteProfileInt("Preferences", "Pin10" , (int)InPins[0] );
	AfxGetApp( )->WriteProfileInt("Preferences", "Pin11" , (int)InPins[1] );
    AfxGetApp( )->WriteProfileInt("Preferences", "Pin12" , (int)InPins[2] );
    AfxGetApp( )->WriteProfileInt("Preferences", "Pin13" , (int)InPins[3] );
    AfxGetApp( )->WriteProfileInt("Preferences", "Pin15" , (int)InPins[4] );

    AfxGetApp( )->WriteProfileInt("Preferences", "Pin1" ,  (int)AuxPins[0] );
    AfxGetApp( )->WriteProfileInt("Preferences", "Pin14" , (int)AuxPins[1] );
    AfxGetApp( )->WriteProfileInt("Preferences", "Pin16" , (int)AuxPins[2] );
	AfxGetApp( )->WriteProfileInt("Preferences", "Pin17" , (int)AuxPins[3] );
	AfxGetApp( )->WriteProfileInt("Preferences", "Limits", (int)Limits );

	return CPropertyPage::OnKillActive();	
}

void PropAux::OnLimitson() 
{
		SetModified(TRUE);

	if ( Limits ) Limits = false;
	  else
		  Limits = true;
   if( Limits ) 
	{
		m_LimitsOn.SetCheck(1);
	}
	else m_LimitsOn.SetCheck(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -