Commit 5a6515c9 authored by flechsig's avatar flechsig
Browse files

add parameters to ReadConfig

parent 14a65eff
......@@ -124,6 +124,7 @@ Start the ZMQ server to publish the test image
```
$ source /opt/gfa/python
$ python zmq_server.py sfb_0087.h5
$ python zmq_server.py 190315_jkuf.h5
```
Start the viewer, use Array address 2
......
// File : /afs/psi.ch/user/f/flechsig/git/WFI/src/algorithms.cpp
// Date : <11 Feb 19 10:02:46 flechsig>
// Time-stamp: <14 Mar 19 14:00:41 flechsig>
// Time-stamp: <15 Mar 19 11:40:04 flechsig>
// Author : Flechsig Uwe, uwe.flechsig&#64;psi.&#99;&#104;
#include <iostream>
......@@ -1010,12 +1010,14 @@ void overlay(double *data, int rows, int cols, int center, int width, double val
// read config from json? file filename hardcoded in CONFIGFILENAME
void ReadConfig(struct ConfigStruct *cs)
{
int lines= 0;
int lines= 0, ok= 0;
std::string line, key, value;
//std::string::size_type sz; // alias of size_t
char *pend;
cout << "UF ReadConfig called, filename: " << CONFIGFILENAME << endl;
cout << "****************************************************" << endl;
cout << "UF ReadConfig called, filename: " << CONFIGFILENAME << endl;
cout << "****************************************************" << endl;
// define defaults in case the configfile is not found or values not defined
cs->zeropadding= 19990101;
......@@ -1042,16 +1044,27 @@ void ReadConfig(struct ConfigStruct *cs)
{
if( std::getline(is_line, value) )
{
cout << "(key=val) (" << key << "=" << value << ")" <<endl;
if ( !strcmp("version", key.c_str())) cs->version = strtol(value.c_str(), &pend, 10);
if ( !strcmp("zeropadding", key.c_str())) cs->zeropadding = strtol(value.c_str(), &pend, 10);
if ( !strcmp("mytestdouble", key.c_str())) cs->mytestdouble= strtod(value.c_str(), &pend);
if ( !strcmp("version", key.c_str())) {cs->version = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("zeropadding", key.c_str())) {cs->zeropadding = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("mytestdouble", key.c_str())) {cs->mytestdouble = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("d", key.c_str())) {cs->d = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("eta", key.c_str())) {cs->eta = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("p1", key.c_str())) {cs->p1 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("p2", key.c_str())) {cs->p2 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("photon_energy", key.c_str())) {cs->photon_energy= strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("pixel_size", key.c_str())) {cs->pixel_size = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("R0", key.c_str())) {cs->R0 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("talbot_n", key.c_str())) {cs->talbot_n = strtol(value.c_str(), &pend, 10); ok++; }
}
}
}
//cout << "version: " << cs->version << endl;
cout << "end ReadConfig lines: " << lines << endl;
cout << "parse line " << lines << " >>" << line << "<<, valid: " << ok << endl;
} // while line
cout << "version: " << cs->version << endl;
cout << "photon_energy: " << cs->photon_energy << endl;
cout << "end ReadConfig lines: " << lines << " valid: " << ok << endl;
cout << "****************************************************" << endl;
// UF json cpp did not compile- cant use it
#ifdef TEST
Json::Value root; // starts as "null"; will contain the root value after parsing
......@@ -1072,4 +1085,6 @@ void ReadConfig(struct ConfigStruct *cs)
} // ReadConfig
// end algorithms.cpp
/* File : /afs/psi.ch/user/f/flechsig/git/WFI/src/algorithms.h */
/* Date : <11 Feb 19 10:03:58 flechsig> */
/* Time-stamp: <14 Mar 19 11:03:35 flechsig> */
/* Time-stamp: <14 Mar 19 16:53:23 flechsig> */
/* Author : Flechsig Uwe, uwe.flechsig&#64;psi.&#99;&#104; */
#ifndef ALGORITMS_H
......@@ -14,7 +14,8 @@
#define ROWDIR 1
#ifndef CONFIGFILENAME
#define CONFIGFILENAME "/tmp/XGI_config.conf"
// #define CONFIGFILENAME "/tmp/XGI_config.conf"
#define CONFIGFILENAME "/afs/psi.ch/user/f/flechsig/git/WFI/test/XGI_config.conf"
#endif
// configuration structure type
......@@ -30,6 +31,13 @@ struct ConfigStruct {
int width;
int zeropadding;
double mytestdouble;
double R0; // design wavefront radius of curvature in m
double d; // distance between gratings in m
double photon_energy; // in eV
double eta; // SR page 23 eta = 1 for pi/2 phase shifting grating or amplitude grating; eta=2 for pi .. grating
int talbot_n; // fractional talbot order
double p1, p2; // grating pitch in m
double pixel_size; // in m
};
// procedure prototypes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment