// BaseParaSet.cpp: implementation file 
// 

# include "stdafx.h" 
# include "DEMO.h" 
# include "BaseParaSet.h" 
# include "CtrlCard.h" 

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

extern CCtrlCard g_CtrlCard; 
///////////////////////////////////////////////////////////////////////////// 
// CBaseParaSet dialog 
int effectlogic_x; 
int effectlogic_y; 
int effectlogic_z; 
int effectlogic_a; 
int effectlogic_b; 
int effectlogic_c; 
int registermode = 0; 

CBaseParaSet:: CBaseParaSet (CWnd * pParent /*= NULL */) 
: CDialog (CBaseParaSet:: IDD, pParent) 
{ 
// ((AFX_DATA_INIT (CBaseParaSet) 
m_nEffectLogic_x = -1; 
m_nEffectLogic_y = -1; 
m_nEffectLogic_z = -1; 
m_nNLimitMode_x = -1; 
m_nNLimitMode_y = -1; 
m_nNLimitMode_z = -1; 
m_nPLimitMode_x = -1; 
m_nPLimitMode_y = -1; 
m_nPLimitMode_z = -1; 
m_nPulseMode_x = -1; 
m_nPulseMode_y = -1; 
m_nPulseMode_z = -1; 
m_nStop0Mode_x = -1; 
m_nStop0Mode_y = -1; 
m_nStop0Mode_z = -1; 
m_nStop1Mode_x = -1; 
m_nStop1Mode_y = -1; 
m_nStop1Mode_z = -1; 
m_nHardLogic = -1; 
m_nHardStop = -1; 
m_nStop1Mode_a = -1; 
m_nStop0Mode_a = -1; 
m_nPLimitMode_a = -1; 
m_nNLimitMode_a = -1; 
m_nEffectLogic_a = -1; 
m_nPulseMode_a = -1; 
m_nRegMode = 0; 
m_nEffectLogic_b = -1; 
m_nEffectLogic_c = -1; 
m_nNLimitMode_b = -1; 
m_nNLimitMode_c = -1; 
m_nPLimitMode_b = -1; 
m_nPLimitMode_c = -1; 
m_nPulseMode_b = -1; 
m_nPulseMode_c = -1; 
m_nStop0Mode_b = -1; 
m_nStop0Mode_c = -1; 
m_nStop1Mode_b = -1; 
m_nStop1Mode_c = -1; 
//)) AFX_DATA_INIT 
} 


void CBaseParaSet:: DoDataExchange (CDataExchange * pDX) 
{
CDialog:: DoDataExchange (pDX); 
// ((AFX_DATA_MAP (CBaseParaSet) 
DDX_Radio (pDX, IDC_EFFECTLOGIC_X, m_nEffectLogic_x); 
DDX_Radio (pDX, IDC_EFFECTLOGIC_Y, m_nEffectLogic_y); 
DDX_Radio (pDX, IDC_EFFECTLOGIC_Z, m_nEffectLogic_z); 
DDX_Radio (pDX, IDC_NLIMITMODE_X, m_nNLimitMode_x); 
DDX_Radio (pDX, IDC_NLIMITMODE_Y, m_nNLimitMode_y); 
DDX_Radio (pDX, IDC_NLIMITMODE_Z, m_nNLimitMode_z); 
DDX_Radio (pDX, IDC_PLIMITMODE_X, m_nPLimitMode_x); 
DDX_Radio (pDX, IDC_PLIMITMODE_Y, m_nPLimitMode_y); 
DDX_Radio (pDX, IDC_PLIMITMODE_Z, m_nPLimitMode_z); 
DDX_Radio (pDX, IDC_PULSEMODE_X, m_nPulseMode_x); 
DDX_Radio (pDX, IDC_PULSEMODE_Y, m_nPulseMode_y); 
DDX_Radio (pDX, IDC_PULSEMODE_Z, m_nPulseMode_z); 
DDX_Radio (pDX, IDC_STOP0MODE_X, m_nStop0Mode_x); 
DDX_Radio (pDX, IDC_STOP0MODE_Y, m_nStop0Mode_y); 
DDX_Radio (pDX, IDC_STOP0MODE_Z, m_nStop0Mode_z); 
DDX_Radio (pDX, IDC_STOP1MODE_X, m_nStop1Mode_x); 
DDX_Radio (pDX, IDC_STOP1MODE_Y, m_nStop1Mode_y); 
DDX_Radio (pDX, IDC_STOP1MODE_Z, m_nStop1Mode_z); 
DDX_Radio (pDX, IDC_HARDLOGIC, m_nHardLogic); 
DDX_Radio (pDX, IDC_HARDSTOP, m_nHardStop); 
DDX_Radio (pDX, IDC_STOP1MODE_A, m_nStop1Mode_a); 
DDX_Radio (pDX, IDC_STOP0MODE_A, m_nStop0Mode_a); 
DDX_Radio (pDX, IDC_PLIMITMODE_A, m_nPLimitMode_a); 
DDX_Radio (pDX, IDC_NLIMITMODE_A, m_nNLimitMode_a); 
DDX_Radio (pDX, IDC_EFFECTLOGIC_A, m_nEffectLogic_a); 
DDX_Radio (pDX, IDC_PULSEMODE_A, m_nPulseMode_a); 
DDX_Radio (pDX, IDC_REGISTER_MODE0, m_nRegMode); 
DDX_Radio (pDX, IDC_EFFECTLOGIC_B, m_nEffectLogic_b); 
DDX_Radio (pDX, IDC_EFFECTLOGIC_C, m_nEffectLogic_c); 
DDX_Radio (pDX, IDC_NLIMITMODE_B, m_nNLimitMode_b); 
DDX_Radio (pDX, IDC_NLIMITMODE_C, m_nNLimitMode_c); 
DDX_Radio (pDX, IDC_PLIMITMODE_B, m_nPLimitMode_b); 
DDX_Radio (pDX, IDC_PLIMITMODE_C, m_nPLimitMode_c); 
DDX_Radio (pDX, IDC_PULSEMODE_B, m_nPulseMode_b); 
DDX_Radio (pDX, IDC_PULSEMODE_C, m_nPulseMode_c); 
DDX_Radio (pDX, IDC_STOP0MODE_B, m_nStop0Mode_b); 
DDX_Radio (pDX, IDC_STOP0MODE_C, m_nStop0Mode_c); 
DDX_Radio (pDX, IDC_STOP1MODE_B, m_nStop1Mode_b); 
DDX_Radio (pDX, IDC_STOP1MODE_C, m_nStop1Mode_c); 
//)) AFX_DATA_MAP 
} 


BEGIN_MESSAGE_MAP (CBaseParaSet, CDialog) 
// ((AFX_MSG_MAP (CBaseParaSet) 
//)) AFX_MSG_MAP 
END_MESSAGE_MAP () 

///////////////////////////////////////////////////////////////////////////// 
// CBaseParaSet message handlers 

BOOL CBaseParaSet:: OnInitDialog () 
{
CDialog:: OnInitDialog (); 
//************ Basic parameter settings ***********// 

//********** Output pulse mode *************// 
// 0 - Pulse + Pulse 1 - Pulse + direction // 
// Default mode for the pulse + direction // 
//***********************************// 
    m_nPulseMode_x = 1; 
m_nPulseMode_y = 1; 
m_nPulseMode_z = 1; 
m_nPulseMode_a = 1; 
m_nPulseMode_b = 1; 
m_nPulseMode_c = 1; 
//********** Limit mode is set ***********// 
// 0 - are limit the effective 1 - is limit Invalid // 
// Default mode is limit the effective // 
//***********************************// 
m_nPLimitMode_x = 0; 
m_nPLimitMode_y = 0; 
m_nPLimitMode_z = 0; 
m_nPLimitMode_a = 0; 
m_nPLimitMode_b = 0; 
m_nPLimitMode_c = 0; 
//********** Negative limit mode is set to ***********// 
// 0 - Negative limit effective 1 - negative limit is invalid // 
// Default mode for the negative limit valid // 
//***********************************// 
m_nNLimitMode_x = 0; 
m_nNLimitMode_y = 0; 
m_nNLimitMode_z = 0; 
m_nNLimitMode_a = 0; 
m_nNLimitMode_b = 0; 
m_nNLimitMode_c = 0; 
//*********** STOP0 mode setting ***********// 
// 0 - invalid 1 - effective // 
// Default mode is invalid // 
//***********************************// 
m_nStop0Mode_x = 0; 
m_nStop0Mode_y = 0; 
m_nStop0Mode_z = 0; 
m_nStop0Mode_a = 0; 
m_nStop0Mode_b = 0; 
m_nStop0Mode_c = 0; 
//*********** STOP1 mode setting ***********// 
// 0 - invalid 1 - effective // 
// Default mode is invalid // 
//***********************************// 
m_nStop1Mode_x = 0; 
m_nStop1Mode_y = 0; 
m_nStop1Mode_z = 0; 
m_nStop1Mode_a = 0; 
m_nStop1Mode_b = 0; 
m_nStop1Mode_c = 0; 
//*********** Level mode setting ************// 
// This is the limit, STOP0, STOP1 mode level set // 
// 0 - active low 1 - high effective // 
// Default mode for the low efficiency // 
//***********************************// 
m_nEffectLogic_x = 0; 
m_nEffectLogic_y = 0; 
m_nEffectLogic_z = 0; 
m_nEffectLogic_a = 0; 
m_nEffectLogic_b = 0; 
m_nEffectLogic_c = 0; 
//*********** Hardware to stop setting ************// 
// The stop function for the hardware set // 
// M_nHardStop 0 - invalid 1 - effective // 
// M_nHardLogic 0 - low 1 - high // 
// Default is invalid // 
//***********************************// 
m_nHardStop = 0; 
m_nHardLogic = 0; 

UpdateData (FALSE); 

return TRUE; // return TRUE unless you set the focus to a control 
// EXCEPTION: OCX Property Pages should return FALSE 
} 

void CBaseParaSet:: OnOK () 
{
UpdateData (); 

effectlogic_x = m_nEffectLogic_x; 

effectlogic_y = m_nEffectLogic_y; 

effectlogic_z = m_nEffectLogic_z; 

effectlogic_a = m_nEffectLogic_a; 

effectlogic_b = m_nEffectLogic_b; 

effectlogic_c = m_nEffectLogic_c; 

registermode = m_nRegMode; 

int pulsemode[]={m_nPulseMode_x, m_nPulseMode_y, m_nPulseMode_z, m_nPulseMode_a, m_nPulseMode_b, m_nPulseMode_c}; // pulse output mode 

int plimitmode[] = {m_nPLimitMode_x, m_nPLimitMode_y, m_nPLimitMode_z, m_nPLimitMode_a, m_nPLimitMode_b, m_nPLimitMode_c}; // positive limit mode 

int nlimitmode[] = {m_nNLimitMode_x, m_nNLimitMode_y, m_nNLimitMode_z, m_nNLimitMode_a, m_nNLimitMode_b, m_nNLimitMode_c}; // negative limit mode 

int stop0mode[] = {m_nStop0Mode_x, m_nStop0Mode_y, m_nStop0Mode_z, m_nStop0Mode_a, m_nStop0Mode_b, m_nStop0Mode_c}; // stop0 mode 

int stop1mode[]= {m_nStop1Mode_x, m_nStop1Mode_y, m_nStop1Mode_z, m_nStop1Mode_a, m_nStop1Mode_b, m_nStop1Mode_c}; // stop1 mode 

int effectlogic[]= {m_nEffectLogic_x, m_nEffectLogic_y, m_nEffectLogic_z, m_nEffectLogic_a, m_nEffectLogic_b, m_nEffectLogic_c}; // Level 

for (int i = 1; i <MAXAXIS+1;i++) 
{ 
// Set the pulse output mode 
g_CtrlCard.Setup_PulseMode (i, pulsemode [i-1]); 

// Limit mode settings 
g_CtrlCard.Setup_LimitMode (i, plimitmode [i-1], nlimitmode [i-1], effectlogic [i-1]); 

// Stop0 signal mode settings 
g_CtrlCard.Setup_Stop0Mode (i, stop0mode [i-1], effectlogic [i-1]); 

// Stop1 signal mode settings 
g_CtrlCard.Setup_Stop1Mode (i, stop1mode [i-1], effectlogic [i-1]); 
} 

// Hardware settings to stop signal pattern 
g_CtrlCard.Setup_HardStop (m_nHardStop, m_nHardLogic); 

CDialog:: OnOK (); 
} 
