本文整理汇总了C++中DEBUGF函数的典型用法代码示例。如果您正苦于以下问题:C++ DEBUGF函数的具体用法?C++ DEBUGF怎么用?C++ DEBUGF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DEBUGF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: supported
/* Reserve space in the buffer for a file.
filename: name of the file to open
offset: offset at which to start buffering the file, useful when the first
(offset-1) bytes of the file aren't needed.
type: one of the data types supported (audio, image, cuesheet, others
user_data: user data passed possibly passed in subcalls specific to a
data_type (only used for image (albumart) buffering so far )
return value: <0 if the file cannot be opened, or one file already
queued to be opened, otherwise the handle for the file in the buffer
*/
int bufopen(const char *file, size_t offset, enum data_type type,
void *user_data)
{
#ifndef HAVE_ALBUMART
/* currently only used for aa loading */
(void)user_data;
#endif
if (type == TYPE_ID3)
{
/* ID3 case: allocate space, init the handle and return. */
struct memory_handle *h = add_handle(sizeof(struct mp3entry), false, true);
if (!h)
return ERR_BUFFER_FULL;
h->fd = -1;
h->filesize = sizeof(struct mp3entry);
h->filerem = sizeof(struct mp3entry);
h->offset = 0;
h->data = buf_widx;
h->ridx = buf_widx;
h->widx = buf_widx;
h->available = 0;
h->type = type;
strlcpy(h->path, file, MAX_PATH);
buf_widx += sizeof(struct mp3entry); /* safe because the handle
can't wrap */
/* Inform the buffering thread that we added a handle */
LOGFQUEUE("buffering > Q_HANDLE_ADDED %d", h->id);
queue_post(&buffering_queue, Q_HANDLE_ADDED, h->id);
return h->id;
}
/* Other cases: there is a little more work. */
int fd = open(file, O_RDONLY);
if (fd < 0)
return ERR_FILE_ERROR;
size_t size = filesize(fd);
bool can_wrap = type==TYPE_PACKET_AUDIO || type==TYPE_CODEC;
size_t adjusted_offset = offset;
if (adjusted_offset > size)
adjusted_offset = 0;
/* Reserve extra space because alignment can move data forward */
size_t padded_size = STORAGE_PAD(size-adjusted_offset);
struct memory_handle *h = add_handle(padded_size, can_wrap, false);
if (!h)
{
DEBUGF("%s(): failed to add handle\n", __func__);
close(fd);
return ERR_BUFFER_FULL;
}
strlcpy(h->path, file, MAX_PATH);
h->offset = adjusted_offset;
/* Don't bother to storage align bitmaps because they are not
* loaded directly into the buffer.
*/
if (type != TYPE_BITMAP)
{
size_t alignment_pad;
/* Remember where data area starts, for use by reset_handle */
h->start = buf_widx;
/* Align to desired storage alignment */
alignment_pad = STORAGE_OVERLAP(adjusted_offset - (size_t)(&buffer[buf_widx]));
buf_widx = ringbuf_add(buf_widx, alignment_pad);
}
h->ridx = buf_widx;
h->widx = buf_widx;
h->data = buf_widx;
h->available = 0;
h->filerem = 0;
h->type = type;
#ifdef HAVE_ALBUMART
if (type == TYPE_BITMAP)
{
/* Bitmap file: we load the data instead of the file */
int rc;
mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields */
//.........这里部分代码省略.........
示例2: DEBUG
bool QHYCCD::StartExposure(float duration)
{
int ret = QHYCCD_ERROR;
if (streamer->isBusy())
{
DEBUG(INDI::Logger::DBG_ERROR, "Cannot take exposure while streaming/recording is active.");
return false;
}
//AbortPrimaryFrame = false;
if (duration < MINIMUM_CCD_EXPOSURE)
{
DEBUGF(INDI::Logger::DBG_WARNING, "Exposure shorter than minimum duration %g s requested. Setting exposure time to %g s.", duration, MINIMUM_CCD_EXPOSURE);
duration = MINIMUM_CCD_EXPOSURE;
}
imageFrameType = PrimaryCCD.getFrameType();
if (imageFrameType == CCDChip::BIAS_FRAME)
{
duration = MINIMUM_CCD_EXPOSURE;
DEBUGF(INDI::Logger::DBG_SESSION, "Bias Frame (s) : %g", duration);
}
else if(imageFrameType == CCDChip::DARK_FRAME)
{
ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_CLOSE);
}
else
{
ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_FREE);
}
DEBUGF(INDI::Logger::DBG_DEBUG, "Current exposure time is %f us",duration * 1000 * 1000);
ExposureRequest = duration;
PrimaryCCD.setExposureDuration(duration);
if (sim)
ret = QHYCCD_SUCCESS;
else
ret = SetQHYCCDParam(camhandle,CONTROL_EXPOSURE,ExposureRequest * 1000 * 1000);
if(ret != QHYCCD_SUCCESS)
{
DEBUGF(INDI::Logger::DBG_ERROR, "Set expose time failed (%d).", ret);
return false;
}
// lzr: we need to call the following apis every single exposure,the usleep(200000) is important
if (sim)
ret = QHYCCD_SUCCESS;
else
ret = SetQHYCCDBinMode(camhandle,camxbin,camybin);
if(ret != QHYCCD_SUCCESS)
{
DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD Bin mode failed (%d)", ret);
return false;
}
DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDBinMode %dx%d", camxbin, camybin);
if (sim)
ret = QHYCCD_SUCCESS;
else
ret = SetQHYCCDResolution(camhandle,camroix,camroiy,camroiwidth,camroiheight);
if(ret != QHYCCD_SUCCESS)
{
DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD ROI resolution failed (%d)", ret);
return false;
}
DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDResolution camroix %d camroiy %d camroiwidth %d camroiheight %d", camroix,camroiy,camroiwidth,camroiheight);
// Jasem: Removed QHY 300ms delay that was added without specifying the reason. It seems any delay less than 100ms results in QHY Frame error. Again no reason. This renders
// exposures less than 100ms useless, but there is nothing I can do about that.
usleep(100000);
if (sim)
ret = QHYCCD_SUCCESS;
else
ret = ExpQHYCCDSingleFrame(camhandle);
if(ret != QHYCCD_SUCCESS)
{
DEBUGF(INDI::Logger::DBG_SESSION, "Begin QHYCCD expose failed (%d)", ret);
return false;
}
gettimeofday(&ExpStart, NULL);
DEBUGF(INDI::Logger::DBG_DEBUG, "Taking a %g seconds frame...", ExposureRequest);
InExposure = true;
// if (ExposureRequest*1000 < POLLMS)
// SetTimer(ExposureRequest*1000);
// else
SetTimer(POLLMS);
return true;
}
示例3: search_files
int
search_files(const char *path, const char *expr, TranslationFlags flags, const SearchOptions *opts, Callback found_file, Callback err_message, void *user_data)
{
int ret = -1;
assert(path != NULL);
assert(expr != NULL);
assert(opts != NULL);
int outfds[2];
int errfds[2];
memset(outfds, 0, sizeof(outfds));
memset(errfds, 0, sizeof(errfds));
TRACE("search", "Creating pipes.");
if(pipe2(outfds, 0) >= 0 && pipe2(errfds, 0) >= 0)
{
char **argv = NULL;
size_t argc = 0;
ParserResult *result;
TRACE("search", "Pipes created successfully, translating expression.");
result = _search_translate_expr(path, expr, flags, opts, &argc, &argv);
assert(result != NULL);
if(result->success)
{
DEBUG("search", "Expression parsed successfully, forking and running `find'.");
pid_t pid = fork();
if(pid == -1)
{
FATALF("search", "`fork' failed with result %ld.", pid);
perror("fork()");
}
else if(pid == 0)
{
if(_search_close_and_dup_child_fds(outfds, errfds))
{
_search_child_process(argv);
}
else
{
ERROR("search", "Couldn't initialize child's file descriptors.");
}
}
else
{
if(_search_close_parent_fds(outfds, errfds))
{
ParentCtx ctx;
memset(&ctx, 0, sizeof(ParentCtx));
ctx.child_pid = pid;
ctx.outfd = outfds[0];
ctx.errfd = errfds[0];
ctx.found_file = found_file;
ctx.err_message = err_message;
ctx.user_data = user_data;
_search_filter_args_init(&ctx.filter_args, result);
ret = _search_parent_process(&ctx);
_search_filter_args_free(&ctx.filter_args);
}
else
{
WARNING("search", "Couldn't close parent's file descriptors.");
}
}
}
else if(result->err)
{
TRACEF("search", "Couldn't parse expression: %s", result->err);
}
else
{
TRACE("search", "Couldn't parse expression, no error message set.");
}
DEBUGF("search", "Search finished with result %d.", ret);
if(argv)
{
for(size_t i = 0; i < argc; i++)
{
free(argv[i]);
}
free(argv);
}
parser_result_free(result);
//.........这里部分代码省略.........
示例4: processFilterSlot
bool QHYCCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
// first check if it's for our device
//IDLog("INDI::CCD::ISNewNumber %s\n",name);
if(strcmp(dev,getDeviceName())==0)
{
if (strcmp(name,FilterSlotNP.name)==0)
{
processFilterSlot(getDeviceName(), values, names);
return true;
}
if(strcmp(name,GainNP.name) == 0)
{
IUUpdateNumber(&GainNP, values, names, n);
SetQHYCCDParam(camhandle,CONTROL_GAIN,GainN[0].value);
DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",GainNP.name,GainN[0].value);
GainNP.s = IPS_OK;
IDSetNumber(&GainNP, NULL);
//saveConfig();
return true;
}
if(strcmp(name,OffsetNP.name) == 0)
{
IUUpdateNumber(&OffsetNP, values, names, n);
SetQHYCCDParam(camhandle,CONTROL_OFFSET,OffsetN[0].value);
DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",OffsetNP.name,OffsetN[0].value);
OffsetNP.s = IPS_OK;
IDSetNumber(&OffsetNP, NULL);
saveConfig();
return true;
}
if(strcmp(name,SpeedNP.name) == 0)
{
IUUpdateNumber(&SpeedNP, values, names, n);
SetQHYCCDParam(camhandle,CONTROL_SPEED,SpeedN[0].value);
DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",SpeedNP.name,SpeedN[0].value);
SpeedNP.s = IPS_OK;
IDSetNumber(&SpeedNP, NULL);
saveConfig();
return true;
}
if(strcmp(name,USBTrafficNP.name) == 0)
{
IUUpdateNumber(&USBTrafficNP, values, names, n);
SetQHYCCDParam(camhandle,CONTROL_USBTRAFFIC,USBTrafficN[0].value);
DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",USBTrafficNP.name,USBTrafficN[0].value);
USBTrafficNP.s = IPS_OK;
IDSetNumber(&USBTrafficNP, NULL);
saveConfig();
return true;
}
}
// if we didn't process it, continue up the chain, let somebody else
// give it a shot
return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
示例5: defineSwitch
bool QHYCCD::updateProperties()
{
INDI::CCD::updateProperties();
double min,max,step;
if (isConnected())
{
if (HasCooler())
{
defineSwitch(&CoolerSP);
defineNumber(&CoolerNP);
temperatureID = IEAddTimer(POLLMS, QHYCCD::updateTemperatureHelper, this);
}
if(HasUSBSpeed)
{
if (sim)
{
SpeedN[0].min = 1;
SpeedN[0].max = 5;
SpeedN[0].step = 1;
SpeedN[0].value = 1;
}
else
{
int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_SPEED,&min,&max,&step);
if(ret == QHYCCD_SUCCESS)
{
SpeedN[0].min = min;
SpeedN[0].max = max;
SpeedN[0].step = step;
}
SpeedN[0].value = GetQHYCCDParam(camhandle,CONTROL_SPEED);
DEBUGF(INDI::Logger::DBG_DEBUG, "USB Speed. Value: %g Min: %g Max: %g Step %g", SpeedN[0].value, SpeedN[0].min, SpeedN[0].max, SpeedN[0].step);
}
defineNumber(&SpeedNP);
}
if(HasGain)
{
if (sim)
{
GainN[0].min = 0;
GainN[0].max = 100;
GainN[0].step = 10;
GainN[0].value = 50;
}
else
{
int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_GAIN,&min,&max,&step);
if(ret == QHYCCD_SUCCESS)
{
GainN[0].min = min;
GainN[0].max = max;
GainN[0].step = step;
}
GainN[0].value = GetQHYCCDParam(camhandle,CONTROL_GAIN);
DEBUGF(INDI::Logger::DBG_DEBUG, "Gain. Value: %g Min: %g Max: %g Step %g", GainN[0].value, GainN[0].min, GainN[0].max, GainN[0].step);
}
defineNumber(&GainNP);
}
if(HasOffset)
{
if (sim)
{
OffsetN[0].min = 1;
OffsetN[0].max = 10;
OffsetN[0].step = 1;
OffsetN[0].value = 1;
}
else
{
int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_OFFSET,&min,&max,&step);
if(ret == QHYCCD_SUCCESS)
{
OffsetN[0].min = min;
OffsetN[0].max = max;
OffsetN[0].step = step;
}
OffsetN[0].value = GetQHYCCDParam(camhandle,CONTROL_OFFSET);
DEBUGF(INDI::Logger::DBG_DEBUG, "Offset. Value: %g Min: %g Max: %g Step %g", OffsetN[0].value, OffsetN[0].min, OffsetN[0].max, OffsetN[0].step);
}
//Define the Offset
defineNumber(&OffsetNP);
}
if(HasFilters)
{
//Define the Filter Slot and name properties
defineNumber(&FilterSlotNP);
//.........这里部分代码省略.........
示例6: set_pinfo
static
void set_pinfo (
lame_global_flags *gfp,
gr_info * const cod_info,
const III_psy_ratio * const ratio,
const III_scalefac_t * const scalefac,
const int gr,
const int ch )
{
lame_internal_flags *gfc=gfp->internal_flags;
int sfb;
int j,i,l,start,end,bw;
FLOAT8 en0,en1;
FLOAT ifqstep = ( cod_info->scalefac_scale == 0 ) ? .5 : 1.0;
III_psy_xmin l3_xmin;
calc_noise_result noise;
III_psy_xmin xfsf;
calc_xmin (gfp, ratio, cod_info, &l3_xmin);
calc_noise (gfc, cod_info->l3_enc, cod_info,
&l3_xmin, scalefac, &xfsf, &noise);
if (cod_info->block_type == SHORT_TYPE) {
for (j=0, sfb = 0; sfb < SBMAX_s; sfb++ ) {
start = gfc->scalefac_band.s[ sfb ];
end = gfc->scalefac_band.s[ sfb + 1 ];
bw = end - start;
for ( i = 0; i < 3; i++ ) {
for ( en0 = 0.0, l = start; l < end; l++ ) {
en0 += cod_info->xr[j] * cod_info->xr[j];
++j;
}
en0=Max(en0/bw,1e-20);
#if 0
{
double tot1,tot2;
if (sfb<SBMAX_s-1) {
if (sfb==0) {
tot1=0;
tot2=0;
}
tot1 += en0;
tot2 += ratio->en.s[sfb][i];
DEBUGF("%i %i sfb=%i mdct=%f fft=%f fft-mdct=%f db \n",
gr,ch,sfb,
10*log10(Max(1e-25,ratio->en.s[sfb][i])),
10*log10(Max(1e-25,en0)),
10*log10((Max(1e-25,en0)/Max(1e-25,ratio->en.s[sfb][i]))));
if (sfb==SBMAX_s-2) {
DEBUGF("%i %i toti %f %f ratio=%f db \n",gr,ch,
10*log10(Max(1e-25,tot2)),
10*log(Max(1e-25,tot1)),
10*log10(Max(1e-25,tot1)/(Max(1e-25,tot2))));
}
}
/*
masking: multiplied by en0/fft_energy
average seems to be about -135db.
*/
}
#endif
/* convert to MDCT units */
en1=1e15; /* scaling so it shows up on FFT plot */
gfc->pinfo->xfsf_s[gr][ch][3*sfb+i]
= en1*xfsf.s[sfb][i]*l3_xmin.s[sfb][i]/bw;
gfc->pinfo->en_s[gr][ch][3*sfb+i] = en1*en0;
if (ratio->en.s[sfb][i]>0)
en0 = en0/ratio->en.s[sfb][i];
else
en0=0;
if (gfp->ATHonly || gfp->ATHshort)
en0=0;
gfc->pinfo->thr_s[gr][ch][3*sfb+i] =
en1*Max(en0*ratio->thm.s[sfb][i],gfc->ATH->s[sfb]);
/* there is no scalefactor bands >= SBPSY_s */
if (sfb < SBPSY_s) {
gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i]=
-ifqstep*scalefac->s[sfb][i];
} else {
gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i]=0;
}
gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i] -=
2*cod_info->subblock_gain[i];
}
}
} else {
for ( sfb = 0; sfb < SBMAX_l; sfb++ ) {
//.........这里部分代码省略.........
示例7: CalcTimeLeft
void FishCampCCD::TimerHit()
{
int timerHitID = -1, state = -1, rc = -1;
long timeleft;
double ccdTemp;
if (isConnected() == false)
return; // No need to reset timer if we are not connected anymore
if (InExposure)
{
timeleft = CalcTimeLeft();
if (timeleft < 1.0)
{
if (timeleft > 0.25)
{
// a quarter of a second or more
// just set a tighter timer
timerHitID = SetTimer(250);
}
else
{
if (timeleft > 0.07)
{
// use an even tighter timer
timerHitID = SetTimer(50);
}
else
{
// it's real close now, so spin on it
while (!sim && timeleft > 0)
{
state = fcUsb_cmd_getState(cameraNum);
if (state == 0)
timeleft = 0;
int slv;
slv = 100000 * timeleft;
usleep(slv);
}
/* We're done exposing */
DEBUG(INDI::Logger::DBG_DEBUG, "Exposure done, downloading image...");
PrimaryCCD.setExposureLeft(0);
InExposure = false;
/* grab and save image */
grabImage();
}
}
}
else
{
DEBUGF(INDI::Logger::DBG_DEBUG, "Image not yet ready. With time left %ld\n", timeleft);
}
PrimaryCCD.setExposureLeft(timeleft);
}
switch (TemperatureNP.s)
{
case IPS_IDLE:
case IPS_OK:
rc = fcUsb_cmd_getTemperature(cameraNum);
DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc);
ccdTemp = rc / 100.0;
DEBUGF(INDI::Logger::DBG_DEBUG, "Temperature %g", ccdTemp);
if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD)
{
TemperatureN[0].value = ccdTemp;
IDSetNumber(&TemperatureNP, NULL);
}
break;
case IPS_BUSY:
if (sim)
{
TemperatureN[0].value = TemperatureRequest;
}
else
{
rc = fcUsb_cmd_getTemperature(cameraNum);
DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc);
TemperatureN[0].value = rc / 100.0;
}
// If we're within threshold, let's make it BUSY ---> OK
if (fabs(TemperatureRequest - TemperatureN[0].value) <= TEMP_THRESHOLD)
TemperatureNP.s = IPS_OK;
IDSetNumber(&TemperatureNP, NULL);
break;
//.........这里部分代码省略.........
示例8: catch
bool QSICCD::setupParams()
{
string name, model;
double temperature;
double pixel_size_x, pixel_size_y;
long sub_frame_x, sub_frame_y;
try
{
QSICam.get_Name(name);
QSICam.get_ModelNumber(model);
QSICam.get_PixelSizeX(&pixel_size_x);
QSICam.get_PixelSizeY(&pixel_size_y);
QSICam.get_NumX(&sub_frame_x);
QSICam.get_NumY(&sub_frame_y);
QSICam.get_CCDTemperature(&temperature);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "Setup Params failed. %s.", err.what());
return false;
}
DEBUGF(INDI::Logger::DBG_SESSION, "The CCD Temperature is %f.", temperature);
TemperatureN[0].value = temperature; /* CCD chip temperatre (degrees C) */
IDSetNumber(&TemperatureNP, nullptr);
SetCCDParams(sub_frame_x, sub_frame_y, 16, pixel_size_x, pixel_size_y);
imageWidth = PrimaryCCD.getSubW();
imageHeight = PrimaryCCD.getSubH();
int nbuf;
nbuf = PrimaryCCD.getXRes() * PrimaryCCD.getYRes() * PrimaryCCD.getBPP() / 8; // this is pixel count
nbuf += 512; // leave a little extra at the end
PrimaryCCD.setFrameBufferSize(nbuf);
try
{
QSICam.get_Name(name);
}
catch (std::runtime_error &err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "get_Name() failed. %s.", err.what());
return false;
}
DEBUGF(INDI::Logger::DBG_SESSION, "%s", name.c_str());
try
{
QSICam.get_FilterCount(filterCount);
DEBUGF(INDI::Logger::DBG_SESSION, "The filter count is %d", filterCount);
FilterSlotN[0].min = 1;
FilterSlotN[0].max = filterCount;
FilterSlotNP.s = IPS_OK;
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_SESSION, "get_FilterCount() failed. %s.", err.what());
return false;
}
// Only generate filter names if there are none initially
//if (FilterNameT == nullptr)
//GetFilterNames(FILTER_TAB);
double minDuration = 0;
try
{
QSICam.get_MinExposureTime(&minDuration);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "get_MinExposureTime() failed. %s.", err.what());
return false;
}
PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", minDuration, 3600, 1, true);
bool coolerOn = false;
try
{
QSICam.get_CoolerOn(&coolerOn);
}
catch (std::runtime_error err)
{
CoolerSP.s = IPS_IDLE;
CoolerS[0].s = ISS_OFF;
CoolerS[1].s = ISS_ON;
DEBUGF(INDI::Logger::DBG_ERROR, "Error: CoolerOn() failed. %s.", err.what());
IDSetSwitch(&CoolerSP, nullptr);
return false;
}
CoolerS[0].s = coolerOn ? ISS_ON : ISS_OFF;
CoolerS[1].s = coolerOn ? ISS_OFF : ISS_ON;
CoolerSP.s = IPS_OK;
//.........这里部分代码省略.........
示例9: CalcTimeLeft
void QSICCD::TimerHit()
{
long timeleft = 0;
double ccdTemp = 0;
double coolerPower = 0;
if (isConnected() == false)
return; // No need to reset timer if we are not connected anymore
if (InExposure)
{
bool imageReady;
timeleft = CalcTimeLeft(ExpStart, ExposureRequest);
if (timeleft < 1)
{
QSICam.get_ImageReady(&imageReady);
while (!imageReady)
{
usleep(100);
QSICam.get_ImageReady(&imageReady);
}
/* We're done exposing */
DEBUG(INDI::Logger::DBG_SESSION, "Exposure done, downloading image...");
PrimaryCCD.setExposureLeft(0);
InExposure = false;
/* grab and save image */
grabImage();
}
else
{
DEBUGF(INDI::Logger::DBG_DEBUG, "Image not ready, time left %ld\n", timeleft);
PrimaryCCD.setExposureLeft(timeleft);
}
}
switch (TemperatureNP.s)
{
case IPS_IDLE:
case IPS_OK:
try
{
QSICam.get_CCDTemperature(&ccdTemp);
}
catch (std::runtime_error err)
{
TemperatureNP.s = IPS_IDLE;
DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what());
IDSetNumber(&TemperatureNP, nullptr);
return;
}
if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD)
{
TemperatureN[0].value = ccdTemp;
IDSetNumber(&TemperatureNP, nullptr);
}
break;
case IPS_BUSY:
try
{
QSICam.get_CCDTemperature(&TemperatureN[0].value);
}
catch (std::runtime_error err)
{
TemperatureNP.s = IPS_ALERT;
DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what());
IDSetNumber(&TemperatureNP, nullptr);
return;
}
if (fabs(TemperatureN[0].value - targetTemperature) <= TEMP_THRESHOLD)
TemperatureNP.s = IPS_OK;
IDSetNumber(&TemperatureNP, nullptr);
break;
case IPS_ALERT:
break;
}
switch (CoolerNP.s)
{
case IPS_IDLE:
case IPS_OK:
try
{
QSICam.get_CoolerPower(&coolerPower);
}
catch (std::runtime_error err)
{
CoolerNP.s = IPS_IDLE;
DEBUGF(INDI::Logger::DBG_ERROR, "get_CoolerPower() failed. %s.", err.what());
IDSetNumber(&CoolerNP, nullptr);
return;
}
//.........这里部分代码省略.........
示例10: switch
void QSICCD::turnWheel()
{
short current_filter = 0;
switch (FilterS[0].s)
{
case ISS_ON:
try
{
current_filter = QueryFilter();
if (current_filter < filterCount)
current_filter++;
else
current_filter = 1;
SelectFilter(current_filter);
}
catch (std::runtime_error err)
{
FilterSP.s = IPS_IDLE;
FilterS[0].s = ISS_OFF;
FilterS[1].s = ISS_OFF;
DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());
return;
}
FilterSlotN[0].value = current_filter;
FilterS[0].s = ISS_OFF;
FilterS[1].s = ISS_OFF;
FilterSP.s = IPS_OK;
DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d", current_filter);
IDSetSwitch(&FilterSP, nullptr);
break;
case ISS_OFF:
try
{
current_filter = QueryFilter();
if (current_filter > 1)
current_filter--;
else
current_filter = filterCount;
SelectFilter(current_filter);
}
catch (std::runtime_error err)
{
FilterSP.s = IPS_IDLE;
FilterS[0].s = ISS_OFF;
FilterS[1].s = ISS_OFF;
DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());
return;
}
FilterSlotN[0].value = current_filter;
FilterS[0].s = ISS_OFF;
FilterS[1].s = ISS_OFF;
FilterSP.s = IPS_OK;
DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d", current_filter);
IDSetSwitch(&FilterSP, nullptr);
IDSetNumber(&FilterSlotNP, nullptr);
break;
}
}
示例11: set_debugflags
/*Set the debug flags------------------------------------------------*/
void set_debugflags(char *flags) {
debugflags = flags;
if (strchr(debugflags, '@') != NULL) alldebugflags = true;
DEBUGF('a', "Debugflags = \"%s\"\n", debugflags);
}
示例12: pbuf_alloc
/*-----------------------------------------------------------------------------------*/
struct pbuf *
pbuf_alloc(pbuf_layer l, uint16_t size, pbuf_flag flag)
{
struct pbuf *p, *q, *r;
uint16_t offset;
int32_t rsize;
offset = 0;
switch(l) {
case PBUF_TRANSPORT:
offset += PBUF_TRANSPORT_HLEN;
/* FALLTHROUGH */
case PBUF_IP:
offset += PBUF_IP_HLEN;
offset += PBUF_LINK_HLEN;
/* FALLTHROUGH */
case PBUF_LINK:
break;
case PBUF_RAW:
break;
default:
ASSERT("pbuf_alloc: bad pbuf layer", 0);
return NULL;
}
switch(flag)
{
case PBUF_POOL:
/* Allocate head of pbuf chain into p. */
p = pbuf_pool_alloc();
if(p == NULL) {
#ifdef PBUF_STATS
++stats.pbuf.err;
#endif /* PBUF_STATS */
return NULL;
}
p->next = NULL;
/* Set the payload pointer so that it points offset bytes into
pbuf data memory. */
p->payload = MEM_ALIGN((void *)((uint8_t *)p + (sizeof(struct pbuf) + offset)));
/* The total length of the pbuf is the requested size. */
p->tot_len = size;
/* Set the length of the first pbuf is the chain. */
p->len = size > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: size;
p->flags = PBUF_FLAG_POOL;
/* Allocate the tail of the pbuf chain. */
r = p;
rsize = size - p->len;
while(rsize > 0) {
q = pbuf_pool_alloc();
if(q == NULL) {
DEBUGF(PBUF_DEBUG, ("pbuf_alloc: Out of pbufs in pool,\n"));
#ifdef PBUF_STATS
++stats.pbuf.err;
#endif /* PBUF_STATS */
pbuf_pool_free(p);
return NULL;
}
q->next = NULL;
r->next = q;
q->len = rsize > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rsize;
q->flags = PBUF_FLAG_POOL;
q->payload = (void *)((uint8_t *)q + sizeof(struct pbuf));
r = q;
q->ref = 1;
q = q->next;
rsize -= PBUF_POOL_BUFSIZE;
}
r->next = NULL;
ASSERT("pbuf_alloc: pbuf->payload properly aligned",
((uint32_t)p->payload % MEM_ALIGNMENT) == 0);
break;
case PBUF_RAM:
/* If pbuf is to be allocated in RAM, allocate memory for it. */
p = (struct pbuf*)mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + size + offset));
if(p == NULL)
{ return NULL; }
/* Set up internal structure of the pbuf. */
p->payload = MEM_ALIGN((void *)((uint8_t *)p + sizeof(struct pbuf) + offset));
p->len = p->tot_len = size;
p->next = NULL;
p->flags = PBUF_FLAG_RAM;
ASSERT("pbuf_alloc: pbuf->payload properly aligned",
((uint32_t)p->payload % MEM_ALIGNMENT) == 0);
break;
case PBUF_ROM:
/* If the pbuf should point to ROM, we only need to allocate
memory for the pbuf structure. */
p = (struct pbuf*)memp_mallocp(MEMP_PBUF);
if(p == NULL) {
return NULL;
//.........这里部分代码省略.........
示例13: DEBUG
bool QSICCD::Connect()
{
bool connected;
DEBUG(INDI::Logger::DBG_SESSION, "Attempting to find QSI CCD...");
try
{
QSICam.get_Connected(&connected);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "Error: get_Connected() failed. %s.", err.what());
return false;
}
if (!connected)
{
try
{
QSICam.put_Connected(true);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "Error: put_Connected(true) failed. %s.", err.what());
return false;
}
}
bool hasST4Port = false;
try
{
QSICam.get_CanPulseGuide(&hasST4Port);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "get_canPulseGuide() failed. %s.", err.what());
return false;
}
try
{
QSICam.get_CanAbortExposure(&canAbort);
}
catch (std::runtime_error err)
{
DEBUGF(INDI::Logger::DBG_ERROR, "get_CanAbortExposure() failed. %s.", err.what());
return false;
}
uint32_t cap = CCD_CAN_BIN | CCD_CAN_SUBFRAME | CCD_HAS_COOLER | CCD_HAS_SHUTTER;
if (canAbort)
cap |= CCD_CAN_ABORT;
if (hasST4Port)
cap |= CCD_HAS_ST4_PORT;
SetCCDCapability(cap);
/* Success! */
DEBUG(INDI::Logger::DBG_SESSION, "CCD is online. Retrieving basic data.");
return true;
}
示例14: curl_global_init
/**
* curl_global_init() globally initializes cURL given a bitwise set of the
* different features of what to initialize.
*/
CURLcode curl_global_init(long flags)
{
if(initialized++)
return CURLE_OK;
/* Setup the default memory functions here (again) */
Curl_cmalloc = (curl_malloc_callback)malloc;
Curl_cfree = (curl_free_callback)free;
Curl_crealloc = (curl_realloc_callback)realloc;
Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
#if defined(WIN32) && defined(UNICODE)
Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
#endif
if(flags & CURL_GLOBAL_SSL)
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
return CURLE_FAILED_INIT;
}
if(flags & CURL_GLOBAL_WIN32)
if(win32_init() != CURLE_OK) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
return CURLE_FAILED_INIT;
}
#ifdef __AMIGA__
if(!Curl_amiga_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_amiga_init failed\n"));
return CURLE_FAILED_INIT;
}
#endif
#ifdef NETWARE
if(netware_init()) {
DEBUGF(fprintf(stderr, "Warning: LONG namespace not available\n"));
}
#endif
#ifdef USE_LIBIDN
idna_init();
#endif
if(Curl_resolver_global_init() != CURLE_OK) {
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
return CURLE_FAILED_INIT;
}
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT)
if(libssh2_init(0)) {
DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n"));
return CURLE_FAILED_INIT;
}
#endif
if(flags & CURL_GLOBAL_ACK_EINTR)
Curl_ack_eintr = 1;
init_flags = flags;
return CURLE_OK;
}
示例15: tcp_slowtmr
/*-----------------------------------------------------------------------------------*/
void
tcp_slowtmr(void)
{
static struct tcp_pcb *pcb, *pcb2, *prev;
static struct tcp_seg *seg, *useg;
static uint32_t eff_wnd;
static uint8_t pcb_remove; /* flag if a PCB should be removed */
++tcp_ticks;
/* Steps through all of the active PCBs. */
prev = NULL;
pcb = tcp_active_pcbs;
while(pcb != NULL) {
ASSERT("tcp_timer_coarse: active pcb->state != CLOSED", pcb->state != CLOSED);
ASSERT("tcp_timer_coarse: active pcb->state != LISTEN", pcb->state != LISTEN);
ASSERT("tcp_timer_coarse: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
pcb_remove = 0;
if(pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
++pcb_remove;
} else if(pcb->nrtx == TCP_MAXRTX) {
++pcb_remove;
} else {
++pcb->rtime;
seg = pcb->unacked;
if(seg != NULL && pcb->rtime >= pcb->rto) {
DEBUGF(TCP_RTO_DEBUG, ("tcp_timer_coarse: rtime %ld pcb->rto %d\n",
tcp_ticks - pcb->rtime, pcb->rto));
/* Double retransmission time-out unless we are trying to
connect to somebody (i.e., we are in SYN_SENT). */
if(pcb->state != SYN_SENT) {
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
}
/* Move all other unacked segments to the unsent queue. */
if(seg->next != NULL) {
for(useg = seg->next; useg->next != NULL; useg = useg->next);
/* useg now points to the last segment on the unacked queue. */
useg->next = pcb->unsent;
pcb->unsent = seg->next;
seg->next = NULL;
pcb->snd_nxt = ntohl(pcb->unsent->tcphdr->seqno);
}
/* Do the actual retransmission. */
tcp_rexmit_seg(pcb, seg);
/* Reduce congestion window and ssthresh. */
eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);
pcb->ssthresh = eff_wnd >> 1;
if(pcb->ssthresh < pcb->mss) {
pcb->ssthresh = pcb->mss * 2;
}
pcb->cwnd = pcb->mss;
DEBUGF(TCP_CWND_DEBUG, ("tcp_rexmit_seg: cwnd %u ssthresh %u\n",
pcb->cwnd, pcb->ssthresh));
}
}