コード例 #1
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;
}
コード例 #2
0
McoStatus SpectroChart::getNextPatch(long patchnum,double *lab)
{
char j1[255],j2[255],j3[255];
char st[5000];
char *p;
int32	tc;
double xyz[3];
int32 X,Y,Z;
McoStatus status = MCO_SUCCESS;
int	code;
double t;
int 	i;

if (sp == 0L) return MCO_SERIAL_ERROR;

// do a calibration if 100 patches have been read so far
if (patchCount >= 100) status = Calibrate();
if (status != MCO_SUCCESS) return status;

// move to the patch
status = moveToPatch(patchnum,0);
if (status != MCO_SUCCESS) return status;

// send read command
status = sendReadCommand(st);
if (status != MCO_SUCCESS) return status;



if (mode == ReadLabMode)
	{
	// now read the data in
	sp->sendData("; 186 9 1\r\n",11);
	sp->getNextLine(st,5000,thermd);

	// check for an error
	sscanf_n_i(st,1,1,&code);
	if (code != 187) return MCO_FAILURE;
	
	// read in the data
	sscanf_n(st,2,3,lab);

	// check for an error again
	sscanf_n_i(st,6,1,&code);
	if (code != 0) return MCO_FAILURE;

	// now apply the tweak if it exist
	if (tweak != NULL) tweak->eval(lab,lab,1);
	}
else if (mode == ReadDensityMode)
	{
	// now read the data in
	sp->sendData("; 188 9\r\n",9);
	sp->getNextLine(st,5000,thermd);

	// check for an error
	sscanf_n_i(st,1,1,&code);
	if (code != 189) return MCO_FAILURE;
		
	// read in the black
	sscanf_n(st,1,4,lab);
	
	// check for an error again
	sscanf_n_i(st,6,1,&code);
	if (code != 0) return MCO_FAILURE;
	
	t = lab[0];
	lab[0] = lab[1];
	lab[1] = lab[2];
	lab[2] = lab[3];
	lab[3] = t;
	
	if (lab != paperDensity) for (i=0; i<4; i++)
		{
		lab[i] -= paperDensity[i];
		if (lab[i] < 0) lab[i] = 0;
		}

	
	}

patchCount++;



return MCO_SUCCESS;
}