Exemplo n.º 1
0
/*
 * Requests movement to new z postion from the controller.  This function does the actual communication
 */
int RAMPSZStage::SetPositionSteps(long steps)
{
  RAMPSHub* pHub = static_cast<RAMPSHub*>(GetParentHub());
  if (pHub->Busy()) {
      return ERR_STAGE_MOVING;
  }

  posZ_um_ = steps * stepSize_um_;

  char buff[100];
  sprintf(buff, "G0 Z%f", posZ_um_/1000.);
  std::string buffAsStdStr = buff;
  int ret = pHub->SendCommand(buffAsStdStr);
  if (ret != DEVICE_OK)
    return ret;

  
  std::string answer;
  ret = pHub->ReadResponse(answer, 1000);
  if (ret != DEVICE_OK) {
	  LogMessage("Error sending Z move.");
	  return ret;
  }
  if (answer != "ok") {
	  LogMessage("Failed to get ok response to Z move.");
  }
  ret = OnStagePositionChanged(posZ_um_);
  if (ret != DEVICE_OK)
    return ret;

  return DEVICE_OK;
}
Exemplo n.º 2
0
bool RAMPSZStage::Busy()
{
  RAMPSHub* pHub = static_cast<RAMPSHub*>(GetParentHub());

  return pHub->Busy();
}