Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 124:bdfc61a8ebee
Add thousands separator to important numeric displays
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 13 Dec 2013 12:24:00 +0100 |
parents | 35861fe64d14 |
children | 37535873ee83 |
comparison
equal
deleted
inserted
replaced
123:35861fe64d14 | 124:bdfc61a8ebee |
---|---|
155 // panels | 155 // panels |
156 static int MainPanel; | 156 static int MainPanel; |
157 static int CalcNPanel; | 157 static int CalcNPanel; |
158 static int EstimateN3Panel; | 158 static int EstimateN3Panel; |
159 static int LoggingPanel; | 159 static int LoggingPanel; |
160 | |
161 | |
162 // format and add thousands separator */ | |
163 char * thousands(char *buffer, int len, char *fmt, double val) | |
164 { | |
165 int c = snprintf(buffer, len, fmt, val); | |
166 char *p = strchr(buffer, '.'); | |
167 int n = buffer + c - p; | |
168 while (p > (buffer + 3)) { | |
169 // shift by 3 digits | |
170 p -= 3; | |
171 n += 4; | |
172 // make space for separator | |
173 memmove(p + 1, p, n); | |
174 // insert thousand separator | |
175 *p = ' '; | |
176 } | |
177 return buffer; | |
178 } | |
160 | 179 |
161 | 180 |
162 struct stat { | 181 struct stat { |
163 int samples; | 182 int samples; |
164 double mean; | 183 double mean; |
613 int read; | 632 int read; |
614 int BoxChecked = FALSE; | 633 int BoxChecked = FALSE; |
615 | 634 |
616 switch (ev) { | 635 switch (ev) { |
617 case EVENT_TSQ_ITEMS_IN_QUEUE: | 636 case EVENT_TSQ_ITEMS_IN_QUEUE: |
618 /* read data from the data queue */ | 637 // read data from the data queue |
619 while (value > 0) { | 638 while (value > 0) { |
620 | 639 |
621 read = CmtReadTSQData(queueHandle, &event, 1, TSQ_INFINITE_TIMEOUT, 0); | 640 read = CmtReadTSQData(queueHandle, &event, 1, TSQ_INFINITE_TIMEOUT, 0); |
622 if (read != 1) | 641 if (read != 1) |
623 logmsg("Error!"); | 642 logmsg("Error!"); |
626 utc = event.time.tv_sec + event.time.tv_usec * 1e-6; | 645 utc = event.time.tv_sec + event.time.tv_usec * 1e-6; |
627 Ch1 = event.data[0]; | 646 Ch1 = event.data[0]; |
628 Ch2 = event.data[1]; | 647 Ch2 = event.data[1]; |
629 Ch3 = event.data[2]; | 648 Ch3 = event.data[2]; |
630 Ch4 = event.data[3]; | 649 Ch4 = event.data[3]; |
631 | 650 |
651 // update display | |
632 SetCtrlVal(MainPanel, PANEL_UTC, utc); | 652 SetCtrlVal(MainPanel, PANEL_UTC, utc); |
633 SetCtrlVal(MainPanel, PANEL_FREQ1, Ch1); | 653 SetCtrlVal(MainPanel, PANEL_CH1, Ch1); |
634 SetCtrlVal(MainPanel, PANEL_FREQ2, Ch2); | 654 SetCtrlVal(MainPanel, PANEL_CH2, Ch2); |
635 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3); | 655 SetCtrlVal(MainPanel, PANEL_CH3, Ch3); |
636 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4); | 656 SetCtrlVal(MainPanel, PANEL_CH4, Ch4); |
637 | 657 |
638 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2); | 658 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2); |
639 | 659 |
640 // Treat data | 660 // compute |
641 | |
642 Math1 = mupEval(MathParser1); | 661 Math1 = mupEval(MathParser1); |
643 SetCtrlVal(MainPanel,PANEL_MATH1, Math1); | |
644 | |
645 Math2 = mupEval(MathParser2); | 662 Math2 = mupEval(MathParser2); |
646 SetCtrlVal(MainPanel,PANEL_MATH2, Math2); | |
647 | |
648 Math3 = mupEval(MathParser3); | 663 Math3 = mupEval(MathParser3); |
649 SetCtrlVal(MainPanel,PANEL_MATH3, Math3); | |
650 | |
651 Math4 = mupEval(MathParser4); | 664 Math4 = mupEval(MathParser4); |
652 SetCtrlVal(MainPanel,PANEL_MATH4, Math4); | |
653 | |
654 Math5 = mupEval(MathParser5); | 665 Math5 = mupEval(MathParser5); |
655 SetCtrlVal(MainPanel,PANEL_MATH5, Math5); | 666 |
656 | 667 // update display. numeric controllers do not format values |
657 // Plot Data and calculus if required | 668 // with a thousands separator: use string controllers and a |
669 // custom formatting function | |
670 char buffer[256]; | |
671 SetCtrlVal(MainPanel,PANEL_MATH1, thousands(buffer, sizeof(buffer), "%.3f", Math1)); | |
672 SetCtrlVal(MainPanel,PANEL_MATH2, thousands(buffer, sizeof(buffer), "%.3f", Math2)); | |
673 SetCtrlVal(MainPanel,PANEL_MATH3, thousands(buffer, sizeof(buffer), "%.3f", Math3)); | |
674 SetCtrlVal(MainPanel,PANEL_MATH4, thousands(buffer, sizeof(buffer), "%.3f", Math4)); | |
675 SetCtrlVal(MainPanel,PANEL_MATH5, thousands(buffer, sizeof(buffer), "%.3f", Math5)); | |
676 | |
677 // plot | |
658 | 678 |
659 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1PLOT, &BoxChecked); | 679 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1PLOT, &BoxChecked); |
660 if (BoxChecked) { | 680 if (BoxChecked) { |
661 Plot_AddFrequency(&PlotCh1, Ch1); | 681 Plot_AddFrequency(&PlotCh1, Ch1); |
662 } | 682 } |