38 updateTimer =
new QTimer(
this);
67 connect(updateTimer, SIGNAL(timeout()),
this, SLOT(
updateGui()));
72 widget.spinBoxSpeed, SIGNAL(valueChanged(
double)),
this, SLOT(
speedChanged(
double)));
75 lastChangeSystemTime = IceUtil::Time::now();
78 updateTimer->start(53);
83 widget.btnStart->setEnabled(
true);
84 widget.btnStop->setEnabled(
true);
85 widget.btnStep->setEnabled(
true);
86 widget.spinBoxSpeed->setEnabled(
true);
87 widget.spinBoxStepCount->setEnabled(
true);
92 widget.spinBoxSpeed->setValue(timeServerPtr->getSpeed());
94 catch (IceUtil::NullHandleException&)
96 widget.spinBoxSpeed->setValue(1);
104 timeServerPtr = NULL;
105 widget.btnStart->setEnabled(
false);
106 widget.btnStop->setEnabled(
false);
107 widget.btnStep->setEnabled(
false);
108 widget.spinBoxSpeed->setEnabled(
false);
109 widget.spinBoxStepCount->setEnabled(
false);
123 if (iteration % 10 == 0)
125 auto timeDiffVirtual = time - lastChangeTime;
126 auto now = IceUtil::Time::now();
127 auto timeDiffSystem = now - lastChangeSystemTime;
128 if (timeDiffSystem.toMilliSeconds() > 0 &&
129 timeDiffVirtual.toMilliSeconds() >=
133 float(timeDiffVirtual.toMilliSeconds()) / timeDiffSystem.toMilliSeconds();
134 widget.lblActualSpeed->setText(QString(
"(%1)").arg(actualFactor, 0,
'f', 2));
136 if (timeDiffVirtual.toMilliSeconds() != 0)
138 lastChangeSystemTime = now;
139 lastChangeTime = time;
144 if (timeServerPtr && iteration % 20 == 0)
148 widget.lblSteps->setText(QString(
"x %1ms").arg(timeServerPtr->getStepTimeMS()));
149 if (!widget.spinBoxSpeed->hasFocus())
151 widget.spinBoxSpeed->setValue(timeServerPtr->getSpeed());
154 catch (Ice::NotRegisteredException&)
158 catch (IceUtil::NullHandleException&)
162 catch (Ice::ConnectionRefusedException&)
171 timeStr = QString::fromStdString(time.toDuration());
175 timeStr = QString::fromStdString(time.toDateTime());
178 widget.lblTime->setText(timeStr);
188 timeServerPtr->start();
197 for (
int i = 0; i < widget.spinBoxStepCount->value(); ++i)
199 timeServerPtr->step();
209 timeServerPtr->stop();
218 timeServerPtr->setSpeed(newSpeed);