46 m_Mutex(QMutex::Recursive)
49 bool bConnected(
true);
50 QDBusConnection Connection = QDBusConnection::sessionBus();
54 m_pStateMachine->AttachObserver(
this);
57 QObject::connect(
this, SIGNAL(Updated(
void)),
this, SLOT(UpdateSlot(
void)), Qt::AutoConnection);
60 this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
71 m_pAdaptor = new ::ADMI(
this);
74 bConnected &= Connection.registerService(
"oETCS.DF.IDMI");
75 bConnected &= Connection.registerObject(
"/oETCS/DMI",
this);
77 catch (const ::std::bad_alloc& Exception)
80 ::std::cerr << Exception.what() << ::std::endl;
88 ::std::cerr <<
"DMI adaptor was not registered successfully on D-Bus" << ::std::endl;
208 QString AllowedValues;
209 QMessageBox ErrorMessage(
this);
210 ::std::string StringInput;
211 unsigned int uiIndex(0);
212 double dDoubleInput(0.0);
215 bool bBoolInput(
false);
221 ErrorMessage.setWindowModality(Qt::NonModal);
222 ErrorMessage.setText(tr(
"Error while setting input: value not allowed"));
223 ErrorMessage.setStandardButtons(QMessageBox::Ok);
224 ErrorMessage.setWindowTitle(tr(
"Input value not allowed"));
225 ErrorMessage.setIcon(QMessageBox::Critical);
232 pSender = this->sender();
235 if (dynamic_cast< QPushButton* >(pSender) != 0)
241 bFound = (*ib == pSender);
256 bBoolInput =
static_cast< QCheckBox*
>(
m_InputWidgets[uiIndex])->checkState() == 0 ?
false :
true;
265 AllowedValues += QString(*abi ?
"true" :
"false") + QString(
"; ");
270 ErrorMessage.setInformativeText(tr(
"Allowed values: ") + AllowedValues);
289 dDoubleInput =
static_cast< QDoubleSpinBox*
>(
m_InputWidgets[uiIndex])->value();
298 AllowedValues += QString::number(*adi) + QString(
"; ");
303 ErrorMessage.setInformativeText(tr(
"Allowed values: ") + AllowedValues);
329 iIntInput =
static_cast< QSpinBox*
>(
m_InputWidgets[uiIndex])->value();
338 AllowedValues += QString::number(*aii) + QString(
"; ");
343 ErrorMessage.setInformativeText(tr(
"Allowed values: ") + AllowedValues);
362 StringInput =
static_cast< QLineEdit*
>(
m_InputWidgets[uiIndex])->text().toStdString();
371 AllowedValues += QString((*asi).c_str()) + QString(
"; ");
376 ErrorMessage.setInformativeText(tr(
"Allowed values: ") + AllowedValues);
418 QMessageBox ErrorMessage(
this);
419 unsigned int uiRow(0);
420 bool bSubjectChanged(
false);
431 if (pSubject !=
nullptr)
498 for (uiRow = 0, o = pSubject->
m_Outputs.begin(); o != pSubject->
m_Outputs.end(); uiRow++, o++)
501 m_Labels.push_back(
new QLabel((*o)->m_Label.c_str(),
this));
519 for (uiRow = 0, i = pSubject->
m_Inputs.begin(); i != pSubject->
m_Inputs.end(); uiRow++, i++)
522 m_Labels.push_back(
new QLabel((*i)->m_Label.c_str(),
this));
529 switch ((*i)->m_eType)
543 static_cast < ::QDoubleSpinBox* >(*(
m_InputWidgets.end() - 1))->setMinimum(0.0);
544 static_cast < ::QDoubleSpinBox* >(*(
m_InputWidgets.end() - 1))->setMaximum(10000.0);
561 static_cast < ::QSpinBox* >(*(
m_InputWidgets.end() - 1))->setMinimum(0);
562 static_cast < ::QSpinBox* >(*(
m_InputWidgets.end() - 1))->setMaximum(10000);
593 for (uiRow = 0, o = pSubject->
m_Outputs.begin(); o != pSubject->
m_Outputs.end(); uiRow++, o++)
597 m_Labels[uiRow]->setVisible((*o)->m_bVisible());
600 switch ((*o)->m_eType)
604 static_cast< QLineEdit*
>(
m_OutputWidgets[uiRow])->setText((*o)->m_bBoolMessage() ?
"true" :
"false");
611 static_cast< QLineEdit*
>(
m_OutputWidgets[uiRow])->setText(QString::number((*o)->m_dDoubleMessage()));
618 for (da = (*o)->m_DoubleArrayMessage().begin(); da != (*o)->m_DoubleArrayMessage().end(); da++)
621 static_cast< QLineEdit*
>(
m_OutputWidgets[uiRow])->setText(static_cast< QLineEdit* >((*(
m_OutputWidgets.end() - 1)))->text()+ QString::number(*da)+
"; ");
630 static_cast< QLineEdit*
>(
m_OutputWidgets[uiRow])->setText(QString::number((*o)->m_iIntMessage()));
637 static_cast< QLineEdit*
>(
m_OutputWidgets[uiRow])->setText((*o)->m_StringMessage().c_str());
647 for (uiRow = 0, i = pSubject->
m_Inputs.begin(); i != pSubject->
m_Inputs.end(); uiRow++, i++)
661 catch (const ::std::bad_alloc& Exception)
667 ErrorMessage.setWindowModality(Qt::NonModal);
668 ErrorMessage.setText(tr(
"Error while allocation of memory for GUI elements.\nThe GUI representation might not be correct!"));
669 ErrorMessage.setStandardButtons(QMessageBox::Ok);
670 ErrorMessage.setWindowTitle(tr(
"Not enough memory"));
671 ErrorMessage.setInformativeText(tr(
"Unfortunately there is nothing you can do about it."));
672 ErrorMessage.setIcon(QMessageBox::Critical);
704 for (x = NUMBER_OUTPUTS; x < (NUMBER_INPUTS + NUMBER_OUTPUTS); x++)
707 if (InputWidgets[x - NUMBER_OUTPUTS]->isVisible())
710 Inputs.append(Labels[x]->text());
713 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
715 ::std::cout <<
"DEBUG: GetInputs() -> input #" << x <<
" \"" << Labels[x]->text().toStdString() <<
"\"" << ::std::endl;
722 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
724 ::std::cout <<
"DEBUG: GetInputs() -> number of inputs in list " << Inputs.size() << ::std::endl;
749 for (x = 0; x < NUMBER_OUTPUTS; x++)
755 Outputs.append(
m_Labels[x]->text());
783 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
785 ::std::cout <<
"DEBUG: GetOutputValue() -> started" << ::std::endl;
795 if ((*x)->text() == OutputName && (*x)->isVisible())
809 Value =
static_cast< ::QLineEdit*
>(
m_OutputWidgets[iPosition])->text();
815 ::std::cerr <<
"warning in CDMIQWidget::GetOutputValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> output field \"" << OutputName.toStdString() <<
"\" not found" << ::std::endl;
822 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
824 ::std::cout <<
"DEBUG: GetOutputValue() -> finished with value \"" << Value.toStdString() <<
"\"" << ::std::endl;
839 bool bHasInput(
false);
843 bHasInput = !(this->
GetInputs().empty());
863 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
865 ::std::cout <<
"DEBUG: started CDMIQWidget::SetBooleanValue()" << ::std::endl;
875 if ((*x)->text() == InputName)
888 if (dynamic_cast< ::QCheckBox* >(
m_InputWidgets[iPosition]) !=
nullptr)
891 if (static_cast< ::QCheckBox* >(
m_InputWidgets[iPosition])->isVisible())
894 static_cast< ::QCheckBox*
>(
m_InputWidgets[iPosition])->setChecked(bValue);
903 ::std::cerr <<
"warning in CDMIQWidget::SetBooleanValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is currently not visible" << ::std::endl;
912 ::std::cerr <<
"warning in CDMIQWidget::SetBooleanValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is not a boolean field" << ::std::endl;
920 ::std::cerr <<
"warning in CDMIQWidget::SetBooleanValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" not found" << ::std::endl;
927 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
929 ::std::cout <<
"DEBUG: finished CDMIQWidget::SetBooleanValue()" << ::std::endl;
947 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
949 ::std::cout <<
"DEBUG: started CDMIQWidget::SetDoubleValue()" << ::std::endl;
959 if ((*x)->text() == InputName)
972 if (dynamic_cast< ::QDoubleSpinBox* >(
m_InputWidgets[iPosition]) !=
nullptr)
975 if (static_cast< ::QDoubleSpinBox* >(
m_InputWidgets[iPosition])->isVisible())
978 static_cast< ::QDoubleSpinBox*
>(
m_InputWidgets[iPosition])->setValue(dValue);
987 ::std::cerr <<
"warning in CDMIQWidget::SetDoubleValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is currently not visible" << ::std::endl;
995 ::std::cerr <<
"warning in CDMIQWidget::SetDoubleValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is not a double field" << ::std::endl;
1004 ::std::cerr <<
"warning in CDMIQWidget::SetDoubleValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" not found" << ::std::endl;
1011 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
1013 ::std::cout <<
"DEBUG: finished CDMIQWidget::SetDoubleValue()" << ::std::endl;
1038 if ((*x)->text() == InputName)
1048 if (iPosition != -1)
1051 if (dynamic_cast< ::QSpinBox* >(
m_InputWidgets[iPosition]) !=
nullptr)
1054 if (static_cast< ::QSpinBox* >(
m_InputWidgets[iPosition])->isVisible())
1057 static_cast< ::QSpinBox*
>(
m_InputWidgets[iPosition])->setValue(iValue);
1066 ::std::cerr <<
"warning in CDMIQWidget::SetIntegerValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is currently not visible" << ::std::endl;
1074 ::std::cerr <<
"warning in CDMIQWidget::SetIntegerValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is not a integer field" << ::std::endl;
1082 ::std::cerr <<
"warning in CDMIQWidget::SetIntegerValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" not found" << ::std::endl;
1106 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
1108 ::std::cout <<
"DEBUG: started CDMIQWidget::SetStringValue()" << ::std::endl;
1118 if ((*x)->text() == InputName)
1128 if (iPosition != -1)
1131 if (dynamic_cast< ::QLineEdit* >(
m_InputWidgets[iPosition]) !=
nullptr)
1134 if (static_cast< ::QLineEdit* >(
m_InputWidgets[iPosition])->isVisible())
1137 static_cast< ::QLineEdit*
>(
m_InputWidgets[iPosition])->setText(Value);
1146 ::std::cerr <<
"warning in CDMIQWidget::SetStringValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is currently not visible" << ::std::endl;
1154 ::std::cerr <<
"warning in CDMIQWidget::SetStringValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" is not a string field" << ::std::endl;
1162 ::std::cerr <<
"warning in CDMIQWidget::SetStringValue() in " << __FILE__ <<
":" << __LINE__ <<
" -> input field \"" << InputName.toStdString() <<
"\" not found" << ::std::endl;
1169 #ifdef __OETCS_DF_DMI_DEBUG_OUTPUT__
1171 ::std::cout <<
"DEBUG: finished CDMIQWidget::SetStringValue()" << ::std::endl;