first of all, I have some global data, in it 2 structures
typedef struct {
LVBoolean status;
int32 code;
LStrHandle source;
} LVError;
typedef struct {
int32 dimSizes[2];
float64 arg1[1];
} LVpotty;
typedef LVpotty **LVpottyHdl;
the first is the error handler, the second is a simple labview array
double toltes[120][3]; //this is an array in which i collect the data and then tranform it
to a labview type array and pass it through the CIN
in the CINInit I have place calls that start up the device i will be using, these are calls
to functions in the device's SDK
the ints and floats in the CINRun routine are values whose value is decided in the CINInit()
LVpottyHdl potty - this is the struct above, the array
VError *zebriserror - is error handling
CIN MgErr CINRun(int32 *lchannelcount, float64 *latomduration, float64 *lfrequency,
int32 *lmotionquantsperatom, LVpottyHdl potty, float64 *kijelzo, LVError *zebriserror)
{
zebriserror->status = LVTRUE; // means there is no error
*lchannelcount = motionChannelCount; // decided in CINInit
*latomduration = atomDuration;
*lmotionquantsperatom = motionQuantsPerAtom;
*lfrequency = motionQuantsPerAtom/atomDuration;
// start the device //this is maybe where the problem is. if i don't use the activate flag
//than the program stops here and it sais that the current configuration
//won't allow this to execute (error handling tells me)
//so when i put this in, the second time this CIN executes, it just crashes
if (active==false) {
active = true;
if (!ZebDevice_Start(device))
goto __end;
}
if (!motionFeed(1)) //call the routine that gathers the data
goto __end;
k = 6/motionChannelCount; //determines how many data a sensor has (it can be adjusted...)
*kijelzo = k;
// fill up the out array, and in order
for (i=0; i<6; i++)
switch (i % motionChannelCount){
case 0:
for(j=0; j<3; j++)
(**potty).arg1[i/motionChannelCount*3 + j] = toltes[j];
break;
case 1:
for(j=0; j<3; j++)
(**potty).arg1[k*3 + i/motionChannelCount*3 + j] = toltes[j];
break;
case 2:
for(j=0; j<3; j++)
(**potty).arg1[k*6 + i/motionChannelCount*3 + j] = toltes[j];
break;
case 3:
for(j=0; j<3; j++)
(**potty).arg1[k*12 + i/motionChannelCount*3 + j] = toltes[j];
break;
case 4:
for(j=0; j<3; j++)
(**potty).arg1[k*24 + i/motionChannelCount*3 + j] = toltes[j];
break;
case 5:
for(j=0; j<3; j++)
(**potty).arg1[k*48 + i/motionChannelCount*3 + j] = toltes[j];
break;
}
// stop the device
if (!ZebDevice_Stop(device))
goto __end;
zebriserror->status = LVFALSE; // there was no error
__end:
if (device)
ZebDevice_Release(device);
if (zebriserror->status) //error handling
{
const char *cerrorstr = Zeb_GetLastError();
int32 length = strlen(cerrorstr);
if (cinerror = NumericArrayResize(uB, 1L, (UHandle*)&zebriserror->source, length))
goto out;
LStrLen(*zebriserror->source) = length;
MoveBlock((const void*)cerrorstr, LStrBuf(*zebriserror->source), length);
}
return noErr;
out:
return cinerror;
}
BOOL motionFeed(int atomCount) //the main data gathering routine
{
if (!motionInput)
return TRUE;
const ZebVector3* pos[MAX_MOTION_CHANNELS];
for(int ch = 0; ch < motionChannelCount; ch++)
{
if (!ZebMotionChannel_GetPos(motionChannels[ch], &pos[ch]))
return FALSE;
}
for(int ctr = atomCount*motionQuantsPerAtom; ctr--; )
{
for(int ch = 0; ch < motionChannelCount; ch++)
{
const ZebVector3* v = pos[ch]++;
//this is where i fill up the array (a global array)
toltes[szamlalo][0] = v->x; toltes[szamlalo][1] = v->y; toltes[szamlalo][2] = v->z;
szamlalo++;
}
}
return TRUE;
}
i tried using a dynamic array but then labview crashed even on the first run...