Affichage et interaction dynamique dans une boîte de dialogue de valeurs dans u
cs_Karcynotron
Messages postés1Date d'inscriptionlundi 2 février 2004StatutMembreDernière intervention 6 juillet 2008
-
6 juil. 2008 à 18:50
cs_juju12
Messages postés966Date d'inscriptionsamedi 3 avril 2004StatutMembreDernière intervention 4 mars 2010
-
7 juil. 2008 à 09:28
Bonjour à tous!
Voilà j' essayes de porter un programme que j'ai réalisé sous DOS en C et qui lui fonctionne trés bien qui gère des moteurs pas à pas ainsi qu'un convertisseur analogique /numérique pour une application scientifique.
J'ai dejà résolu grâce à vous le problème de communication avec les ports sous XP en utilisant la DLL WinIo
que j'ai implementé et qui fonctionne tres bien et dont je vous remercie de m'en avoir fait connaitre l'existance!!
Mon probleme est un probleme de récupéation de la valeur des variables en cours d'execution de la boucle et de les afficher ainsi que de pouvoir par l'intermédiaire d'un contôle (bouton) pouvoir agir sur la variable pour obtenir une action.
Par avance merci de vos idées ...
Ah oui!! JE SUIS DEBUTANT EN Visual C++ ... :)
Je vous joint ci dessous le code tres commenté sur les points qui me semblent obscur:
CTestobjectDlg::CTestobjectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestobjectDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestobjectDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// -------------------------------------------------------------------------------
// Call InitializeWinIo to initialize the WinIo library.
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CTestobjectDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTestobjectDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTestobjectDlg::OnButtonStart1()
{
// TODO: Add your control notification handler code here
_outp(888,255);
}
void CTestobjectDlg::OnButtonOff2()
{
// TODO: Add your control notification handler code here
_outp(888,0);
}
void CTestobjectDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CTestobjectDlg::OnCancel()
{
// TODO: Add extra cleanup here
void CTestobjectDlg::OnButtonRunMotor1()
{
// TODO: Add your control notification handler code here
//////////////////////////////////////////////////////////////////////////////////
//JE VEUX POUVOIR EN COURS D'EXECUTION DE LA BOUCLE: do while
//AGIR SUR LA VARIABLE: m_speed "ICI m_speed EST BLOQUE COMME CONSTANTE
//MAIS QUI DANS L'APPLICATION REELLE SERA ISSUE DU RESULTAT D'UN TRAITEMENT
//PAR CALCUL (CHAQUE PAS FAISANT APPEL A UNE AQUISITION DE MESURE ICI NON DECRITE
//QUI EN FONCTION DE SA VALEUR JOUERA SUR LA VARIABLE m_speed DE FACON A REGULER
//LA VITESSE DU MOTEUR EN FONCTION DE CETTE VALEUR)
////////////////////////////////////////////////////////////////////////////////////
//
// TOUT CA FONCTIONNE TRES BIEN SOUS DOS EN C ET EN BASIC !!!!!!!!!!!!!!!!
//
////////////////////////////////////////////////////////////////////////////////////
//
//J'AI ESSAYE AUSSI AVEC UNE SIMPLE BOUCLE WHILE .... PAS MIEUX... :(
//
////////////////////////////////////////////////////////////////////////////////////
do
{
{
for (a=0;a<=m_speed;a++); // temps entre step
_outp (888,1); //ordre commande moteur
m_ctr = m_ctr+1;
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//JE VEUX AFFICHER SUR UN CONTRÔLE LA VALEUR DE: m_ctr ; //
//J'AI ESSAYE AVEC UN IDC_EDIT EN PROTOCOLE DDV/DDX EN //
//UTILISANT UpdateData(TRUE)/UpdateData(FALSE)... //
//CA ME MARCHE PAS LE COMPILATEUR REFUSE MEME DE ME GENERER //
//L'EXE ... //
//PAR CONTRE SANS AFFICHAGE CA MARCHE MON MOTEUR TOURNE MAIS//
//EN "AVEUGLE SE LIMITANT AU VALEURS PREDEFINIES EN DUR SANS//
//MOYEN DE VOIR NI D'AGIR DESSUS PENDANT L'EXECUTION.......// //
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
{
for (a=0;a<=m_speed;a++); // temps entre step
_outp (888,2); //ordre commande moteur
m_ctr = m_ctr+1;
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//JE VEUX AFFICHER SUR UN CONTRÔLE LA VALEUR DE: m_ctr ; //
//J'AI ESSAYE AVEC UN IDC_EDIT EN PROTOCOLE DDV/DDX EN //
//UTILISANT UpdateData(TRUE)/UpdateData(FALSE)... //
//CA ME MARCHE PAS LE COMPILATEUR REFUSE MEME DE ME GENERER //
//L'EXE ... //
//PAR CONTRE SANS AFFICHAGE CA MARCHE MON MOTEUR TOURNE MAIS//
//EN "AVEUGLE SE LIMITANT AU VALEURS PREDEFINIES EN DUR SANS//
//MOYEN DE VOIR NI D'AGIR DESSUS PENDANT L'EXECUTION.......//
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
{
for (a=0;a<=m_speed;a++); // temps entre step
_outp (888,4); //ordre commande moteur
m_ctr = m_ctr+1;
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//JE VEUX AFFICHER SUR UN CONTRÔLE LA VALEUR DE: m_ctr ; //
//J'AI ESSAYE AVEC UN IDC_EDIT EN PROTOCOLE DDV/DDX EN //
//UTILISANT UpdateData(TRUE)/UpdateData(FALSE)... //
//CA ME MARCHE PAS LE COMPILATEUR REFUSE MEME DE ME GENERER //
//L'EXE ... //
//PAR CONTRE SANS AFFICHAGE CA MARCHE MON MOTEUR TOURNE MAIS//
//EN "AVEUGLE SE LIMITANT AU VALEURS PREDEFINIES EN DUR SANS//
//MOYEN DE VOIR NI D'AGIR DESSUS PENDANT L'EXECUTION.......//
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
{
for (a=0;a<=m_speed;a++); // temps entre step
_outp (888,8); //ordre commande moteur
m_ctr = m_ctr+1;
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//JE VEUX AFFICHER SUR UN CONTRÔLE LA VALEUR DE: m_ctr ; //
//J'AI ESSAYE AVEC UN IDC_EDIT EN PROTOCOLE DDV/DDX EN //
//UTILISANT UpdateData(TRUE)/UpdateData(FALSE)... //
//CA ME MARCHE PAS LE COMPILATEUR REFUSE MEME DE ME GENERER //
//L'EXE ... //
//PAR CONTRE SANS AFFICHAGE CA MARCHE MON MOTEUR TOURNE MAIS//
//EN "AVEUGLE SE LIMITANT AU VALEURS PREDEFINIES EN DUR SANS//
//MOYEN DE VOIR NI D'AGIR DESSUS PENDANT L'EXECUTION.......// //
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
}
while (m_ctr < m_limit);
m_ctr = 0;
}
void CTestobjectDlg::OnButtonStopMotor2()
{
// TODO: Add your control notification handler code here
///////////////////////////////////////////////////////////////////////////
// JE VEUX POUVOIR FORCER LA VARIABLE m_limit A 1000 DANS LE
// DEROULEMENT DE LA FONCTION: void CTestobjectDlg::OnButtonRunMotor1()
// DE FACON A STOPPER LA PRECESSION DES PAS DU MOTEUR ET AINSI LE STOPPER
///////////////////////////////////////////////////////////////////////////
m_limit = 1000;
}
A voir également:
Affichage et interaction dynamique dans une boîte de dialogue de valeurs dans u
cs_juju12
Messages postés966Date d'inscriptionsamedi 3 avril 2004StatutMembreDernière intervention 4 mars 20104 7 juil. 2008 à 09:28
Bon pour ton premier problème :
for (a=0;a<=m_speed;a++);
si j'étais un compilateur efficace je remplacerais directement par : a=m_speed+1;
en tous cas on ne procède pas (plus) comme ça pour faire attendre un programme, utilise par exemple la fonction Sleep() de Windows.h