comparison FXAnalyse.c @ 166:fdd2f8fd7714

Minor cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 13 Feb 2014 19:17:32 +0100
parents 211ea3950310
children 4de7f2c9f328
comparison
equal deleted inserted replaced
165:05daf9593946 166:fdd2f8fd7714
2 #include <utility.h> 2 #include <utility.h>
3 #include <ansi_c.h> 3 #include <ansi_c.h>
4 #include <cvirte.h> 4 #include <cvirte.h>
5 #include <userint.h> 5 #include <userint.h>
6 #include <formatio.h> 6 #include <formatio.h>
7 #include <inifile.h>
7 #include <string.h> 8 #include <string.h>
8 #include <future.h>
9 9
10 #include "FXAnalyse.h" 10 #include "FXAnalyse.h"
11 #include "Plot.h" 11 #include "Plot.h"
12 #include "Allan.h" 12 #include "Allan.h"
13 #include "DDS4xAD9912.h" 13 #include "DDS4xAD9912.h"
14 #include "DDS_Fox.h" 14 #include "DDS_Fox.h"
15 #include "muParserDLL.h" 15 #include "muParserDLL.h"
16 #include "utils.h" 16 #include "utils.h"
17 #include "stat.h" 17 #include "stat.h"
18 #include "future.h"
18 #include "data-provider.h" 19 #include "data-provider.h"
20
19 21
20 #define CONFIGFILE "FXAnalyse.ini" 22 #define CONFIGFILE "FXAnalyse.ini"
21 #define SR_LOGGER_IP "145.238.204.91" 23 #define SR_LOGGER_IP "145.238.204.91"
22 #define DATAFOLDER "Z:\\Measures-2014" 24 #define DATAFOLDER "Z:\\Measures-2014"
23 25
24 #define FREP_STEP_SIZE 50000.0 26 #define FREP_STEP_SIZE 50000.0
25 27
26 #define SPEED_OF_LIGHT 299792458.0 // m/s 28 #define SPEED_OF_LIGHT 299792458.0 // m/s
27 #define SR_WAVELENGTH 698.4460 // nm 29 #define SR_WAVELENGTH 698.4460 // nm
28 #define HG_WAVELENGTH 1062.4000 // nm 30 #define HG_WAVELENGTH 1062.4000 // nm
31
29 32
30 // data acquisition status 33 // data acquisition status
31 int acquiring; 34 int acquiring;
32 // data queue 35 // data queue
33 CmtTSQHandle dataQueue; 36 CmtTSQHandle dataQueue;
44 struct event event; 47 struct event event;
45 double utc; 48 double utc;
46 double Ch1, Ch2, Ch3, Ch4; 49 double Ch1, Ch2, Ch3, Ch4;
47 double Math1, Math2, Math3, Math4, Math5; 50 double Math1, Math2, Math3, Math4, Math5;
48 double N1, N2, N3; 51 double N1, N2, N3;
52 double Ndiv = 8.0;
53 double Sign1 = 1.0, Sign2 = 1.0, Sign3 = 0.0;
54 typedef void* mathparser_t;
55 mathparser_t *MathParser1, *MathParser2, *MathParser3, *MathParser4, *MathParser5;
49 56
50 // panels 57 // panels
51 static int MainPanel; 58 static int MainPanel;
59 static int LoggingPanel;
52 static int CalcNPanel; 60 static int CalcNPanel;
53 static int EstimateNPanel; 61 static int EstimateNPanel;
54 static int LoggingPanel;
55 62
56 63
57 struct adev { 64 struct adev {
58 Allan_Data allan; 65 Allan_Data allan;
59 double *data; 66 double *data;
153 PLOT(Math5, 0.0, 0.0), 160 PLOT(Math5, 0.0, 0.0),
154 { NULL } 161 { NULL }
155 }; 162 };
156 163
157 164
158 // 1xAD9956 DDS box 165 // dedrift DDS
159 DDSParameter DDS1xAD9956; 166 DDSParameter DDS1xAD9956;
160 // 4xAD9912 DDS box 167 // 4xAD9912 DDS box
161 DDS4xAD9912_Data DDS4xAD9912; 168 DDS4xAD9912_Data DDS4xAD9912;
162 169
163 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5;
164 170
165 enum { 171 enum {
166 LO = 1, 172 LO = 1,
167 HG = 2, 173 HG = 2,
168 SR = 4, 174 SR = 4,
180 186
181 int Measuring_1 = N_MEASUREMENT_NONE; 187 int Measuring_1 = N_MEASUREMENT_NONE;
182 int Measuring_2 = N_MEASUREMENT_NONE; 188 int Measuring_2 = N_MEASUREMENT_NONE;
183 int Measuring_3 = N_MEASUREMENT_NONE; 189 int Measuring_3 = N_MEASUREMENT_NONE;
184 190
185 double Ndiv = 8.0;
186
187 int nobs = 0; 191 int nobs = 0;
188 int settling = 0; 192 int settling = 0;
189 193
190 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, df_DDS3; 194 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, df_DDS3;
191 195
202 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; 206 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0;
203 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; 207 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0;
204 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; 208 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0;
205 209
206 int Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; 210 int Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE;
207 double Sign1=1.0, Sign2=1.0, Sign3=0.0;
208
209 211
210 struct stat stat_math1, stat_ch2, stat_ch3, freq; 212 struct stat stat_math1, stat_ch2, stat_ch3, freq;
211 struct rollmean rollmean_ch1, rollmean_ch2, rollmean_ch3, rollmean_ch4; 213 struct rollmean rollmean_ch1, rollmean_ch2, rollmean_ch3, rollmean_ch4;
212 214
213 215
384 386
385 return 0; 387 return 0;
386 } 388 }
387 389
388 390
389 muParserHandle_t initMathParser() 391 mathparser_t * mathparser_new()
390 { 392 {
391 muParserHandle_t parser = mupCreate(); 393 mathparser_t parser = mupCreate();
394
392 mupDefineOprtChars(parser, "abcdefghijklmnopqrstuvwxyzµ" 395 mupDefineOprtChars(parser, "abcdefghijklmnopqrstuvwxyzµ"
393 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 396 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
394 "+-*^/?<>=#!$%&|~'_"); 397 "+-*^/?<>=#!$%&|~'_");
398
395 mupDefineVar(parser, "Ch1", &Ch1); 399 mupDefineVar(parser, "Ch1", &Ch1);
396 mupDefineVar(parser, "Ch2", &Ch2); 400 mupDefineVar(parser, "Ch2", &Ch2);
397 mupDefineVar(parser, "Ch3", &Ch3); 401 mupDefineVar(parser, "Ch3", &Ch3);
398 mupDefineVar(parser, "Ch4", &Ch4); 402 mupDefineVar(parser, "Ch4", &Ch4);
399 mupDefineVar(parser, "DDS1", &(DDS4xAD9912.frequency[0])); 403 mupDefineVar(parser, "DDS1", &(DDS4xAD9912.frequency[0]));
400 mupDefineVar(parser, "DDS2", &(DDS4xAD9912.frequency[1])); 404 mupDefineVar(parser, "DDS2", &(DDS4xAD9912.frequency[1]));
401 mupDefineVar(parser, "DDS3", &(DDS4xAD9912.frequency[2])); 405 mupDefineVar(parser, "DDS3", &(DDS4xAD9912.frequency[2]));
402 mupDefineVar(parser, "DDS4", &(DDS4xAD9912.frequency[3])); 406 mupDefineVar(parser, "DDS4", &(DDS4xAD9912.frequency[3]));
403 mupDefineVar(parser, "N1", &N1); 407 mupDefineVar(parser, "N1", &N1);
404 mupDefineVar(parser, "N2", &N2); 408 mupDefineVar(parser, "N2", &N2);
405 mupDefineVar(parser, "N3", &N3); 409 mupDefineVar(parser, "N3", &N3);
406 mupDefineVar(parser, "Sign1", &Sign1); 410 mupDefineVar(parser, "Sign1", &Sign1);
407 mupDefineVar(parser, "Sign2", &Sign2); 411 mupDefineVar(parser, "Sign2", &Sign2);
421 425
422 return parser; 426 return parser;
423 } 427 }
424 428
425 429
426
427
428 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event, 430 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event,
429 int value, void *callbackData); 431 int value, void *callbackData);
430 432
431 433
432 int main (int argc, char *argv[]) 434 int main (int argc, char *argv[])
433 { 435 {
434 int rv; 436 int rv;
435 double frequency; 437 double frequency;
436 char expr[1024]; 438 char expr[1024];
437 439
438 if (InitCVIRTE (0, argv, 0) == 0) 440 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0)
439 return -1; 441 return -1;
440 442 if ((LoggingPanel = LoadPanel (0, "FXAnalyse.uir", LOGGING)) < 0)
441 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0)
442 return -1; 443 return -1;
443 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) 444 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0)
444 return -1; 445 return -1;
445 if ((EstimateNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN)) < 0) 446 if ((EstimateNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN)) < 0)
446 return -1; 447 return -1;
447 if ((LoggingPanel = LoadPanel (0, "FXAnalyse.uir", LOGGING)) < 0)
448 return -1;
449 448
450 // construct configuration file path 449 // construct configuration file path
451 char pathname[MAX_PATHNAME_LEN]; 450 char pathname[MAX_PATHNAME_LEN];
452 char project[MAX_PATHNAME_LEN]; 451 char project[MAX_PATHNAME_LEN];
453 GetProjectDir(project); 452 GetProjectDir(project);
454 MakePathname(project, CONFIGFILE, pathname); 453 MakePathname(project, CONFIGFILE, pathname);
455 454
456 // load configuration file */ 455 // load configuration file
457 IniText configuration = Ini_New(TRUE); 456 IniText configuration = Ini_New(TRUE);
458 Ini_ReadFromFile(configuration, pathname); 457 Ini_ReadFromFile(configuration, pathname);
459 458
460 // get AD9956 configuration parameters 459 // get AD9956 configuration parameters
461 char host[256]; 460 char host[256];
462 int port; 461 int port;
463 double clock; 462 double clock;
464 rv = Ini_StringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); 463 rv = Ini_GetStringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host));
465 if (! rv) 464 if (! rv)
466 return -1; 465 return -1;
467 rv = Ini_GetInt(configuration, "AD9956", "port", &port); 466 rv = Ini_GetInt(configuration, "AD9956", "port", &port);
468 if (! rv) 467 if (! rv)
469 return -1; 468 return -1;
470 rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); 469 rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock);
471 if (! rv) 470 if (! rv)
472 return -1; 471 return -1;
473 472
474 // initialyze 1x AD9956 DDS box 473 // dispose configuration
474 Ini_Dispose(configuration);
475
476 // dedrift DDS
475 DDSFox_Initialize(&DDS1xAD9956, host, port, dedrift.freq0); 477 DDSFox_Initialize(&DDS1xAD9956, host, port, dedrift.freq0);
476
477 // free
478 Ini_Dispose(configuration);
479 478
480 // initialize 4x AD9959 DDS box 479 // initialize 4x AD9959 DDS box
481 DDS4xAD9912_Reset(&DDS4xAD9912); 480 DDS4xAD9912_Reset(&DDS4xAD9912);
482 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); 481 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency);
483 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); 482 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency);
489 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); 488 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency);
490 489
491 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); 490 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1);
492 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); 491 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2);
493 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); 492 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3);
494 493
495 MathParser1 = initMathParser(); 494 MathParser1 = mathparser_new();
496 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, expr); 495 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, expr);
497 mupSetExpr(MathParser1, expr); 496 mupSetExpr(MathParser1, expr);
498 497
499 MathParser2 = initMathParser(); 498 MathParser2 = mathparser_new();
500 mupDefineVar(MathParser2, "Math1", &Math1); 499 mupDefineVar(MathParser2, "Math1", &Math1);
501 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, expr); 500 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, expr);
502 mupSetExpr(MathParser2, expr); 501 mupSetExpr(MathParser2, expr);
503 502
504 MathParser3 = initMathParser(); 503 MathParser3 = mathparser_new();
505 mupDefineVar(MathParser3, "Math1", &Math1); 504 mupDefineVar(MathParser3, "Math1", &Math1);
506 mupDefineVar(MathParser3, "Math2", &Math2); 505 mupDefineVar(MathParser3, "Math2", &Math2);
507 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, expr); 506 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, expr);
508 mupSetExpr(MathParser3, expr); 507 mupSetExpr(MathParser3, expr);
509 508
510 MathParser4 = initMathParser(); 509 MathParser4 = mathparser_new();
511 mupDefineVar(MathParser4, "Math1", &Math1); 510 mupDefineVar(MathParser4, "Math1", &Math1);
512 mupDefineVar(MathParser4, "Math2", &Math2); 511 mupDefineVar(MathParser4, "Math2", &Math2);
513 mupDefineVar(MathParser4, "Math3", &Math3); 512 mupDefineVar(MathParser4, "Math3", &Math3);
514 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, expr); 513 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, expr);
515 mupSetExpr(MathParser4, expr); 514 mupSetExpr(MathParser4, expr);
516 515
517 MathParser5 = initMathParser(); 516 MathParser5 = mathparser_new();
518 mupDefineVar(MathParser5, "Math1", &Math1); 517 mupDefineVar(MathParser5, "Math1", &Math1);
519 mupDefineVar(MathParser5, "Math2", &Math2); 518 mupDefineVar(MathParser5, "Math2", &Math2);
520 mupDefineVar(MathParser5, "Math3", &Math3); 519 mupDefineVar(MathParser5, "Math3", &Math3);
521 mupDefineVar(MathParser5, "Math4", &Math4); 520 mupDefineVar(MathParser5, "Math4", &Math4);
522 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, expr); 521 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, expr);
523 mupSetExpr(MathParser5, expr); 522 mupSetExpr(MathParser5, expr);
524 523
525 // data queue 524 // data queue
526 CmtNewTSQ(128, sizeof(struct event), 0, &dataQueue); 525 CmtNewTSQ(128, sizeof(struct event), 0, &dataQueue);
527 526
528 // register callback to execute when data will be in the data queue 527 // register callback to execute when data will be in the data queue
529 CmtInstallTSQCallback(dataQueue, EVENT_TSQ_ITEMS_IN_QUEUE, 1, 528 CmtInstallTSQCallback(dataQueue, EVENT_TSQ_ITEMS_IN_QUEUE, 1,
535 534
536 DiscardPanel(MainPanel); 535 DiscardPanel(MainPanel);
537 return 0; 536 return 0;
538 } 537 }
539 538
540
541 int CVICALLBACK QuitCallback (int panel, int control, int event, 539 int CVICALLBACK QuitCallback (int panel, int control, int event,
542 void *callbackData, int eventData1, int eventData2) 540 void *callbackData, int eventData1, int eventData2)
543 { 541 {
544 switch (event) 542 switch (event)
545 { 543 {
556 int control, index; 554 int control, index;
557 double step; 555 double step;
558 556
559 #define do_arrow(__DDS, __STEP) \ 557 #define do_arrow(__DDS, __STEP) \
560 do { \ 558 do { \
561 GetCtrlIndex(MainPanel, __STEP, &index); \ 559 GetCtrlIndex(panel, __STEP, &index); \
562 if ((eventData1 == VAL_RIGHT_ARROW_VKEY) && (index < 14)) \ 560 if ((eventData1 == VAL_RIGHT_ARROW_VKEY) && (index < 14)) \
563 SetCtrlIndex(MainPanel, __STEP, index + 1); \ 561 SetCtrlIndex(panel, __STEP, index + 1); \
564 if ((eventData1 == VAL_LEFT_ARROW_VKEY) && (index > 0)) \ 562 if ((eventData1 == VAL_LEFT_ARROW_VKEY) && (index > 0)) \
565 SetCtrlIndex(MainPanel, __STEP, index - 1); \ 563 SetCtrlIndex(panel, __STEP, index - 1); \
566 GetCtrlVal(MainPanel, __STEP, &step); \ 564 GetCtrlVal(panel, __STEP, &step); \
567 SetCtrlAttribute(MainPanel, __DDS, ATTR_INCR_VALUE, step); \ 565 SetCtrlAttribute(panel, __DDS, ATTR_INCR_VALUE, step); \
568 } while (0) 566 } while (0)
569 567
570 switch (event) { 568 switch (event) {
571 case EVENT_KEYPRESS: 569 case EVENT_KEYPRESS:
572 /* key code */ 570 /* key code */
592 do_arrow(PANEL_DDS4, PANEL_DDS4STEP); 590 do_arrow(PANEL_DDS4, PANEL_DDS4STEP);
593 break; 591 break;
594 } 592 }
595 break; 593 break;
596 case VAL_F2_VKEY : 594 case VAL_F2_VKEY :
597 SetActiveCtrl(MainPanel, PANEL_DDS1); 595 SetActiveCtrl(panel, PANEL_DDS1);
598 break; 596 break;
599 case VAL_F3_VKEY : 597 case VAL_F3_VKEY :
600 SetActiveCtrl(MainPanel, PANEL_DDS2); 598 SetActiveCtrl(panel, PANEL_DDS2);
601 break; 599 break;
602 case VAL_F4_VKEY : 600 case VAL_F4_VKEY :
603 SetActiveCtrl(MainPanel, PANEL_DDS3); 601 SetActiveCtrl(panel, PANEL_DDS3);
604 break; 602 break;
605 case VAL_F5_VKEY : 603 case VAL_F5_VKEY :
606 SetActiveCtrl(MainPanel, PANEL_DDS4); 604 SetActiveCtrl(panel, PANEL_DDS4);
607 break; 605 break;
608 } 606 }
609 break; 607 break;
610 } 608 }
611 return 0; 609 return 0;
618 { 616 {
619 case EVENT_COMMIT: 617 case EVENT_COMMIT:
620 if (acquiring) 618 if (acquiring)
621 break; 619 break;
622 620
623 logmsg("Start"); 621 logmsg("start");
624 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE); 622 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE);
625 acquiring = 1; 623 acquiring = 1;
626 624
627 // start data provider thread 625 // start data provider thread
628 CmtScheduleThreadPoolFunctionAdv( 626 CmtScheduleThreadPoolFunctionAdv(
640 switch (event) { 638 switch (event) {
641 case EVENT_COMMIT: 639 case EVENT_COMMIT:
642 if (! acquiring) 640 if (! acquiring)
643 break; 641 break;
644 642
645 logmsg("Stop"); 643 logmsg("stop");
646 acquiring = 0; 644 acquiring = 0;
647 645
648 // wait for data provider thread to terminate 646 // wait for data provider thread to terminate
649 CmtWaitForThreadPoolFunctionCompletion( 647 CmtWaitForThreadPoolFunctionCompletion(
650 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread, 648 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread,
651 OPT_TP_PROCESS_EVENTS_WHILE_WAITING); 649 OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
652 CmtReleaseThreadPoolFunctionID( 650 CmtReleaseThreadPoolFunctionID(
653 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread); 651 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread);
654 652
655 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, FALSE); 653 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, FALSE);
656 654
657 break; 655 break;
658 } 656 }
659 return 0; 657 return 0;
684 SetCtrlVal(MainPanel, PANEL_UTC, utc); 682 SetCtrlVal(MainPanel, PANEL_UTC, utc);
685 SetCtrlVal(MainPanel, PANEL_CH1, Ch1); 683 SetCtrlVal(MainPanel, PANEL_CH1, Ch1);
686 SetCtrlVal(MainPanel, PANEL_CH2, Ch2); 684 SetCtrlVal(MainPanel, PANEL_CH2, Ch2);
687 SetCtrlVal(MainPanel, PANEL_CH3, Ch3); 685 SetCtrlVal(MainPanel, PANEL_CH3, Ch3);
688 SetCtrlVal(MainPanel, PANEL_CH4, Ch4); 686 SetCtrlVal(MainPanel, PANEL_CH4, Ch4);
689 687
690 // compute 688 // compute
691 Math1 = mupEval(MathParser1); 689 Math1 = mupEval(MathParser1);
692 Math2 = mupEval(MathParser2); 690 Math2 = mupEval(MathParser2);
693 Math3 = mupEval(MathParser3); 691 Math3 = mupEval(MathParser3);
694 Math4 = mupEval(MathParser4); 692 Math4 = mupEval(MathParser4);
701 SetCtrlVal(MainPanel, PANEL_MATH1, thousands(buffer, sizeof(buffer), "%.6f", Math1)); 699 SetCtrlVal(MainPanel, PANEL_MATH1, thousands(buffer, sizeof(buffer), "%.6f", Math1));
702 SetCtrlVal(MainPanel, PANEL_MATH2, thousands(buffer, sizeof(buffer), "%.3f", Math2)); 700 SetCtrlVal(MainPanel, PANEL_MATH2, thousands(buffer, sizeof(buffer), "%.3f", Math2));
703 SetCtrlVal(MainPanel, PANEL_MATH3, thousands(buffer, sizeof(buffer), "%.3f", Math3)); 701 SetCtrlVal(MainPanel, PANEL_MATH3, thousands(buffer, sizeof(buffer), "%.3f", Math3));
704 SetCtrlVal(MainPanel, PANEL_MATH4, thousands(buffer, sizeof(buffer), "%.3f", Math4)); 702 SetCtrlVal(MainPanel, PANEL_MATH4, thousands(buffer, sizeof(buffer), "%.3f", Math4));
705 SetCtrlVal(MainPanel, PANEL_MATH5, thousands(buffer, sizeof(buffer), "%.3f", Math5)); 703 SetCtrlVal(MainPanel, PANEL_MATH5, thousands(buffer, sizeof(buffer), "%.3f", Math5));
706 704
707 // update timeseries plots 705 // update timeseries plots
708 for (struct plot *plot = plots; plot->data; plot++) 706 for (struct plot *plot = plots; plot->data; plot++)
709 plot_update(plot); 707 plot_update(plot);
710 708
711 // update allan deviation plots 709 // update allan deviation plots
1324 datafile_append(d, id, timestr); 1322 datafile_append(d, id, timestr);
1325 1323
1326 // send Sr frequency (Math4) to Sr data logger 1324 // send Sr frequency (Math4) to Sr data logger
1327 if (Sr_datalogger_enabled) 1325 if (Sr_datalogger_enabled)
1328 Sr_datalogger_send("FEMTO2", utc, Math4); 1326 Sr_datalogger_send("FEMTO2", utc, Math4);
1329
1330 } 1327 }
1331 break; 1328 break;
1332 } 1329 }
1333 } 1330 }
1334 1331
1452 } 1449 }
1453 1450
1454 int CVICALLBACK CB_ChangeN (int panel, int control, int event, 1451 int CVICALLBACK CB_ChangeN (int panel, int control, int event,
1455 void *callbackData, int eventData1, int eventData2) 1452 void *callbackData, int eventData1, int eventData2)
1456 { 1453 {
1457
1458 switch (event) 1454 switch (event)
1459 { 1455 {
1460 case EVENT_COMMIT: 1456 case EVENT_COMMIT:
1461 switch (control) 1457 switch (control)
1462 { 1458 {
1477 1473
1478 int CVICALLBACK CB_OnPlus10k (int panel, int control, int event, 1474 int CVICALLBACK CB_OnPlus10k (int panel, int control, int event,
1479 void *callbackData, int eventData1, int eventData2) 1475 void *callbackData, int eventData1, int eventData2)
1480 { 1476 {
1481 double Frequency ; 1477 double Frequency ;
1482 1478
1483 switch (event) 1479 switch (event)
1484 { 1480 {
1485 case EVENT_COMMIT: 1481 case EVENT_COMMIT:
1486 switch (control) 1482 switch (control)
1487 { 1483 {
1583 } 1579 }
1584 1580
1585 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event, 1581 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event,
1586 void *callbackData, int eventData1, int eventData2) 1582 void *callbackData, int eventData1, int eventData2)
1587 { 1583 {
1588
1589 int visible; 1584 int visible;
1590 1585
1591 switch (event) { 1586 switch (event) {
1592 case EVENT_COMMIT: 1587 case EVENT_COMMIT:
1593 switch (control) { 1588 switch (control) {
1713 } 1708 }
1714 1709
1715 int CVICALLBACK CB_OnFindSign (int panel, int control, int event, 1710 int CVICALLBACK CB_OnFindSign (int panel, int control, int event,
1716 void *callbackData, int eventData1, int eventData2) 1711 void *callbackData, int eventData1, int eventData2)
1717 { 1712 {
1718
1719 switch (event) 1713 switch (event)
1720 { 1714 {
1721 case EVENT_COMMIT: 1715 case EVENT_COMMIT:
1722 switch (control) 1716 switch (control)
1723 { 1717 {
1826 } 1820 }
1827 1821
1828 int CVICALLBACK CB_OnResetSlope (int panel, int control, int event, 1822 int CVICALLBACK CB_OnResetSlope (int panel, int control, int event,
1829 void *callbackData, int eventData1, int eventData2) 1823 void *callbackData, int eventData1, int eventData2)
1830 { 1824 {
1831
1832 switch (event) 1825 switch (event)
1833 { 1826 {
1834 case EVENT_COMMIT: 1827 case EVENT_COMMIT:
1835 dedrift.applied = 0.0; 1828 dedrift.applied = 0.0;
1836 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied); 1829 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied);
1842 } 1835 }
1843 1836
1844 int CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event, 1837 int CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event,
1845 void *callbackData, int eventData1, int eventData2) 1838 void *callbackData, int eventData1, int eventData2)
1846 { 1839 {
1847
1848 switch (event) 1840 switch (event)
1849 { 1841 {
1850 case EVENT_COMMIT: 1842 case EVENT_COMMIT:
1851 GetCtrlVal(MainPanel, PANEL_SLOPETIME, &dedrift.interval); 1843 GetCtrlVal(MainPanel, PANEL_SLOPETIME, &dedrift.interval);
1852 break; 1844 break;