Skip to content

Commit

Permalink
adds status bar update
Browse files Browse the repository at this point in the history
  • Loading branch information
bytecod3 committed Oct 13, 2024
1 parent 5140ed9 commit 89d918b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 48 deletions.
3 changes: 2 additions & 1 deletion app/NaFCSE/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/*!< This enum contains states that the app can be in at any given time */
enum APP_STATES {
HANDSHAKE = 0, /*!< handshake state - here we are trying to establish hardware connections with flight computer */
NOMINAL /*!< nominal state - we have already established connection with fligth computer */
NOMINAL, /*!< nominal state - we have already established connection with flight computer */
RUNNING /*!< running state - the flight computer has received test data and the simulation is in progress */
};

extern int current_app_state;
Expand Down
62 changes: 32 additions & 30 deletions app/NaFCSE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@ MainWindow::MainWindow(QWidget *parent)
/// 2. process data received from the serial monitor
connect(&port, &SerialPort::dataReceived, this, &MainWindow::readData);

/// 3. handles plug-n-play
/// 3. handles plug-n-play for serial port
connect(mSerialScanTimer, &QTimer::timeout, this, &updateSerialPorts);

////////////////// INIT PLOT AREA ///////////////////////
ui->plotWidget->resize(300, 200);
this->initPlotArea();

// check our current app state to display on status bar
if(current_app_state == APP_STATES::HANDSHAKE) {
ui->statusbar->showMessage("STATE: HANDSHAKE");
} else if (current_app_state == APP_STATES::HANDSHAKE){
ui->statusbar->showMessage("STATE: NOMINAL");
} else if (current_app_state == APP_STATES::RUNNING) {
ui->statusbar->showMessage("STATE: RUNNING");
} else {
ui->statusbar->showMessage("Waiting");
}

}

/////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -140,37 +151,11 @@ void MainWindow::readData(QString data) {
* @brief MainWindow::on_btnRun_clicked
* Run the application
*/
void MainWindow::on_btnRun_clicked(QString data)
{
// remove the trailing newline
data = data.trimmed();

// check the current app state
if(current_app_state == APP_STATES::HANDSHAKE) {
qDebug() << "HANDSHAKE STATE";

if(data == NAK) {
// if NAK received, we respond with SOH to signify start of header to the MCU
// we send this -> "21\n"
QByteArray SOH_BYTE(QString(SOH).toUtf8());
SOH_BYTE.append('\n');
port.writeToSerial(SOH_BYTE);
// void MainWindow::on_btnRun_clicked(QString data)
// {

// at this point we should start sending test data to the MCU

// send EOT

// done sending data, change state to NOMINAL

}

} else if(current_app_state == APP_STATES::NOMINAL) {
qDebug() << "NOMINAL STATE";
}

// check if the simulation data select box is empty

}
// }

/**
* @brief MainWindow::on_toolButton_clicked
Expand Down Expand Up @@ -411,3 +396,20 @@ MainWindow::~MainWindow()
{
delete ui;
}


/**
* @brief MainWindow::on_btnLink_clicked
* Establish handshake with the flight computer hardware via XMODEM
* @param data command received from serial port from the device under test
*/
void MainWindow::on_btnLink_clicked(QString data)
{
qDebug() << "Linking";

if(current_app_state == APP_STATES::HANDSHAKE) {
qDebug() << "HANDSHAKE STATE";

}
}

7 changes: 6 additions & 1 deletion app/NaFCSE/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ class MainWindow : public QMainWindow
QString activeStateStyle = "QLabel { background-color : black; color : #00FF00; border: 1px solid gray; border-radius: 4px; font: 700 9pt; }";
~MainWindow();

void on_btnRun_clicked(QString);

void on_btnLink_clicked(QString);

private slots:
// serial monitor functions
void updateSerialMonitor(const QString data);
void readData(const QString data);

// button press handlers
void on_btnRun_clicked(QString);
//void on_btnRun_clicked(QString);
void on_btnChooseFile_clicked();
void on_connectSerial_clicked();
void on_writeSerialButton_clicked();
Expand All @@ -43,6 +47,7 @@ private slots:
// graphing capabilities
void initPlotArea();


private:
Ui::MainWindow *ui;
static constexpr uint8_t numBaudRates = 9;
Expand Down
59 changes: 44 additions & 15 deletions app/NaFCSE/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</size>
</property>
<property name="title">
<string>States</string>
<string>Flight states</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
Expand Down Expand Up @@ -298,7 +298,7 @@ padding-bottom: 4px;</string>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>System Diagnostics</string>
<string>Flight system checks</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
Expand Down Expand Up @@ -408,6 +408,9 @@ color: black;</string>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
Expand Down Expand Up @@ -492,20 +495,37 @@ color: black;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRun">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>20</number>
</property>
<property name="text">
<string>RUN</string>
</property>
</widget>
<item>
<widget class="QPushButton" name="btnLink">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>LINK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnMainRun">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MAIN RUN</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
Expand Down Expand Up @@ -627,6 +647,15 @@ color: black;</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background: {
color: #000000;
}

font: {
color: #ffffff;
}</string>
</property>
</widget>
</item>
</layout>
Expand Down
3 changes: 2 additions & 1 deletion code-playground/x-modem/xmodem-pio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ void checkRunTestToggle() {
*/

/*!****************************************************************************
* @brief Initiate XMODEM protocol by sending a NAK command every 4 seconds until the transmitter returns an ACK signal
* @brief Initiate XMODEM protocol by sending a NAK command every 4 seconds until the
* transmitter(test PC) returns an ACK signal
* @param none
*******************************************************************************/
void InitXMODEM() {
Expand Down

0 comments on commit 89d918b

Please sign in to comment.