Exemplo n.º 1
0
void IndiGui::SetCheckboxEvent(wxCommandEvent & event)
{
    wxString b_name;
    int i;
    wxCheckBox *button = (wxCheckBox *)event.GetEventObject();
    if (! button) return;
    IndiProp *indiProp = (IndiProp *) button->GetClientData();
    if (! indiProp) return;
    ISwitchVectorProperty *svp = indiProp->property->getSwitch();
    ptrHash::iterator it;
    for( it = indiProp->ctrl.begin(); it !=indiProp->ctrl.end(); ++it )
    {
       wxString key = it->first;
       wxCheckBox *value = (wxCheckBox *) it->second;
       if (value == button) {
	  b_name = key;
	  break;
       }
    }
    for (i=0; i<svp->nsp; i++){
       if (svp->sp[i].name == b_name) {
	  svp->sp[i].s = button->GetValue() ? ISS_ON : ISS_OFF;
	  break;
       }
    }
    sendNewSwitch(svp);
}
Exemplo n.º 2
0
void INDI::BaseClientQt::setDriverConnection(bool status, const char * deviceName)
{
    INDI::BaseDevice * drv = getDevice(deviceName);
    ISwitchVectorProperty * drv_connection = NULL;

    if (drv == NULL)
    {
        IDLog("INDI::BaseClientQt: Error. Unable to find driver %s\n", deviceName);
        return;
    }

    drv_connection = drv->getSwitch("CONNECTION");

    if (drv_connection == NULL)
        return;

    // If we need to connect
    if (status)
    {
        // If there is no need to do anything, i.e. already connected.
        if (drv_connection->sp[0].s == ISS_ON)
            return;

        IUResetSwitch(drv_connection);
        drv_connection->s = IPS_BUSY;
        drv_connection->sp[0].s = ISS_ON;
        drv_connection->sp[1].s = ISS_OFF;

        sendNewSwitch(drv_connection);
    }
    else
    {
        // If there is no need to do anything, i.e. already disconnected.
        if (drv_connection->sp[1].s == ISS_ON)
            return;

        IUResetSwitch(drv_connection);
        drv_connection->s = IPS_BUSY;
        drv_connection->sp[0].s = ISS_OFF;
        drv_connection->sp[1].s = ISS_ON;

        sendNewSwitch(drv_connection);

    }
}
Exemplo n.º 3
0
bool   ScopeINDI::SlewToCoordinates(double ra, double dec)
{
    bool err = true;
    if (coord_prop && oncoordset_prop) {
	setslew_prop->s = ISS_ON;
	settrack_prop->s = ISS_OFF;
	setsync_prop->s = ISS_OFF;
	sendNewSwitch(oncoordset_prop);
	INumber *raprop = IUFindNumber(coord_prop,"RA");
	INumber *decprop = IUFindNumber(coord_prop,"DEC");
	raprop->value = ra;
	decprop->value = dec;
	sendNewNumber(coord_prop);
	err = false;
    }
    return err;
}
Exemplo n.º 4
0
void IndiGui::SetToggleButtonEvent(wxCommandEvent & event)
{
   wxString b_name;
   int i;
   wxToggleButton *button = (wxToggleButton *)event.GetEventObject();
   if (! button) return;
   IndiProp *indiProp = (IndiProp *) button->GetClientData();
   if (! indiProp) return;
   ISwitchVectorProperty *svp = indiProp->property->getSwitch();

   if (!allow_connect_disconnect && strcmp(svp->name,"CONNECTION")==0) {
      // Prevent device disconnection from this window.
      // Use Gear manager instead.
      return;
   }
      
   ptrHash::iterator it;
   for( it = indiProp->ctrl.begin(); it !=indiProp->ctrl.end(); ++it )
   {
      wxString key = it->first;
      wxToggleButton *value = (wxToggleButton *) it->second;
      if (value == button) {
	 b_name = key;
	 break;
      }
   }
   if (svp->r == ISR_1OFMANY){
      for (i=0; i<svp->nsp; i++){
	 if (svp->sp[i].name == b_name) {
	    svp->sp[i].s = ISS_ON;
	 }
	 else {
	    svp->sp[i].s = ISS_OFF;
	 }
      }
   }
   else {
      for (i=0; i<svp->nsp; i++){
	 if (svp->sp[i].name == b_name) {
	    svp->sp[i].s = button->GetValue() ? ISS_ON : ISS_OFF;
	    break;
	 }
      }
   }
   sendNewSwitch(svp);
}
Exemplo n.º 5
0
void IndiGui::SetComboboxEvent(wxCommandEvent & event)
{
    int i;
    wxChoice *combo = (wxChoice *)event.GetEventObject();
    if (! combo) return;
    IndiProp *indiProp = (IndiProp *) combo->GetClientData();
    if (! indiProp) return;
    ISwitchVectorProperty *svp = indiProp->property->getSwitch();
    int choice = combo->GetSelection();
    for (i=0; i<svp->nsp; i++){
       if (i == choice) {
	  svp->sp[i].s = ISS_ON;
       }
       else {
	  svp->sp[i].s = ISS_OFF;
       }
    }
    sendNewSwitch(svp);
}
Exemplo n.º 6
0
void INDI::BaseClientQt::sendNewSwitch (const char * deviceName, const char * propertyName, const char * elementName)
{
    INDI::BaseDevice * drv = getDevice(deviceName);

    if (drv == NULL)
        return;

    ISwitchVectorProperty * svp = drv->getSwitch(propertyName);

    if (svp == NULL)
        return;

    ISwitch * sp = IUFindSwitch(svp, elementName);

    if (sp == NULL)
        return;

    sp->s = ISS_ON;

    sendNewSwitch(svp);

}
Exemplo n.º 7
0
Mount::MOVE_RESULT ScopeINDI::Guide(GUIDE_DIRECTION direction, int duration) 
{
  // guide using timed pulse guide 
    if (pulseGuideNS_prop && pulseGuideEW_prop) {
    // despite what is said in INDI standard properties description, every telescope driver expect the guided time in msec.
    switch (direction) {
        case EAST:
	    pulseE_prop->value = duration;
	    pulseW_prop->value = 0;
	    sendNewNumber(pulseGuideEW_prop);
            break;
        case WEST:
	    pulseE_prop->value = 0;
	    pulseW_prop->value = duration;
	    sendNewNumber(pulseGuideEW_prop);
            break;
        case NORTH:
	    pulseN_prop->value = duration;
	    pulseS_prop->value = 0;
	    sendNewNumber(pulseGuideNS_prop);
            break;
        case SOUTH:
	    pulseN_prop->value = 0;
	    pulseS_prop->value = duration;
	    sendNewNumber(pulseGuideNS_prop);
            break;
        case NONE:
	    printf("error ScopeINDI::Guide NONE\n");
            break;
    }
    wxMilliSleep(duration);
    return MOVE_OK;
  }
  // guide using motion rate and telescope motion
  // !!! untested as no driver implement TELESCOPE_MOTION_RATE at the moment (INDI 0.9.9) !!!
  else if (MotionRate_prop && moveNS_prop && moveEW_prop) {
      MotionRate_prop->np->value = 0.3 * 15 / 60;  // set 0.3 sidereal in arcmin/sec
      sendNewNumber(MotionRate_prop);
      switch (direction) {
	  case EAST:
	      moveW_prop->s = ISS_OFF;
	      moveE_prop->s = ISS_ON;
	      sendNewSwitch(moveEW_prop);
	      wxMilliSleep(duration);
	      moveW_prop->s = ISS_OFF;
	      moveE_prop->s = ISS_OFF;
	      sendNewSwitch(moveEW_prop);
	      break;
	  case WEST:
	      moveW_prop->s = ISS_ON;
	      moveE_prop->s = ISS_OFF;
	      sendNewSwitch(moveEW_prop);
	      wxMilliSleep(duration);
	      moveW_prop->s = ISS_OFF;
	      moveE_prop->s = ISS_OFF;
	      sendNewSwitch(moveEW_prop);
	      break;
	  case NORTH:
	      moveN_prop->s = ISS_ON;
	      moveS_prop->s = ISS_OFF;
	      sendNewSwitch(moveNS_prop);
	      wxMilliSleep(duration);
	      moveN_prop->s = ISS_OFF;
	      moveS_prop->s = ISS_OFF;
	      sendNewSwitch(moveNS_prop);
	      break;
	  case SOUTH:
	      moveN_prop->s = ISS_OFF;
	      moveS_prop->s = ISS_ON;
	      sendNewSwitch(moveNS_prop);
	      wxMilliSleep(duration);
	      moveN_prop->s = ISS_OFF;
	      moveS_prop->s = ISS_OFF;
	      sendNewSwitch(moveNS_prop);
	      break;
	  case NONE:
	      printf("error ScopeINDI::Guide NONE\n");
	      break;
      }
      return MOVE_OK;
  }    
  else return MOVE_ERROR;
}
Exemplo n.º 8
0
bool Camera_INDIClass::Capture(int duration, usImage& img, int options, const wxRect& subframeArg)
{
    if (Connected) {

        bool takeSubframe = UseSubframes;
        wxRect subframe(subframeArg);

        // we can set the exposure time directly in the camera
        if (expose_prop) {
            if (Binning != m_curBinning)
            {
                FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
                binning_x->value = Binning;
                binning_y->value = Binning;
                sendNewNumber(binning_prop);
                m_curBinning = Binning;
            }

            if (subframe.width <= 0 || subframe.height <= 0)
            {
                takeSubframe = false;
            }

            // Program the size
            if (!takeSubframe)
            {
                subframe = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight());
            }

            if (subframe != m_roi)
            {
                frame_x->value = subframe.x*Binning;
                frame_y->value = subframe.y*Binning;
                frame_width->value = subframe.width*Binning;
                frame_height->value = subframe.height*Binning;
                sendNewNumber(frame_prop);
                m_roi = subframe;
            }
            //printf("Exposing for %d(ms)\n", duration);

            // set the exposure time, this immediately start the exposure
            expose_prop->np->value = (double)duration/1000;
            sendNewNumber(expose_prop);

            modal = true;  // will be reset when the image blob is received

            unsigned long loopwait = duration > 100 ? 10 : 1;

            CameraWatchdog watchdog(duration, GetTimeoutMs());

            while (modal) {
                wxMilliSleep(loopwait);
                if (WorkerThread::TerminateRequested())
                    return true;
                if (watchdog.Expired())
                {
                    DisconnectWithAlert(CAPT_FAIL_TIMEOUT);
                    return true;
                }
            }
        }
        // for video camera without exposure time setting
        else if (video_prop) {
            takeSubframe = false;
            //printf("Enabling video capture\n");
            ISwitch *v_on = IUFindSwitch(video_prop,"ON");
            ISwitch *v_off = IUFindSwitch(video_prop,"OFF");
            v_on->s = ISS_ON;
            v_off->s = ISS_OFF;
            // start capture, every video frame is received as a blob
            sendNewSwitch(video_prop);

            // wait the required time
            wxMilliSleep(duration); // TODO : add the frames received during exposure

            //printf("Stop video capture\n");
            v_on->s = ISS_OFF;
            v_off->s = ISS_ON;
            sendNewSwitch(video_prop);
        }
        else {
            return true;
        }

        //printf("Exposure end\n");

        if (strcmp(cam_bp->format, ".fits") == 0) {
            //printf("Processing fits file\n");
            // for CCD camera
            if ( ! ReadFITS(img,takeSubframe,subframe) ) {
                if (options & CAPTURE_SUBTRACT_DARK) {
                    //printf("Subtracting dark\n");
                    SubtractDark(img);
                }
                if (options & CAPTURE_RECON) {
                    if (PixSizeX != PixSizeY) SquarePixels(img, PixSizeX, PixSizeY);
                }
                return false;
            } else {
                return true;
            }
        } else if (strcmp(cam_bp->format, ".stream") == 0) {
            //printf("Processing stream file\n");
            // for video camera
            return ReadStream(img);
        } else {
            pFrame->Alert(_("Unknown image format: ") + wxString::FromAscii(cam_bp->format));
            return true;
        }

    }
    else {
        // in case the camera is not connected
        return true;
    }
    // we must never go here
    return true;
}