void test::doStoreLoadTest() { int waveformLen = 1000; int pulseLen = 500; float * pulseMem; int cnt; pulseMem = (float *) buildPulseMemory(waveformLen , pulseLen, FLOAT_TYPE); if (pulseMem == 0) return; printf("Storing Waveform\n"); for( cnt = 0; cnt < 4; cnt++) set_waveform_float(0, cnt, pulseMem, waveformLen); printf("Saving Cache\n"); //saveCache(0,0); printf("Loading Cache\n"); //loadCache(0,0); printf("Triggering:\n"); set_trigger_source(0, 0); run(0); printf("Press key:\n"); getchar(); stop(0); }
static char *tsource_cmd(void * arg) { int *argp, rv; argp = (int *)(arg); rv = set_trigger_source(*argp); if ( rv < 0 ) { return "could not set trigger source"; } return NULL; }
void test::doToggleTest() { int ask; char cmd; programSquareWaves(); set_trigger_source(0,0); //Enable all channels for (int ct=0; ct<4; ct++){ set_channel_enabled(0, ct, 1); } ask = 1; cout << "Cmd: [t]rigger [d]isable e[x]it: "; while(ask) { cmd = getchar(); switch (toupper(cmd)) { case 'T': printf("Triggering"); run(0); break; case 'D': printf("Disabling"); stop(0); break; case 'X':case 'x': printf("Exiting\n"); stop(0); ask = 0; continue; case '\r': case '\n': continue; default: printf("No command: %c", cmd); break; } // written this way to handle interactive session where // input is buffered until \n' cout << "\nCmd: [t]rigger [d]isable e[x]it: "; } close(0); }
int main(int argc, char* argv[]) { print_title("BBN APS2 Sequence Player"); argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present option::Stats stats(usage, argc, argv); option::Option *options = new option::Option[stats.options_max]; option::Option *buffer = new option::Option[stats.buffer_max]; option::Parser parse(usage, argc, argv, options, buffer); if (parse.error()) return -1; if (options[HELP] || argc == 0) { option::printUsage(std::cout, usage); return 0; } for (option::Option* opt = options[UNKNOWN]; opt; opt = opt->next()) std::cout << "Unknown option: " << opt->name << "\n"; for (int i = 0; i < parse.nonOptionsCount(); ++i) std::cout << "Non-option #" << i << ": " << parse.nonOption(i) << "\n"; //Logging level TLogLevel logLevel = logINFO; if (options[LOG_LEVEL]) { logLevel = TLogLevel(atoi(options[LOG_LEVEL].arg)); } //Trigger source -- default of internal APS2_TRIGGER_SOURCE triggerSource = INTERNAL; if (options[TRIG_MODE]) { triggerSource = APS2_TRIGGER_SOURCE(atoi(options[TRIG_MODE].arg)); } set_logging_level(logLevel); set_log("stdout"); //Trigger interval -- default of 10ms double trigInterval = 10e-3; if (options[TRIG_INTERVAL]) { trigInterval = atof(options[TRIG_INTERVAL].arg); } string seqFile; if (options[SEQ_FILE]){ seqFile = string(options[SEQ_FILE].arg); } else { std::cerr << "A sequence file is required."; return -1; } string deviceSerial = get_device_id(); if (deviceSerial.empty()){ cout << concol::RED << "No APS2 devices connected! Exiting..." << concol::RESET << endl; return 0; } connect_APS(deviceSerial.c_str()); double uptime; get_uptime(deviceSerial.c_str(), &uptime); cout << concol::CYAN << "Uptime for device " << deviceSerial << " is " << uptime << " seconds" << concol::RESET << endl; // force initialize device init_APS(deviceSerial.c_str(), 1); //load the sequence file load_sequence_file(deviceSerial.c_str(), seqFile.c_str()); //Set the trigger mode set_trigger_source(deviceSerial.c_str(), triggerSource); //Trigger interval set_trigger_interval(deviceSerial.c_str(), trigInterval); //Set to sequence mode set_run_mode(deviceSerial.c_str(), RUN_SEQUENCE); run(deviceSerial.c_str()); //For software trigger, trigger on key stroke if (triggerSource == 2) { cout << concol::YELLOW << "Press t-Return to trigger or q-Return to exit" << concol::RESET << endl; while(true) { char keyStroke = cin.get(); if (keyStroke == 't') { trigger(deviceSerial.c_str()); } else if (keyStroke == 'q') { break; } } } else { cout << concol::YELLOW << "Press any key to stop" << concol::RESET; cin.get(); } stop(deviceSerial.c_str()); disconnect_APS(deviceSerial.c_str()); delete[] options; delete[] buffer; return 0; }