Exemple #1
0
McoStatus Techkon::getNextPatch(double *lab)
{
char j1[255],j2[255],j3[255];
unsigned char st[5000];
char *p;
int32	tc;
double xyz[3];
int32 X,Y,Z;

if (sp == 0L) return MCO_SERIAL_ERROR;

// get the 18 byte packet of info
sp->getData(st,18,tc);
// check length
if (tc != 18) 
	{
	sp->clearInputBuf();
	return MCO_FAILURE;
	}

// do some checking
if (st[0] != 0xAA)
	{
	sp->clearInputBuf();
	return MCO_FAILURE;
	}


//get the xyz values
X = ((char)st[10]<<8)+st[11];
Y = ((char)st[12]<<8)+st[13];
Z = ((char)st[14]<<8)+st[15];


xyz[0] = (double)X/100.0;
xyz[1] = (double)Y/100.0;
xyz[2] = (double)Z/100.0;

// convert to lab for 5000K

translatetoLab(xyz,lab);


return MCO_SUCCESS;
}
Exemple #2
0
McoStatus TCR::getNextPatch(long patchnum,double *lab)
{
char j1[255],j2[255],j3[255];
unsigned char st[5000];
char *p;
int32	tc;
double xyz[3];
int32 X,Y,Z;
int i,j;

if (sp == 0L) return MCO_SERIAL_ERROR;

sp->clearInputBuf();

if (doPenDown)
	{
	sprintf(j1,"PU;");

	sp->sendData(j1,strlen(j1));
	}
else
	{
	sprintf(j1,"PD;");
	sp->sendData(j1,strlen(j1));
	}

// move to the patch
moveToPatch(patchnum,0);


if (doPenDown)
	{
	sprintf(j1,"PD;");

	sp->sendData(j1,strlen(j1));

	tc = TickCount();
	while (TickCount() - tc < 10) {}
	}

for (j=0; j<3; j++)
	{
	// send read command
	sendReadCommand();

	// get the 18 byte packet of info
	for (i=0; i<2; i++)
		{
		sp->getData(st,18,tc);
		if (tc) break;
		waitTenthSec();
		}
	if (tc) break;
	waitTenthSec();
	}
// check length
if (tc != 18) return MCO_FAILURE;

// do some checking
if (st[0] != 0xAA) return MCO_FAILURE;

//get the xyz values
X = ((char)st[10]<<8)+st[11];
Y = ((char)st[12]<<8)+st[13];
Z = ((char)st[14]<<8)+st[15];


xyz[0] = (double)X/100.0;
xyz[1] = (double)Y/100.0;
xyz[2] = (double)Z/100.0;

// convert to lab for 5000K

translatetoLab(xyz,lab);


return MCO_SUCCESS;
}