void INDI_P::processSetButton() { switch (dataProp->getType()) { case INDI_TEXT: if (!strcmp(dataProp->getName(), "TIME_UTC")) newTime(); else sendText(); break; case INDI_NUMBER: sendText(); break; case INDI_BLOB: sendBlob(); break; default: break; } }
void INDI_P::newTime() { INDI_E * timeEle; //INDI_P *SDProp; timeEle = getElement("UTC"); if (!timeEle) return; TimeDialog timedialog ( KStars::Instance()->data()->ut(), KStars::Instance()->data()->geo(), KStars::Instance(), true ); if ( timedialog.exec() == QDialog::Accepted ) { QTime newTime( timedialog.selectedTime() ); QDate newDate( timedialog.selectedDate() ); timeEle->setText(QString("%1-%2-%3T%4:%5:%6") .arg(newDate.year()).arg(newDate.month()) .arg(newDate.day()).arg(newTime.hour()) .arg(newTime.minute()).arg(newTime.second())); sendText(); } else return; /*SDProp = pp->pg->dp->findProp("TIME_LST"); if (!SDProp) return; timeEle = SDProp->findElement("LST"); if (!timeEle) return; timeEle->write_w->setText(ksw->data()->lst()->toHMSString()); SDProp->newText();*/ }
DateTime TimeTable::applyTimeZone(const DateTime& dateTimeUtc) { uint16_t year = dateTimeUtc.year(); uint8_t month = dateTimeUtc.month(); uint8_t day = dateTimeUtc.date(); uint8_t hour = dateTimeUtc.hour(); uint8_t minute = dateTimeUtc.minute(); uint8_t second = dateTimeUtc.second(); uint8_t weekday = dateTimeUtc.dayOfWeek(); // CET, CEST bool isLastSundayFirstHour = day > 24 && weekday == SUN && hour < 1; bool isPastLastSunday1AM = day - weekday >= 24 && !isLastSundayFirstHour; bool isBeforeLastSunday1AM = day - weekday < 24 || isLastSundayFirstHour; if ( ( month > 3 || month == 3 && isPastLastSunday1AM ) && ( month < 10 || month == 10 && isBeforeLastSunday1AM ) ) { // Summer time hour += 2; } else { // Winter time hour += 1; } DateTime newTime(year, month, day, hour, minute, second, weekday); return newTime; }
BOOL CSNTPClient::GetServerTime( LPSYSTEMTIME lpSystemTime ) { NtpServerResponse response; for( int i = 0; i < MAX_NTP_SERVER; i++ ) { if( GetServerTime( CSNTPClient::m_pszHostNames[i], response ) ) { CNtpTime newTime( CNtpTime::GetCurrentTime() + response.LocalClockOffset ); *lpSystemTime = newTime; return TRUE; } } return FALSE; }
/* * This method will request a time advance to the current time, plus the given * timestep. It will then wait until a notification of the time advance grant * has been received. */ void ExampleCPPFederate::advanceTime( double timestep ) { // request the advance fedamb->isAdvancing = true; auto_ptr<HLAfloat64Time> newTime( new HLAfloat64Time(fedamb->federateTime+timestep) ); rtiamb->timeAdvanceRequest( *newTime ); // wait for the time advance to be granted. ticking will tell the // LRC to start delivering callbacks to the federate while( fedamb->isAdvancing ) { rtiamb->evokeMultipleCallbacks( 0.1, 1.0 ); } }
QTime SessionDefaults::correctFPTime(const QTime &time) const { int hour = time.hour(); int min = time.minute(); int sec = time.second(); int t = getFPLength() * 60 - hour * 3600 - min * 60 - sec; hour = t/3600; min = (t%3600)/60; sec = (t%3600)%60; QTime newTime(hour, min, sec); return newTime; }
QTime SessionDefaults::correctQualiTime(const QTime &time, int qualiPeriod) const { int hour = time.hour(); int min = time.minute(); int sec = time.second(); int sLength = 10 + (qualiLengths.size() - qualiPeriod)*5; int t = sLength * 60 - hour * 3600 - min * 60 - sec; hour = t/3600; min = (t%3600)/60; sec = (t%3600)%60; QTime newTime(hour, min, sec); return newTime; }
Time Time::operator-(Time t) { int newHours = 0; int newMinutes = 0; int newSeconds = 0; int newDay = 0; newSeconds = seconds - t.seconds; if (newSeconds < 0) { newSeconds = 60 + newSeconds; newMinutes--; } newMinutes = newMinutes + (minutes - t.minutes); if (newMinutes < 0) { newMinutes = 60 + newMinutes; newHours--; } newHours = newHours + (hours - t.hours); if (newHours < 0) { newHours = 24 + newHours; newDay--; } newDay = newDay + (day - t.day); Time newTime(newHours, newMinutes, newSeconds, newDay); return newTime; }
Time Time::operator+(Time t) { int newHours = 0; int newMinutes = 0; int newSeconds = 0; int newDay = 0; newSeconds = t.seconds + seconds; if (newSeconds > 59) { newSeconds = newSeconds - 60; newMinutes++; } newMinutes = newMinutes + t.minutes + minutes; if (newMinutes > 59) { newMinutes = newMinutes - 60; newHours++; } newHours = newHours + t.hours + hours; if (newHours > 23) { newHours = newHours - 24; newDay++; } newDay = newDay + t.day + day; Time newTime(newHours, newMinutes, newSeconds, newDay); return newTime; }
void NodeList_sV::moveSelected(const Node_sV &time) { qreal maxRMove = 100000; qreal maxLMove = -100000; qreal maxUMove = 100000; qreal maxDMove = -100000; const Node_sV *left = NULL; const Node_sV *right; for (int i = 0; i < m_list.size(); i++) { right = &m_list.at(i); /* Get the maximum allowed horizontal movement distance here such that there is no overlapping. For moving the selected nodes to the left, only unselected nodes which are directly followed by a selected node need to be taken into account. O----O / \ x -----x \ / x-----------O min( ^1^, ^-----2-----^ ) + minDist */ if (left != NULL) { if (left->selected() && !right->selected()) { // Move-right distance maxRMove = qMin(maxRMove, right->xUnmoved()+right->leftNodeHandle().x() - (left->xUnmoved()+left->rightNodeHandle().x()) - m_minDist); } else if (!left->selected() && right->selected()) { // Move-left distance maxLMove = qMax(maxLMove, left->xUnmoved()+left->rightNodeHandle().x() - (right->xUnmoved()+right->leftNodeHandle().x()) + m_minDist); } } if (right->selected()) { maxDMove = qMax(maxDMove, -right->yUnmoved()); maxUMove = qMin(maxUMove, m_maxY-right->yUnmoved()); } left = right; } if (m_list.size() > 0 && m_list.at(0).selected()) { // Do not allow to move nodes to x < 0 maxLMove = qMax(maxLMove, -m_list.at(0).xUnmoved()); } #ifdef DEBUG_NL qDebug() << "Max move: left " << maxLMove << ", right: " << maxRMove; #endif Node_sV newTime( qMax(maxLMove, qMin(maxRMove, time.x())), qMax(maxDMove, qMin(maxUMove, time.y())) ); for (int i = 0; i < m_list.size(); i++) { if (m_list.at(i).selected()) { m_list[i].move(newTime); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Create our market market = new Market(":/market-data",this,5000); // Create the windows sim = new SimulationWindow(market, 0); dec = new DecryptionWindow(market, 0); title = new TitleScreen(0); inst1 = new InstructionScreen1(0); inst2 = new InstructionScreen2(0); //inst3 = new InstructionScreen3(0); inst4 = new InstructionScreen4(0); inst5 = new InstructionScreen5(0); inst6 = new InstructionScreen6(0); inst7 = new InstructionScreen7(0); inst8 = new InstructionScreen8(0); instTest1 = new InstructionScreenTest1(0); instTest2 = new InstructionScreenTest2(0); instTest3 = new InstructionScreenTest3(0); initAlloc = new InitialAllocationScreen(market, 0); quest1 = new QuestionScreen1(0); fin = new FinalScreen(0); ui->stackedWidget->addWidget(title); ui->stackedWidget->addWidget(inst1); ui->stackedWidget->addWidget(inst2); //ui->stackedWidget->addWidget(inst3); ui->stackedWidget->addWidget(inst4); ui->stackedWidget->addWidget(inst5); ui->stackedWidget->addWidget(inst6); ui->stackedWidget->addWidget(inst7); ui->stackedWidget->addWidget(inst8); ui->stackedWidget->addWidget(instTest1); ui->stackedWidget->addWidget(instTest2); ui->stackedWidget->addWidget(instTest3); ui->stackedWidget->addWidget(initAlloc); ui->stackedWidget->addWidget(dec); ui->stackedWidget->addWidget(sim); ui->stackedWidget->addWidget(quest1); ui->stackedWidget->addWidget(fin); // Make a list of widget pointers, so we can easily swap between them widgets = new QList<QWidget*>(); widgets->push_back(title); //1 widgets->push_back(inst1); //2 widgets->push_back(inst2); //3 //widgets->push_back(inst3); //4 widgets->push_back(instTest1); //5 widgets->push_back(instTest2); //6 widgets->push_back(inst4); //7 widgets->push_back(inst5); //8 widgets->push_back(inst6); //9 widgets->push_back(inst7); //10 widgets->push_back(instTest3); //11 widgets->push_back(inst8); //12 widgets->push_back(initAlloc); widgets->push_back(dec); widgets->push_back(sim); widgets->push_back(quest1); widgets->push_back(fin); pos = widgets->begin(); ui->stackedWidget->setCurrentWidget(*pos); preNavigation(); simStarted = false; finishedExperiment = false; test1Passed = false; test2Passed = false; test3Passed = false; connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextScreen())); connect(ui->prevButton, SIGNAL(clicked()), this, SLOT(prevScreen())); connect(instTest1,SIGNAL(testPassed()),this,SLOT(passTest1())); connect(instTest2,SIGNAL(testPassed()),this,SLOT(passTest2())); connect(instTest3->win, SIGNAL(DecryptionCompleted()), this, SLOT(passTest3())); connect(market, SIGNAL(newTime(QString)), this, SLOT(updateTime(QString))); connect(market, SIGNAL(allocationUpdated(double)), this, SLOT(waitForInitialAlocation(double))); connect(quest1, SIGNAL(gimmeANextButton()), this, SLOT(enableNextButton())); connect(market, SIGNAL(priceChange(double)), this, SLOT(updateIndex()) ); // Hide the labels (until the right time) ui->simulationDisplay->setHidden(true); this->setWindowFlags(Qt::FramelessWindowHint); this->showFullScreen(); }
// Set the time to time_t + msec // ============================================================================================= void DateTime::setCtime(double t) { DateTime newTime(t); uaDateTime_ = UaDateTime(newTime.toFileTime()); }