04-01-2012 12:25 PM
bonjour a tous j'ai crée un programme a base d'activex qui permet de faire appelle à un logiciel Insight Explorer (cognex).
je transfert les données sous forme SAFE ARRAY puis je les convertit en C-style ARRAY 2D mais le problème lorsque j'exécute le programme, j'aurais un message d'erreur (funtion CA_SafeArrayTo2DArrayEx:return value== -2147024890
et voila le programme
#include "QSSS.h"
#include <ansi_c.h>
#include <cvirte.h>
#include <userint.h>
#include "GRID.h"
#include <cviauto.h>
#include <utility.h>
#include <formatio.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int panelHandle;
static CAObjHandle CognexHandle = 0;
LPSAFEARRAY Items;
double *dblArray ;
int index1, index2
double d;
unsigned numElements;
size_t *dim1Size, *dim2Size;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED);
if (InitCVIRTE (hInstance, 0, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "GRID.uir", PANEL)) < 0)
return -1;
GetObjHandleFromActiveXCtrl (panelHandle, PANEL_COGNEX, &CognexHandle);
CognexInSight__CvsHostTableCollectionGetItems (CognexHandle, NULL, &Items);
////////////////////////////////////////////////////////////////////////////////////
CA_SafeArrayTo2DArrayEx(&Items, CAVT_INT, 0, &dblArray, dim1Size, dim2Size);
for (index1 = 0; index1 < dim1Size; index1++)
for (index2 = 0; index2 < dim2Size; index2++)
{
CA_SafeArrayGet2DSize (Items, dim1NumberOfElements);
d = CA_Get2DArrayElement(dblArray, dim1Size, dim2Size,index1, index2, double);
printf("%f", d);
////////////////////////////////////////////////////////////////////////
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
04-01-2012 02:01 PM
Hello, I'll answer in English.
I've never used that ActiveX object, but error -2147024890 (or 0x80070006) is not listed among CVI ActiveX error codes; It is listed in winerror.h, though, as "invalid handle": as far as I can see, the only handle passed to the function can be 'Items' variable, so you must double check if CognexInSight__CvsHostTableCollectionGetItems returns a LPSAFEARRAY variable and whether this value is valid or not.
04-01-2012 03:14 PM
L'activée se charge le tableau suivant qui déjà établira par un autre logiciel insghit explorer dont la resulat obtnue sous forme d'un tableau puis je veux lire par exemple le premier case(480) par labwindows cvi
comment faire ca et merci d'avance
04-01-2012 03:34 PM - edited 04-01-2012 03:35 PM
Hello, I'm not a french speaking person so I can just guess your posts ...
Can you post the definition of CognexInSight__CvsHostTableCollectionGetItems function? If parameters are expressed in types defined by Cognex you should also post the definition of those variable types. By this you should be able to detect if your use of SAFE ARRAY variable is legal.
Additionally, you should add some error checking to your program so that you can see if previous functions executed regularly: you should check the return value from both GetObjHandleFromActiveXCtrl and CognexInSight__CvsHostTableCollectionGetItems functions. You should also check whether CognexHandle value is valid.
04-16-2012 06:13 AM
slt.je veut commander un moteur pas a pas a base d'une carte NI pci 6220 ,ma question cette commande se passe par la variation du tension ou fréquence
04-17-2012 04:49 PM
Hi elyes,
Controlling a stepper motor with a PCI-6220 card is not simple. I'm not sure I understand the question you are asking. The best route to take to control a stepper motor is to use NI's motion software, such as SoftMotion.
For us to be able to answer your questions I would also recommend posting your question in the french discussion forum:
http://forums.ni.com/t5/Discussions-de-produit-de-NI/bd-p/4170
I hope this information helps.
Regards,