@@ -40,6 +40,7 @@ QStandardItemModel model_image_state;
4040smp_group_img_mgmt *my_img;
4141smp_group_os_mgmt *my_os;
4242smp_group_shell_mgmt *my_shell;
43+ smp_group_stat_mgmt *my_stat;
4344QList<image_state_t > blaharray;
4445
4546void plugin_mcumgr::setup (QMainWindow *main_window)
@@ -566,6 +567,12 @@ void plugin_mcumgr::setup(QMainWindow *main_window)
566567 gridLayout_11->addWidget (label_16, 1 , 0 , 1 , 1 );
567568
568569 table_STAT_Values = new QTableWidget (tab_5);
570+ if (table_STAT_Values->columnCount () < 2 )
571+ table_STAT_Values->setColumnCount (2 );
572+ QTableWidgetItem *__qtablewidgetitem12 = new QTableWidgetItem ();
573+ table_STAT_Values->setHorizontalHeaderItem (0 , __qtablewidgetitem12);
574+ QTableWidgetItem *__qtablewidgetitem13 = new QTableWidgetItem ();
575+ table_STAT_Values->setHorizontalHeaderItem (1 , __qtablewidgetitem13);
569576 table_STAT_Values->setObjectName (QString::fromUtf8 (" table_STAT_Values" ));
570577
571578 gridLayout_11->addWidget (table_STAT_Values, 1 , 1 , 1 , 1 );
@@ -797,7 +804,7 @@ void plugin_mcumgr::setup(QMainWindow *main_window)
797804// retranslateUi(Form);
798805
799806// tabWidget->setCurrentIndex(0);
800- tabWidget_2->setCurrentIndex (2 );
807+ tabWidget_2->setCurrentIndex (3 );
801808 tabWidget_3->setCurrentIndex (1 );
802809 selector_OS->setCurrentIndex (2 );
803810// /AUTOGEN_END_INIT
@@ -876,6 +883,10 @@ void plugin_mcumgr::setup(QMainWindow *main_window)
876883 tabWidget_2->setTabText (tabWidget_2->indexOf (tab_OS), QCoreApplication::translate (" Form" , " OS" , nullptr ));
877884 label_15->setText (QCoreApplication::translate (" Form" , " Group:" , nullptr ));
878885 label_16->setText (QCoreApplication::translate (" Form" , " Values:" , nullptr ));
886+ QTableWidgetItem *___qtablewidgetitem12 = table_STAT_Values->horizontalHeaderItem (0 );
887+ ___qtablewidgetitem12->setText (QCoreApplication::translate (" Form" , " Name" , nullptr ));
888+ QTableWidgetItem *___qtablewidgetitem13 = table_STAT_Values->horizontalHeaderItem (1 );
889+ ___qtablewidgetitem13->setText (QCoreApplication::translate (" Form" , " Value" , nullptr ));
879890 radio_STAT_List->setText (QCoreApplication::translate (" Form" , " List Groups" , nullptr ));
880891 radio_STAT_Fetch->setText (QCoreApplication::translate (" Form" , " Fetch Stats" , nullptr ));
881892 lbl_STAT_Status->setText (QCoreApplication::translate (" Form" , " [Status]" , nullptr ));
@@ -944,6 +955,7 @@ connect(colview_IMG_Images, SIGNAL(updatePreviewWidget(QModelIndex)), this, SLOT
944955 my_img = new smp_group_img_mgmt (processor);
945956 my_os = new smp_group_os_mgmt (processor);
946957 my_shell = new smp_group_shell_mgmt (processor);
958+ my_stat = new smp_group_stat_mgmt (processor);
947959
948960 connect (my_img, SIGNAL (status (uint8_t ,group_status,QString)), this , SLOT (status (uint8_t ,group_status,QString)));
949961 connect (my_img, SIGNAL (progress (uint8_t ,uint8_t )), this , SLOT (progress (uint8_t ,uint8_t )));
@@ -956,10 +968,15 @@ connect(colview_IMG_Images, SIGNAL(updatePreviewWidget(QModelIndex)), this, SLOT
956968 connect (my_shell, SIGNAL (status (uint8_t ,group_status,QString)), this , SLOT (status (uint8_t ,group_status,QString)));
957969 connect (my_shell, SIGNAL (progress (uint8_t ,uint8_t )), this , SLOT (progress (uint8_t ,uint8_t )));
958970// connect(my_shell, SIGNAL(plugin_to_hex(QByteArray*)), this, SLOT(group_to_hex(QByteArray*)));
971+
972+ connect (my_stat, SIGNAL (status (uint8_t ,group_status,QString)), this , SLOT (status (uint8_t ,group_status,QString)));
973+ connect (my_stat, SIGNAL (progress (uint8_t ,uint8_t )), this , SLOT (progress (uint8_t ,uint8_t )));
974+ // connect(my_shell, SIGNAL(plugin_to_hex(QByteArray*)), this, SLOT(group_to_hex(QByteArray*)));
959975}
960976
961977plugin_mcumgr::~plugin_mcumgr ()
962978{
979+ delete my_stat;
963980 delete my_shell;
964981 delete my_os;
965982 delete my_img;
@@ -1288,9 +1305,25 @@ void plugin_mcumgr::on_btn_STAT_Go_clicked()
12881305{
12891306 if (radio_STAT_List->isChecked ())
12901307 {
1308+ // Execute stat list command
1309+ emit plugin_set_status (true , false );
1310+
1311+ mode = ACTION_STAT_LIST_GROUPS;
1312+ my_stat->set_parameters ((check_V2_Protocol->isChecked () ? 1 : 0 ), edit_MTU->value (), retries, timeout_ms, mode);
1313+ my_stat->start_list_groups (&group_list);
1314+
1315+ lbl_STAT_Status->setText (" Listing..." );
12911316 }
1292- else if (radio_STAT_Fetch->isChecked ())
1317+ else if (radio_STAT_Fetch->isChecked () && !combo_STAT_Group-> currentText (). isEmpty () )
12931318 {
1319+ // Execute stat get command
1320+ emit plugin_set_status (true , false );
1321+
1322+ mode = ACTION_STAT_GROUP_DATA;
1323+ my_stat->set_parameters ((check_V2_Protocol->isChecked () ? 1 : 0 ), edit_MTU->value (), retries, timeout_ms, mode);
1324+ my_stat->start_group_data (combo_STAT_Group->currentText (), &stat_list);
1325+
1326+ lbl_STAT_Status->setText (" Fetching..." );
12941327 }
12951328}
12961329
@@ -1578,6 +1611,38 @@ void plugin_mcumgr::status(uint8_t user_data, group_status status, QString error
15781611 }
15791612 }
15801613 }
1614+ else if (sender () == my_stat)
1615+ {
1616+ qDebug () << " stat sender" ;
1617+ if (status == STATUS_COMPLETE)
1618+ {
1619+ qDebug () << " complete" ;
1620+ if (user_data == ACTION_STAT_GROUP_DATA)
1621+ {
1622+ uint8_t i = 0 ;
1623+
1624+ // TODO: optimise
1625+ table_STAT_Values->clearContents ();
1626+
1627+ while (i < stat_list.length ())
1628+ {
1629+ QTableWidgetItem *row_name = new QTableWidgetItem (stat_list[i].name );
1630+ QTableWidgetItem *row_value = new QTableWidgetItem (QString::number (stat_list[i].value ));
1631+
1632+ table_STAT_Values->insertRow (table_STAT_Values->rowCount ());
1633+ table_STAT_Values->setItem ((table_STAT_Values->rowCount () - 1 ), 0 , row_name);
1634+ table_STAT_Values->setItem ((table_STAT_Values->rowCount () - 1 ), 1 , row_value);
1635+
1636+ ++i;
1637+ }
1638+ }
1639+ else if (user_data == ACTION_STAT_LIST_GROUPS)
1640+ {
1641+ combo_STAT_Group->clear ();
1642+ combo_STAT_Group->addItems (group_list);
1643+ }
1644+ }
1645+ }
15811646
15821647 if (finished == true )
15831648 {
0 commit comments