Beispiel #1
0
McoStatus SpectroChart::moveToPatch(int32 patchNum,int ref)
{
char st[500];
int32 dx_i,dy_i;
double dist;
int tc;
int waitTime;
int32	table[2];
int error;
McoStatus state;

if (sp == 0L) return MCO_SERIAL_ERROR;

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

translateToTable(&pointArray[patchNum*2],table);

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

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

sprintf(st,"; 208 0 %d %ld %ld\r\n",ref,(long)table[0],(long)table[1]);

dx_i = table[0]-current_x;
dy_i = table[1]-current_y;


sp->sendData(st,strlen(st));
state = CheckErrorChart();
return state;
}
Beispiel #2
0
McoStatus TCR::moveToPatch(int32 patchNum, int ref)
{
char st[500];
int32 dx_i,dy_i;
double dist;
long tc;
int waitTime;
int32	table[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

translateToTable(&pointArray[patchNum*2],table);

//dx_i = table[0]-current_x;
//dy_i = table[1]-current_y;

//sprintf(st,"PR %ld %ld;",dx_i,dy_i);	// the move command

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

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

sprintf(st,"PA %ld %ld;",(long)table[0],(long)table[1]);	// the move command

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


dx_i = table[0]-current_x;
dy_i = table[1]-current_y;

// wait a time that is determined by the distance moved
dist = sqrt((double)(dx_i*dx_i+dy_i*dy_i))*0.025;

// assume that it moves 250mm/sec

waitTime = 36+(int)(60.0*dist/150.0);

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

//current_x = pointArray[patchNum*2];
//current_y = pointArray[patchNum*2+1];

current_x += dx_i;
current_y += dy_i;

return MCO_SUCCESS;
}