Example #1
0
///
/// 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;
}
///
/// read back software version
/// to check communication with device
///
void HuberPetiteFleur::Device_Init( void ) {

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

  char buffer[1000];
  
  comHandler_->SendCommand( "CA?" );
  usleep( uDelay_ );

  comHandler_->ReceiveString( buffer );
  usleep( uDelay_ );
  StripBuffer( buffer );
  std::string temp(buffer);

  if (temp.compare(0, 2, "CA")!=0) {
    std::cerr << " [HuberPetiteFleur::Device_Init] ** ERROR: Device communication problem."
        << std::endl;
    isCommunication_ = false;
    return;
  }

  isCommunication_ = true;
}
///
/// return success flag
///
bool HuberPetiteFleur::SetCirculatorOn( void ) const {

  #ifdef __HUBERPETITEFLEUR_DEBUG
  std::cout << "[HuberPetiteFleur::SetCirculatorOn] -- DEBUG: Called." << std::endl;
  #endif

  char buffer[1000];
  
  usleep( uDelay_ );
  comHandler_->SendCommand( "CA@ +00001" );

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

  int status = ToInteger(buffer);

  if( status != 1 ) {
    std::cerr << " [HuberPetiteFleur::SetCirculatorOn] ** ERROR: check failed."
        << std::endl;
    std::cerr << "  > Expected: ON (1) but received (string):"
        << buffer << "." << std::endl;
    return false;
  }

  return true;
}
Example #4
0
bool LeyboldGraphixThree::ReceiveData(std::string& buffer) const
{
  char buf[1000];
  comHandler_->ReceiveString(buf);
  StripBuffer(buf);

  buffer = buf;

  bool isACK = false;

  if (buffer[0]==ACK) isACK = true;
  buffer.erase(0, 1);

  if (!isACK) {
    std::cout << "*** NACK *** " << buffer[0] << std::endl;
    return isACK;
  }

  size_t idxEOT = buffer.find(EOT);
  if (idxEOT==std::string::npos) {
    return false;
  }

  char crc = buffer[idxEOT-1];
  buffer.resize(idxEOT-1);

  // std::cout << " ->  |" << buffer << "|" << std::endl;

  return isACK;
}
Example #5
0
void KeyenceFake::ReceiveString(std::string & buffer)
{
  usleep(1000);

  char temp[1000];
  comHandler_->ReceiveString(buffer, temp, samplingRate_, averagingRate_);
  StripBuffer(buffer);
#ifdef KEYENCEDEBUG
  std::cout << "ReceiveCommand: " << buffer << std::endl;
#endif
}
Example #6
0
std::string CoriFlow::setTag( void ) const {

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

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( ":0A03027166056E696C7300" );//set tag to "nils"

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

  return buffer;
}
Example #7
0
std::string CoriFlow::setInit( void ) const {

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

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( ":050301000A40" ); //set to 64 -> write permission
  
  usleep( uDelay_ );
  comHandler_->ReceiveString( buffer );
  StripBuffer( buffer );

  return buffer;
}
Example #8
0
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);
}
Example #9
0
float CoriFlow::getCapacity( void ) const {

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

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( ":0603040141014D" );

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

  return ToFloat(buffer);
}
float HuberPetiteFleur::GetBathTemperature( void ) const {

  #ifdef __HUBERPETITEFLEUR_DEBUG
  std::cout << "[HuberPetiteFleur::GetBathTemperature] -- DEBUG: Called." << std::endl;
  #endif

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( "TI?" );

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

  return ToFloat(buffer);
}
Example #11
0
float CoriFlow::getMeasure( void ) const {

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

  char buffer[1000];

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

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

  return ToInt(buffer)*getCapacity()/32000/60/(getDensity()*0.001);
}
///
/// returns success flag
///
bool HuberPetiteFleur::SetWorkingTemperature( const float workingTemp ) const {

  #ifdef __HUBERPETITEFLEUR_DEBUG
  std::cout << "[HuberPetiteFleur::SetWorkingTemp] -- DEBUG: Called." << std::endl;
  #endif

  if( workingTemp > PetiteFleurUpperTempLimit || workingTemp < PetiteFleurLowerTempLimit ) {
    std::cerr << " [HuberPetiteFleur::SetWorkingTemp] ** ERROR: working temp T=" 
	      << workingTemp << " exceeds soft limits." << std::endl;
    std::cerr << "  > (s. HuberPetiteFleur class definition)" << std::endl;
    return false;
  }

  char buffer[1000];

  int iTemp = workingTemp * 100.;
  sprintf(buffer, "%+06d", iTemp);

  std::stringstream theCommand;
  theCommand << "SP@ " << buffer;

  comHandler_->SendCommand( theCommand.str().c_str() );
  usleep( uDelay_ );

  memset( buffer, 0, sizeof( buffer ) );
  comHandler_->ReceiveString( buffer );
  usleep( uDelay_ );
  StripBuffer( buffer );
  
  int oTemp = ToInteger( buffer );

  if( iTemp != oTemp ) {
    std::cerr << " [HuberPetiteFleur::SetWorkingTemp] ** ERROR: check failed."
        << std::endl;
    if ( strlen( buffer ) == 0 )
      std::cerr << "  > Got no reply. (timeout?)" << std::endl;
    else
      std::cerr << "  > Expected: T=" << workingTemp
          << " but received T=" << oTemp / 100 << std::endl;

    return false;
  }
  
  return true;
}
Example #13
0
std::string CoriFlow::setCapacity( void ) const {

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

  char buffer[1000];

  usleep( uDelay_ );
//   comHandler_->SendCommand( ":080301014D457A0000" ); //set to 4000 must set INIT first
  comHandler_->SendCommand( ":080301014D457A0000" ); //set to 4200 = 70 ml/min must set INIT first

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

  return buffer;
}
Example #14
0
float Hameg8143::GetSetVoltage(int channel) const
{
  if (channel==0 || channel>2) return -99;
  
  if (channel==1) {
    comHandler_->SendCommand("RU1");
  } else {
    comHandler_->SendCommand("RU2");
  }

  char buffer[1000];
  comHandler_->ReceiveString(buffer);
  StripBuffer(buffer);
  std::string buf = buffer;
  buf = buf.substr(buf.find(':')+1);
  buf = buf.substr(0, buf.find('V'));

  float voltage = std::atof(buf.c_str());
  return voltage;
}
Example #15
0
void Hameg8143::DeviceInit()
{
  isDeviceAvailable_ = false;

  if (comHandler_->DeviceAvailable()) {
    
    comHandler_->SendCommand("ID?");

    char buffer[1000];
    comHandler_->ReceiveString(buffer);
    StripBuffer(buffer);
    std::string buf = buffer;
    
    if (buf.find("HAMEG Instruments,HM8143", 0)==0) {
      isDeviceAvailable_ = true;
    } else {
      isDeviceAvailable_ = false;
    }
  }
}
Example #16
0
float Hameg8143::GetCurrent(int channel) const
{
  if (channel==0 || channel>2) return -99;
  
  if (channel==1) {
    comHandler_->SendCommand("MI1");
  } else {
    comHandler_->SendCommand("MI2");
  }

  char buffer[1000];
  comHandler_->ReceiveString(buffer);
  StripBuffer(buffer);
  std::string buf = buffer;
  buf = buf.substr(buf.find(':')+1);
  buf = buf.substr(0, buf.find('A'));

  float current = std::atof(buf.c_str());
  return current;
}
///
/// true = on / false = off
///
bool HuberPetiteFleur::GetCirculatorStatus( void ) const {

  #ifdef __HUBERPETITEFLEUR_DEBUG
  std::cout << "[HuberPetiteFleur::GetCirculatorStatus] -- DEBUG: Called." << std::endl;
  #endif

  char buffer[1000];

  usleep( uDelay_ );
  comHandler_->SendCommand( "CA?" );

  usleep( uDelay_ );
  comHandler_->ReceiveString( buffer );
  StripBuffer( buffer );
  int status = ToInteger(buffer);

  //std::cout << buffer << std::endl;

  if( status>0 ) return true;
  else return false;
}
Example #18
0
unsigned int Hameg8143::GetStatus() const
{
  comHandler_->SendCommand("STA");
  char buffer[1000];
  comHandler_->ReceiveString(buffer);
  StripBuffer(buffer);

  std::istringstream iss(buffer);
  std::string temp;
  unsigned int status = 0;
  while (iss >> temp) {
	  if (temp=="OP0") status |= hmOP0;
	  if (temp=="OP1") status |= hmOP1;
	  if (temp=="CV1") status |= hmCV1;
	  if (temp=="CC1") status |= hmCC1;
	  if (temp=="CV2") status |= hmCV2;
	  if (temp=="CC2") status |= hmCC2;
	  if (temp=="RM1") status |= hmRM1;
	  if (temp=="RM0") status |= hmRM0;
  }

  return status;
}