Exemplo n.º 1
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.º 2
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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
Arquivo: ieqpro.cpp Projeto: mp77/indi
bool IEQPro::updateTime(ln_date * utc, double utc_offset)
{    
    struct ln_zonedate ltm;

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

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

     // Send it as YY (i.e. 2015 --> 15)
     ltm.years -= 2000;

     // Set Local date
     if (set_ieqpro_local_date(PortFD, ltm.years, ltm.months, ltm.days) == false)
     {
          DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date.");
          return false;
     }

    // UTC Offset
    if (set_ieqpro_utc_offset(PortFD, utc_offset) == false)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
        return false;
    }

   DEBUG(INDI::Logger::DBG_SESSION, "Time and date updated.");

   return true;
}
Exemplo n.º 5
0
bool LX200GPS::updateTime(ln_date *utc, double utc_offset)
{
    ln_zonedate ltm;

    if (isSimulation())
        return true;

    JD = ln_get_julian_day(utc);

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

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

    DEBUGF(INDI::Logger::DBG_DEBUG, "Local time is %02d:%02d:%02g", ltm.hours, ltm.minutes, ltm.seconds);

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

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

    // 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!
    if (setUTCOffset(PortFD, (utc_offset * -1.0)) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
        return false;
    }

    DEBUG(INDI::Logger::DBG_SESSION, "Time updated, updating planetary data...");
    return true;
}
Exemplo n.º 6
0
/*! \fn void ln_get_local_date (double JD, struct ln_zonedate * zonedate)
* \param JD Julian day
* \param zonedate Pointer to new calendar date.
*
* Calculate the zone date from the Julian day (UT). Gets zone info from 
* system using either _timezone or tm_gmtoff fields.
*/
void ln_get_local_date (double JD, struct ln_zonedate * zonedate)
{
	struct ln_date date;
#ifndef __WIN32__	
	time_t curtime;
	struct tm *loctime;
#endif	
	long gmtoff;

	ln_get_date (JD, &date);

    /* add day light savings time and hour angle */
#ifdef __WIN32__
	_tzset();
	gmtoff = _timezone;
	if (_daylight)
		gmtoff += 3600;
#else
 	curtime = time (NULL);
 	loctime = localtime(&curtime);
 	gmtoff = loctime->tm_gmtoff;
#endif
	ln_date_to_zonedate (&date, zonedate, gmtoff);
}