|
- #include "CableTestPage.h"
- #include "ui_CableTestPage.h"
- #include "CableTestBench.h"
- #include <QTextCodec>
- #include "CableParametersData.h"
- #include <QScrollBar>
-
- CCableTestPage::CCableTestPage(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::CCableTestPage)
- {
-
- QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
-
- ui->setupUi(this);
- mProgramHandle = 0;
-
- ui->mStationNameCombo->insertItem(0,"Frontenac",QVariant("1S52"));
- ui->mStationNameCombo->insertItem(1,"Côte-Vertu",QVariant("2S22"));
- ui->mStationNameCombo->insertItem(2,"Angrignon",QVariant("1S18"));
- ui->mStationNameCombo->insertItem(3,"Garage Angrignon",QVariant("1G17"));
- ui->mStationNameCombo->insertItem(4,"Atwater",QVariant("1S34"));
- ui->mStationNameCombo->insertItem(5,"Lionel-Groulx",QVariant("1S32"));
- ui->mStationNameCombo->insertItem(6,"Viau",QVariant("1S60"));
-
-
- mInspectionNotDonePixmap = QPixmap("./images/todo.png").scaled(ui->mInspectionDoneIcon->geometry().width(),ui->mInspectionDoneIcon->geometry().height());
- mInspectionDonePixmap = QPixmap("./images/done1.png").scaled(ui->mInspectionDoneIcon->geometry().width(),ui->mInspectionDoneIcon->geometry().height());
- ui->mInspectionDoneIcon->setPixmap(mInspectionNotDonePixmap);
-
- connect(ui->mExecInspVisuelleBtn,SIGNAL(clicked()),this,SLOT(InspVisuelleBtnClicked()));
- connect(ui->mConnectorSelectWidget,SIGNAL(ConnectorSelected(CConnectorDefs::eConnectorType)),this,SLOT(ConnectorSelectionChanged(CConnectorDefs::eConnectorType)));
- ui->mInputTestVisualisationWidget->SetConnectorPinCount(0);
- ui->mOutputTestVisualisationWidget->SetConnectorPinCount(0);
-
-
- mGuiRefreshTimer.setSingleShot(false);
- mGuiRefreshTimer.setInterval(200);
-
-
- connect(ui->mStartTestBtn,SIGNAL(clicked()),this,SLOT(StartTestBtnClicked()));
- connect(ui->mReinitTestBtn,SIGNAL(clicked()),this,SLOT(ResetTestBtnClicked()));
- connect(ui->mNewCableBtn,SIGNAL(clicked()),this,SLOT(NewCableBtnClicked()));
- connect(ui->mStartManualTestBtn,SIGNAL(clicked()),this,SLOT(StartManualTestBtnClicked()));
- connect(ui->mOutputTestVisualisationWidget,SIGNAL(PinClicked(int)),this,SLOT(OutputConnectorPinClicked(int)));
- connect(&mGuiRefreshTimer,SIGNAL(timeout()),this,SLOT(GuiRefreshTimerExpired()));
- connect(ui->mSaveReportBtn,SIGNAL(clicked()),this,SLOT(SaveReportBtnClicked()));
- connect(ui->mOpenReportBtn,SIGNAL(clicked()),this,SLOT(OpenReportBtnClicked()));
- connect(ui->mIdentCableEditBox,SIGNAL(textEdited(QString)),this,SLOT(CableConfigTextChanged()));
- connect(ui->mNomTesteurEditBox,SIGNAL(textEdited(QString)),this,SLOT(CableConfigTextChanged()));
-
-
-
- mDefaultCableName = "CABLE_XX_NO_AA_BB.c";
- mDefaultInspectorName = "JFMartel";
-
- ui->mStartTestBtn->setEnabled(false);
- ui->mStartManualTestBtn->setEnabled(false);
- ui->mOutputTestVisualisationWidget->DisablePinClicks();
-
- QPalette pal;
- pal.setColor(QPalette::WindowText,Qt::red);
- ui->mVisualInspectionStepLabel->setPalette(pal);
- ui->mVisualInspectionStepLabel->setText("2. Inspection visuelle: À FAIRE");
-
- ui->mCableIdentStepLabel->setPalette(pal);
- ui->mCableIdentStepLabel->setText("1. Identification du câble: À REMPLIR");
-
- ui->mConnectorSelStepLabel->setPalette(pal);
- ui->mConnectorSelStepLabel->setText("3. Sélection du connecteur d'entrée: À FAIRE");
-
-
-
- ResetCable();
- }
-
- CCableTestPage::~CCableTestPage()
- {
- delete ui;
- }
-
- void CCableTestPage::InspVisuelleBtnClicked()
- {
- mProgramHandle->ExecVisualInspectionRequest();
-
- }
-
- int CCableTestPage::SetVisualInspectionDone(bool Done)
- {
- if(Done)
- {
- ui->mInspectionDoneIcon->setPixmap(mInspectionDonePixmap);
- ui->mExecInspVisuelleBtn->setText(QString("Réviser\n Inspection").toUtf8());
-
- QPalette pal;
- pal.setColor(QPalette::WindowText,Qt::darkGreen);
- ui->mVisualInspectionStepLabel->setPalette(pal);
- ui->mVisualInspectionStepLabel->setText("2. Inspection visuelle: OK");
- }
- else
- {
- ui->mInspectionDoneIcon->setPixmap(mInspectionNotDonePixmap);
- ui->mExecInspVisuelleBtn->setText("Effectuer\n Inspection");
-
- QPalette pal;
- pal.setColor(QPalette::WindowText,Qt::red);
- ui->mVisualInspectionStepLabel->setPalette(pal);
- ui->mVisualInspectionStepLabel->setText("2. Inspection visuelle: À FAIRE");
- }
- return RET_OK;
- }
-
- int CCableTestPage::SetConnectorSelStep(bool done)
- {
- QPalette pal;
-
- if(done)
- {
- pal.setColor(QPalette::WindowText,Qt::darkGreen);
- ui->mConnectorSelStepLabel->setPalette(pal);
- ui->mConnectorSelStepLabel->setText("3. Sélection du connecteur d'entrée: OK");
- }
- else
- {
- pal.setColor(QPalette::WindowText,Qt::red);
- ui->mConnectorSelStepLabel->setPalette(pal);
- ui->mConnectorSelStepLabel->setText("3. Sélection du connecteur d'entrée: À FAIRE");
- }
-
- return RET_OK;
- }
-
- int CCableTestPage::SetCableConfigureStep(bool done)
- {
- QPalette pal;
-
- if(done)
- {
- pal.setColor(QPalette::WindowText,Qt::darkGreen);
- ui->mCableIdentStepLabel->setPalette(pal);
- ui->mCableIdentStepLabel->setText("1. Identification du câble: OK");
- }
- else
- {
- pal.setColor(QPalette::WindowText,Qt::red);
- ui->mCableIdentStepLabel->setPalette(pal);
- ui->mCableIdentStepLabel->setText("1. Identification du câble: À REMPLIR");
- }
-
- return RET_OK;
- }
-
-
- void CCableTestPage::ConnectorSelectionChanged(CConnectorDefs::eConnectorType ConType)
- {
- CCable* Cable;
- Cable = mProgramHandle->SetSelectedConnector(ConType);
-
- if(Cable != 0)
- {
- ui->mInputTestVisualisationWidget->SetConnectorPinCount(Cable->GetInputConnector()->GetPinCount());
- ui->mOutputTestVisualisationWidget->SetConnectorPinCount(Cable->GetOutputConnector()->GetPinCount());
- }
-
-
- }
-
- void CCableTestPage::StartTestBtnClicked()
- {
- mProgramHandle->StartPauseAutomaticTestRequest();
- }
-
- void CCableTestPage::StartManualTestBtnClicked()
- {
- mProgramHandle->StartStopManualTestRequest();
- }
-
- void CCableTestPage::ResetTestBtnClicked()
- {
- mProgramHandle->ResetAutomaticTestRequest();
- }
-
- void CCableTestPage::NewCableBtnClicked()
- {
- mProgramHandle->NewCableRequest();
- }
-
- int CCableTestPage::ResetCable()
- {
- //reset pins state visualization area
- ui->mInputTestVisualisationWidget->ClearConnectorsLists();
- ui->mOutputTestVisualisationWidget->ClearConnectorsLists();
-
- //Reset cable config zone
- // ui->mIdentCableEditBox->setText(mDefaultCableName);
- // ui->mNomTesteurEditBox->setText(mDefaultInspectorName);
-
- //Reset Inspection Visuelle result (main program will clear the form)
- SetVisualInspectionDone(false);
-
- // SetCableConfigureStep(false);
- SetConnectorSelStep(false);
-
- //Clear connector selection zone
- ui->mConnectorSelectWidget->ClearAllConnectorsSelections();
-
- ui->mTestLogTextBox->clear();
-
- ui->mSaveReportBtn->setEnabled(false);
- ui->mOpenReportBtn->setEnabled(false);
- SetAutoTestResult("");
-
- return RET_OK;
-
- }
-
- int CCableTestPage::EnableStartTestBtn()
- {
- ui->mStartTestBtn->setEnabled(true);
- ui->mStartManualTestBtn->setEnabled(true);
- return RET_OK;
- }
-
- int CCableTestPage::DisableStartTestBtn()
- {
- ui->mStartTestBtn->setEnabled(false);
- ui->mStartManualTestBtn->setEnabled(false);
- return RET_OK;
- }
-
- int CCableTestPage::CableAutomaticTestStarted()
- {
- ui->mStartManualTestBtn->setEnabled(false);
- DisableGuiForTest();
- ui->mStartTestBtn->setText("Interrompre Test");
- SetAutoTestResult("En Cours...",Qt::black);
- return RET_OK;
- }
-
- int CCableTestPage::CableAutomaticTestPaused()
- {
- ui->mStartTestBtn->setText("Reprendre Test");
- return RET_OK;
- }
-
- int CCableTestPage::CableTestEnded()
- {
- EnableGuiAfterTest();
- ui->mOutputTestVisualisationWidget->DisablePinClicks();
- ui->mStartManualTestBtn->setEnabled(true);
- ui->mStartTestBtn->setEnabled(true);
- ui->mStartTestBtn->setText("Démarrer Test");
- ui->mStartManualTestBtn->setText("Démarrer");
- ui->mReinitTestBtn->setEnabled(true);
- ui->mSaveReportBtn->setEnabled(true);
-
- return RET_OK;
- }
-
- int CCableTestPage::CableManualTestStarted()
- {
- ui->mStartTestBtn->setEnabled(false);
- ui->mOutputTestVisualisationWidget->EnablePinClicks();
- DisableGuiForTest();
- ui->mStartManualTestBtn->setText("Terminer");
- ui->mReinitTestBtn->setEnabled(false);
- ui->mSaveReportBtn->setEnabled(false);
- return RET_OK;
- }
-
- int CCableTestPage::DisableGuiForTest()
- {
- ui->mNewCableBtn->setEnabled(false);
- ui->mConnectorSelectWidget->setEnabled(false);
- ui->mIdentCableEditBox->setEnabled(false);
- ui->mExecInspVisuelleBtn->setEnabled(false);
- ui->mNomTesteurEditBox->setEnabled(false);
- ui->mTypeCableCombo->setEnabled(false);
- ui->mStationNameCombo->setEnabled(false);
- return RET_OK;
- }
-
- int CCableTestPage::EnableGuiAfterTest()
- {
- ui->mNewCableBtn->setEnabled(true);
- ui->mConnectorSelectWidget->setEnabled(true);
- ui->mIdentCableEditBox->setEnabled(true);
- ui->mExecInspVisuelleBtn->setEnabled(true);
- ui->mNomTesteurEditBox->setEnabled(true);
- ui->mTypeCableCombo->setEnabled(true);
- ui->mStationNameCombo->setEnabled(true);
- return RET_OK;
- }
-
- void CCableTestPage::OutputConnectorPinClicked(int PinNbr)
- {
- mProgramHandle->ManualPinToggleRequest(PinNbr);
- }
-
- void CCableTestPage::GuiRefreshTimerExpired()
- {
- mProgramHandle->RefreshConnectorsStateRequest();
- }
-
- int CCableTestPage::SetOutputConnectorState(QBitArray PinStates)
- {
- return ui->mOutputTestVisualisationWidget->SetConnectorPinStates(PinStates);
- }
-
- int CCableTestPage::SetInputConnectorState(QBitArray PinStates)
- {
- return ui->mInputTestVisualisationWidget->SetConnectorPinStates(PinStates);
- }
-
- void CCableTestPage::showEvent(QShowEvent *event)
- {
-
- qDebug("Refresh timer started");
- mGuiRefreshTimer.start();
-
- }
-
- void CCableTestPage::hideEvent(QHideEvent *event)
- {
- qDebug("Refresh timer stopped");
- mGuiRefreshTimer.stop();
- }
-
- int CCableTestPage::FillReportCableParametersData(CCableParametersData *ReportPtr)
- {
- ReportPtr->SetCableParams(ui->mStationNameCombo->currentText(),
- ui->mStationNameCombo->itemData(ui->mStationNameCombo->currentIndex()).toString(),
- ui->mIdentCableEditBox->text(),
- ui->mTypeCableCombo->currentText(),
- ui->mNomTesteurEditBox->text());
- return RET_OK;
- }
-
- void CCableTestPage::AddTestLogEntry(QString Entry)
- {
- ui->mTestLogTextBox->insertPlainText(Entry);
- ui->mTestLogTextBox->verticalScrollBar()->setValue(ui->mTestLogTextBox->verticalScrollBar()->maximum());
- }
-
- void CCableTestPage::SaveReportBtnClicked()
- {
- mProgramHandle->SaveReportRequest();
- }
-
- void CCableTestPage::OpenReportBtnClicked()
- {
- mProgramHandle->OpenReportRequest();
- }
-
- int CCableTestPage::EnableOpenReportBtn()
- {
- ui->mOpenReportBtn->setEnabled(true);
- return RET_OK;
- }
-
- int CCableTestPage::SetAutoTestResult(QString Result, QColor color)
- {
- QPalette pal;
- pal.setColor(QPalette::WindowText,color);
- ui->mAutoTestResultLabel->setPalette(pal);
- ui->mAutoTestResultLabel->setText(Result);
-
- return RET_OK;
- }
-
- bool CCableTestPage::IsCableConfigured()
- {
- if(ui->mIdentCableEditBox->text().isEmpty())
- {
- return false;
- }
-
- if(ui->mNomTesteurEditBox->text().isEmpty())
- {
- return false;
- }
-
- return true;
- }
-
- void CCableTestPage::CableConfigTextChanged()
- {
- mProgramHandle->CableConfigChanged();
- }
|