Commit d1d874a3 authored by Projects's avatar Projects Committed by Grzegorz Daniluk

Code comments and debug messages

parent a113b8f8
......@@ -129,7 +129,7 @@ void DiotIOCard::SetOutput(unsigned int state) {
void DiotIOCard::action_click(int slot, int io) {
qDebug() << "Button test clicked - slot(" << slot << ") io(" << io << ")";
qDebug() << "button test clicked - slot(" << slot << ") io(" << io << ")";
outputs[io] = !outputs[io];
emit OutputChanged(slot_nr, GetOutput());
}
......@@ -263,13 +263,16 @@ void DiotDiag::UpdateVoltage(unsigned int volt, bool state)
{
QLabel* label = volt_lbl[volt];
auto volt_enum = DIOT_Crate::GetVoltEnum(volt);
qDebug() << "voltage " << DIOT_Crate::GetVoltName(volt_enum).c_str() << " state: " << state;
if(state) {
label->setStyleSheet("color: green");
label->setText(QString("%1 OK").arg(QString::fromStdString(DIOT_Crate::GetVoltName(volt_enum))));
label->setText(QString("%1 OK").arg(
QString::fromStdString(DIOT_Crate::GetVoltName(volt_enum))));
} else {
label->setStyleSheet("color: red");
label->setText(QString("%1 ERR").arg(QString::fromStdString(DIOT_Crate::GetVoltName(volt_enum))));
label->setText(QString("%1 ERR").arg(
QString::fromStdString(DIOT_Crate::GetVoltName(volt_enum))));
}
}
......
......@@ -32,11 +32,24 @@ class QDialog;
class QLabel;
class QPushButton;
/**
* Class representing the DIOT crate hardware in the Qt world.
* It initalizes the hardware and provides signals and slots to other classes.
*/
class DiotHardware : public QObject {
Q_OBJECT
public:
/**
* Constructor.
* @param address is the FIP agent address of the crate.
* @param slots_nr is the number of I/O cards in the crate.
*/
DiotHardware(int address, int slots_nr);
/**
* Start the WorldFIP cycle.
*/
void Start();
DIOT_Crate* GetCrate() const
......@@ -45,12 +58,43 @@ public:
}
public slots:
/**
* Change the output state for a card in a particular slot.
* @param slot is the card number (indexing from 0).
* @param state is the new output state.
*/
void SetOutput(int slot, unsigned int state);
signals:
/**
* Signal emitted on every macrocycle, provides information about inputs state.
* @param slot is the card number (indexing from 0).
* @param state is the inputs state.
*/
void InputChanged(int slot, unsigned int state);
/**
* Signal emitted on every macrocycle, provides information about fan state.
* @param fan is the fan number (indexing from 0).
* @param state is the fan state (true == operational, false == failure).
* @param rpm is the fan speed (expressed in RPM).
*/
void FanChanged(unsigned int fan, bool state, int rpm);
/**
* Signal emitted on every macrocycle, provides information about temperature.
* @param sensor is the sensor number (indexing from 0).
* @param state is the fan state (true == operational, false == failure).
* @param temp is the temperature (Celsius degrees).
*/
void TemperatureChanged(unsigned int sensor, bool state, int temp);
/**
* Signal emitted on every macrocycle, provides information about voltage.
* @param volt is the voltage number (indexing from 0).
* @param state is the voltage state (true == operational, false == failure).
* @see DIOT_Crate::GetVoltages()
*/
void VoltageChanged(unsigned int volt, bool state);
private:
......@@ -62,6 +106,9 @@ private:
};
/**
* Widget representing a single I/O card in the crate.
*/
class DiotIOCard : public QFrame {
Q_OBJECT
......@@ -100,6 +147,9 @@ protected:
};
/**
* Widget grouping the I/O cards.
*/
class DiotIOController : public QFrame {
Q_OBJECT
......@@ -115,6 +165,9 @@ private:
};
/**
* Widget displaying diagnostic data obtained from the crate.
*/
class DiotDiag : public QFrame {
Q_OBJECT
......@@ -125,17 +178,20 @@ public:
public slots:
void UpdateFan(unsigned int fan, bool state, int rpm)
{
qDebug() << "fan " << fan << " state: " << state << " RPM: " << rpm;
updateLabel(fan_lbl, fan, state, "Fan", rpm);
}
void UpdateTemperature(unsigned int sensor, bool state, int temp)
{
qDebug() << "temperature " << sensor << " state: " << state << " value: " << temp;
updateLabel(temp_lbl, sensor, state, "Temperature", temp);
}
void UpdateVoltage(unsigned int volt, bool state);
private:
// Helper function to update labels
void updateLabel(std::vector<QLabel*> labels,
unsigned int idx, bool state, const QString& desc, int val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment