@@ -86,7 +86,6 @@ static void deactivate_sample_thread(void);
8686static void mult_changed (GtkAdjustment * adj , gpointer gdata );
8787static void zoom_changed (GtkAdjustment * adj , gpointer gdata );
8888static void pos_changed (GtkAdjustment * adj , gpointer gdata );
89- static void rec_len_button (GtkWidget * widget , gpointer gdata );
9089
9190static void calc_horiz_scaling (void );
9291
@@ -113,6 +112,10 @@ void init_horiz(void)
113112{
114113 /* stop sampling */
115114 ctrl_shm -> state = IDLE ;
115+ /* always use 16 channels - initialize sample_len and rec_len
116+ so sampling works without opening the acquire dialog */
117+ ctrl_shm -> sample_len = 16 ;
118+ ctrl_shm -> rec_len = ctrl_shm -> buf_len / 16 ;
116119 /* init non-zero members of the horizontal structure */
117120 /* set up the window */
118121 init_horiz_window ();
@@ -310,10 +313,15 @@ void refresh_state_info(void)
310313void write_horiz_config (FILE * fp )
311314{
312315 scope_horiz_t * horiz ;
316+ int samples_to_save ;
313317
314318 horiz = & (ctrl_usr -> horiz );
319+ /* SAMPLES must be first - it's read early before scope_rt loads */
320+ /* save requested_samples if set, otherwise current buf_len */
321+ samples_to_save = (horiz -> requested_samples > 0 ) ?
322+ horiz -> requested_samples : ctrl_shm -> buf_len ;
323+ fprintf (fp , "SAMPLES %d\n" , samples_to_save );
315324 fprintf (fp , "THREAD %s\n" , horiz -> thread_name );
316- fprintf (fp , "MAXCHAN %d\n" , ctrl_shm -> sample_len );
317325 fprintf (fp , "HMULT %d\n" , ctrl_shm -> mult );
318326 fprintf (fp , "HZOOM %d\n" , horiz -> zoom_setting );
319327 fprintf (fp , "HPOS %e\n" , horiz -> pos_setting );
@@ -340,33 +348,11 @@ int set_sample_thread(char *name)
340348
341349int set_rec_len (int setting )
342350{
343- int count , n ;
344-
345- switch ( setting ) {
346- case 1 :
347- case 2 :
348- case 4 :
349- case 8 :
350- case 16 :
351- /* acceptable value */
352- break ;
353- default :
354- /* bad value */
355- return -1 ;
356- }
357- /* count enabled channels */
358- count = 0 ;
359- for (n = 0 ; n < 16 ; n ++ ) {
360- if (ctrl_usr -> vert .chan_enabled [n ]) {
361- count ++ ;
362- }
363- }
364- if (count > setting ) {
365- /* too many channels already enabled */
366- return -1 ;
367- }
368- ctrl_shm -> sample_len = setting ;
369- ctrl_shm -> rec_len = ctrl_shm -> buf_len / ctrl_shm -> sample_len ;
351+ /* This function is kept for backwards compatibility */
352+ /* We now always use 16 channels, setting is ignored */
353+ (void )setting ;
354+ ctrl_shm -> sample_len = 16 ;
355+ ctrl_shm -> rec_len = ctrl_shm -> buf_len / 16 ;
370356 calc_horiz_scaling ();
371357 refresh_horiz_info ();
372358 return 0 ;
@@ -507,7 +493,6 @@ static void dialog_realtime_not_linked(void)
507493 GtkWidget * hbox , * label ;
508494 GtkWidget * content_area ;
509495 GtkWidget * dialog ;
510- GtkWidget * buttons [5 ];
511496 GtkWidget * scrolled_window ;
512497 GtkTreeSelection * selection ;
513498
@@ -653,65 +638,31 @@ static void dialog_realtime_not_linked(void)
653638 gtk_box_pack_start (GTK_BOX (GTK_CONTAINER (content_area )),
654639 gtk_separator_new (GTK_ORIENTATION_HORIZONTAL ), FALSE, FALSE , 0 );
655640
656- /* box for record length buttons */
657- label = gtk_label_new (_ ("Record Length" ));
658- gtk_box_pack_start (GTK_BOX (GTK_CONTAINER (content_area )),
659- label , TRUE, TRUE, 0 );
660-
661- /* now define the radio buttons */
662- snprintf (buf , BUFLEN , _ ("%5d samples (1 channel)" ), ctrl_shm -> buf_len );
663- buttons [0 ] = gtk_radio_button_new_with_label (NULL , buf );
664- snprintf (buf , BUFLEN , _ ("%5d samples (2 channels)" ), ctrl_shm -> buf_len / 2 );
665- buttons [1 ] =
666- gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (buttons
667- [0 ]), buf );
668- snprintf (buf , BUFLEN , _ ("%5d samples (4 channels)" ), ctrl_shm -> buf_len / 4 );
669- buttons [2 ] =
670- gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (buttons
671- [0 ]), buf );
672- snprintf (buf , BUFLEN , _ ("%5d samples (8 channels)" ), ctrl_shm -> buf_len / 8 );
673- buttons [3 ] =
674- gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (buttons
675- [0 ]), buf );
676- snprintf (buf , BUFLEN , _ ("%5d samples (16 channels)" ),
677- ctrl_shm -> buf_len / 16 );
678- buttons [4 ] =
679- gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (buttons
680- [0 ]), buf );
681- /* now put them into the box and make visible */
682- for (n = 0 ; n < 5 ; n ++ ) {
683- gtk_box_pack_start (GTK_BOX (GTK_CONTAINER (content_area )),
684- buttons [n ], FALSE, FALSE, 0 );
685- }
686- /* determine which button should be pressed by default */
687- if (ctrl_shm -> sample_len == 1 ) {
688- n = 0 ;
689- } else if (ctrl_shm -> sample_len == 2 ) {
690- n = 1 ;
691- } else if (ctrl_shm -> sample_len == 4 ) {
692- n = 2 ;
693- } else if (ctrl_shm -> sample_len == 8 ) {
694- n = 3 ;
695- } else if (ctrl_shm -> sample_len == 16 ) {
696- n = 4 ;
697- } else {
698- n = 2 ;
699- ctrl_shm -> sample_len = 4 ;
700- ctrl_shm -> rec_len = ctrl_shm -> buf_len / ctrl_shm -> sample_len ;
641+ /* Samples setting - all 16 channels always available */
642+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL , 5 );
643+ gtk_box_set_homogeneous (GTK_BOX (hbox ), TRUE);
644+ gtk_label_new_in_box (_ ("Samples (16 channels):" ), hbox , FALSE, FALSE, 0 );
645+ /* initialize requested_samples from current if not set */
646+ if (horiz -> requested_samples <= 0 ) {
647+ horiz -> requested_samples = ctrl_shm -> buf_len ;
701648 }
702- /* set the default button */
703- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buttons [n ]), TRUE);
704- /* set up callbacks for the buttons */
705- g_signal_connect (buttons [0 ], "clicked" ,
706- G_CALLBACK (rec_len_button ), (gpointer ) 1 );
707- g_signal_connect (buttons [1 ], "clicked" ,
708- G_CALLBACK (rec_len_button ), (gpointer ) 2 );
709- g_signal_connect (buttons [2 ], "clicked" ,
710- G_CALLBACK (rec_len_button ), (gpointer ) 4 );
711- g_signal_connect (buttons [3 ], "clicked" ,
712- G_CALLBACK (rec_len_button ), (gpointer ) 8 );
713- g_signal_connect (buttons [4 ], "clicked" ,
714- G_CALLBACK (rec_len_button ), (gpointer ) 16 );
649+ horiz -> samples_adj = gtk_adjustment_new (horiz -> requested_samples ,
650+ SCOPE_NUM_SAMPLES_MIN , SCOPE_NUM_SAMPLES_MAX , 1000 , 10000 , 0 );
651+ horiz -> samples_spinbutton =
652+ gtk_spin_button_new (GTK_ADJUSTMENT (horiz -> samples_adj ), 1000 , 0 );
653+ gtk_box_pack_start (GTK_BOX (hbox ), horiz -> samples_spinbutton , FALSE, TRUE, 0 );
654+ gtk_box_pack_start (GTK_BOX (GTK_CONTAINER (content_area )),
655+ hbox , FALSE, TRUE, 0 );
656+ /* show current record length info */
657+ snprintf (buf , BUFLEN , _ ("Current: %d samples (%d per channel)" ),
658+ ctrl_shm -> buf_len , ctrl_shm -> buf_len / 16 );
659+ label = gtk_label_new (buf );
660+ gtk_box_pack_start (GTK_BOX (GTK_CONTAINER (content_area )),
661+ label , FALSE, TRUE, 0 );
662+
663+ /* always use 16 channels */
664+ ctrl_shm -> sample_len = 16 ;
665+ ctrl_shm -> rec_len = ctrl_shm -> buf_len / 16 ;
715666
716667 /* was a thread previously used? */
717668 if (sel_row > -1 ) {
@@ -721,6 +672,31 @@ static void dialog_realtime_not_linked(void)
721672 gtk_widget_show_all (dialog );
722673
723674 retval = gtk_dialog_run (GTK_DIALOG (dialog ));
675+
676+ /* save requested samples before destroying dialog */
677+ if (retval == GTK_RESPONSE_OK ) {
678+ int new_samples = gtk_spin_button_get_value_as_int (
679+ GTK_SPIN_BUTTON (horiz -> samples_spinbutton ));
680+ horiz -> requested_samples = new_samples ;
681+ if (new_samples != ctrl_shm -> buf_len ) {
682+ /* samples changed, show restart message */
683+ GtkWidget * info_dialog = gtk_message_dialog_new (
684+ GTK_WINDOW (ctrl_usr -> main_win ),
685+ GTK_DIALOG_MODAL ,
686+ GTK_MESSAGE_INFO ,
687+ GTK_BUTTONS_OK ,
688+ _ ("Sample count changed" ));
689+ gtk_message_dialog_format_secondary_text (
690+ GTK_MESSAGE_DIALOG (info_dialog ),
691+ _ ("The new sample count (%d) will take effect\n"
692+ "the next time halscope is started.\n\n"
693+ "The setting has been saved to the configuration file." ),
694+ new_samples );
695+ gtk_dialog_run (GTK_DIALOG (info_dialog ));
696+ gtk_widget_destroy (info_dialog );
697+ }
698+ }
699+
724700 gtk_widget_destroy (dialog );
725701
726702 /* these items no longer exist - NULL them */
@@ -730,6 +706,8 @@ static void dialog_realtime_not_linked(void)
730706 horiz -> sample_period_label = NULL ;
731707 horiz -> mult_adj = NULL ;
732708 horiz -> mult_spinbutton = NULL ;
709+ horiz -> samples_adj = NULL ;
710+ horiz -> samples_spinbutton = NULL ;
733711
734712 /* we get here when the user hits OK or Quit */
735713 if (retval == GTK_RESPONSE_CLOSE ) {
@@ -963,32 +941,6 @@ static void pos_changed(GtkAdjustment * adj, gpointer gdata)
963941 set_horiz_pos (gtk_adjustment_get_value (adj ) / 1000.0 );
964942}
965943
966- static void rec_len_button (GtkWidget * widget , gpointer gdata )
967- {
968- int retval ;
969- GtkWidget * dialog ;
970-
971- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget )) != TRUE) {
972- /* not pressed, ignore it */
973- return ;
974- }
975- retval = set_rec_len ((long )gdata );
976- if (retval < 0 ) {
977- /* too many channels already enabled */
978- dialog = gtk_message_dialog_new (GTK_WINDOW (ctrl_usr -> main_win ),
979- GTK_DIALOG_MODAL ,
980- GTK_MESSAGE_INFO ,
981- GTK_BUTTONS_OK ,
982- _ ("Not enough channels" ));
983- gtk_message_dialog_format_secondary_text (
984- GTK_MESSAGE_DIALOG (dialog ),
985- _ ("This record length cannot handle the channels\n"
986- "that are currently enabled. Pick a shorter\n"
987- "record length that supports more channels." ));
988- gtk_dialog_run (GTK_DIALOG (dialog ));
989- gtk_widget_destroy (dialog );
990- }
991- }
992944
993945static void calc_horiz_scaling (void )
994946{
0 commit comments