#include #include #include #include "ClassDigitizer2Gen.h" #include "influxdb.h" std::mutex digiMTX; Digitizer2Gen * digi = NULL; // new Digitizer2Gen(); unsigned short nDigi = 0; InfluxDB * influx = NULL; // new InfluxDB("https://fsunuc.physics.fsu.edu/influx/", false); GtkTextBuffer * logBuffer = NULL; GtkWidget * notebook = NULL; GtkWidget * bnOpenDigis = NULL; static void OpenDigitizers(){ digi = new Digitizer2Gen(); digi->OpenDigitizer("dig2://192.168.0.100/"); //digi->Reset(); if( digi->IsConnected() ){ gtk_text_buffer_set_text(logBuffer, ("A digitizer " + digi->ReadValue("/par/SerialNum") + " is opened.").c_str(), -1); GtkWidget * box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); // 2nd arg is the spacing gtk_widget_set_halign(box, GTK_ALIGN_CENTER); gtk_widget_set_valign(box, GTK_ALIGN_CENTER); gtk_box_set_homogeneous(GTK_BOX (box), true); gtk_notebook_append_page( GTK_NOTEBOOK(notebook), box, gtk_label_new( ("Digi-" + digi->ReadValue("/par/SerialNum") ).c_str() ) ) ; GtkWidget * v1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); gtk_box_append( GTK_BOX(box), v1); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("IP: " + digi->ReadValue("/par/IPAddress")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("Model name: " + digi->ReadValue("/par/ModelName")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("Firmware version: " + digi->ReadValue("/par/cupver")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("DPPType: " + digi->ReadValue("/par/FwType")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("DPP version: " + digi->ReadValue("/par/FPGA_FwVer")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("ADC bits: " + digi->ReadValue("/par/ADC_Nbit")).c_str())); gtk_box_append(GTK_BOX(v1), gtk_label_new( ("ADC rate: " + digi->ReadValue("/par/ADC_SamplRate") + " Msps, ch2ns: " + std::to_string(digi->GetCh2ns()) + " ns").c_str())); unsigned short nCh = digi->GetNChannels(); nDigi ++; } } static void CloseDigitizers(){ if( digi != NULL){ digi->CloseDigitizer(); delete digi; digi = NULL; gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), nDigi); }else{ gtk_text_buffer_set_text(logBuffer, "No digitizer is opened.", -1); } } static void ProgramSetting(){ GtkWidget * window = gtk_window_new(); gtk_window_set_title( GTK_WINDOW(window), "Program Setting"); gtk_window_set_default_size( GTK_WINDOW(window), 600, 500); // w, h gtk_widget_show(window); } static void MainWindow (GtkApplication *app){ GtkWidget * window = gtk_application_window_new(app); gtk_window_set_title( GTK_WINDOW(window), "SOLARIS DAQ"); gtk_window_set_default_size( GTK_WINDOW(window), 600, 600); // w, h //=========== Tabs notebook = gtk_notebook_new(); gtk_window_set_child( GTK_WINDOW(window), notebook); //=========== Main Tab GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); // 2nd arg is the spacing //gtk_widget_set_halign(box, GTK_ALIGN_CENTER); //gtk_widget_set_valign(box, GTK_ALIGN_CENTER); //gtk_box_set_homogeneous(GTK_BOX (box), true); gtk_notebook_append_page( GTK_NOTEBOOK(notebook), box, gtk_label_new("Main")); { GtkWidget * box2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_widget_set_halign(box, GTK_ALIGN_CENTER); gtk_widget_set_valign(box, GTK_ALIGN_CENTER); gtk_box_set_homogeneous(GTK_BOX (box2), true); gtk_box_append( GTK_BOX(box), box2); GtkWidget * bnProgramSettings = gtk_button_new_with_label("Program Settings"); g_signal_connect( bnProgramSettings, "clicked", G_CALLBACK(ProgramSetting), NULL); gtk_box_append( GTK_BOX(box2), bnProgramSettings); GtkWidget * bnOpenDigis = gtk_button_new_with_label("Open Digitizers"); g_signal_connect( bnOpenDigis, "clicked", G_CALLBACK(OpenDigitizers), NULL); gtk_box_append( GTK_BOX(box2), bnOpenDigis); GtkWidget * bnCloseDigis = gtk_button_new_with_label("Close Digitizers"); g_signal_connect( bnCloseDigis, "clicked", G_CALLBACK(CloseDigitizers), NULL); gtk_box_append( GTK_BOX(box2), bnCloseDigis); } { GtkWidget * box3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_widget_set_halign(box, GTK_ALIGN_CENTER); gtk_widget_set_valign(box, GTK_ALIGN_CENTER); gtk_box_set_homogeneous(GTK_BOX (box3), true); gtk_box_append( GTK_BOX(box), box3); GtkWidget * bnStart = gtk_button_new_with_label("Start Run"); //g_signal_connect( bnStart, "clicked", G_CALLBACK(OpenDigitizers), NULL); gtk_box_append( GTK_BOX(box3), bnStart); GtkWidget * bnEnd = gtk_button_new_with_label("End Run"); //g_signal_connect( bnEnd, "clicked", G_CALLBACK(OpenDigitizers), NULL); gtk_box_append( GTK_BOX(box3), bnEnd); GtkWidget * cbRunNum = gtk_combo_box_new(); gtk_box_append( GTK_BOX(box3), cbRunNum); } GtkWidget * logBox = gtk_scrolled_window_new (); gtk_box_append( GTK_BOX(box), logBox); GtkWidget * logTextView = gtk_text_view_new(); logBuffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(logTextView)); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (logTextView), GTK_WRAP_WORD_CHAR); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (logBox), logTextView); gtk_widget_show(window); } int main (int argc, char **argv){ GtkApplication * app = gtk_application_new("example.example", G_APPLICATION_FLAGS_NONE); g_signal_connect( app, "activate", G_CALLBACK(MainWindow), NULL); int status = g_application_run( G_APPLICATION(app), argc, argv); g_object_unref( app); //=================== clear memory delete digi; delete influx; printf("============= GoodBye! ============\n"); return status; }