StreamInfo Chroma2::init(const ParameterMap& params, const StreamInfo& in) { m_cqtSize = in.size; m_cqtMinFreq = getDoubleParam("CQTMinFreq",params); m_cqtMaxFreq = getDoubleParam("CQTMaxFreq",params); m_cqtNbBins = getIntParam("CQTBinsPerOctave",params); m_nbBinsSemitone = getIntParam("CZBinsPerSemitone",params); m_nbBins = getIntParam("CZNbCQTBinsAggregatedToPCPBin",params); if (m_nbBins<0) m_nbBins = m_cqtNbBins / 24; m_tuning = getDoubleParam("CZTuning",params); m_deviation = m_cqtNbBins * log2(m_tuning / m_cqtMinFreq); double deviationRealPart = m_deviation - floor(m_deviation); m_cqtMinFreq = m_cqtMinFreq * pow(2.0, deviationRealPart / m_cqtNbBins); m_tuningBin = 1 + ((int) floor(m_deviation) - 1) % (m_cqtNbBins / 12); m_Q = 1 / (pow(2.0, 1.0 / (double) m_cqtNbBins) - 1); m_K = log2(m_cqtMaxFreq / m_cqtMinFreq); m_nbNote = (int) floor(m_cqtSize * 12.0 * m_nbBinsSemitone / m_cqtNbBins); m_notePartial.resize(m_nbNote); m_notePartialA = (int) floor((double) m_nbBins / 2.0); if (m_tuningBin > (m_cqtNbBins / 12 - m_notePartialA)) m_tuningBin = m_tuningBin - m_cqtNbBins / 12; m_notePartialFactor = m_cqtNbBins / (12 * m_nbBinsSemitone); m_pcpSize = 12 * m_nbBinsSemitone; m_pcp.resize(m_pcpSize); int firstCode = (int) round(m_nbBinsSemitone * (69.0 + 12.0 * log2(m_cqtMinFreq * pow(2.0, ((double)m_tuningBin / m_cqtNbBins)) / m_tuning ))); m_pcpShift = firstCode % m_pcpSize; return StreamInfo(in,m_pcpSize); }
void ProgSSNR::readParams() { radial_avg = checkParam("--radial_avg"); fourierProjections = checkParam("--fourierProjections"); if (!radial_avg) { fn_S = getParam("-S"); fn_N = getParam("-N"); fn_S_sel = getParam("--sel_signal"); fn_N_sel = getParam("--sel_noise"); generate_VSSNR = checkParam("--gen_VSSNR"); if (generate_VSSNR) { fn_VSSNR = getParam("--VSSNR"); fn_out_images = getParam("--oroot"); sym=getParam("--sym"); Nthreads=getIntParam("--thr"); } } else fn_VSSNR = getParam("--VSSNR"); ring_width = getDoubleParam("--ring"); Tm = getDoubleParam("--sampling_rate"); min_power = getDoubleParam("--min_power"); fn_out = getParam("-o"); }
int LibV4::peak_indices(mapStr2intVec& IntFeatureData, mapStr2doubleVec& DoubleFeatureData, mapStr2Str& StringData) { int size; if (CheckInIntmap(IntFeatureData, StringData, "peak_indices", size)) { return size; } vector<int> peakindices; vector<double> v; vector<double> min_spike_height; vector<double> threshold; if (getDoubleVec(DoubleFeatureData, StringData, "V", v) <= 0) { return -1; } if (getDoubleParam(DoubleFeatureData, "min_spike_height", min_spike_height) <= 0) { return -1; } if (getDoubleParam(DoubleFeatureData, "Threshold", threshold) <= 0) { return -1; } int retval = __peak_indices(v, min_spike_height[0], threshold[0], peakindices); if (retval >= 0) { setIntVec(IntFeatureData, StringData, "peak_indices", peakindices); return peakindices.size(); } else { return retval; } }
// Read from command line -------------------------------------------------- void ProgDetectMissingWedge::readParams() { fn_vol = getParam("-i"); maxFreq = getDoubleParam("--maxFreq"); planeWidth = getDoubleParam("--width"); saveMarks = checkParam("--saveMarks"); saveMask = checkParam("--saveMask"); }
void ProgCTFPhaseFlipping::readParams() { fn_in = getParam("-i"); fn_out = getParam("-o"); fnt_ctf = getParam("--ctf"); downsampling = getDoubleParam("--downsampling"); Tm = getDoubleParam("--sampling"); }
bool MelFilterBank::init(const ParameterMap& params, const Ports<StreamInfo>& inp) { assert(inp.size()==1); const StreamInfo& in = inp[0].data; // build mel filter bank m_size = in.size; int nbMelFilters = getIntParam("MelNbFilters",params); double sampleRate = in.sampleRate; double freqMin = getDoubleParam("MelMinFreq",params); double freqMax = getDoubleParam("MelMaxFreq",params); // set freqMax to Nyquist frequency if greater than nyquist frequency freqMax = min(freqMax, sampleRate/2.0); double melFreqMin = 1127 * log(1 + freqMin / 700); double melFreqMax = 1127 * log(1 + freqMax / 700); VectorXd melPeak(nbMelFilters+2); VectorXd freqs(nbMelFilters+2); melPeak = VectorXd::LinSpaced(nbMelFilters+2,melFreqMin,melFreqMax); freqs = ((melPeak / 1127).array().exp() - 1.0) * 700.0; VectorXd fftFreqs(m_size); fftFreqs = VectorXd::LinSpaced(m_size,0,m_size-1) * sampleRate / ((m_size-1)*2); for (int b=1;b<nbMelFilters+1;b++) { double norm = 2.0 / (freqs(b+1)-freqs(b-1)); VectorXd fullfilt(m_size); // fullfilt.setZero(m_size); // firstIndex i; // fullfilt += where((fftFreqs(i)>freqs(b-1)) && (fftFreqs(i)<=freqs(b)),norm*(fftFreqs(i)-freqs(b-1))/(freqs(b)-freqs(b-1)),0.0); // fullfilt += where((fftFreqs(i)>freqs(b)) && (fftFreqs(i)<freqs(b+1)),norm*(freqs(b+1)-fftFreqs(i))/(freqs(b+1)-freqs(b)),0.0); double ffmin = freqs(b-1); double ffmiddle = freqs(b); double ffmax = freqs(b+1); for (int i=0;i<m_size;i++) { if ((fftFreqs(i)<ffmin) || (fftFreqs(i)>ffmax)) { fullfilt(i) = 0; continue; } if (fftFreqs(i)<ffmiddle) fullfilt(i) = norm*(fftFreqs(i)-ffmin)/(ffmiddle-ffmin); else fullfilt(i) = norm*(ffmax-fftFreqs(i))/(ffmax-ffmiddle); } int fStart=0; while (fullfilt(fStart)==0.0) fStart++; int fEnd=fStart+1; while ((fEnd<m_size) && (fullfilt(fEnd)!=0.0)) fEnd++; m_filterStart.push_back(fStart); m_filters.push_back(RowVectorXd()); m_filters.back() = fullfilt.segment(fStart,fEnd-fStart); } outStreamInfo().add(StreamInfo(in, m_filters.size())); return true; }
void ProgSortByStatistics::readParams() { fn = getParam("-i"); fn_out = getParam("-o"); addToInput = checkParam("--addToInput"); fn_train = getParam("--train"); cutoff = getDoubleParam("--zcut"); per = getDoubleParam("--percent"); targetXdim = getIntParam("--dim"); }
int main(int argc, char *argv[]) { double sq_distance_from_initial_pt; int i; // overhead setCommandLineParameters(argc, argv); verbose = getFlagParam("-verbose"); getIntParam("-seed", &seed); if (getFlagParam("-randomize")) randomize(); else initializeRandomNumberGenerator(); getVectorParam("-box", &box_x, &box_y, &box_z); getDoubleParam("-verlet_cutoff", &verlet_cutoff); getDoubleParam("-sea_level", &sea_level); getDoubleParam("-test_diameter", &test_diameter); getDoubleParam("-test_epsilon", &test_epsilon); getIntParam("-n", &number_of_samples); if (getFlagParam("-usage")) { printf("\nusage:\t-box [ 10 10 10 ]\n"); printf(" \t-verlet_cutoff [ 64.0 ]\n"); printf(" \t-sea_level [ 347.0 ]\n"); printf(" \t-test_diameter [ 1.0 ]\n"); printf(" \t-test_epsilon [ 1.0 ]\n"); printf(" \t-n [ 100 ]\n\n"); exit(0); } x_increment=box_x/(0.0 + number_of_samples); y_increment=box_y/(0.0 + number_of_samples); z_increment=box_z/(0.0 + number_of_samples); readConfiguration(); for (i=0; i<number_of_molecules; i++) { while (x[i] >= box_x) x[i] -= box_x; while (y[i] >= box_y) y[i] -= box_y; while (z[i] >= box_z) z[i] -= box_z; while (x[i] < 0) x[i] += box_x; while (y[i] < 0) y[i] += box_y; while (z[i] < 0) z[i] += box_z; } for (test_x=0; test_x < box_x; test_x += x_increment) for (test_y=0; test_y < box_y; test_y += y_increment) for (test_z=0; test_z < box_z; test_z += z_increment) if (calculateEnergy(test_diameter) < sea_level) printf("%lf\t%lf\t%lf\t%lf\n", test_x, test_y, test_z, test_diameter); return 0; }
int main(int argc, char *argv[]) { double sq_distance_from_initial_pt; double step_number; double dx, dy, dz; // overhead setCommandLineParameters(argc, argv); verbose = getFlagParam("-verbose"); getIntParam("-seed", &seed); if (getFlagParam("-randomize")) randomize(); else initializeRandomNumberGeneratorTo(seed); getVectorParam("-box", &box_x, &box_y, &box_z); getDoubleParam("-step_size_factor", &step_size_factor); getDoubleParam("-verlet_cutoff", &verlet_cutoff); getDoubleParam("-test_diameter", &test_diameter); getDoubleParam("-T", &T); getIntParam("-n", &number_of_samples); getIntParam("-n_steps", &n_steps); beta=1/(kB*T); readConfiguration(); while (number_of_samples-- > 0) { generateTestPoint(); successes=0; drift_x=drift_y=drift_z=0; for (step_number=0; step_number<n_steps; step_number++) { attemptRandomStep(); dx=test_x - verlet_center_x; dy=test_y - verlet_center_y; dz=test_z - verlet_center_z; if (dx*dx + dy*dy + dz*dz > .01 * verlet_cutoff) makeVerletList(); } dx = test_x - test_x0 + drift_x; dy = test_y - test_y0 + drift_y; dz = test_z - test_z0 + drift_z; printf("%lf\t%d\n", sqrt(dx*dx + dy*dy + dz*dz), successes); } return 0; }
void readParams() { XmippMetadataProgram::readParams(); min_val = getDoubleParam("--range", 0); max_val = getDoubleParam("--range", 1); sigma = getDoubleParam("--noise"); randomize_random_generator(); if (checkParam("--mask")) { mask_prm.allowed_data_types = INT_MASK; mask_prm.readParams(this); } }
void readParams() { if (checkParam("--extract")) { operation = HEADER_EXTRACT; produces_a_metadata = true; } else if (checkParam("--assign")) operation = HEADER_ASSIGN; else if (checkParam("--reset")) operation = HEADER_RESET; else if (checkParam("--sampling_rate")) { operation = HEADER_SAMPLINGRATE; sampling = getDoubleParam("--sampling_rate"); allow_time_bar = false; } else if (checkParam("--tree")) { operation = HEADER_TREE; decompose_stacks = false; } else { operation = HEADER_PRINT; allow_time_bar = false; decompose_stacks = getIntParam("--print") == 1; } XmippMetadataProgram::readParams(); round_shifts = checkParam("--round_shifts"); if (operation != HEADER_EXTRACT && checkParam("-o")) REPORT_ERROR(ERR_PARAM_INCORRECT, "Argument -o is not valid for this operation"); params.datamode = HEADER; }
void ProgValidationNonTilt::readParams() { fnDir = getParam("--odir"); fnSym = getParam("--sym"); fnInit = getParam("--volume"); sampling_rate = getDoubleParam("--sampling_rate"); }
asynStatus ReadASCII::writeInt32(asynUser *pasynUser, epicsInt32 value) { //Checks for updates to the index and on/off of PID lookup int function = pasynUser->reason; asynStatus status = asynSuccess; const char *paramName; const char* functionName = "writeInt32"; int LUTOn; /* Set the parameter in the parameter library. */ status = (asynStatus)setIntegerParam(function, value); if (function == P_Index) { //check lookup on getIntegerParam(P_LookUpOn, &LUTOn); if (LUTOn) { //update all column floats setDoubleParam(P_SPOut, pSP_[value]); setDoubleParam(P_P, pP_[value]); setDoubleParam(P_I, pI_[value]); setDoubleParam(P_D, pD_[value]); setDoubleParam(P_MaxHeat, pMaxHeat_[value]); } }else if (function == P_LookUpOn) { //reload file if bad if (true == fileBad) { status = readFileBasedOnParameters(); } //file may now be good - retry if (false == fileBad) { //uses the current temperature to find PID values if (value) { double curTemp; getDoubleParam(P_CurTemp, &curTemp); updatePID(getSPInd(curTemp)); } } } /* Do callbacks so higher layers see any changes */ status = (asynStatus)callParamCallbacks(); if (status) epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "%s:%s: status=%d, function=%d, name=%s, value=%d", driverName, functionName, status, function, paramName, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, name=%s, value=%d\n", driverName, functionName, function, paramName, value); return status; }
/** Downloads all of the current EPICS settings to the electrometer. * Typically used after the electrometer is power-cycled. */ asynStatus drvQuadEM::reset() { epicsInt32 iValue; epicsFloat64 dValue; getIntegerParam(P_Range, &iValue); setRange(iValue); getIntegerParam(P_ValuesPerRead, &iValue); setValuesPerRead(iValue); getDoubleParam(P_AveragingTime, &dValue); setAveragingTime(dValue); getIntegerParam(P_TriggerMode, &iValue); setTriggerMode(iValue); getIntegerParam(P_NumChannels, &iValue); setNumChannels(iValue); getIntegerParam(P_BiasState, &iValue); setBiasState(iValue); getIntegerParam(P_BiasInterlock, &iValue); setBiasInterlock(iValue); getDoubleParam(P_BiasVoltage, &dValue); setBiasVoltage(dValue); getIntegerParam(P_Resolution, &iValue); setResolution(iValue); getIntegerParam(P_ReadFormat, &iValue); setReadFormat(iValue); getDoubleParam(P_IntegrationTime, &dValue); setIntegrationTime(dValue); readStatus(); getIntegerParam(P_Acquire, &iValue); setAcquire(iValue); return asynSuccess; }
void ProgValidationNonTilt::readParams() { fnParticles = getParam("--i"); fnDir = getParam("--odir"); fnSym = getParam("--sym"); fnInit = getParam("--volume"); useSignificant = checkParam("--useSignificant"); significance_noise = getDoubleParam("--significance_noise"); }
void readParams() { fn_in = getParam("-i"); fn_root = getParam("--oroot"); invert = checkParam("--invert"); min_size = getDoubleParam("--min_size"); if (fn_root == "") fn_root = fn_in.withoutExtension(); }
/** Array generation ask that runs as a separate thread. When the P_RunStop parameter is set to 1 * it periodically generates a burst of arrays. */ void testArrayRingBuffer::arrayGenTask(void) { double loopDelay; int runStop; int i, j; int burstLength; double burstDelay; int maxArrayLength; int arrayLength; lock(); /* Loop forever */ getIntegerParam(P_MaxArrayLength, &maxArrayLength); while (1) { getDoubleParam(P_LoopDelay, &loopDelay); getDoubleParam(P_BurstDelay, &burstDelay); getIntegerParam(P_RunStop, &runStop); // Release the lock while we wait for a command to start or wait for updateTime unlock(); if (runStop) epicsEventWaitWithTimeout(eventId_, loopDelay); else (void)epicsEventWait(eventId_); // Take the lock again lock(); /* runStop could have changed while we were waiting */ getIntegerParam(P_RunStop, &runStop); if (!runStop) continue; getIntegerParam(P_ArrayLength, &arrayLength); if (arrayLength > maxArrayLength) { arrayLength = maxArrayLength; setIntegerParam(P_ArrayLength, arrayLength); } getIntegerParam(P_BurstLength, &burstLength); for (i=0; i<burstLength; i++) { for (j=0; j<arrayLength; j++) { pData_[j] = i; } setIntegerParam(P_ScalarData, i); callParamCallbacks(); doCallbacksInt32Array(pData_, arrayLength, P_ArrayData, 0); if (burstDelay > 0.0) epicsThreadSleep(burstDelay); } } }
void drvSIS3820::setLNEOutputDelay() { double value; epicsUInt32 ivalue; if (firmwareVersion_ < 0x0111) return; getDoubleParam(SIS38XXLNEOutputDelay_, &value); ivalue = epicsUInt32(value * SIS3820_INTERNAL_CLOCK + 0.5); registers_->lne_output_delay_reg = ivalue; }
int main(int argc, char *argv[]) { instream = stdin; setCommandLineParameters(argc, argv); getVectorParam("-box", &box_x, &box_y, &box_z); verbose = getFlagParam("-verbose"); if (getFlagParam("-randomize")) randomize(); else initializeRandomNumberGenerator(); getDoubleParam("-c_convergence_ratio", &c_convergence_ratio); getDoubleParam("-d_step_size", &d_step_size); getIntParam("-n", &number_of_samples); getIntParam("-n_trials", &n_trials); volume_sampling = getFlagParam("-volume_sampling"); readConfiguration(); sampleCavities(); return 0; }
/* Read parameters --------------------------------------------------------- */ void ProgAngularProjectLibrary::readParams() { input_volume = getParam("-i"); output_file = getParam("-o"); output_file_root = output_file.withoutExtension(); fn_sym = getParam("--sym"); fn_sym_neigh=checkParam("--sym_neigh")?getParam("--sym_neigh"):fn_sym; sampling = getDoubleParam("--sampling_rate"); psi_sampling = getDoubleParam("--psi_sampling"); max_tilt_angle = getDoubleParam("--max_tilt_angle"); min_tilt_angle = getDoubleParam("--min_tilt_angle"); angular_distance_bool = checkParam("--angular_distance"); angular_distance=0.; if(angular_distance_bool) { FnexperimentalImages = getParam("--experimental_images"); angular_distance = getDoubleParam("--angular_distance"); } compute_closer_sampling_point_bool= checkParam("--closer_sampling_points"); if(compute_closer_sampling_point_bool) FnexperimentalImages = getParam("--experimental_images"); if (STR_EQUAL(getParam("--method"), "real_space")) projType = REALSPACE; if (STR_EQUAL(getParam("--method"), "shears")) projType = SHEARS; if (STR_EQUAL(getParam("--method"), "fourier")) { projType = FOURIER; paddFactor = getDoubleParam("--method", 1); maxFrequency = getDoubleParam("--method", 2); String degree = getParam("--method", 3); if (degree == "nearest") BSplineDeg = NEAREST; else if (degree == "linear") BSplineDeg = LINEAR; else if (degree == "bspline") BSplineDeg = BSPLINE3; else REPORT_ERROR(ERR_ARG_BADCMDLINE, "The interpolation kernel can be : nearest, linear, bspline"); } //NOTE perturb in computed after the even sampling is computes // and max tilt min tilt applied perturb_projection_vector=getDoubleParam("--perturb"); compute_neighbors_bool=checkParam("--compute_neighbors"); remove_points_far_away_from_experimental_data_bool=checkParam("--near_exp_data"); if(remove_points_far_away_from_experimental_data_bool) FnexperimentalImages = getParam("--experimental_images"); fn_groups = getParam("--groups"); only_winner = checkParam("--only_winner"); }
// Read arguments ========================================================== void ProgXrayImport::readParams() { if (checkParam("--mistral")) { fnInput = getParam("--mistral"); fnFlat = "NXtomo/instrument/bright_field/data@" + fnInput; dSource = MISTRAL; } else if (checkParam("--bessy")) { fnInput = getParam("--bessy", 0); tIni = getIntParam("--bessy", 1); tEnd = getIntParam("--bessy", 2); fIni = getIntParam("--bessy", 3); fEnd = getIntParam("--bessy", 4); fnFlat = fnInput; dSource = BESSY; } else { fnInput = getParam("--input"); dSource = GENERIC; } // If --flat is passed it forces the use of this flatfield if (checkParam("--flat")) { fnFlat = getParam("--flat"); extFlat = true; } fnRoot = getParam("--oroot"); cropSizeX = getIntParam("--crop"); if ( STR_EQUAL(getParam("--crop", 1), "sizeX") ) cropSizeY = cropSizeX; else cropSizeY = getIntParam("--crop",1); thrNum = getIntParam("--thr"); String tempString = getParam("--bad_pixels"); if (tempString == "factor") BPFactor = getDoubleParam("--bad_pixels", 1); else if (tempString == "mask") fnBPMask = getParam("--bad_pixels",1); else BPFactor = -1; selfAttFix = checkParam("--correct"); logFix = (selfAttFix)? true : checkParam("--log"); }
////////////////////////////////////////////////////////////////////////////////////////////////// // // // bool CLeyboldSimPortDriver::process(USSPacket<NoOfPZD6>& USSWritePacket, int TableIndex) // // // // Description: // // Called from the listening thread to process a packet request. // // The response should resemble the behaviour of the 'real' pump controller. // // // // Parameters: // // USSWritePacket - this is the packet that will be returned as output. // // // ////////////////////////////////////////////////////////////////////////////////////////////////// void CLeyboldSimPortDriver::process(USSPacket<NoOfPZD6>& USSWritePacket, int TableIndex) { epicsInt32 IBuf; epicsFloat64 DBuf; // Converter temperature - actual value. This is equivalent to parameter 11. IBuf = getIntegerParam(TableIndex, CONVERTERTEMPERATURE); USSWritePacket.m_USSPacketStruct.m_PZD[2] = IBuf; // Motor current - actual value. This is equivalent to parameter 5. DBuf = getDoubleParam(TableIndex, MOTORCURRENT); USSWritePacket.m_USSPacketStruct.m_PZD[3] = epicsUInt32(10.0 * DBuf + 0.5); // Motor temperature - actual value. This is equivalent to parameter 7. IBuf = getIntegerParam(TableIndex, PUMPTEMPERATURE); USSWritePacket.m_USSPacketStruct.m_PZD[4] = IBuf; // Intermediate circuit voltage Uzk. This is equivalent to parameter 4. DBuf = getDoubleParam(TableIndex, CIRCUITVOLTAGE); USSWritePacket.m_USSPacketStruct.m_PZD[5] = epicsUInt32(10.0 * DBuf + 0.5); }
/** * Redefine the origins of the hexapod coordinate-systems */ int HXPController::setCS(HXPAxis *pAxis) { int status = 0; int cs; // 0=None,1=Work,2=Tool,3=Base double x, y, z, u, v, w; getIntegerParam(0, HXPCoordSysToSet_, &cs); getDoubleParam(0, HXPCoordSysSetX_, &x); getDoubleParam(0, HXPCoordSysSetY_, &y); getDoubleParam(0, HXPCoordSysSetZ_, &z); getDoubleParam(0, HXPCoordSysSetU_, &u); getDoubleParam(0, HXPCoordSysSetV_, &v); getDoubleParam(0, HXPCoordSysSetW_, &w); if (cs == 1) { status = HXPHexapodCoordinateSystemSet(pAxis->moveSocket_, GROUP, "Work", x, y, z, u, v, w); } else if (cs == 2) { status = HXPHexapodCoordinateSystemSet(pAxis->moveSocket_, GROUP, "Tool", x, y, z, u, v, w); } else if (cs == 3) { status = HXPHexapodCoordinateSystemSet(pAxis->moveSocket_, GROUP, "Base", x, y, z, u, v, w); } postError(pAxis, status); return status; }
void BISDetector::setShutter(int open) { ADShutterMode_t shutterMode; int itemp; double delay; double shutterOpenDelay, shutterCloseDelay; getIntegerParam(ADShutterMode, &itemp); shutterMode = (ADShutterMode_t)itemp; getDoubleParam(ADShutterOpenDelay, &shutterOpenDelay); getDoubleParam(ADShutterCloseDelay, &shutterCloseDelay); switch (shutterMode) { case ADShutterModeDetector: if (open) { /* Open the shutter */ epicsSnprintf(this->toBIS, sizeof(this->toBIS), "[Shutter /Status=1]"); writeBIS(2.0); /* This delay is to get the exposure time correct. * It is equal to the opening time of the shutter minus the * closing time. If they are equal then no delay is needed, * except use 1msec so delay is not negative and commands are * not back-to-back */ delay = shutterOpenDelay - shutterCloseDelay; if (delay < .001) delay=.001; epicsThreadSleep(delay); } else { /* Close shutter */ epicsSnprintf(this->toBIS, sizeof(this->toBIS), "[Shutter /Status=0]"); writeBIS(2.0); epicsThreadSleep(shutterCloseDelay); } callParamCallbacks(); break; default: ADDriver::setShutter(open); break; } }
void motorSimController::report(FILE *fp, int level) { int axis; motorSimAxis *pAxis; fprintf(fp, "Simulation motor driver %s, numAxes=%d\n", this->portName, numAxes_); for (axis=0; axis<numAxes_; axis++) { pAxis = getAxis(axis); fprintf(fp, " axis %d\n", pAxis->axisNo_); if (level > 0) { double lowSoftLimit=0.0; double hiSoftLimit=0.0; fprintf(fp, " Current position = %f, velocity = %f at current time: %f\n", pAxis->nextpoint_.axis[0].p, pAxis->nextpoint_.axis[0].v, pAxis->nextpoint_.T); fprintf(fp, " Destination posn = %f, velocity = %f at desination time: %f\n", pAxis->endpoint_.axis[0].p, pAxis->endpoint_.axis[0].v, pAxis->endpoint_.T); fprintf(fp, " Hard limits: %f, %f\n", pAxis->lowHardLimit_, pAxis->hiHardLimit_); fprintf(fp, " Home: %f\n", pAxis->home_); fprintf(fp, " Enc. offset: %f\n", pAxis->enc_offset_); getDoubleParam(pAxis->axisNo_, motorHighLimit_, &hiSoftLimit); getDoubleParam(pAxis->axisNo_, motorLowLimit_, &lowSoftLimit); fprintf(fp, " Soft limits: %f, %f\n", lowSoftLimit, hiSoftLimit ); if (pAxis->homing_) fprintf(fp, " Currently homing axis\n" ); } } // Call the base class method asynMotorController::report(fp, level); }
void mar345::setShutter(int open) { ADShutterMode_t shutterMode; int itemp; double delay; double shutterOpenDelay, shutterCloseDelay; getIntegerParam(ADShutterMode, &itemp); shutterMode = (ADShutterMode_t)itemp; getDoubleParam(ADShutterOpenDelay, &shutterOpenDelay); getDoubleParam(ADShutterCloseDelay, &shutterCloseDelay); switch (shutterMode) { case ADShutterModeDetector: if (open) { /* Open the shutter */ writeServer("COMMAND SHUTTER OPEN"); /* This delay is to get the exposure time correct. * It is equal to the opening time of the shutter minus the * closing time. If they are equal then no delay is needed, * except use 1msec so delay is not negative and commands are * not back-to-back */ delay = shutterOpenDelay - shutterCloseDelay; if (delay < .001) delay=.001; epicsThreadSleep(delay); } else { /* Close shutter */ writeServer("COMMAND SHUTTER CLOSE"); epicsThreadSleep(shutterCloseDelay); } /* The mar345 does not provide a way to read the actual shutter status, so * set it to agree with the control value */ setIntegerParam(ADShutterStatus, open); callParamCallbacks(); break; default: ADDriver::setShutter(open); break; } }
/** Simulation task that runs as a separate thread. When the P_Run parameter is set to 1 * to rub the simulation it computes a 1 kHz sine wave with 1V amplitude and user-controllable * noise, and displays it on * a simulated scope. It computes waveforms for the X (time) and Y (volt) axes, and computes * statistics about the waveform. */ void testAsynPortDriver::simTask(void) { /* This thread computes the waveform and does callbacks with it */ double timePerDiv, voltsPerDiv, voltOffset, triggerDelay, noiseAmplitude; double updateTime, minValue, maxValue, meanValue; double time, timeStep; double noise, yScale; int run, i, maxPoints; double pi=4.0*atan(1.0); lock(); /* Loop forever */ while (1) { getDoubleParam(P_UpdateTime, &updateTime); getIntegerParam(P_Run, &run); // Release the lock while we wait for a command to start or wait for updateTime unlock(); if (run) epicsEventWaitWithTimeout(eventId_, updateTime); else (void) epicsEventWait(eventId_); // Take the lock again lock(); /* run could have changed while we were waiting */ getIntegerParam(P_Run, &run); if (!run) continue; getIntegerParam(P_MaxPoints, &maxPoints); getDoubleParam (P_TimePerDiv, &timePerDiv); getDoubleParam (P_VoltsPerDiv, &voltsPerDiv); getDoubleParam (P_VoltOffset, &voltOffset); getDoubleParam (P_TriggerDelay, &triggerDelay); getDoubleParam (P_NoiseAmplitude, &noiseAmplitude); time = triggerDelay; timeStep = timePerDiv * NUM_DIVISIONS / maxPoints; minValue = 1e6; maxValue = -1e6; meanValue = 0.; yScale = 1.0 / voltsPerDiv; for (i=0; i<maxPoints; i++) { noise = noiseAmplitude * (rand()/(double)RAND_MAX - 0.5); pData_[i] = AMPLITUDE * (sin(time*FREQUENCY*2*pi)) + noise; /* Compute statistics before doing the yOffset and yScale */ if (pData_[i] < minValue) minValue = pData_[i]; if (pData_[i] > maxValue) maxValue = pData_[i]; meanValue += pData_[i]; pData_[i] = NUM_DIVISIONS/2 + yScale * (voltOffset + pData_[i]); time += timeStep; } updateTimeStamp(); meanValue = meanValue/maxPoints; setDoubleParam(P_MinValue, minValue); setDoubleParam(P_MaxValue, maxValue); setDoubleParam(P_MeanValue, meanValue); callParamCallbacks(); doCallbacksFloat64Array(pData_, maxPoints, P_Waveform, 0); } }
int main(int argc, char *argv[]) { setCommandLineParameters(argc, argv); getVectorParam("-box", &box_x, &box_y, &box_z); getDoubleParam("-verlet_cutoff", &verlet_cutoff); getDoubleParam("-resolution", &resolution); getDoubleParam("-diameter", &diameter); diameter_sq = diameter * diameter; if (getFlagParam("-usage")) { printf("\nusage:\t-box [ 6.0 6.0 6.0 ]\n"); printf("\t\t-verlet_cutoff [ 25.0 ]\n"); printf("\t\t-resolution [ 0.01 ]\n"); printf("\t\t-diameter [ 1.0 ]\n"); printf("\n"); exit(0); } readConfiguration(); // loop over set of rattlers for (rattler = 0; rattler < number_of_rattlers; rattler++) { int i, j, k; // clear recursion_matrix for (i=0; i<256; i++) for (j=0; j<256; j++) for (k=0; k<256; k++) recursion_matrix[i][j][k] = 0; // start recursion with rattler 0 test_x = x[rattler]; test_y = y[rattler]; test_z = z[rattler]; makeVerletList(); visit(128, 128, 128); } return 0; }
/** Callback task that runs as a separate thread. */ void testErrors::callbackTask(void) { asynStatus currentStatus; int itemp; epicsInt32 iVal; epicsFloat64 dVal; int i; char octetValue[20]; /* Loop forever */ while (1) { lock(); getIntegerParam(P_StatusReturn, &itemp); currentStatus = (asynStatus)itemp; getIntegerParam(P_Int32Value, &iVal); iVal++; if (iVal > 15) iVal=0; setIntegerParam(P_Int32Value, iVal); setParamStatus(P_Int32Value, currentStatus); getDoubleParam(P_Float64Value, &dVal); dVal += 0.1; setDoubleParam(P_Float64Value, dVal); setParamStatus(P_Float64Value, currentStatus); sprintf(octetValue, "%.1f", dVal); setParamStatus(P_UInt32DigitalValue, currentStatus); setStringParam(P_OctetValue, octetValue); setParamStatus(P_OctetValue, currentStatus); setParamStatus(P_Float64ArrayValue, currentStatus); for (i=0; i<MAX_ARRAY_POINTS; i++) { int8ArrayValue_[i] = iVal; int16ArrayValue_[i] = iVal; int32ArrayValue_[i] = iVal; float32ArrayValue_[i] = (epicsFloat32)dVal; float64ArrayValue_[i] = dVal; } callParamCallbacks(); setParamStatus(P_Int8ArrayValue, currentStatus); doCallbacksInt8Array(int8ArrayValue_, MAX_ARRAY_POINTS, P_Int8ArrayValue, 0); setParamStatus(P_Int16ArrayValue, currentStatus); doCallbacksInt16Array(int16ArrayValue_, MAX_ARRAY_POINTS, P_Int16ArrayValue, 0); setParamStatus(P_Int32ArrayValue, currentStatus); doCallbacksInt32Array(int32ArrayValue_, MAX_ARRAY_POINTS, P_Int32ArrayValue, 0); setParamStatus(P_Float32ArrayValue, currentStatus); doCallbacksFloat32Array(float32ArrayValue_, MAX_ARRAY_POINTS, P_Float32ArrayValue, 0); setParamStatus(P_Float64ArrayValue, currentStatus); doCallbacksFloat64Array(float64ArrayValue_, MAX_ARRAY_POINTS, P_Float64ArrayValue, 0); unlock(); epicsThreadSleep(CALLBACK_PERIOD); } }
/** Set the shutter position. * This method will open (1) or close (0) the shutter if * ADShutterMode==ADShutterModeEPICS. Drivers will implement setShutter if they * support ADShutterModeDetector. If ADShutterMode=ADShutterModeDetector they will * control the shutter directly, else they will call this method. * \param[in] open 1 (open) or 0 (closed) */ void ADDriver::setShutter(int open) { ADShutterMode_t shutterMode; int itemp; double delay; double shutterOpenDelay, shutterCloseDelay; getIntegerParam(ADShutterMode, &itemp); shutterMode = (ADShutterMode_t)itemp; getDoubleParam(ADShutterOpenDelay, &shutterOpenDelay); getDoubleParam(ADShutterCloseDelay, &shutterCloseDelay); switch (shutterMode) { case ADShutterModeNone: break; case ADShutterModeEPICS: setIntegerParam(ADShutterControlEPICS, open); callParamCallbacks(); delay = shutterOpenDelay - shutterCloseDelay; epicsThreadSleep(delay); break; case ADShutterModeDetector: break; } }