#include "hardwaretester.h"
#include "cserialporthandler.h"
#include "comthread.h"
#include <iostream>
#include <QStringList>
#include <QGraphicsScene>
#include <QMessageBox>
HardwareTester
::HardwareTester(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
//Check if got in, in input a version string.
_inVersionString = false;
CSerialPortHandler handler;
handler.enumerate(this->_ports, false);
for(std::vector<_SSerialPortInfo>::const_iterator it = _ports.begin(); it != _ports.end(); ++it)
{
s = (*it).strFriendlyName.c_str();
qs->append((*it).strPortName.c_str());
qDebug( "Port name %s Friendly name: %s", qs->toAscii(), qPrintable( s ) );
delete qs;
_portList << s;
}
ui.comboBoxPorts->addItems(_portList);
ui.graphicsView1->setScene(_scene1);
//Ensures that the view is always updated, no need for think about boundingRect.
ui.
graphicsView1->setViewportUpdateMode
(QGraphicsView::FullViewportUpdate);
//ui.graphicsView1->setBackgroundColor( Qt::black );
this->_panelRightOk = false;
this->_panelLeftOk = false;
this->_eblRightOk = false;
this->_eblLeftOk = false;
this->_gainRightOk = false;
this->_acRainRightOk = false;
this->_acRainLeftOk = false;
this->_acSeaRightOk = false;
this->_acSeaLeftOk = false;
this->_vrmRightOk = false;
this->_vrmLeftOk = false;
this->_rangeUpPressOk = false;
this->_rangeUpReleaseOk = false;
this->_rangeDownPressOk = false;
this->_rangeDownReleaseOk = false;
this->_centrePressOk = false;
this->_centreReleaseOk = false;
this->_ackAlarmPressOk = false;
this->_ackAlarmReleaseOk = false;
this->_tmrmPressOk = false;
this->_tmrmReleaseOk = false;
this->_truerelVectorsPressOk = false;
this->_truerelVectorsReleaseOk = false;
this->_lightTurnOffOk = false;
this->_lightTurnOnOk = false;
_dimBackLightsOk = false;
_PANEL
= new ScrewButton
(QPointF(-340,
100),
"PANEL");
_EBL
= new ScrewButton
(QPointF(-330,
30),
"EBL");
_GAIN
= new ScrewButton
(QPointF(-210,
20),
"GAIN");
_AC_RAIN
= new ScrewButton
(QPointF(-135,
20),
"A/C RAIN");
_AC_SEA
= new ScrewButton
(QPointF( -60,
20),
"A/C SEA");
_VRM
= new ScrewButton
(QPointF(15,
35),
"VRM");
_scene1->addItem(_PANEL);
_scene1->addItem(_EBL);
_scene1->addItem(_GAIN);
_scene1->addItem(_AC_RAIN);
_scene1->addItem(_AC_SEA);
_scene1->addItem(_VRM);
_RANGE_UP
= new PushButton
(QPointF(-275,
20),
"RANGE\nUP");
_RANGE_DOWN
= new PushButton
(QPointF(-275,
100),
"RANGE\nDOWN");
_CENTRE
= new PushButton
(QPointF(-210,
100),
"CENTRE");
_ACK_ALARM
= new PushButton
(QPointF(-135,
100),
"ACK\nALARM");
_TM_RM
= new PushButton
(QPointF(-60,
100),
"TM/RM");
_TRUE_REL_VECTORS
= new PushButton
(QPointF(15,
100),
"TRUE/REL\nVECTORS");;
_scene1->addItem(_RANGE_UP);
_scene1->addItem(_RANGE_DOWN);
_scene1->addItem(_CENTRE);
_scene1->addItem(_ACK_ALARM);
_scene1->addItem(_TM_RM);
_scene1->addItem(_TRUE_REL_VECTORS);
ui.pushButtonCloseConnection->setEnabled(false);
ui.pushButtonSend->setEnabled(false);
ui.pushButtonTurnOffLight->setEnabled(false);
ui.pushButtonTurnOnLight->setEnabled(false);
ui.horizontalSliderBackLights->setEnabled(false);
ui.pushButtonDoesDim->setEnabled(false);
//Start Alarm panel
ui.graphicsViewAlarmPanel->setScene(this->_alarmPanelScene);
ui.
graphicsViewAlarmPanel->setViewportUpdateMode
(QGraphicsView::FullViewportUpdate);
_speakerLine1
= new SpeakerLine
(QPointF(-322,
-245));
_speakerLine2
= new SpeakerLine
(QPointF(-322,
-230));
_speakerLine3
= new SpeakerLine
(QPointF(-322,
-215));
_speakerLine4
= new SpeakerLine
(QPointF(-322,
-200));
_speakerLine5
= new SpeakerLine
(QPointF(-322,
-185));
_speakerLine6
= new SpeakerLine
(QPointF(-322,
-170));
_speakerLine7
= new SpeakerLine
(QPointF(-322,
-155));
this->_alarmPanelScene->addItem(this->_speakerLine1);
this->_alarmPanelScene->addItem(this->_speakerLine2);
this->_alarmPanelScene->addItem(this->_speakerLine3);
this->_alarmPanelScene->addItem(this->_speakerLine4);
this->_alarmPanelScene->addItem(this->_speakerLine5);
this->_alarmPanelScene->addItem(this->_speakerLine6);
this->_alarmPanelScene->addItem(this->_speakerLine7);
_alarmPanelDisplay
= new AlarmPanelDisplay
(QPointF(-210,
-245));
this->_alarmPanelScene->addItem(this->_alarmPanelDisplay);
this
->_alarmPanelLed1
= new AlarmPanelLed
(QPointF(-205,
-225),
"VHF1", Qt
::red);
this->_alarmPanelScene->addItem(this->_alarmPanelLed1);
connect(this->_alarmPanelLed1, SIGNAL(lightChanged(bool)),this->_comThread, SLOT(lightChanged(bool)) );
this
->_alarmPanelLed2
= new AlarmPanelLed
(QPointF(-175,
-225),
"·", Qt
::red);
this->_alarmPanelScene->addItem(this->_alarmPanelLed2);
this
->_alarmPanelLed3
= new AlarmPanelLed
(QPointF(-155,
-225),
"Distress", Qt
::red);
this->_alarmPanelScene->addItem(this->_alarmPanelLed3);
this
->_alarmPanelLed4
= new AlarmPanelLed
(QPointF(-115,
-225),
"Fault", Qt
::red);
this->_alarmPanelScene->addItem(this->_alarmPanelLed4);
this
->_alarmPanelLed5
= new AlarmPanelLed
(QPointF(-90,
-225),
"Test", Qt
::green);
this->_alarmPanelScene->addItem(this->_alarmPanelLed5);
}