Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 174:d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 21 Feb 2014 18:37:32 +0100 |
parents | a4fcebb5941b |
children | 03dcca7e5ba4 |
comparison
equal
deleted
inserted
replaced
173:24ab61179ab5 | 174:d96f0b04f7fe |
---|---|
356 mupDefineVar(parser, "N3", &N3); | 356 mupDefineVar(parser, "N3", &N3); |
357 mupDefineVar(parser, "Sign1", &Sign1); | 357 mupDefineVar(parser, "Sign1", &Sign1); |
358 mupDefineVar(parser, "Sign2", &Sign2); | 358 mupDefineVar(parser, "Sign2", &Sign2); |
359 mupDefineVar(parser, "Sign3", &Sign3); | 359 mupDefineVar(parser, "Sign3", &Sign3); |
360 mupDefineVar(parser, "Ndiv", &Ndiv); | 360 mupDefineVar(parser, "Ndiv", &Ndiv); |
361 | |
361 mupDefinePostfixOprt(parser, "P", &Peta, 1); | 362 mupDefinePostfixOprt(parser, "P", &Peta, 1); |
362 mupDefinePostfixOprt(parser, "T", &Tera, 1); | 363 mupDefinePostfixOprt(parser, "T", &Tera, 1); |
363 mupDefinePostfixOprt(parser, "G", &Giga, 1); | 364 mupDefinePostfixOprt(parser, "G", &Giga, 1); |
364 mupDefinePostfixOprt(parser, "M", &Mega, 1); | 365 mupDefinePostfixOprt(parser, "M", &Mega, 1); |
365 mupDefinePostfixOprt(parser, "k", &kilo, 1); | 366 mupDefinePostfixOprt(parser, "k", &kilo, 1); |
381 int main (int argc, char *argv[]) | 382 int main (int argc, char *argv[]) |
382 { | 383 { |
383 int rv; | 384 int rv; |
384 double frequency; | 385 double frequency; |
385 char expr[1024]; | 386 char expr[1024]; |
387 char host[256]; | |
388 int port; | |
389 double clock; | |
386 | 390 |
387 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) | 391 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) |
388 return -1; | 392 return -1; |
389 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) | 393 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) |
390 return -1; | 394 return -1; |
400 IniText configuration = Ini_New(TRUE); | 404 IniText configuration = Ini_New(TRUE); |
401 Ini_ReadFromFile(configuration, path); | 405 Ini_ReadFromFile(configuration, path); |
402 | 406 |
403 // data folder | 407 // data folder |
404 rv = Ini_GetStringCopy(configuration, "data", "folder", &datafolder); | 408 rv = Ini_GetStringCopy(configuration, "data", "folder", &datafolder); |
405 if (rv <= 0) { | 409 if (rv > 0) { |
410 logmessage(INFO, "writing data files in %s", datafolder); | |
411 } else { | |
406 logmessage(ERROR, "data folder not configured in %s", path); | 412 logmessage(ERROR, "data folder not configured in %s", path); |
407 // do not allow to start the acquisition | 413 // do not allow to start the acquisition |
408 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE); | 414 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE); |
409 } | 415 } |
410 | 416 |
411 // get AD9956 configuration parameters | 417 // AD9956 configuration parameters |
412 char host[256]; | |
413 int port; | |
414 double clock; | |
415 rv = Ini_GetStringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); | 418 rv = Ini_GetStringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); |
416 if (! rv) | 419 if (! rv) |
417 return -1; | 420 return -1; |
418 rv = Ini_GetInt(configuration, "AD9956", "port", &port); | 421 rv = Ini_GetInt(configuration, "AD9956", "port", &port); |
419 if (! rv) | 422 if (! rv) |
420 return -1; | 423 return -1; |
421 rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); | 424 rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); |
422 if (! rv) | 425 if (! rv) |
423 return -1; | 426 return -1; |
424 | 427 |
425 // dispose configuration | |
426 Ini_Dispose(configuration); | |
427 | |
428 // Sr data logger | |
429 sr_datalogger_init(&datalogger); | |
430 | |
431 // dedrift DDS | 428 // dedrift DDS |
432 DDSFox_Initialize(&DDS1xAD9956, host, port, dedrift.freq0); | 429 DDSFox_Initialize(&DDS1xAD9956, host, port, dedrift.freq0); |
433 | 430 |
434 // initialize 4x AD9959 DDS box | 431 // AD9912 configuration parameters |
432 rv = Ini_GetStringIntoBuffer(configuration, "AD9912", "host", host, sizeof(host)); | |
433 if (! rv) | |
434 return -1; | |
435 rv = Ini_GetDouble(configuration, "AD9912", "clock", &clock); | |
436 if (! rv) | |
437 return -1; | |
438 | |
439 // initialize 4x AD9912 DDS box | |
440 DDS4xAD9912_Init(&DDS4xAD9912, host, clock); | |
435 DDS4xAD9912_Reset(&DDS4xAD9912); | 441 DDS4xAD9912_Reset(&DDS4xAD9912); |
436 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); | 442 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); |
437 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); | 443 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); |
438 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); | 444 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); |
439 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency); | 445 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency); |
440 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); | 446 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); |
441 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency); | 447 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency); |
442 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); | 448 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); |
443 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); | 449 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); |
450 | |
451 // dispose configuration | |
452 Ini_Dispose(configuration); | |
453 | |
454 // Sr data logger | |
455 sr_datalogger_init(&datalogger); | |
444 | 456 |
445 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); | 457 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); |
446 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); | 458 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); |
447 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); | 459 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); |
448 | 460 |