コード例 #1
0
ファイル: CoriFlow.cpp プロジェクト: DESY-FH-ELab/cmstkmodlab
///
/// read back software version
/// to check communication with device
///
void CoriFlow::Device_Init( void ) {

  #ifdef __CORIFLOW_DEBUG
  std::cout << "[CoriFlow::Device_Init] -- DEBUG: Called." << std::endl;
  #endif

  char buffer[1000];
  
  comHandler_->SendCommand( ":0703047161716610" );
  usleep( uDelay_ );

  comHandler_->ReceiveString( buffer );

  usleep( uDelay_ );
  StripBuffer( buffer );
  std::string temp = ToUnit(buffer);
//   std::cout<<"status = "<<temp<<std::endl;
  
  if (!temp.compare("nils")) {
    std::cerr << " [CoriFlow::Device_Init] ** ERROR: Device communication problem." << std::endl;
    isCommunication_ = false;
    return;
  }

  isCommunication_ = true;
}
コード例 #2
0
//旋转卡壳求包围点的最小面积(周长)的矩形,p是凸包,n是凸包点数
pair<Type,Type> Rotating_Calipers(Point *p,int n){
	p[n] = p[0];
	Type min_area = 1e99,min_c = 1e99;//最小的矩形面积和矩形周长
	int l = 1,r = 1,u = 1;
	for(int i = 0;i<n;i++){
		Vector v = ToUnit(p[i+1]-p[i]);
		while(sign(Dot(v,p[r%n]-p[i])-Dot(v,p[(r+1)%n]-p[i]))<0) r++;
		while(u<r||sign(Cross(v,p[u%n]-p[i])-Cross(v,p[(u+1)%n]-p[i]))<0) u++;
		while(l<u||sign(Dot(v,p[l%n]-p[i])-Dot(v,p[(l+1)%n]-p[i]))>0) l++;
		Type w = Dot(v,p[r%n]-p[i])-Dot(v,p[l%n]-p[i]);
		Type h = DistanceToLine(p[u%n],Line(p[i],p[i+1]));
		min_area = min(min_area,w*h);
		min_c = min(min_c,2*(w+h));
	}
	return MP(min_area,min_c);
}
コード例 #3
0
ファイル: CoriFlow.cpp プロジェクト: DESY-FH-ELab/cmstkmodlab
std::string CoriFlow::getTag( void ) const {

  #ifdef __CORIFLOW_DEBUG
  std::cout << "[CoriFlow::test] -- DEBUG: Called." << std::endl;
  #endif

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( ":0703047161716610" );

  usleep( uDelay_ );
  comHandler_->ReceiveString( buffer );
  StripBuffer( buffer );

  return ToUnit(buffer);
}