Esempio n. 1
0
// get the current location of the table
McoStatus TCR::getLocation(int32 *position,int refrence)
{
char st[5000];

if (sp == 0L) return MCO_SERIAL_ERROR;

sprintf(st,"OA;");
sp->setDTR();
waitTenthSec();
sp->sendData(st,strlen(st));
waitTenthSec();
sp->getNextLine(st,5000,thermd);
sp->clearDTR();
sscanf(st,"%ld,%ld",&position[0],&position[1]);
return MCO_SUCCESS;
}
Esempio n. 2
0
// move a specifed distance in mm
McoStatus TCR::moveDistance(double dx,double dy)
{
char st[500];
int32 dx_i,dy_i;
int32 pos[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

getLocation(pos,0);

dx_i = (40*(dx)+0.5);
dy_i = (40*(dy)+0.5);

pos[0] += dx_i;
pos[1] += dy_i;

pos[0] = MaxVal(pos[0],min_x);
pos[0] = MinVal(pos[0],max_x);

pos[1] = MaxVal(pos[1],min_y);
pos[1] = MinVal(pos[1],max_y);

sprintf(st,"PA %ld %ld;",pos[0],pos[1]);

current_x = pos[0];
current_y = pos[1];

sp->sendData(st,strlen(st));
waitTenthSec();

return MCO_SUCCESS;
}
Esempio n. 3
0
TCR::TCR(int port_num,DeviceTypes device_type):
Techkon(port_num,device_type),Table()
{
char  st[255];

a = 40;
b = 0;
c = 0;
d = 40;

Tx = 400;

Ty = 11000;

if (sp == 0L) return;

sp->setlineend((char)0x0d);

sprintf(st,"PD;");

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

sprintf(st,"VS %ld;",10);

waitTenthSec();

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

sprintf(st,"PU;");

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

min_x = 400;
min_y = 712;

max_x = 15462;
max_y = 11880;

doPenDown = 1;

}
Esempio n. 4
0
Boolean Techkon::IsDataPresent(void)
{

int32	last_size;
int32	current_size;

// Just wait around until buffer gets large enough 
// and stabilizes

if (sp == 0L) return FALSE;

do {
	last_size = sp->numInChars();

	waitTenthSec();
	current_size = sp->numInChars();
	} while (last_size != current_size);

if (current_size < 1) return FALSE;
return TRUE;
}
Esempio n. 5
0
// move a specifed distance in mm
McoStatus SpectroChart::moveDistance(double dx,double dy)
{
char st[5000];
int32 dx_i,dy_i;
int	error;
McoStatus state;
int32 pos[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

getLocation(pos,1);

dx_i = (10*(dx)+0.5);
dy_i = (-10*(dy)+0.5);

pos[0] += dx_i;
pos[1] += dy_i;

pos[0] = MaxVal(pos[0],min_x);
pos[0] = MinVal(pos[0],max_x);

pos[1] = MaxVal(pos[1],min_y);
pos[1] = MinVal(pos[1],max_y);

// turn online
state = turnOnline();
if (state != MCO_SUCCESS) return state;

sprintf(st,"; 208 0 %ld %ld\r\n",pos[0],pos[1]);

sp->sendData(st,strlen(st));
waitTenthSec();
state = CheckErrorChart();

current_x = pos[0];
current_y = pos[1];
return state;
}
Esempio n. 6
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;
}