Exemplo n.º 1
0
void cmd_setSiteLatitude(BaseSequentialStream *chp, int argc, char *argv){
  float dp;
  if (argc != 1 || (f_scansexa (argv, &dp)!=0 )) {
      chprintf(chp, "0");
      return;
   }
//Format sDD*MM
   siteLatLon.lat=dp;
   chprintf(chp, "1");  
}
Exemplo n.º 2
0
void cmd_setTargetDEC(BaseSequentialStream *chp, int argc, char *argv){
  float dp;
  if (argc != 1 || (f_scansexa (argv, &dp)!=0 )) {
    chprintf(chp, "0");
    return;
  }
   chprintf(chp, "1");
   targetDEC=dp;
   telescopeDEC=dp;
}
Exemplo n.º 3
0
void INDI_E::updateNP()
{
    if (np == NULL)
        return;

    if (write_w != NULL)
    {
        if (write_w->text().isEmpty())
            return;

        f_scansexa(write_w->text().toLatin1().constData(), &(np->value));
        return;
    }

    if (spin_w != NULL)
        np->value = spin_w->value();

}
Exemplo n.º 4
0
void ioptronHC8406::sendScopeTime()
{
    char cdate[32]={0};
    double ctime;
    int h, m, s;
    int utc_h, utc_m, utc_s;
    double lx200_utc_offset = 0;
    char utc_offset_res[32]={0};
    int day, month, year, result;
    struct tm ltm;
    struct tm utm;
    time_t time_epoch;

    if (isSimulation())
    {
        snprintf(cdate, 32, "%d-%02d-%02dT%02d:%02d:%02d", 1979, 6, 25, 3, 30, 30);
        IDLog("Telescope ISO date and time: %s\n", cdate);
        IUSaveText(&TimeT[0], cdate);
        IUSaveText(&TimeT[1], "3");
        IDSetText(&TimeTP, nullptr);
        return;
    }

    //getCommandSexa(PortFD, &lx200_utc_offset, ":GG#");
    //tcflush(PortFD, TCIOFLUSH);
    getCommandString(PortFD, utc_offset_res, ":GG#");

    f_scansexa(utc_offset_res,&lx200_utc_offset);
    result = sscanf(utc_offset_res, "%d%*c%d%*c%d", &utc_h, &utc_m, &utc_s);
    if (result != 3)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error reading UTC offset from Telescope.");
        return;
    }
    DEBUGF(INDI::Logger::DBG_DEBUG, "<VAL> UTC offset: %d:%d:%d --->%g",utc_h,utc_m, utc_s, lx200_utc_offset);
    // LX200 TimeT Offset is defined at the number of hours added to LOCAL TIME to get TimeT. This is contrary to the normal definition.
    DEBUGF(INDI::Logger::DBG_DEBUG, "<VAL> UTC offset str: %s",utc_offset_res);
    IUSaveText(&TimeT[1], utc_offset_res);
    //IUSaveText(&TimeT[1], lx200_utc_offset);

    getLocalTime24(PortFD, &ctime);
    getSexComponents(ctime, &h, &m, &s);

    getCalendarDate(PortFD, cdate);
    result = sscanf(cdate, "%d%*c%d%*c%d", &year, &month, &day);
    if (result != 3)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error reading date from Telescope.");
        return;
    }

    // Let's fill in the local time
    ltm.tm_sec  = s;
    ltm.tm_min  = m;
    ltm.tm_hour = h;
    ltm.tm_mday = day;
    ltm.tm_mon  = month - 1;
    ltm.tm_year = year - 1900;

    // Get time epoch
    time_epoch = mktime(&ltm);

    // Convert to TimeT
    //time_epoch -= (int)(atof(TimeT[1].text) * 3600.0);
    time_epoch -= (int)(lx200_utc_offset * 3600.0);

    // Get UTC (we're using localtime_r, but since we shifted time_epoch above by UTCOffset, we should be getting the real UTC time
    localtime_r(&time_epoch, &utm);

    /* Format it into ISO 8601 */
    strftime(cdate, 32, "%Y-%m-%dT%H:%M:%S", &utm);
    IUSaveText(&TimeT[0], cdate);

    DEBUGF(INDI::Logger::DBG_DEBUG, "Mount controller Local Time: %02d:%02d:%02d", h, m, s);
    DEBUGF(INDI::Logger::DBG_DEBUG, "Mount controller UTC Time: %s", TimeT[0].text);

    // Let's send everything to the client
    IDSetText(&TimeTP, nullptr);
}