mirror of
https://github.com/nqrduck/LimeDriver.git
synced 2024-11-24 11:02:25 +00:00
commit
844b2d9191
2 changed files with 78 additions and 46 deletions
|
@ -325,16 +325,16 @@ void dumpConfig(std::vector<Config2HDFattr_t> &config) {
|
|||
std::cout << "}" << std::endl;
|
||||
}
|
||||
|
||||
LimeConfig_t initializeLimeConfig(int Npulses,
|
||||
std::ostringstream &stringstream) {
|
||||
LimeConfig_t initializeLimeConfig(int Npulses) {
|
||||
/* Initialize the LimeConfig_t struct
|
||||
|
||||
@param Npulses: Number of pulses
|
||||
@param stringstream: std::ostringstream object
|
||||
|
||||
@return LimeConfig_t: LimeConfig_t struct with default values
|
||||
|
||||
*/
|
||||
std::ostringstream stringstream;
|
||||
|
||||
LimeConfig_t LimeCfg{};
|
||||
|
||||
LimeCfg.Npulses = Npulses;
|
||||
|
@ -648,60 +648,33 @@ double Modfunction(double argument, int mode) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int run_experiment(LimeConfig_t LimeCfg, std::vector<Config2HDFattr_t> &HDFattrVector) {
|
||||
/* Run the experiment
|
||||
|
||||
@param LimeCfg: LimeConfig_t struct
|
||||
@param Config2HDFattr_t: HDFattr_t struct
|
||||
@param device: lms_device_t struct
|
||||
|
||||
@return int: 0 if successful, -1 if not
|
||||
|
||||
*/
|
||||
std::ostringstream stringstream;
|
||||
const double pi = acos(-1);
|
||||
|
||||
std::ostringstream stringstream;
|
||||
size_t no_of_attr = HDFattrVector.size();
|
||||
|
||||
int Npulses = 2; // default number of pulses
|
||||
// check if nPulses has been given as argument, so that all the arrays are
|
||||
// initialized with proper size
|
||||
for (int ii_arg = 1; ii_arg < argc; ii_arg++) {
|
||||
if (strcmp(argv[ii_arg], "-npu") == 0 && ii_arg + 1 < argc) {
|
||||
Npulses = atoi(argv[ii_arg + 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the LimeConfig_t struct
|
||||
LimeConfig_t LimeCfg = initializeLimeConfig(Npulses, stringstream);
|
||||
|
||||
// Getting HDF Attributes from dedicated function
|
||||
std::vector<Config2HDFattr_t> HDFattrVector = getHDFAttributes(LimeCfg);
|
||||
size_t no_of_attr = HDFattrVector.size();
|
||||
|
||||
bool dumpFlag = false;
|
||||
|
||||
// Checking for dump flag
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "--dump") == 0) {
|
||||
dumpFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If dump flag is set, dump the config and exit
|
||||
if (dumpFlag) {
|
||||
dumpConfig(HDFattrVector);
|
||||
std::exit(0);
|
||||
}
|
||||
// Converting to array to maintain compatibility with older code
|
||||
Config2HDFattr_t HDFattr[no_of_attr];
|
||||
std::copy(HDFattrVector.begin(), HDFattrVector.end(), HDFattr);
|
||||
|
||||
|
||||
// Parse command line arguments
|
||||
if (parseArguments(argc, argv, LimeCfg, HDFattrVector) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check directory first
|
||||
// check directory first
|
||||
if (makePath(LimeCfg.save_path) == 0) {
|
||||
cout << "Problem entering the specified path: " << LimeCfg.save_path
|
||||
<< endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Converting to array to maintain compatibility with older code
|
||||
Config2HDFattr_t HDFattr[no_of_attr];
|
||||
std::copy(HDFattrVector.begin(), HDFattrVector.end(), HDFattr);
|
||||
|
||||
// Find devices
|
||||
int n;
|
||||
lms_info_str_t list[8]; // should be large enough to hold all detected devices
|
||||
|
@ -1919,4 +1892,61 @@ DC_Q << endl;
|
|||
LMS_Close(device);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int run_experiment_from_LimeCfg(LimeConfig_t LimeCfg){
|
||||
|
||||
int Npulses = LimeCfg.Npulses; // Number of pulses from the LimeCfg
|
||||
|
||||
// Getting HDF Attributes from dedicated function
|
||||
std::vector<Config2HDFattr_t> HDFattrVector = getHDFAttributes(LimeCfg);
|
||||
|
||||
run_experiment(LimeCfg, HDFattrVector);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const double pi = acos(-1);
|
||||
|
||||
int Npulses = 2; // default number of pulses
|
||||
// check if nPulses has been given as argument, so that all the arrays are
|
||||
// initialized with proper size
|
||||
for (int ii_arg = 1; ii_arg < argc; ii_arg++) {
|
||||
if (strcmp(argv[ii_arg], "-npu") == 0 && ii_arg + 1 < argc) {
|
||||
Npulses = atoi(argv[ii_arg + 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the LimeConfig_t struct
|
||||
LimeConfig_t LimeCfg = initializeLimeConfig(Npulses);
|
||||
|
||||
// Getting HDF Attributes from dedicated function
|
||||
std::vector<Config2HDFattr_t> HDFattrVector = getHDFAttributes(LimeCfg);
|
||||
size_t no_of_attr = HDFattrVector.size();
|
||||
|
||||
bool dumpFlag = false;
|
||||
|
||||
// Checking for dump flag
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "--dump") == 0) {
|
||||
dumpFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If dump flag is set, dump the config and exit
|
||||
if (dumpFlag) {
|
||||
dumpConfig(HDFattrVector);
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
|
||||
// Parse command line arguments
|
||||
if (parseArguments(argc, argv, LimeCfg, HDFattrVector) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
run_experiment(LimeCfg, HDFattrVector);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -112,4 +112,6 @@ struct Config2HDFattr_t {
|
|||
// Device structure, should be initialize to NULL
|
||||
static lms_device_t *device = NULL;
|
||||
|
||||
LimeConfig_t initializeLimeConfig(int Npulses);
|
||||
|
||||
#endif // LIMECONFIG_H
|
Loading…
Reference in a new issue