Ejemplo n.º 1
0
bool ioptronHC8406::updateLocation(double latitude, double longitude, double elevation)
{
    INDI_UNUSED(elevation);

    if (isSimulation())
        return true;

    double final_longitude;

    if (longitude > 180)
        final_longitude = longitude - 360.0;
    else
        final_longitude = longitude;

    if (!isSimulation() && setioptronHC8406Longitude(final_longitude) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting site longitude coordinates");
        return false;
    }

    if (!isSimulation() && setioptronHC8406Latitude(latitude) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting site latitude coordinates");
        return false;
    }

    char l[32], L[32];
    fs_sexa(l, latitude, 3, 3600);
    fs_sexa(L, longitude, 4, 3600);

    IDMessage(getDeviceName(), "Site location updated to Lat %.32s - Long %.32s", l, L);

    return true;
}
Ejemplo n.º 2
0
bool LX200SS2000PC::updateTime(ln_date * utc, double utc_offset) {
  bool result = true;
  // This method is largely identical to the one in the LX200Generic class.
  // The difference is that it ensures that updates that require planetary
  // data to be recomputed by the SkySensor2000PC are only done when really
  // necessary because this takes quite some time.
  if (!isSimulation()) {
    result = false;
    struct ln_zonedate ltm;
    ln_date_to_zonedate(utc, &ltm, static_cast<long>(utc_offset*3600.0+0.5));
    DEBUGF(INDI::Logger::DBG_DEBUG, "New zonetime is %04d-%02d-%02d %02d:%02d:%06.3f (offset=%ld)", ltm.years, ltm.months, ltm.days, ltm.hours, ltm.minutes, ltm.seconds, ltm.gmtoff);
    JD = ln_get_julian_day(utc);
    DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %f", JD);
    if (setLocalTime(PortFD, ltm.hours, ltm.minutes, static_cast<int>(ltm.seconds+0.5)) < 0) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time.");
    }
    else if (!setCalenderDate(ltm.years, ltm.months, ltm.days)) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date.");
    }
    // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which
    // is the opposite of the standard definition of UTC offset!
    else if (!setUTCOffset(-static_cast<int>(utc_offset))) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
    }
    else {
      DEBUG(INDI::Logger::DBG_SESSION, "Time updated.");
      result = true;
    }
  }
  return result;
}
Ejemplo n.º 3
0
Archivo: tcfs.cpp Proyecto: djibb/indi
bool TCFS::Handshake()
{
LOGF_DEBUG("%s %s",__FUNCTION__, me);
    if (isSimulation())
    {
        LOG_INFO("TCF-S: Simulating connection.");
        currentPosition = simulated_position;
        return true;
    }
    char response[TCFS_MAX_CMD] = { 0 };
    if(SetManualMode())
    {
            dispatch_command(FWAKUP);
            read_tcfs(response);        
            tcflush(PortFD, TCIOFLUSH);
            LOG_INFO("Successfully connected to TCF-S Focuser in Manual Mode.");

            // Enable temperature readout
            FocusTemperatureNP.s = IPS_OK;

            return true;
    }
    tcflush(PortFD, TCIOFLUSH);
    LOG_ERROR("Failed connection to TCF-S Focuser.");
    return false;
}
Ejemplo n.º 4
0
Archivo: tcfs.cpp Proyecto: djibb/indi
bool TCFS::read_tcfs(char *response, bool silent)
{
    int err_code = 0, nbytes_read = 0;
    char err_msg[TCFS_ERROR_BUFFER];

    if (isSimulation())
    {
        strncpy(response, "SIMULATION", TCFS_MAX_CMD);
        return true;
    }

    // Read until encountring a CR
    if ((err_code = tty_read_section(PortFD, response, 0x0D, 2, &nbytes_read)) != TTY_OK)
    {
        if (!silent)
        {
            tty_error_msg(err_code, err_msg, 32);
            LOGF_ERROR("TTY error detected: %s", err_msg);
        }

        return false;
    }

    // Remove LF & CR
    response[nbytes_read - 2] = '\0';

    LOGF_DEBUG("RES <%s>", response);

    return true;
}
Ejemplo n.º 5
0
int RoboFocus::updateRFPositionAbsolute(double value)
{

    char rf_cmd[32] ;
    int robofocus_rc ;

    DEBUGF(INDI::Logger::DBG_DEBUG, "Moving Absolute Position: %g", value);

    if (isSimulation())
    {
        simulatedPosition = value;
        return 0;
    }

    rf_cmd[0]= 0 ;

    if(value > 9999) {
        sprintf( rf_cmd, "FG0%5d", (int) value) ;
    } else if(value > 999) {
        sprintf( rf_cmd, "FG00%4d", (int) value) ;
    } else if(value > 99) {
        sprintf( rf_cmd, "FG000%3d", (int) value) ;
    } else if(value > 9) {
        sprintf( rf_cmd, "FG0000%2d", (int) value) ;
    } else {
        sprintf( rf_cmd, "FG00000%1d", (int) value) ;
    }

    if ((robofocus_rc= SendCommand( rf_cmd)) < 0)
        return robofocus_rc;

    return 0;
}
Ejemplo n.º 6
0
int RoboFocus::updateRFPositionRelativeOutward(double value)
{

    char rf_cmd[32] ;
    int robofocus_rc ;
    //float temp ;

    DEBUGF(INDI::Logger::DBG_DEBUG, "Update Relative Position Outward: %g", value);

    if (isSimulation())
    {
        simulatedPosition-= value;
        //value = simulatedPosition;
        return 0;
    }

    rf_cmd[0]= 0 ;

    if(value > 9999) {
        sprintf( rf_cmd, "FO0%5d", (int) value) ;
    } else if(value > 999) {
        sprintf( rf_cmd, "FO00%4d", (int) value) ;
    } else if(value > 99) {
        sprintf( rf_cmd, "FO000%3d", (int) value) ;
    } else if(value > 9) {
        sprintf( rf_cmd, "FO0000%2d", (int) value) ;
    } else {
        sprintf( rf_cmd, "FO00000%1d", (int) value) ;
    }

    if ((robofocus_rc= SendCommand( rf_cmd)) < 0)
        return robofocus_rc;

    return 0;
}
Ejemplo n.º 7
0
int RoboFocus::updateRFTemperature(double *value)
{
    DEBUGF(INDI::Logger::DBG_DEBUG, "Update Temperature: %g", value);

    float temp ;
    char rf_cmd[32] ;
    int robofocus_rc ;

    strcpy(rf_cmd, "FT000000" ) ;

    if ((robofocus_rc= SendCommand( rf_cmd)) < 0)
        return robofocus_rc;

    if (isSimulation())
        snprintf(rf_cmd, 32, "FT%6g", simulatedTemperature);
    else  if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
            return robofocus_rc;

    if (sscanf(rf_cmd, "FT%6f", &temp) < 1)
        return -1;

    *value = (double) temp/2.- 273.15;

    return 0;
}
Ejemplo n.º 8
0
bool ioptronHC8406::updateTime(ln_date *utc, double utc_offset)
{
    struct ln_zonedate ltm;

    if (isSimulation())
        return true;

    ln_date_to_zonedate(utc, &ltm, utc_offset * 3600.0);

    JD = ln_get_julian_day(utc);

    DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %.2f", JD);

    // Set Local Time
    if (setLocalTime(PortFD, ltm.hours, ltm.minutes, ltm.seconds) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time.");
        return false;
    }

    if (setCalenderDate(PortFD, ltm.days, ltm.months, ltm.years) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date.");
        return false;
    }

    if (setioptronHC8406UTCOffset(utc_offset) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
        return false;
    }

    return true;
}
Ejemplo n.º 9
0
int RoboFocus::SendCommand(char *rf_cmd)
{
    int nbytes_written=0, nbytes_read=0, check_ret=0, err_code=0;
    char rf_cmd_cks[32],robofocus_error[MAXRBUF];

    unsigned char val= 0 ;

    val = CalculateSum( rf_cmd );

    for(int i=0; i < 8; i++)
        rf_cmd_cks[i]= rf_cmd[i] ;

    rf_cmd_cks[8]=  (unsigned char) val ;
    rf_cmd_cks[9]= 0 ;

    if (isSimulation())
        return 0;

    tcflush(PortFD, TCIOFLUSH);

    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%#02X %#02X %#02X %#02X %#02X %#02X %#02X %#02X %#02X)", rf_cmd_cks[0], rf_cmd_cks[1], rf_cmd_cks[2], rf_cmd_cks[3], rf_cmd_cks[4], rf_cmd_cks[5], rf_cmd_cks[6], rf_cmd_cks[7], rf_cmd_cks[8]);

    if  ( (err_code = tty_write(PortFD, rf_cmd_cks, RF_MAX_CMD, &nbytes_written) != TTY_OK))
    {
        tty_error_msg(err_code, robofocus_error, MAXRBUF);
        DEBUGF(INDI::Logger::DBG_ERROR, "TTY error detected: %s", robofocus_error);
        return -1;
    }

    return nbytes_written;
}
Ejemplo n.º 10
0
bool SestoSenso::isCommandOK(const char *cmd)
{
    int nbytes_read = 0, rc = -1;
    char errstr[MAXRBUF], resp[16];

    char expectedResp[16];
    snprintf(expectedResp, 16, "%sok!", cmd);

    if (isSimulation())
    {
        strncpy(resp, expectedResp, 16);
        nbytes_read = strlen(resp)+1;
    }
    else
    {
        if ((rc = tty_read_section(PortFD, resp, 0xD, SESTOSENSO_TIMEOUT, &nbytes_read)) != TTY_OK)
        {
            tty_error_msg(rc, errstr, MAXRBUF);
            DEBUGF(INDI::Logger::DBG_ERROR, "%s error for command %s: %s.", __FUNCTION__, cmd, errstr);
            return false;
        }
    }

    resp[nbytes_read-1] = '\0';

    DEBUGF(INDI::Logger::DBG_DEBUG, "RES <%s>", resp);

    return (!strcmp(resp, expectedResp));
}
Ejemplo n.º 11
0
IPState SestoSenso::MoveAbsFocuser(uint32_t targetTicks)
{
    targetPos = targetTicks;

    int nbytes_written = 0, rc = -1;
    char errstr[MAXRBUF];
    char cmd[16]={0};

    snprintf(cmd, 16, "#GT%d!", targetTicks);
    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD <%s>", cmd);

    if (isSimulation() == false)
    {
        if ((rc = tty_write(PortFD, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)
        {
            tty_error_msg(rc, errstr, MAXRBUF);
            DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", __FUNCTION__, errstr);
            return IPS_ALERT;
        }
    }

    return IPS_BUSY;

    /*if (isCommandOK("GT"))
    {
        FocusAbsPosNP.s = IPS_BUSY;
        return IPS_BUSY;
    }

    return IPS_ALERT;
    */
}
Ejemplo n.º 12
0
bool SestoSenso::sync(uint32_t newPosition)
{
    int nbytes_written = 0, rc = -1;
    char errstr[MAXRBUF];
    char cmd[16]={0};

    snprintf(cmd, 16, "#SP%d!", newPosition);

    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD <%s>", cmd);

    if (isSimulation())
    {
        FocusAbsPosN[0].value = newPosition;
    }
    else
    {
        tcflush(PortFD, TCIOFLUSH);

        // Sync
        if ((rc = tty_write(PortFD, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)
        {
            tty_error_msg(rc, errstr, MAXRBUF);
            DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", __FUNCTION__, errstr);
            return false;
        }
    }

    return isCommandOK("SP");
}
Ejemplo n.º 13
0
bool FlipFlat::getBrightness()
{
    if (isSimulation())
    {
        return true;
    }

    char response[FLAT_RES]={0};
    if (!sendCommand(">J000", response))
        return false;

    char brightnessString[4] = { 0 };
    snprintf(brightnessString, 4, "%s", response + 4);

    int brightnessValue = 0;
    int rc              = sscanf(brightnessString, "%d", &brightnessValue);

    if (rc <= 0)
    {
        LOGF_ERROR("Unable to parse brightness value (%s)", response);
        return false;
    }

    if (brightnessValue != prevBrightness)
    {
        prevBrightness           = brightnessValue;
        LightIntensityN[0].value = brightnessValue;
        IDSetNumber(&LightIntensityNP, nullptr);
    }

    return true;
}
Ejemplo n.º 14
0
bool FlipFlat::EnableLightBox(bool enable)
{
    char command[FLAT_CMD];
    char response[FLAT_RES];

    if (isFlipFlat && ParkCapS[1].s == ISS_ON)
    {
        LOG_ERROR("Cannot control light while cap is unparked.");
        return false;
    }

    if (isSimulation())
        return true;

    if (enable)
        strncpy(command, ">L000", FLAT_CMD);
    else
        strncpy(command, ">D000", FLAT_CMD);

    if (!sendCommand(command, response))
        return false;

    char expectedResponse[FLAT_RES];
    if (enable)
        snprintf(expectedResponse, FLAT_RES, "*L%02d000", productID);
    else
        snprintf(expectedResponse, FLAT_RES, "*D%02d000", productID);

    if (strcmp(response, expectedResponse) == 0)
        return true;

    return false;
}
Ejemplo n.º 15
0
IPState FlipFlat::UnParkCap()
{
    if (isSimulation())
    {
        simulationWorkCounter = 3;
        return IPS_BUSY;
    }

    char response[FLAT_RES];
    if (!sendCommand(">O000", response))
        return IPS_ALERT;

    char expectedResponse[FLAT_RES];
    snprintf(expectedResponse, FLAT_RES, "*O%02d000", productID);

    if (strcmp(response, expectedResponse) == 0)
    {
        // Set cover status to random value outside of range to force it to refresh
        prevCoverStatus = 10;

        IERmTimer(unparkTimeoutID);
        unparkTimeoutID = IEAddTimer(30000, unparkTimeoutHelper, this);

        return IPS_BUSY;
    }
    else
        return IPS_ALERT;
}
Ejemplo n.º 16
0
int RoboFocus::updateRFPosition(double *value)
{
    float temp ;
    char rf_cmd[RF_MAX_CMD] ;
    int robofocus_rc ;

    DEBUG(INDI::Logger::DBG_DEBUG, "Querying Position...");

    if (isSimulation())
    {
        *value = simulatedPosition;
        return 0;
    }

    strcpy(rf_cmd, "FG000000" ) ;

    if ((robofocus_rc= SendCommand(rf_cmd)) < 0)
        return robofocus_rc;

    if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
        return robofocus_rc;

    if (sscanf(rf_cmd, "FD%6f", &temp) < 1)
        return -1;

    *value = (double) temp;

    DEBUGF(INDI::Logger::DBG_DEBUG, "Position: %g", *value);

    return 0;

}
Ejemplo n.º 17
0
int ioptronHC8406::setMoveRate(int rate,int move_type) 
{
    char cmd[16];
    int errcode = 0;
    char errmsg[MAXRBUF];
    int nbytes_written = 0;

    if (isSimulation())
    {
        return 0;
    }

    if (rate>=0)
    {
	    switch (move_type)
	    {
	    case USE_GUIDE_SPEED:
		snprintf(cmd, 16, ":RG%0d#", rate);
        	break;
	    case USE_CENTERING_SPEED:
		snprintf(cmd, 16, ":RC%0d#", rate);
        	break;
	    case USE_SLEW_SPEED:
		snprintf(cmd, 16, ":RS%0d#", rate);  //NOT WORK!!
        	break;

	    default:
        	break;
	    }
    } else {
	    switch (move_type)
	    {
	    case USE_GUIDE_SPEED:
		snprintf(cmd, 16, ":RG#");
        	break;
	    case USE_CENTERING_SPEED:
		snprintf(cmd, 16, ":RC#"); //NOT WORK!!
        	break;
	    case USE_SLEW_SPEED:
		snprintf(cmd, 16, ":RS#"); //NOT WORK!!
        	break;
	    default:
        	break;
	    }
    }

    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);


    tcflush(PortFD, TCIFLUSH);

    if ((errcode = tty_write(PortFD, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)
    {
        tty_error_msg(errcode, errmsg, MAXRBUF);
        DEBUGF(INDI::Logger::DBG_ERROR, "%s", errmsg);
        return errcode;
    }

    return 0;
}
Ejemplo n.º 18
0
bool LX200_16::handleAltAzSlew()
{
	char altStr[64], azStr[64];

      if (HorizontalCoordsNP.s == IPS_BUSY)
	  {
         abortSlew(PortFD);

	     // sleep for 100 mseconds
	     usleep(100000);
	  }

      if (isSimulation() == false && slewToAltAz(PortFD))
	  {
        HorizontalCoordsNP.s = IPS_ALERT;
        IDSetNumber(&HorizontalCoordsNP, "Slew is not possible.");
        return false;
	  }

      HorizontalCoordsNP.s = IPS_BUSY;
	  fs_sexa(azStr, targetAZ, 2, 3600);
	  fs_sexa(altStr, targetALT, 2, 3600);

      TrackState = SCOPE_SLEWING;
      IDSetNumber(&HorizontalCoordsNP, "Slewing to Alt %s - Az %s", altStr, azStr);
      return true;
}
Ejemplo n.º 19
0
bool ATIKCCD::Disconnect()
{
    ImageState  tState;
    LOGF_DEBUG("Closing %s...", name);

    stopTimerNS();
    stopTimerWE();
    RemoveTimer(genTimerID);
    genTimerID = -1;

    pthread_mutex_lock(&condMutex);
    tState = threadState;
    threadRequest = StateTerminate;
    pthread_cond_signal(&cv);
    pthread_mutex_unlock(&condMutex);
    pthread_join(imagingThread, nullptr);
    tState = StateNone;
    if (isSimulation() == false)
    {
        if (tState == StateExposure)
            ArtemisStopExposure(hCam);
        ArtemisDisconnect(hCam);
    }

    LOG_INFO("Camera is offline.");

    return true;
}
Ejemplo n.º 20
0
bool SynscanDriver::Sync(double ra, double dec)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    TargetRA = ra;
    TargetDE = dec;

    if (isSimulation())
        return true;

    // INDI is JNow. Synscan Controll uses J2000 Epoch
    ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };

    epochPos.ra  = ra * 15.0;
    epochPos.dec = dec;

    // Synscan accepts J2000 coordinates so we need to convert from JNow to J2000
    ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);

    // Mount deals in J2000 coords.
    uint32_t n1 = J2000Pos.ra  / 360 * 0x100000000;
    uint32_t n2 = J2000Pos.dec / 360 * 0x100000000;

    LOGF_DEBUG("Sync - JNow RA: %g JNow DE: %g J2000 RA: %g J2000 DE: %g", ra, dec, J2000Pos.ra / 15.0, J2000Pos.dec);

    snprintf(cmd, SYN_RES, "s%08X,%08X", n1, n2);
    return sendCommand(cmd, res, 18);
}
Ejemplo n.º 21
0
void MICCD::updateTemperature()
{
    float ccdtemp  = 0;
    float ccdpower = 0;
    int err        = 0;

    if (isSimulation())
    {
        ccdtemp = TemperatureN[0].value;
        if (TemperatureN[0].value < TemperatureRequest)
            ccdtemp += TEMP_THRESHOLD;
        else if (TemperatureN[0].value > TemperatureRequest)
            ccdtemp -= TEMP_THRESHOLD;

        ccdpower = 30;
    }
    else
    {
        if (gxccd_get_value(cameraHandle, GV_CHIP_TEMPERATURE, &ccdtemp) < 0)
        {
            char errorStr[MAX_ERROR_LEN];
            gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
            LOGF_ERROR("Getting temperature failed: %s.", errorStr);
            err |= 1;
        }
        if (gxccd_get_value(cameraHandle, GV_POWER_UTILIZATION, &ccdpower) < 0)
        {
            char errorStr[MAX_ERROR_LEN];
            gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
            LOGF_ERROR("Getting voltage failed: %s.", errorStr);
            err |= 2;
        }
    }

    TemperatureN[0].value = ccdtemp;
    CoolerN[0].value      = ccdpower * 100.0;

    if (TemperatureNP.s == IPS_BUSY && fabs(TemperatureN[0].value - TemperatureRequest) <= TEMP_THRESHOLD)
    {
        // end of temperature ramp
        TemperatureN[0].value = TemperatureRequest;
        TemperatureNP.s       = IPS_OK;
    }

    if (err)
    {
        if (err & 1)
            TemperatureNP.s = IPS_ALERT;
        if (err & 2)
            CoolerNP.s = IPS_ALERT;
    }
    else
    {
        CoolerNP.s = IPS_OK;
    }

    IDSetNumber(&TemperatureNP, nullptr);
    IDSetNumber(&CoolerNP, nullptr);
    temperatureID = IEAddTimer(POLLMS, MICCD::updateTemperatureHelper, this);
}
Ejemplo n.º 22
0
bool SynscanDriver::updateTime(ln_date * utc, double utc_offset)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    //  start by formatting a time for the hand controller
    //  we are going to set controller to local time
    struct ln_zonedate ltm;

    ln_date_to_zonedate(utc, &ltm, utc_offset * 3600.0);

    int yr = ltm.years;

    yr = yr % 100;

    cmd[0] = 'H';
    cmd[1] = ltm.hours;
    cmd[2] = ltm.minutes;
    cmd[3] = static_cast<char>(ltm.seconds);
    cmd[4] = ltm.months;
    cmd[5] = ltm.days;
    cmd[6] = yr;
    //  offset from utc so hand controller is running in local time
    cmd[7] = utc_offset > 0 ? static_cast<uint8_t>(utc_offset) : static_cast<uint8_t>(256 + utc_offset);
    //  and no daylight savings adjustments, it's already included in the offset
    cmd[8] = 0;

    LOGF_INFO("Setting mount date/time to %04d-%02d-%02d %d:%02d:%02d UTC Offset: %.2f",
              ltm.years, ltm.months, ltm.days, ltm.hours, ltm.minutes, static_cast<int>(rint(ltm.seconds)), utc_offset);

    if (isSimulation())
        return true;

    return sendCommand(cmd, res, 9);
}
Ejemplo n.º 23
0
/* Downloads the image from the CCD. */
int MICCD::grabImage()
{
    unsigned char *image = (unsigned char *) PrimaryCCD.getFrameBuffer();

    if (isSimulation())
    {
        int height = PrimaryCCD.getSubH() / PrimaryCCD.getBinY();
        int width  = PrimaryCCD.getSubW() / PrimaryCCD.getBinX();

        uint16_t *buffer = (uint16_t *) image;

        for (int i = 0; i < height; i++)
          for (int j = 0; j < width; j++)
            buffer[i * width + j] = rand() % UINT16_MAX;
    }
    else
    {
        int ret = 0;
        if (gxccd_read_image(cameraHandle, image, PrimaryCCD.getFrameBufferSize()) < 0)
        {
            char errorStr[MAX_ERROR_LEN];
            gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
            DEBUGF(INDI::Logger::DBG_ERROR, "Error getting image: %s.", errorStr);
        }
    }

    if (ExposureRequest > POLLMS * 5)
      DEBUG(INDI::Logger::DBG_SESSION, "Download complete.");

    downloading = false;
    ExposureComplete(&PrimaryCCD);

    return 0;
}
Ejemplo n.º 24
0
bool MICCD::StartExposure(float duration)
{
    imageFrameType = PrimaryCCD.getFrameType();
    useShutter = (imageFrameType == INDI::CCDChip::LIGHT_FRAME || imageFrameType == INDI::CCDChip::FLAT_FRAME);

    if (!isSimulation())
    {
        // read modes in G2/G3/G4 cameras are in inverse order, we have to calculate correct value
        int mode, prm;
        gxccd_get_integer_parameter(cameraHandle, GIP_PREVIEW_READ_MODE, &prm);
        if (prm == 0) // preview mode == 0 means smaller G0/G1 cameras
            mode = IUFindOnSwitchIndex(&ReadModeSP);
        else
            mode = prm - IUFindOnSwitchIndex(&ReadModeSP);
        gxccd_set_read_mode(cameraHandle, mode);

        // send binned coords
        int x = PrimaryCCD.getSubX() / PrimaryCCD.getBinX();
        int y = PrimaryCCD.getSubY() / PrimaryCCD.getBinY();
        int w = PrimaryCCD.getSubW() / PrimaryCCD.getBinX();
        int d = PrimaryCCD.getSubH() / PrimaryCCD.getBinY();
        gxccd_start_exposure(cameraHandle, duration, useShutter, x, y, w, d);
    }

    ExposureRequest = duration;
    PrimaryCCD.setExposureDuration(duration);

    gettimeofday(&ExpStart, nullptr);
    InExposure  = true;
    downloading = false;
    LOGF_DEBUG("Taking a %.3f seconds frame...", ExposureRequest);
    return true;
}
Ejemplo n.º 25
0
bool ASICCD::Connect()
{

  DEBUGF(INDI::Logger::DBG_DEBUG,  "Attempting to open %s...", name);

  sim = isSimulation();

  ASI_ERROR_CODE errCode = ASI_SUCCESS;

  if (sim == false)
        errCode = ASIOpenCamera(m_camInfo->CameraID);

  if (errCode != ASI_SUCCESS)
  {
      DEBUGF(INDI::Logger::DBG_ERROR, "Error connecting to the CCD (%d)", errCode);
      return false;
  }

  TemperatureUpdateCounter = 0;

#ifndef OSX_EMBEDED_MODE
  pthread_create( &primary_thread, NULL, &streamVideoHelper, this);
#endif
  
  /* Success! */
  DEBUG(INDI::Logger::DBG_SESSION,  "CCD is online. Retrieving basic data.");

  return true;
}
Ejemplo n.º 26
0
bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    int index = 0;

    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        // Focus Motion
        if (!strcmp(name, FocusMotionSP.name))
        {
            // If speed is "halt"
            if (FocusSpeedN[0].value == 0)
            {
                FocusMotionSP.s = IPS_IDLE;
                IDSetSwitch(&FocusMotionSP, nullptr);
                return false;
            }

            int last_motion = IUFindOnSwitchIndex(&FocusMotionSP);

            if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0)
                return false;

            index = IUFindOnSwitchIndex(&FocusMotionSP);

            // If same direction and we're busy, stop
            if (last_motion == index && FocusMotionSP.s == IPS_BUSY)
            {
                IUResetSwitch(&FocusMotionSP);
                FocusMotionSP.s = IPS_IDLE;
                setFocuserSpeedMode(PortFD, 0);
                IDSetSwitch(&FocusMotionSP, nullptr);
                return true;
            }

            if (!isSimulation() && setFocuserMotion(PortFD, index) < 0)
            {
                FocusMotionSP.s = IPS_ALERT;
                IDSetSwitch(&FocusMotionSP, "Error setting focuser speed.");
                return false;
            }

            FocusMotionSP.s = IPS_BUSY;

            // with a timer
            if (FocusTimerNP.np[0].value > 0)
            {
                FocusTimerNP.s = IPS_BUSY;
                if (isDebug())
                    IDLog("Starting Focus Timer BUSY\n");

                IEAddTimer(50, LX200Generic::updateFocusHelper, this);
            }

            IDSetSwitch(&FocusMotionSP, nullptr);
            return true;
        }
    }

    return LX200Generic::ISNewSwitch(dev, name, states, names, n);
}
Ejemplo n.º 27
0
bool FishCampCCD::Connect()
{
    sim = isSimulation();

    if (sim)
    {
        LOG_INFO("Simulated Fishcamp is online.");
        return true;
    }

    if (fcUsb_haveCamera())
    {
        fcUsb_cmd_setReadMode(cameraNum, fc_classicDataXfr, fc_16b_data);
        fcUsb_cmd_setCameraGain(cameraNum, GainN[0].value);
        fcUsb_cmd_setRoi(cameraNum, 0, 0, camInfo.width - 1, camInfo.height - 1);
        if (fcUsb_cmd_getTECInPowerOK(cameraNum))
            CoolerNP.s = IPS_OK;
        LOG_INFO("Fishcamp CCD is online.");
        return true;
    }
    else
    {
        LOG_ERROR("Cannot find Fishcamp CCD. Please check the logfile and try again.");
        return false;
    }
}
Ejemplo n.º 28
0
int NFocus::setNFMaxPosition(double *value)
{
    float temp;
    char rf_cmd[32];
    char vl_tmp[6];
    int ret_read_tmp;
    char waste[1];

    if (isSimulation())
        return 0;

    if (*value == MAXTRAVEL_READOUT)
    {
        strncpy(rf_cmd, "FL000000", 9);
    }
    else
    {
        rf_cmd[0] = 'F';
        rf_cmd[1] = 'L';
        rf_cmd[2] = '0';

        if (*value > 9999)
        {
            snprintf(vl_tmp, 6, "%5d", (int)*value);
        }
        else if (*value > 999)
        {
            snprintf(vl_tmp, 6, "0%4d", (int)*value);
        }
        else if (*value > 99)
        {
            snprintf(vl_tmp, 6, "00%3d", (int)*value);
        }
        else if (*value > 9)
        {
            snprintf(vl_tmp, 6, "000%2d", (int)*value);
        }
        else
        {
            snprintf(vl_tmp, 6, "0000%1d", (int)*value);
        }
        rf_cmd[3] = vl_tmp[0];
        rf_cmd[4] = vl_tmp[1];
        rf_cmd[5] = vl_tmp[2];
        rf_cmd[6] = vl_tmp[3];
        rf_cmd[7] = vl_tmp[4];
        rf_cmd[8] = 0;
    }

    if ((ret_read_tmp = SendCommand(rf_cmd)) < 0)
        return ret_read_tmp;

    if (sscanf(rf_cmd, "FL%1c%5f", waste, &temp) < 1)
        return -1;

    *value = (double)temp;

    return 0;
}
Ejemplo n.º 29
0
bool MICCD::Connect()
{
    uint32_t cap = 0;

    if (isSimulation())
    {
        LOGF_INFO("Connected to %s", name);

        cap = CCD_CAN_SUBFRAME | CCD_CAN_ABORT | CCD_CAN_BIN | CCD_HAS_SHUTTER | CCD_HAS_COOLER;
        SetCCDCapability(cap);

        numFilters = 5;

        return true;
    }

    if (!cameraHandle)
    {
        if (isEth)
            cameraHandle = gxccd_initialize_eth(cameraId);
        else
            cameraHandle = gxccd_initialize_usb(cameraId);
    }
    if (!cameraHandle)
    {
        LOGF_ERROR("Error connecting to %s.", name);
        return false;
    }

    LOGF_INFO("Connected to %s.", name);

    bool value;
    cap = CCD_CAN_ABORT | CCD_CAN_BIN;

    gxccd_get_boolean_parameter(cameraHandle, GBP_SUB_FRAME, &value);
    if (value)
        cap |= CCD_CAN_SUBFRAME;

    gxccd_get_boolean_parameter(cameraHandle, GBP_GUIDE, &value);
    if (value)
        cap |= CCD_HAS_ST4_PORT;

    gxccd_get_boolean_parameter(cameraHandle, GBP_SHUTTER, &value);
    if (value)
        cap |= CCD_HAS_SHUTTER;

    gxccd_get_boolean_parameter(cameraHandle, GBP_COOLER, &value);
    if (value)
        cap |= CCD_HAS_COOLER;

    gxccd_get_boolean_parameter(cameraHandle, GBP_GAIN, &hasGain);

    gxccd_get_boolean_parameter(cameraHandle, GBP_PREFLASH, &canDoPreflash);

    SetCCDCapability(cap);

    return true;
}
Ejemplo n.º 30
0
bool SynscanDriver::Goto(double ra, double dec)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    TargetRA = ra;
    TargetDE = dec;

    if (isSimulation())
        return true;

    // INDI is JNow. Synscan Controll uses J2000 Epoch
    ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };

    epochPos.ra  = ra * 15.0;
    epochPos.dec = dec;

    // For Alt/Az mounts, we must issue Goto Alt/Az
    if (m_isAltAz)
    {
        struct ln_lnlat_posn lnobserver;
        struct ln_hrz_posn lnaltaz;

        lnobserver.lng = LocationN[LOCATION_LONGITUDE].value;
        if (lnobserver.lng > 180)
            lnobserver.lng -= 360;
        lnobserver.lat = LocationN[LOCATION_LATITUDE].value;
        ln_get_hrz_from_equ(&epochPos, &lnobserver, ln_get_julian_from_sys(), &lnaltaz);
        /* libnova measures azimuth from south towards west */
        double az = range360(lnaltaz.az + 180);
        double al = lnaltaz.alt;

        return GotoAzAlt(az, al);
    }

    // Synscan accepts J2000 coordinates so we need to convert from JNow to J2000
    ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);

    // Mount deals in J2000 coords.
    uint32_t n1 = J2000Pos.ra  / 360  * 0x100000000;
    uint32_t n2 = J2000Pos.dec / 360 * 0x100000000;

    LOGF_DEBUG("Goto - JNow RA: %g JNow DE: %g J2000 RA: %g J2000 DE: %g", ra, dec, J2000Pos.ra / 15.0, J2000Pos.dec);


    snprintf(cmd, SYN_RES, "r%08X,%08X", n1, n2);
    if (sendCommand(cmd, res, 18))
    {
        TrackState = SCOPE_SLEWING;
        HorizontalCoordsNP.s = IPS_BUSY;
        IDSetNumber(&HorizontalCoordsNP, nullptr);
        return true;
    }

    return false;
}