PDA

View Full Version : labjack plugin


Jerry
03-14-2007, 01:14 PM
Could you please give me all the commands that can be sent to
the LabJack.dls which comes with Viz 3?

farshizzo
03-14-2007, 04:36 PM
The plugin has not changed since it was originally written for VRUT. Here is the code for the CommandSensor function of the LabJack:void CommandSensor(void *sensor)
{
long idnum=-1;
long demo=0;
long numCh=4;
static int tog = 1;
long trisD = 3;
long trisIO = 0;
long stateD1=1;
long stateD2 = 2;
long state;
long stateIO = 0;
long updateDigital = 1;
long outputD[3];
long result;
long overVoltage;
float voltage;

SetThreadPriority(GetCurrentThread,THREAD_PRIORITY _TIME_CRITICAL);

switch( (int) ((VRUTSensorObj *)sensor)->command) {
case 0: // Both eyes closed
state = 0;
DigitalIO(&idnum, demo,&trisD,trisIO, &state, &stateIO, updateDigital, outputD);
break;
case 1: // Left closed, right open
state = 1;
DigitalIO(&idnum, demo,&trisD,trisIO, &state, &stateIO, updateDigital, outputD);
break;
case 10: // Left open, right closed
state = 2;
DigitalIO(&idnum, demo,&trisD,trisIO, &state, &stateIO, updateDigital, outputD);
break;
case 11: // Both open
state = 3;
DigitalIO(&idnum, demo,&trisD,trisIO, &state, &stateIO, updateDigital, outputD);
break;
case 2:
fprintf(stdout,"%.2f %.2f\n",((VRUTSensorObj *)sensor)->data[0],((VRUTSensorObj *)sensor)->data[1]);
result = EAnalogOut(&idnum,demo,((VRUTSensorObj *)sensor)->data[0],((VRUTSensorObj *)sensor)->data[1]);
fprintf(stdout,"result = %d, idnum = %d\n",result,idnum);
break;
case 3:
EAnalogIn(&idnum,demo,0,0,&overVoltage,&voltage);
fprintf(stdout,"voltage = %.2f\n",voltage);
break;
}
SetThreadPriority(GetCurrentThread,THREAD_PRIORITY _NORMAL);
}