Clock::Clock(std::string input) { std::stringstream temp; int count = 0, tempInt; switch (input.length()) { case 8: temp.str(input.substr(0,2)); temp >> tempInt; setHour(tempInt); temp.clear(); temp.str(input.substr(3,2)); temp >> tempInt; setMin(tempInt); temp.clear(); temp.str(input.substr(6,2)); temp >> tempInt; setSec(tempInt); temp.clear(); break; case 5: temp.str(input.substr(0,2)); temp >> tempInt; setHour(tempInt); temp.clear(); temp.str(input.substr(3,2)); temp >> tempInt; setMin(tempInt); temp.clear(); break; } }
void ossimLocalTm::setFractionalDay(double fractionalDay) { int h, m, s; double fractionalSecond; extractHmsFromFractionalDay(fractionalDay, h, m, s, fractionalSecond); setHour(h); setMin(m); setSec(s); setFractionalSecond(fractionalSecond); }
ossimDate::ossimDate(int month, int day, int year, int dtfmt) :ossimLocalTm (0), _fmt(dtfmt) { setMonth(month); setDay(day); setYear(year); setHour(0); setMin(0); setSec(0); setFractionalSecond(0.0); }
bool ossimLocalTm::loadXml(ossimRefPtr<ossimXmlNode> dateNode) { bool result = true; ossimRefPtr<ossimXmlNode> month = dateNode->findFirstNode("month"); ossimRefPtr<ossimXmlNode> day = dateNode->findFirstNode("day"); ossimRefPtr<ossimXmlNode> year = dateNode->findFirstNode("year"); ossimRefPtr<ossimXmlNode> hour = dateNode->findFirstNode("hour"); ossimRefPtr<ossimXmlNode> minutes = dateNode->findFirstNode("minutes"); ossimRefPtr<ossimXmlNode> seconds = dateNode->findFirstNode("seconds"); ossimRefPtr<ossimXmlNode> fractionalSecond = dateNode->findFirstNode("fractionalSecond"); ossimRefPtr<ossimXmlNode> julian = dateNode->findFirstNode("julian"); ossimRefPtr<ossimXmlNode> modifiedJulian = dateNode->findFirstNode("modifiedJulian"); if(month.valid()&& day.valid()&& year.valid()&& hour.valid()&& minutes.valid()&& seconds.valid()) { setMonth(month->getText().toInt32()); setDay(day->getText().toInt32()); setYear(year->getText().toInt32()); setHour(hour->getText().toInt32()); setMin(minutes->getText().toInt32()); setSec(seconds->getText().toInt32()); if(fractionalSecond.valid()) { setFractionalSecond(fractionalSecond->getText().toDouble()); } else { setFractionalSecond(0.0); } } else if(modifiedJulian.valid()) { setDateFromModifiedJulian(modifiedJulian->getText().toDouble()); } else if(julian.valid()) { setDateFromJulian(julian->getText().toDouble()); } else { result = false; } return result; }
void PosEdit::stepDown() { int secNo = ed->focusSection(); bool accepted = false; if (!outOfRange(secNo, sec[secNo].val-1)) { accepted = true; setSec(secNo, sec[secNo].val-1); } if (accepted) { changed = true; emit valueChanged(pos()); } ed->repaint(ed->rect(), false); }
//------------------------------------------------------------------------------ // setSeconds() -- //------------------------------------------------------------------------------ bool LatLon::setSeconds(const Number* const ssobj) { bool ok = false; if (ssobj != nullptr) ok = setSec(ssobj->getReal()); return ok; }
int CFrontend::setParameters(TP_params *TP) { int ret, freq_offset = 0; bool high_band = false; #if HAVE_DVB_API_VERSION >= 3 bool can_not_auto_qam = !(info.caps & FE_CAN_QAM_AUTO); bool can_not_auto_inversion = !(info.caps & FE_CAN_INVERSION_AUTO); bool do_auto_qam = TP->feparams.u.qam.modulation == QAM_AUTO; bool do_auto_inversion = TP->feparams.inversion == INVERSION_AUTO; #else bool can_not_auto_qam = true; bool can_not_auto_inversion = true; bool do_auto_qam = false; bool do_auto_inversion = false; #endif if (info.type == FE_QPSK) { if (TP->feparams.frequency < 11700000) { high_band = false; freq_offset = lnbOffsetsLow[TP->diseqc]; } else { high_band = true; freq_offset = lnbOffsetsHigh[TP->diseqc]; } TP->feparams.frequency -= freq_offset; #if HAVE_DVB_API_VERSION >= 3 // for the dreambox, we do this further down... setSec(TP->diseqc, TP->polarization, high_band, TP->feparams.frequency); #endif } /* * frontends which can not handle auto inversion but * are set to auto inversion will try with stored value first */ if (do_auto_inversion && can_not_auto_inversion) TP->feparams.inversion = last_inversion; /* * frontends which can not handle auto qam but * are set to auto qam will try with stored value first */ if (do_auto_qam && can_not_auto_qam) TP->feparams.u.qam.modulation = last_qam; dvb_frontend_event event; int tryagain = 0; //flame on derget for this do { do { #if HAVE_DVB_API_VERSION < 3 /* i have no idea why, but dreamboxen seem to like this ioctl very much and refuse to work without it... */ if (!tuned) { fop(ioctl, FE_SET_POWER_STATE, FE_POWER_ON); // usleep(150000); /* after returning from standby, i need two tries, regardless of the usleep, so i can as well just skip it :-( */ } /* setSec again for each retry, just to make sure, my dreambox needs this since dreamdriver_dm500_20071022.tar.bz2 */ if (info.type == FE_QPSK) setSec(TP->diseqc, TP->polarization, high_band, TP->feparams.frequency); #endif tuned = false; setFrontend (&TP->feparams); event = getEvent(); /* check if tuned */ if (!tuned && !tryagain) { tryagain = 1; WARN("TUNE FAILED I TRY IT ONE TIME AGAIN"); continue; } if (do_auto_inversion && can_not_auto_inversion && !tuned) { switch (TP->feparams.inversion) { case INVERSION_OFF: TP->feparams.inversion = INVERSION_ON; break; case INVERSION_ON: default: TP->feparams.inversion = INVERSION_OFF; break; } if (TP->feparams.inversion == last_inversion) /* can�t tune */ break; } else break; /* tuned */ } while(1); #if HAVE_DVB_API_VERSION >= 3 if (do_auto_qam && can_not_auto_qam && !tuned) { switch (TP->feparams.u.qam.modulation) { case QAM_16: TP->feparams.u.qam.modulation = QAM_32; break; case QAM_32: TP->feparams.u.qam.modulation = QAM_64; break; case QAM_64: TP->feparams.u.qam.modulation = QAM_128; break; case QAM_128: TP->feparams.u.qam.modulation = QAM_256; break; case QAM_256: default: TP->feparams.u.qam.modulation = QAM_16; break; } if (TP->feparams.u.qam.modulation == last_qam) /* can`t tune */ break; continue; /* QAM changed, next try to tune */ } else #else if (tuned || tryagain) #endif break; /* tuned */ } while (1); if (tuned) { last_inversion = TP->feparams.inversion; /* store good value */ #if HAVE_DVB_API_VERSION < 3 last_qam = TP->feparams.u.qam.QAM; /* store good value */ ret = diff(event.u.completionEvent.frequency, TP->feparams.frequency); #if 1 /* * if everything went ok, then it is a good idea to copy the real * frontend parameters, so we can update the service list, if it differs. * * TODO: set a flag to indicate a change in the service list */ memcpy(¤tTransponder.feparams, &event.u.completionEvent, sizeof(FrontendParameters)); #endif #else last_qam = TP->feparams.u.qam.modulation; /* store good value */ ret = diff(event.parameters.frequency, TP->feparams.frequency); #if 1 /* * if everything went ok, then it is a good idea to copy the real * frontend parameters, so we can update the service list, if it differs. * * TODO: set a flag to indicate a change in the service list */ memcpy(¤tTransponder.feparams, &event.parameters, sizeof(dvb_frontend_parameters)); #endif #endif } else { ret = -1; } /* * add the frequency offset to the frontend parameters again * because they are used for the channel list and were given * to this method as a pointer */ if (info.type == FE_QPSK) TP->feparams.frequency += freq_offset; return ret; }
int CFrontend::setParameters(TP_params *TP) { int ret, freq_offset = 0; bool high_band = false; #if HAVE_DVB_API_VERSION >= 3 bool can_not_auto_qam = !(info.caps & FE_CAN_QAM_AUTO); bool can_not_auto_inversion = !(info.caps & FE_CAN_INVERSION_AUTO); bool do_auto_qam = TP->feparams.u.qam.modulation == QAM_AUTO; bool do_auto_inversion = TP->feparams.inversion == INVERSION_AUTO; #else bool can_not_auto_qam = true; bool can_not_auto_inversion = true; bool do_auto_qam = false; bool do_auto_inversion = false; #endif if (info.type == FE_QPSK) { if (TP->feparams.frequency < 11700000) { high_band = false; freq_offset = lnbOffsetsLow[TP->diseqc]; } else { high_band = true; freq_offset = lnbOffsetsHigh[TP->diseqc]; } TP->feparams.frequency -= freq_offset; setSec(TP->diseqc, TP->polarization, high_band, TP->feparams.frequency); } /* * frontends which can not handle auto inversion but * are set to auto inversion will try with stored value first */ if (do_auto_inversion && can_not_auto_inversion) TP->feparams.inversion = last_inversion; /* * frontends which can not handle auto qam but * are set to auto qam will try with stored value first */ if (do_auto_qam && can_not_auto_qam) TP->feparams.u.qam.modulation = last_qam; dvb_frontend_event event; int tryagain = 0; //flame on derget for this do { do { tuned = false; setFrontend (&TP->feparams); event = getEvent(); /* check if tuned */ if (!tuned && !tryagain) { tryagain = 1; WARN("TUNE FAILED I TRY IT ONE TIME AGAIN"); continue; } if (do_auto_inversion && can_not_auto_inversion && !tuned) { switch (TP->feparams.inversion) { case INVERSION_OFF: TP->feparams.inversion = INVERSION_ON; break; case INVERSION_ON: default: TP->feparams.inversion = INVERSION_OFF; break; } if (TP->feparams.inversion == last_inversion) /* can�t tune */ break; } else break; /* tuned */ } while(1); if (tuned && tryagain) /* i've never seen this trigger */ WARN("==============> TRY AGAIN actually helped <======================================================="); #if HAVE_DVB_API_VERSION >= 3 if (do_auto_qam && can_not_auto_qam && !tuned) { switch (TP->feparams.u.qam.modulation) { case QAM_16: TP->feparams.u.qam.modulation = QAM_32; break; case QAM_32: TP->feparams.u.qam.modulation = QAM_64; break; case QAM_64: TP->feparams.u.qam.modulation = QAM_128; break; case QAM_128: TP->feparams.u.qam.modulation = QAM_256; break; case QAM_256: default: TP->feparams.u.qam.modulation = QAM_16; break; } if (TP->feparams.u.qam.modulation == last_qam) /* can`t tune */ break; continue; /* QAM changed, next try to tune */ } else #else if (tuned || tryagain) #endif break; /* tuned */ } while (1); if (tuned) { last_inversion = TP->feparams.inversion; /* store good value */ #if HAVE_DVB_API_VERSION < 3 last_qam = TP->feparams.u.qam.QAM; /* store good value */ ret = diff(event.u.completionEvent.frequency, TP->feparams.frequency); #if 1 /* * if everything went ok, then it is a good idea to copy the real * frontend parameters, so we can update the service list, if it differs. * * TODO: set a flag to indicate a change in the service list */ memcpy(¤tTransponder.feparams, &event.u.completionEvent, sizeof(FrontendParameters)); #endif #else last_qam = TP->feparams.u.qam.modulation; /* store good value */ ret = diff(event.parameters.frequency, TP->feparams.frequency); #if 1 /* * if everything went ok, then it is a good idea to copy the real * frontend parameters, so we can update the service list, if it differs. * * TODO: set a flag to indicate a change in the service list */ memcpy(¤tTransponder.feparams, &event.parameters, sizeof(dvb_frontend_parameters)); #endif #endif } else { ret = -1; } /* * add the frequency offset to the frontend parameters again * because they are used for the channel list and were given * to this method as a pointer */ if (info.type == FE_QPSK) TP->feparams.frequency += freq_offset; return ret; }