38 updateTimer =
new QTimer(
this);
70 connect(updateTimer, SIGNAL(timeout()),
this, SLOT(
updateGui()));
74 connect(widget.spinBoxSpeed, SIGNAL(valueChanged(
double)),
this, SLOT(
speedChanged(
double)));
77 lastChangeSystemTime = IceUtil::Time::now();
80 updateTimer->start(53);
85 widget.btnStart->setEnabled(
true);
86 widget.btnStop->setEnabled(
true);
87 widget.btnStep->setEnabled(
true);
88 widget.spinBoxSpeed->setEnabled(
true);
89 widget.spinBoxStepCount->setEnabled(
true);
94 widget.spinBoxSpeed->setValue(timeServerPtr->getSpeed());
96 catch (IceUtil::NullHandleException&)
98 widget.spinBoxSpeed->setValue(1);
105 timeServerPtr = NULL;
106 widget.btnStart->setEnabled(
false);
107 widget.btnStop->setEnabled(
false);
108 widget.btnStep->setEnabled(
false);
109 widget.spinBoxSpeed->setEnabled(
false);
110 widget.spinBoxStepCount->setEnabled(
false);
122 if (iteration % 10 == 0)
124 auto timeDiffVirtual = time - lastChangeTime;
125 auto now = IceUtil::Time::now();
126 auto timeDiffSystem = now - lastChangeSystemTime;
127 if (timeDiffSystem.toMilliSeconds() > 0 && timeDiffVirtual.toMilliSeconds() >= 0)
129 float actualFactor =
float(timeDiffVirtual.toMilliSeconds()) / timeDiffSystem.toMilliSeconds();
130 widget.lblActualSpeed->setText(QString(
"(%1)").arg(actualFactor, 0,
'f', 2));
132 if (timeDiffVirtual.toMilliSeconds() != 0)
134 lastChangeSystemTime = now;
135 lastChangeTime = time;
140 if (timeServerPtr && iteration % 20 == 0)
144 widget.lblSteps->setText(QString(
"x %1ms").arg(timeServerPtr->getStepTimeMS()));
145 if (!widget.spinBoxSpeed->hasFocus())
147 widget.spinBoxSpeed->setValue(timeServerPtr->getSpeed());
150 catch (Ice::NotRegisteredException&)
154 catch (IceUtil::NullHandleException&)
158 catch (Ice::ConnectionRefusedException&)
168 timeStr = QString::fromStdString(time.toDuration());
172 timeStr = QString::fromStdString(time.toDateTime());
175 widget.lblTime->setText(timeStr);
184 timeServerPtr->start();
192 for (
int i = 0; i < widget.spinBoxStepCount->value() ; ++i)
194 timeServerPtr->step();
203 timeServerPtr->stop();
211 timeServerPtr->setSpeed(newSpeed);