int ASIFW1000Hub::FilterWheelBusy(MM::Device& device, MM::Core& core, bool& busy)
{ 
   ClearAllRcvBuf(device, core);
   int ret = core.SetSerialCommand(&device, port_.c_str(), "?", "");
   if (ret != DEVICE_OK)                                                     
      return ret;                                                           

   unsigned long read = 0;
   MM::MMTime startTime = core.GetCurrentMMTime();
   while (read == 0 && ( (core.GetCurrentMMTime() - startTime) < 10000))
      ret = core.ReadFromSerial(&device, port_.c_str(), (unsigned char*)rcvBuf_, 1, read);  
   if (ret != DEVICE_OK)                                                     
      return ret;                                                           

   if (read != 1) {
      printf (" FilterWheel received no answer!\n");
      return ERR_NO_ANSWER;
   }

   if (rcvBuf_[0] == '0' || rcvBuf_[0] == '1' || rcvBuf_[0] =='2')
      busy = false;
   else
   if (rcvBuf_[0] == '3')
      busy = true;

   return DEVICE_OK;
}
Exemple #2
0
int ASIFW1000Hub::FilterWheelBusy(MM::Device& device, MM::Core& core, bool& busy)
{ 
   busy = false;
   ClearAllRcvBuf(device, core);
   int ret = core.SetSerialCommand(&device, port_.c_str(), "?", "");
   if (ret != DEVICE_OK) {
      std::ostringstream os;
      os << "ERROR: SetSerialCommand returned error code: " << ret;
      core.LogMessage(&device, os.str().c_str(), false);
      return ret;
   }

   unsigned long read = 0;
   MM::TimeoutMs timerOut(core.GetCurrentMMTime(), 200 );
   while (read == 0 && ( !timerOut.expired(core.GetCurrentMMTime()) ) )
   {
      ret = core.ReadFromSerial(&device, port_.c_str(), (unsigned char*)rcvBuf_, 1, read);  
   }

   if (ret != DEVICE_OK) {
      std::ostringstream os;
      os << "ERROR: ReadFromSerial returned error code: " << ret;
      core.LogMessage(&device, os.str().c_str(), false);
      return ret;
   }

   if (read != 1) {
      std::ostringstream os;
      os << "ERROR: Read " << read << " characters instead of 1";
      core.LogMessage(&device, os.str().c_str(), false);
      return ERR_NO_ANSWER;
   }

   if (rcvBuf_[0] == '0' || rcvBuf_[0] == '1' || rcvBuf_[0] =='2')
      busy = false;
   else if (rcvBuf_[0] == '3')
      busy = true;

   return DEVICE_OK;
}