Exemplo n.º 1
0
uint16_t ScopeDome::compensateInertia(uint16_t steps)
{
    if (inertiaTable.size() == 0)
    {
        LOGF_INFO("inertia passthrough %d", steps);
        return steps; // pass value as such if we don't have enough data
    }

    for (uint16_t out = 0; out < inertiaTable.size(); out++)
    {
        if (inertiaTable[out] > steps)
        {
            LOGF_INFO("inertia %d -> %d", steps, out - 1);
            return out - 1;
        }
    }
    // Check difference from largest table entry and assume we have
    // similar inertia also after that
    int lastEntry = inertiaTable.size() - 1;
    int inertia   = inertiaTable[lastEntry] - lastEntry;
    int movement  = (int)steps - inertia;
    LOGF_INFO("inertia %d -> %d", steps, movement);
    if (movement <= 0)
        return 0;

    return movement;
}
Exemplo n.º 2
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::Disconnect()
{
    // If we disconnect F2, No socket to close, set local PortFD to -1
    PortFD = -1;
    LOGF_INFO("%s is offline.", getDeviceName());
    LOGF_INFO("Value of F2 PortFD = %d", PortFD);
    return true;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
/************************************************************************************
 *
* ***********************************************************************************/
bool ScopeDome::SetupParms()
{
    targetAz = 0;

    readU32(GetImpPerTurn, stepsPerTurn);
    LOGF_INFO("Steps per turn read as %d", stepsPerTurn);
    StepsPerRevolutionN[0].value = stepsPerTurn;
    StepsPerRevolutionNP.s       = IPS_OK;
    IDSetNumber(&StepsPerRevolutionNP, nullptr);

    readS32(GetHomeSensorPosition, homePosition);
    LOGF_INFO("Home position read as %d", homePosition);

    if (UpdatePosition())
        IDSetNumber(&DomeAbsPosNP, nullptr);

    if (UpdateShutterStatus())
        IDSetSwitch(&DomeShutterSP, nullptr);

    UpdateSensorStatus();
    UpdateRelayStatus();

    if (InitPark())
    {
        // If loading parking data is successful, we just set the default parking
        // values.
        SetAxis1ParkDefault(0);
    }
    else
    {
        // Otherwise, we set all parking data to default in case no parking data is
        // found.
        SetAxis1Park(0);
        SetAxis1ParkDefault(0);
    }

    uint8_t calibrationNeeded = false;
    readU8(IsFullSystemCalReq, calibrationNeeded);
    CalibrationNeededS[0].s = calibrationNeeded ? ISS_ON : ISS_OFF;
    CalibrationNeededSP.s   = IPS_OK;
    IDSetSwitch(&CalibrationNeededSP, nullptr);

    uint16_t fwVersion;
    readU16(GetVersionFirmware, fwVersion);
    FirmwareVersionsN[0].value = fwVersion / 100.0;

    uint8_t fwVersionRotary;
    readU8(GetVersionFirmwareRotary, fwVersionRotary);
    FirmwareVersionsN[1].value = (fwVersionRotary + 9) / 10.0;
    FirmwareVersionsNP.s       = IPS_OK;
    IDSetNumber(&FirmwareVersionsNP, nullptr);
    return true;
}
Exemplo n.º 5
0
bool SynscanDriver::MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
{
    if (isSimulation())
        return true;

    bool rc = false;
    SynscanDirection move;

    if (currentPierSide == PIER_WEST)
        move = (dir == DIRECTION_NORTH) ? SYN_N : SYN_S;
    else
        move = (dir == DIRECTION_NORTH) ? SYN_S : SYN_N;

    uint8_t rate = static_cast<uint8_t>(IUFindOnSwitchIndex(&SlewRateSP)) + 1;
    double customRate = CustomSlewRateN[AXIS_DE].value;

    // If we have pulse guiding
    if (m_CustomGuideDE > 0)
    {
        rate = 10;
        customRate = m_CustomGuideDE;
    }

    switch (command)
    {
        case MOTION_START:
            rc = (rate < 10) ? slewFixedRate(move, rate) : slewVariableRate(move, customRate);
            if (!rc)
            {
                LOG_ERROR("Error setting N/S motion direction.");
                return false;
            }
            // Only report messages if we are not guiding
            else if (!m_CustomGuideDE)
                LOGF_INFO("Moving toward %s.", (move == SYN_N) ? "North" : "South");
            break;

        case MOTION_STOP:
            if (slewFixedRate(move, 0) == false)
            {
                LOG_ERROR("Error stopping N/S motion.");
                return false;
            }
            else if (!m_CustomGuideDE)
                LOGF_INFO("Movement toward %s halted.", (move == SYN_N) ? "North" : "South");
            break;
    }

    return true;
}
Exemplo n.º 6
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::RemoteDisconnect()
{
  if (isConnected())
  {
    setConnected(false, IPS_IDLE);
    updateProperties();
  }

  // When called by F1, the PortFD should be -1; For debbug purpose
  PortFD = lynxDriveF1->getPortFD();
  LOGF_INFO("Remote disconnection: %s is offline.", getDeviceName());
  LOGF_INFO("Value of F2 PortFD = %d", PortFD);
  return true;
}
Exemplo n.º 7
0
	void Renderer::SetResolution(unsigned int width, unsigned int height)
	{
		// Return if resolution is invalid
		if (width == 0 || width > m_max_resolution || height == 0 || height > m_max_resolution)
		{
			LOGF_WARNING("%dx%d is an invalid resolution", width, height);
			return;
		}

		// Return if resolution already set
		if (m_resolution.x == width && m_resolution.y == height)
			return;

		// Make sure we are pixel perfect
		width	-= (width	% 2 != 0) ? 1 : 0;
		height	-= (height	% 2 != 0) ? 1 : 0;

		// Set resolution
		m_resolution.x = static_cast<float>(width);
		m_resolution.y = static_cast<float>(height);

		// Re-create render textures
		CreateRenderTextures();

		// Log
		LOGF_INFO("Resolution set to %dx%d", width, height);
	}
Exemplo n.º 8
0
bool lacerta_mfoc::Handshake()
{
    char MFOC_cmd[32] = ": Q #";
    char MFOC_res[32] = {0};
    char MFOC_res_type[32] = "0";
    int MFOC_pos_measd = 0;
    int nbytes_written = 0;
    int nbytes_read = 0;


    tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
    LOGF_INFO("CMD <%s>", MFOC_cmd);
    tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
    LOGF_DEBUG("RES <%s>", MFOC_res_type);

    sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_pos_measd);

    if (MFOC_res_type[0] == 'P')
    {
        FocusAbsPosN[0].value = MFOC_pos_measd;
        FocusAbsPosNP.s = IPS_OK;
        return true;
    }

    return false;
}
Exemplo n.º 9
0
bool lacerta_mfoc::SetTempComp(double values[], char *names[], int n)
{
    LOGF_INFO("-> TEMPCOMP_SETTINGS", 0);
    char MFOC_cmd[32]  = ": D ";
    char MFOC_res[32]  = {0};
    int nbytes_read    =  0;
    int nbytes_written =  0;
    int MFOC_tc_measd = 0;
    int tc_int = 0;
    char tc_char[32]  = {0};
    char MFOC_res_type[32]  = "0";
    TempCompNP.s = IPS_OK;
    IUUpdateNumber(&TempCompNP, values, names, n);
    tc_int = TempCompN[0].value;
    sprintf(tc_char, "%d", tc_int);
    strcat(tc_char, " #");
    strcat(MFOC_cmd, tc_char);

    tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
    LOGF_DEBUG("CMD <%s>", MFOC_cmd);
    tty_write_string(PortFD, ": U #", &nbytes_written);

    tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);

    sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tc_measd);

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

    IDSetNumber(&TempCompNP, nullptr);

    return true;
}
Exemplo n.º 10
0
bool FishCampCCD::StartExposure(float duration)
{
    PrimaryCCD.setExposureDuration(duration);
    ExposureRequest = duration;

    bool rc = false;

    LOGF_DEBUG("Exposure Time (s) is: %g", duration);

    // setup the exposure time in ms.
    rc = fcUsb_cmd_setIntegrationTime(cameraNum, (UInt32)(duration * 1000.0));

    LOGF_DEBUG("fcUsb_cmd_setIntegrationTime returns %d", rc);

    rc = fcUsb_cmd_startExposure(cameraNum);

    LOGF_DEBUG("fcUsb_cmd_startExposure returns %d", rc);

    gettimeofday(&ExpStart, nullptr);

    LOGF_INFO("Taking a %g seconds frame...", ExposureRequest);

    InExposure = true;

    return (rc == 0);
}
Exemplo n.º 11
0
/************************************************************************************
 *
* ***********************************************************************************/
IPState ScopeDome::ControlShutter(ShutterOperation operation)
{
    LOGF_INFO("Control shutter %d", (int)operation);
    targetShutter = operation;
    if (operation == SHUTTER_OPEN)
    {
        LOG_INFO("Opening shutter");
        if (getInputState(IN_OPEN1))
        {
            LOG_INFO("Shutter already open");
            return IPS_OK;
        }
        setOutputState(OUT_CLOSE1, ISS_OFF);
        setOutputState(OUT_OPEN1, ISS_ON);
    }
    else
    {
        LOG_INFO("Closing shutter");
        if (getInputState(IN_CLOSED1))
        {
            LOG_INFO("Shutter already closed");
            return IPS_OK;
        }
        setOutputState(OUT_OPEN1, ISS_OFF);
        setOutputState(OUT_CLOSE1, ISS_ON);
    }

    shutterState = SHUTTER_MOVING;
    return IPS_BUSY;
}
Exemplo n.º 12
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);
}
Exemplo n.º 13
0
bool SynscanDriver::readFirmware()
{
    // Read the handset version
    char res[SYN_RES] = {0};
    if (sendCommand("V", res))
    {
        m_FirmwareVersion = static_cast<double>(hexStrToInteger(std::string(&res[0], 2)));
        m_FirmwareVersion += static_cast<double>(hexStrToInteger(std::string(&res[2], 2))) / 100;
        m_FirmwareVersion += static_cast<double>(hexStrToInteger(std::string(&res[4], 2))) / 10000;

        LOGF_INFO("Firmware version: %lf", m_FirmwareVersion);
        m_MountInfo[MI_FW_VERSION] = std::to_string(m_FirmwareVersion);
        IUSaveText(&StatusT[MI_FW_VERSION], m_MountInfo[MI_FW_VERSION].c_str());

        if (m_FirmwareVersion < 3.38 || (m_FirmwareVersion >= 4.0 && m_FirmwareVersion < 4.38))
        {
            LOGF_WARN("Firmware version is too old. Update Synscan firmware to %s",
                      m_FirmwareVersion < 3.38 ? "v3.38+" : "v4.38+");
            return false;
        }
        else
            return true;
    }
    else
        LOG_WARN("Firmware version is too old. Update Synscan firmware to v4.38+");

    return false;
}
Exemplo n.º 14
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::Connect()
/* Overide of connect() function
 * different for F2 or F1 focuser
 * F2 don't connect himself to the hub
 */
{
    configurationComplete = false;

    if (!lynxDriveF1->isConnected())
    {
        if (!lynxDriveF1->Connect())
        {
            LOG_INFO("Focus F1 should be connected before try to connect F2");
            return false;
        }
        lynxDriveF1->setConnected(true, IPS_OK);
        lynxDriveF1->updateProperties();
    }
    PortFD = lynxDriveF1->getPortFD(); //Get the socket descriptor open by focuser F1 connect()
    LOGF_INFO("F2 PortFD : %d", PortFD);

    if (ack())
    {
        LOG_INFO("FocusLynx is online. Getting focus parameters...");
        // as DefaultDevice::Connect() is not involved, initiate the timer.
        SetTimer(POLLMS);
        return true;
    }

    LOG_INFO("Error retreiving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
    return false;
}
Exemplo n.º 15
0
bool ArmPlat::echo()
{
    int rc = -1;
    char cmd[SLP_SEND_BUF_SIZE]={0};

    sprintf( cmd, "!seletek version#" );

    if ( slpSendRxInt( cmd, &rc ) )
    {
        const char *operative[ OPERATIVES + 1 ] = { "", "Bootloader", "Error" };
        const char *models[ MODELS + 1 ] = { "Error", "Seletek", "Armadillo", "Platypus", "Dragonfly" };
        int fwmaj, fwmin, model, oper;
        char txt[ 80 ];

        oper = rc / 10000;		// 0 normal, 1 bootloader
        model = ( rc / 1000 ) % 10;	// 1 seletek, etc.
        fwmaj = ( rc / 100 ) % 10;
        fwmin = ( rc % 100 );
        if ( oper >= OPERATIVES ) oper = OPERATIVES;
        if ( model >= MODELS ) model = 0;
        sprintf( txt, "%s %s fwv %d.%d", operative[ oper ], models[ model ], fwmaj, fwmin );
        if ( strcmp( models[ model ], CONTROLLER_NAME ) )
                DEBUGF( INDI::Logger::DBG_WARNING, "Actual model (%s) and driver (" CONTROLLER_NAME ") mismatch - can lead to limited operability", models[model] );

        IUSaveText( &FirmwareVersionT[0], txt );
        LOGF_INFO("Setting version to [%s]", txt );

        return true;
    }
    return false;
}
Exemplo n.º 16
0
bool SynscanDriver::MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
{
    if (isSimulation())
        return true;

    bool rc = false;
    SynscanDirection move = (dir == DIRECTION_WEST) ? SYN_W : SYN_E;
    uint8_t rate = static_cast<uint8_t>(IUFindOnSwitchIndex(&SlewRateSP)) + 1;
    double customRate = CustomSlewRateN[AXIS_RA].value;

    // If we have pulse guiding
    if (m_CustomGuideRA > 0)
    {
        rate = 10;
        customRate = m_CustomGuideRA;
    }

    switch (command)
    {
        case MOTION_START:
            rc = (rate < 10) ? slewFixedRate(move, rate) : slewVariableRate(move, customRate);
            if (!rc)
            {
                LOG_ERROR("Error setting W/E motion direction.");
                return false;
            }
            // Only report messages if we are not guiding
            else if (!m_CustomGuideRA)
                LOGF_INFO("Moving toward %s.", (move == SYN_W) ? "West" : "East");
            break;

        case MOTION_STOP:
            if (slewFixedRate(move, 0) == false)
            {
                LOG_ERROR("Error stopping W/E motion.");
                return false;
            }
            else if (!m_CustomGuideRA)
                LOGF_INFO("Movement toward %s halted.", (move == SYN_W) ? "West" : "East");
            break;
    }

    return true;
}
Exemplo n.º 17
0
bool ATIKCCD::StartExposure(float duration)
{
    PrimaryCCD.setExposureDuration(duration);
    ExposureRequest = duration;

    // Camera needs to be in idle state to start exposure after previous abort
    int maxWaitCount = 1000; // 1000 * 0.1s = 100s
    while (ArtemisCameraState(hCam) != CAMERA_IDLE && --maxWaitCount > 0)
    {
        LOG_DEBUG("Waiting camera to be idle...");
        usleep(100000);
    }
    if (maxWaitCount == 0)
    {
        LOG_ERROR("Camera not in idle state, can't start exposure");
        return false;
    }

    LOGF_DEBUG("Start Exposure : %.3fs", duration);

    //    if (m_CameraFlags & ARTEMIS_PROPERTIES_CAMERAFLAGS_HAS_SHUTTER)
    //    {
    //        if (PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME ||
    //            PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME)
    //        {
    //            ArtemisCloseShutter(hCam);
    //        }
    //        else
    //        {
    //            ArtemisOpenShutter(hCam);
    //        }
    //    }

    ArtemisSetDarkMode(hCam, PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME ||
                       PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME);

    int rc = ArtemisStartExposure(hCam, duration);

    if (rc != ARTEMIS_OK)
    {
        LOGF_ERROR("Failed to start exposure (%d).", rc);
        return false;
    }

    gettimeofday(&ExpStart, nullptr);
    if (ExposureRequest > VERBOSE_EXPOSURE)
        LOGF_INFO("Taking a %g seconds frame...", ExposureRequest);

    InExposure = true;
    pthread_mutex_lock(&condMutex);
    threadRequest = StateExposure;
    pthread_cond_signal(&cv);
    pthread_mutex_unlock(&condMutex);

    return true;
}
Exemplo n.º 18
0
bool SynscanDriver::readModel()
{
    // extended list of mounts
    std::map<int, std::string> models =
    {
        {0, "EQ6 GOTO Series"},
        {1, "HEQ5 GOTO Series"},
        {2, "EQ5 GOTO Series"},
        {3, "EQ3 GOTO Series"},
        {4, "EQ8 GOTO Series"},
        {5, "AZ-EQ6 GOTO Series"},
        {6, "AZ-EQ5 GOTO Series"},
        {160, "AllView GOTO Series"},
        {165, "AZ-GTi GOTO Series"}
    };

    // Read the handset version
    char res[SYN_RES] = {0};

    if (!sendCommand("m", res))
        return false;

    m_MountModel = res[0];

    // 128 - 143 --> AZ Goto series
    if (m_MountModel >= 128 && m_MountModel <= 143)
        IUSaveText(&StatusT[MI_MOUNT_MODEL], "AZ GOTO Series");
    // 144 - 159 --> DOB Goto series
    else if (m_MountModel >= 144 && m_MountModel <= 159)
        IUSaveText(&StatusT[MI_MOUNT_MODEL], "Dob GOTO Series");
    else if (models.count(m_MountModel) > 0)
        IUSaveText(&StatusT[MI_MOUNT_MODEL], models[m_MountModel].c_str());
    else
        IUSaveText(&StatusT[MI_MOUNT_MODEL], "Unknown model");

    m_isAltAz = m_MountModel > 4;

    LOGF_INFO("Driver is running in %s mode.", m_isAltAz ? "Alt-Az" : "Equatorial");
    LOGF_INFO("Detected mount: %s. Mount must be aligned from the handcontroller before using the driver.", StatusT[MI_MOUNT_MODEL].text);

    return true;
}
Exemplo n.º 19
0
void WatchDog::executeScript()
{
    // child
    if (fork() == 0)
    {
        int rc = execlp(SettingsT[EXECUTE_SCRIPT].text, SettingsT[EXECUTE_SCRIPT].text, nullptr);

        if (rc)
            exit(rc);
    }
    // parent
    else
    {
        int statval;
        LOGF_INFO("Executing script %s...", SettingsT[EXECUTE_SCRIPT].text);
        LOGF_INFO("Waiting for script with PID %d to complete...", getpid());
        wait(&statval);
        if (WIFEXITED(statval))
        {
            int exit_code = WEXITSTATUS(statval);
            LOGF_INFO("Script complete with exit code %d", exit_code);

            if (exit_code == 0)
                shutdownStage = WATCHDOG_COMPLETE;
            else
            {
                LOGF_ERROR("Error: script %s failed. Shutdown procedure terminated.",
                       SettingsT[EXECUTE_SCRIPT].text);
                shutdownStage = WATCHDOG_ERROR;
                return;
            }
        }
        else
        {
            LOGF_ERROR(
                   "Error: script %s did not terminate with exit. Shutdown procedure terminated.",
                   SettingsT[EXECUTE_SCRIPT].text);
            shutdownStage = WATCHDOG_ERROR;
            return;
        }
    }
}
Exemplo n.º 20
0
bool MoonLiteDRO::Handshake()
{
    if (Ack())
    {
        LOGF_INFO("%s is online. Getting focus parameters...", getDeviceName());
        return true;
    }

    LOG_INFO("Handshake failed. please ensure MoonLite controller is powered and the port is correct.");
    return false;
}
Exemplo n.º 21
0
bool ScopeSim::updateLocation(double latitude, double longitude, double elevation)
{
    INDI_UNUSED(elevation);
    // JM: INDI Longitude is 0 to 360 increasing EAST. libnova East is Positive, West is negative
    lnobserver.lng = longitude;

    if (lnobserver.lng > 180)
        lnobserver.lng -= 360;
    lnobserver.lat = latitude;

    LOGF_INFO("Location updated: Longitude (%g) Latitude (%g)", lnobserver.lng, lnobserver.lat);
    return true;
}
Exemplo n.º 22
0
bool ShelyakEshel::Connect()
{
    int rc;
    char errMsg[MAXRBUF];
    if ((rc = tty_connect(PortT[0].text, 2400, 8, 0, 1, &PortFD)) != TTY_OK)
    {
        tty_error_msg(rc, errMsg, MAXRBUF);
        LOGF_ERROR("Failed to connect to port %s. Error: %s", PortT[0].text, errMsg);
        return false;
    }
    LOGF_INFO("%s is online.", getDeviceName());
    return true;
}
Exemplo n.º 23
0
bool SynscanDriver::updateLocation(double latitude, double longitude, double elevation)
{
    INDI_UNUSED(elevation);

    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};
    bool IsWest = false;

    ln_lnlat_posn p1 { 0, 0 };
    lnh_lnlat_posn p2;

    LocationN[LOCATION_LATITUDE].value  = latitude;
    LocationN[LOCATION_LONGITUDE].value = longitude;
    IDSetNumber(&LocationNP, nullptr);

    if (isSimulation())
    {
        if (!CurrentDE)
        {
            CurrentDE = latitude > 0 ? 90 : -90;
            CurrentRA = get_local_sidereal_time(longitude);
        }
        return true;
    }

    if (longitude > 180)
    {
        p1.lng = 360.0 - longitude;
        IsWest = true;
    }
    else
    {
        p1.lng = longitude;
    }
    p1.lat = latitude;
    ln_lnlat_to_hlnlat(&p1, &p2);
    LOGF_INFO("Update location to latitude %d:%d:%1.2f longitude %d:%d:%1.2f",
              p2.lat.degrees, p2.lat.minutes, p2.lat.seconds, p2.lng.degrees, p2.lng.minutes, p2.lng.seconds);

    cmd[0] = 'W';
    cmd[1] = p2.lat.degrees;
    cmd[2] = p2.lat.minutes;
    cmd[3] = rint(p2.lat.seconds);
    cmd[4] = (p2.lat.neg == 0) ? 0 : 1;
    cmd[5] = p2.lng.degrees;
    cmd[6] = p2.lng.minutes;
    cmd[7] = rint(p2.lng.seconds);
    cmd[9] = IsWest ? 1 : 0;

    return sendCommand(cmd, res, 10);
}
Exemplo n.º 24
0
ScopeDome::ScopeDome()
{
    setVersion(1, 0);
    targetAz         = 0;
    shutterState     = SHUTTER_UNKNOWN;
    simShutterStatus = SHUTTER_CLOSED;

    status        = DOME_UNKNOWN;
    targetShutter = SHUTTER_CLOSE;

    SetDomeCapability(DOME_CAN_ABORT | DOME_CAN_ABS_MOVE | DOME_CAN_REL_MOVE | DOME_CAN_PARK | DOME_HAS_SHUTTER);

    stepsPerTurn = -1;

    // Load dome inertia table if present
    wordexp_t wexp;
    if (wordexp("~/.indi/ScopeDome_DomeInertia_Table.txt", &wexp, 0) == 0)
    {
        FILE *inertia = fopen(wexp.we_wordv[0], "r");
        if (inertia)
        {
            // skip UTF-8 marker bytes
            fseek(inertia, 3, SEEK_SET);
            char line[100];
            int lineNum = 0;

            while (fgets(line, sizeof(line), inertia))
            {
                int step, result;
                if (sscanf(line, "%d ;%d", &step, &result) != 2)
                {
                    sscanf(line, "%d;%d", &step, &result);
                }
                if (step == lineNum)
                {
                    inertiaTable.push_back(result);
                }
                lineNum++;
            }
            fclose(inertia);
            LOGF_INFO("Read inertia file %s", wexp.we_wordv[0]);
        }
        else
        {
            LOG_INFO("Could not read inertia file, please generate one with Windows driver setup and copy to "
                     "~/.indi/ScopeDome_DomeInertia_Table.txt");
        }
    }
    wordfree(&wexp);
}
Exemplo n.º 25
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF1::Disconnect()
{
    // If we disconnect F1, the socket would be close.
    INDI::Focuser::Disconnect();

    // Get value of PortFD, should be -1
    if (getActiveConnection() == serialConnection)
        PortFD = serialConnection->getPortFD();
    else
        if (getActiveConnection() == tcpConnection)
            PortFD = tcpConnection->getPortFD();
    // Then we have to disconnect the second focuser F2
    lynxDriveF2->RemoteDisconnect();

    LOGF_INFO("Value of PortFD = %d", PortFD);
    return true;
}
Exemplo n.º 26
0
bool StarbookDriver::getFirmwareVersion() {
    starbook::VersionResponse res;
    starbook::ResponseCode rc = cmd_interface->Version(res);

    if (rc != starbook::OK) {
        LogResponse("Get version", rc);
        return false;
    }
    if (res.major_minor < 2.7) {
        LOGF_WARN("Get version [OK]: %s (< 2.7) not well supported", res.full_str.c_str());
    } else {
        LOGF_INFO("Get version [OK]: %s", res.full_str.c_str());
    }
    IUSaveText(&VersionT[0], res.full_str.c_str());
    IDSetText(&VersionTP, nullptr);

    return true;
}
Exemplo n.º 27
0
int FishCampCCD::SetTemperature(double temperature)
{
    TemperatureRequest = temperature;

    int rc = fcUsb_cmd_setTemperature(cameraNum, TemperatureRequest);

    LOGF_DEBUG("fcUsb_cmd_setTemperature returns %d", rc);

    if (fcUsb_cmd_getTECInPowerOK(cameraNum))
        CoolerNP.s = IPS_OK;
    else
        CoolerNP.s = IPS_IDLE;

    TemperatureNP.s = IPS_BUSY;
    IDSetNumber(&TemperatureNP, nullptr);

    LOGF_INFO("Setting CCD temperature to %+06.2f C", temperature);

    return 0;
}
Exemplo n.º 28
0
bool FlipFlat::Handshake()
{
    if (isSimulation())
    {
        LOGF_INFO("Connected successfuly to simulated %s. Retrieving startup data...", getDeviceName());

        SetTimer(POLLMS);

        setDriverInterface(AUX_INTERFACE | LIGHTBOX_INTERFACE | DUSTCAP_INTERFACE);
        isFlipFlat = true;

        return true;
    }

    PortFD = serialConnection->getPortFD();

    /* Drop RTS */
    int i = 0;
    i |= TIOCM_RTS;
    if (ioctl(PortFD, TIOCMBIC, &i) != 0)
    {
        LOGF_ERROR("IOCTL error %s.", strerror(errno));
        return false;
    }

    i |= TIOCM_RTS;
    if (ioctl(PortFD, TIOCMGET, &i) != 0)
    {
        LOGF_ERROR("IOCTL error %s.", strerror(errno));
        return false;
    }

    if (!ping())
    {
        LOG_ERROR("Device ping failed.");
        return false;
    }

    return true;
}
Exemplo n.º 29
0
bool INovaCCD::Connect()
{
    const char *Sn;
    if(iNovaSDK_MaxCamera() > 0)
    {
        Sn = iNovaSDK_OpenCamera(1);
        LOGF_DEBUG("Serial Number: %s", Sn);
        if(Sn[0] >= '0' && Sn[0] < '3')
        {
            iNovaSDK_InitST4();
            LOGF_INFO("Camera model is %s", iNovaSDK_GetName());
            iNovaSDK_InitCamera(RESOLUTION_FULL);
            //maxW = iNovaSDK_GetImageWidth();
            //maxH = iNovaSDK_GetImageHeight();

            iNovaSDK_SetFrameSpeed(FRAME_SPEED_LOW);
            iNovaSDK_CancelLongExpTime();
            iNovaSDK_OpenVideo();

            CameraPropertiesNP.s = IPS_IDLE;

            // Set camera capabilities
            uint32_t cap = CCD_CAN_ABORT | CCD_CAN_BIN | CCD_CAN_SUBFRAME | (iNovaSDK_HasST4() ? CCD_HAS_ST4_PORT : 0);
            SetCCDCapability(cap);
            if(iNovaSDK_HasColorSensor())
            {
                IUSaveText(&BayerT[2], "RGGB");
                IDSetText(&BayerTP, nullptr);
                SetCCDCapability(GetCCDCapability() | CCD_HAS_BAYER);
            }

            return true;
        }
        iNovaSDK_CloseCamera();
    }
    LOG_ERROR("No cameras opened.");
    return false;
}
Exemplo n.º 30
0
bool QHYCFW2::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, MaxFilterNP.name))
        {
            IUUpdateNumber(&MaxFilterNP, values, names, n);
            MaxFilterNP.s = IPS_OK;
            saveConfig();
            IDSetNumber(&MaxFilterNP, nullptr);
            FilterSlotN[0].max = MaxFilterN[0].value;
            if (isConnected())
                LOG_INFO("Max number of filters updated. You must reconnect for this change to take effect.");
            else
                LOGF_INFO("Max number of filters updated to %.f", MaxFilterN[0].value);

            return true;
        }

    }

    return INDI::FilterWheel::ISNewNumber(dev, name, values, names, n);
}