本文整理汇总了C++中DataNode::getNext方法的典型用法代码示例。如果您正苦于以下问题:C++ DataNode::getNext方法的具体用法?C++ DataNode::getNext怎么用?C++ DataNode::getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataNode
的用法示例。
在下文中一共展示了DataNode::getNext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void DeviceConfig::load(DataNode *node) {
busy_lock.lock();
if (node->hasAnother("name")) {
deviceName = node->getNext("name")->element()->toString();
}
if (node->hasAnother("ppm")) {
DataNode *ppm_node = node->getNext("ppm");
int ppmValue = 0;
ppm_node->element()->get(ppmValue);
setPPM(ppmValue);
std::cout << "Loaded PPM for device '" << deviceId << "' at " << ppmValue << "ppm" << std::endl;
}
if (node->hasAnother("offset")) {
DataNode *offset_node = node->getNext("offset");
long long offsetValue = 0;
offset_node->element()->get(offsetValue);
setOffset(offsetValue);
std::cout << "Loaded offset for device '" << deviceId << "' at " << offsetValue << "Hz" << std::endl;
}
if (node->hasAnother("streamOpts")) {
DataNode *streamOptsNode = node->getNext("streamOpts");
for (int i = 0, iMax = streamOptsNode->numChildren(); i<iMax; i++) {
DataNode *streamOptNode = streamOptsNode->child(i);
std::string keyName = streamOptNode->getName();
std::string strSettingValue = streamOptNode->element()->toString();
if (keyName != "") {
setStreamOpt(keyName, strSettingValue);
}
}
}
if (node->hasAnother("settings")) {
DataNode *settingsNode = node->getNext("settings");
for (int i = 0, iMax = settingsNode->numChildren(); i<iMax; i++) {
DataNode *settingNode = settingsNode->child(i);
std::string keyName = settingNode->getName();
std::string strSettingValue = settingNode->element()->toString();
if (keyName != "") {
setSetting(keyName, strSettingValue);
}
}
}
if (node->hasAnother("rig_ifs")) {
DataNode *rigIFNodes = node->getNext("rig_ifs");
while (rigIFNodes->hasAnother("rig_if")) {
DataNode *rigIFNode = rigIFNodes->getNext("rig_if");
if (rigIFNode->hasAnother("model") && rigIFNode->hasAnother("sdr_if")) {
int load_model;
long long load_freq;
rigIFNode->getNext("model")->element()->get(load_model);
rigIFNode->getNext("sdr_if")->element()->get(load_freq);
rigIF[load_model] = load_freq;
}
}
}
busy_lock.unlock();
}
示例2: releaseDependencyList
void DataNode::releaseDependencyList(){
DataNode* iNode = this;
while (iNode != 0){
DataNode* tmp = iNode->getNext();
delete iNode;
iNode = tmp;
}
}
示例3: mdlTerminate
static void mdlTerminate(SimStruct *S)
{
rtsys = (RTsys*) ssGetUserData(S);
if (rtsys == NULL) {
return;
}
if (rtsys->taskList != NULL) {
// write logs to the MATLAB workspace
DataNode *dn = (DataNode*) rtsys->taskList->getFirst();
while (dn != NULL) {
UserTask *task = (UserTask*) dn->data;
for (int j=0; j<NBRLOGS; j++) {
Log *log = task->logs[j];
if (log) {
// printf("Dumping log %d for task %s\n", j, task->name);
mxArray *ptr = mxCreateDoubleMatrix(log->entries, 1, mxREAL);
for (int n=0; n<log->entries; n++) {
mxGetPr(ptr)[n] = log->vals[n];
}
mexMakeArrayPersistent(ptr);
mexPutVariable("base",log->variable,ptr);
}
}
dn = (DataNode*) dn->getNext();
}
}
#ifdef KERNEL_MATLAB
if (!destroyed) {
mxDestroyArray(segArray);
destroyed = true;
}
#else
cleanup();
#endif
// Delete rtsys and all data structures within
delete rtsys;
#ifdef KERNEL_MATLAB
mxArray* rhs[2];
rhs[0] = mxCreateString("global");
rhs[1] = mxCreateString("_rtsys");
mexCallMATLAB(0, NULL, 2, rhs, "clear");
#endif
}
示例4: while
DataNode *getNode(const char *name, List* list) {
DataNode* n;
if (strcmp(name, "")==0) {
return NULL;
}
n = (DataNode*) list->getFirst();
while (n != NULL) {
if (n->name != NULL) {
if (strcmp(n->name, name) == 0)
break;
}
n = (DataNode*) n->getNext();
}
if (n == NULL) {
return NULL;
} else {
return n;
}
}
示例5: hellocode
//.........这里部分代码省略.........
}
}
// Invalidate route
if (VERBOSE) {
mexPrintf("Node#%d invalidating route to Node#%d through unreachable Node#%d\n", d->nodeID, m+1, k+1);
}
d->routing_table[m].valid = 0;
}
}
}
}
}
}
return 0.0001;;
case 2:
ttSleep(0.001);
return 0.0001;
case 3:
// Send all RERRs
dn = (DataNode*) d->RERRlist->getFirst();
if (dn != NULL) {
rerrmsg = (RERRMsg*) dn->data;
nwkmsg = new GenericNwkMsg;
nwkmsg->type = RERR;
nwkmsg->intermed = d->nodeID;
nwkmsg->msg = rerrmsg;
ttSendMsg(1, rerrmsg->receiver, nwkmsg, 12);
tmp = dn;
dn = (DataNode*) dn->getNext();
tmp->remove();
delete tmp;
ttSleep(0.001);
return 0.0001;
} else {
return FINISHED;
}
case 4:
ttSetNextSegment(3);
return 0.0001;
}
return FINISHED; // to supress compilation warnings
}
示例6: ttCreateTimeTriggeredDispatcher
void ttCreateTimeTriggeredDispatcher(const char *name, double Ts, double *tSeq, int size) {
char errbuf[MAXERRBUF];
UserTask *userTask;
DataNode *dn;
TimeTriggeredDispatcher *dispatcher, *ndispatcher;
if (strcmp(name,"") == 0) {
TT_MEX_ERROR("ttCreateTimeTriggeredDispatcher: Name should be a non-empty string!");
return;
}
if (rtsys->prioFcn == NULL) {
TT_MEX_ERROR("ttCreateTimeTriggeredDispatcher: Kernel must be initialized before creation of TT Dispatcher!");
return;
}
dn = getNode(name, rtsys->ttdispList);
if (dn!=NULL) {
TT_MEX_ERROR("ttCreateTimeTriggeredDispatcher: Name of TimeTriggeredDispatcher Object not unique!");
return;
}
// Check for invalid task identifiers
for(int i = 0;i<size;i++)
{
if((int)*(tSeq+i)>0)
{
bool taskFound = false;
dn = (DataNode*) rtsys->taskList->getFirst();
while (dn != NULL)
{
userTask = (UserTask*) dn->data;
if (userTask->taskIdentifier == (int)*(tSeq+i)) // task idenifiers match
{
taskFound = true;
break;
}
dn = (DataNode*) dn->getNext();
}
if (!taskFound)
{
snprintf(errbuf, MAXERRBUF, "Task identifier %d not found!", (int)*(tSeq+i));
TT_MEX_ERROR(errbuf);
return;
}
}
else if ((int)*(tSeq+i)<0)
{
TT_MEX_ERROR("Task identifiers must be greater than 0. No negative integers allowed.");
return;
}
}
dispatcher = new TimeTriggeredDispatcher(name,Ts,tSeq,size);
rtsys->ttdispList->appendNode(new DataNode(dispatcher, dispatcher->name));
// Create time-triggered handler and timer to activate dispatcher at the slot boundaries
InterruptHandler *hdl = new InterruptHandler("ttdispatcher");
hdl->codeFcn = ttDispatcherCodeFcn;
hdl->priority = -1000.0;
hdl->display = false;
hdl->nonpreemptible = true;
hdl->data = (void *)dispatcher;
Timer *timer = new Timer("ttdispatcher");
timer->period = Ts;
timer->isPeriodic = true;
timer->isOverrunTimer = true; // = do not delete after expiry
timer->task = hdl;
dispatcher->slotTimer = timer;
// Schedule dispatcher timer at start
dispatcher->slotTimer->time = 0.0;
dispatcher->slotTimer->moveToList(rtsys->timeQ);
// Attach tasks defined in the table to the dispatcher
dn = (DataNode*) rtsys->taskList->getFirst();
while (dn != NULL)
{
userTask = (UserTask*) dn->data;
for(int i = 0;i<size;i++)
{
if((int)*(tSeq+i) == userTask->taskIdentifier)
{
ttAttachTimeTriggeredDispatcher(userTask->name, name);
//sprintf(errbuf, "disp(\'Task %s attached to TTdispatcher\')", userTask->name);
//mexEvalString(errbuf);
break;
}
}
dn = (DataNode*) dn->getNext();
}
// Make sure that existing TTDispatchers have no overlapping with current dispatcher
dn = (DataNode*) rtsys->ttdispList->getFirst();
while (dn != NULL)
{
ndispatcher = (TimeTriggeredDispatcher*) dn->data;
if (ndispatcher->affinity == dispatcher->affinity && dispatcher != ndispatcher)
{
//.........这里部分代码省略.........
示例7: mdlOutputs
static void mdlOutputs(SimStruct *S, int_T tid)
{
//printf("mdlOutputs at %g\n", ssGetT(S));
rtsys = (RTsys*) ssGetUserData(S);
if (rtsys->init_phase) {
/* Failure during initialization */
return;
}
real_T *y = ssGetOutputPortRealSignal(S,0);
real_T *n = ssGetOutputPortRealSignal(S,1);
real_T *s = ssGetOutputPortRealSignal(S,2);
real_T *m = ssGetOutputPortRealSignal(S,3);
real_T *energyConsumption = ssGetOutputPortRealSignal(S,4);
int i, j, k, detected;
double dTime;
DataNode *dn;
Task* task;
UserTask* t;
InterruptHandler* hdl;
Monitor *mon;
if (!rtsys->started && ssGetT(S) == 0.0) {
rtsys->started = true;
return;
}
if (!rtsys->mdlzerocalled) {
printf("Zero crossing detection must be turned on in order to run TrueTime!\n");
ssSetErrorStatus(S, "Zero crossing detection must be turned on in order to run TrueTime!");
return;
}
/* Storing the time */
rtsys->time = ssGetT(S) * rtsys->clockDrift + rtsys->clockOffset;
detected = 0;
/* Check interrupts */
i = 0;
dn = (DataNode*) rtsys->triggerList->getFirst();
while (dn != NULL) {
if (fabs(rtsys->interruptinputs[i]-rtsys->oldinterruptinputs[i]) > 0.1) {
hdl = (InterruptHandler*) dn->data;
Trigger* trig = hdl->trigger;
if (rtsys->time - trig->prevHit > trig->latency) {
// Trigger interrupt handler
if (hdl->myList == rtsys->readyQ) {
// handler serving older interrupts
hdl->pending++;
} else {
hdl->moveToList(rtsys->readyQ);
detected = 1;
}
trig->prevHit = rtsys->time;
} else {
//printf("Call to interrupt handler %s ignored at time %f. Within interrupt latency!\n", hdl->name, rtsys->time);
}
rtsys->oldinterruptinputs[i] = rtsys->interruptinputs[i];
}
i++;
dn = (DataNode*) dn->getNext();
}
/* Check network */
dn = (DataNode*) rtsys->networkList->getFirst();
while (dn != NULL) {
hdl = (InterruptHandler*) dn->data;
Network* network = hdl->network;
i = network->networkID - 1;
//printf("mdlOutputs: checking network #%d inp: %d oldinp: %d\n",i,rtsys->networkinputs[i],rtsys->oldnetworkinputs[i]);
if (fabs(rtsys->networkinputs[i] - rtsys->oldnetworkinputs[i]) > 0.1) {
hdl->moveToList(rtsys->readyQ);
detected = 1;
rtsys->oldnetworkinputs[i] = rtsys->networkinputs[i];
}
dn = (DataNode*) dn->getNext();
}
/* Run kernel? */
double externTime = (rtsys->time- rtsys->clockOffset) / rtsys->clockDrift;
if ((externTime >= rtsys->nextHit) || (detected > 0)) {
dTime = runKernel(ssGetT(S));
if (rtsys->error) {
// Something went wrong executing a code function
mxArray *bn[1];
mexCallMATLAB(1, bn, 0, 0, "gcs"); // get current system
char buf[200];
mxGetString(bn[0], buf, 200);
for (unsigned int i=0; i<strlen(buf); i++) if (buf[i]=='\n') buf[i]=' ';
printf("In block ==> '%s'\nSimulation aborted!\n", buf);
ssSetStopRequested(S, 1);
//.........这里部分代码省略.........
示例8: load
void DeviceConfig::load(DataNode *node) {
std::lock_guard < std::mutex > lock(busy_lock);
if (node->hasAnother("name")) {
deviceName = node->getNext("name")->element()->toString();
}
if (node->hasAnother("ppm")) {
DataNode *ppm_node = node->getNext("ppm");
int ppmValue = 0;
ppm_node->element()->get(ppmValue);
setPPM(ppmValue);
}
if (node->hasAnother("offset")) {
DataNode *offset_node = node->getNext("offset");
long long offsetValue = 0;
offset_node->element()->get(offsetValue);
setOffset(offsetValue);
}
if (node->hasAnother("agc_mode")) {
DataNode *agc_node = node->getNext("agc_mode");
int agcModeValue = 0;
agc_node->element()->get(agcModeValue);
setAGCMode(agcModeValue?true:false);
}
if (node->hasAnother("sample_rate")) {
DataNode *sample_rate_node = node->getNext("sample_rate");
long sampleRateValue = 0;
sample_rate_node->element()->get(sampleRateValue);
setSampleRate(sampleRateValue);
}
if (node->hasAnother("antenna")) {
DataNode *antenna_node = node->getNext("antenna");
std::string antennaNameValue;
antenna_node->element()->get(antennaNameValue);
setAntennaName(antennaNameValue);
}
if (node->hasAnother("streamOpts")) {
DataNode *streamOptsNode = node->getNext("streamOpts");
for (int i = 0, iMax = streamOptsNode->numChildren(); i<iMax; i++) {
DataNode *streamOptNode = streamOptsNode->child(i);
std::string keyName = streamOptNode->getName();
std::string strSettingValue = streamOptNode->element()->toString();
if (keyName != "") {
setStreamOpt(keyName, strSettingValue);
}
}
}
if (node->hasAnother("settings")) {
DataNode *settingsNode = node->getNext("settings");
for (int i = 0, iMax = settingsNode->numChildren(); i<iMax; i++) {
DataNode *settingNode = settingsNode->child(i);
std::string keyName = settingNode->getName();
std::string strSettingValue = settingNode->element()->toString();
if (keyName != "") {
setSetting(keyName, strSettingValue);
}
}
}
if (node->hasAnother("rig_ifs")) {
DataNode *rigIFNodes = node->getNext("rig_ifs");
while (rigIFNodes->hasAnother("rig_if")) {
DataNode *rigIFNode = rigIFNodes->getNext("rig_if");
if (rigIFNode->hasAnother("model") && rigIFNode->hasAnother("sdr_if")) {
int load_model;
long long load_freq;
rigIFNode->getNext("model")->element()->get(load_model);
rigIFNode->getNext("sdr_if")->element()->get(load_freq);
rigIF[load_model] = load_freq;
}
}
}
if (node->hasAnother("gains")) {
DataNode *gainsNode = node->getNext("gains");
while (gainsNode->hasAnother("gain")) {
DataNode *gainNode = gainsNode->getNext("gain");
std::string keyName;
float fltSettingValue;
gainNode->getNext("id")->element()->get(keyName);
gainNode->getNext("value")->element()->get(fltSettingValue);
if (keyName != "" && !(fltSettingValue!=fltSettingValue)) {
setGain(keyName, fltSettingValue);
}
}
}
}
示例9: mdlOutputs
static void mdlOutputs(SimStruct *S, int_T tid)
{
debugPrintf("'%s': mdlOutputs at %.16f\n", rtsys->blockName, ssGetT(S));
rtsys = (RTsys*) ssGetUserData(S);
if (rtsys->init_phase) {
/* Failure during initialization */
return;
}
real_T *y = ssGetOutputPortRealSignal(S,0);
real_T *n = ssGetOutputPortRealSignal(S,1);
real_T *s = ssGetOutputPortRealSignal(S,2);
real_T *e = ssGetOutputPortRealSignal(S,3);
int i, shouldRunKernel = 0;
double timestep;
DataNode *dn;
UserTask* t;
InterruptHandler* hdl;
if (!rtsys->started && ssGetT(S) == 0.0) {
rtsys->started = true;
} else {
/* Storing the time */
rtsys->time = ssGetT(S) * rtsys->clockDrift + rtsys->clockOffset;
shouldRunKernel = 0;
/* Run kernel? */
double externTime = (rtsys->time- rtsys->clockOffset) / rtsys->clockDrift;
if ((externTime >= rtsys->nextHit) || (shouldRunKernel > 0)) {
timestep = runKernel(ssGetT(S));
if (rtsys->error) {
mexPrintf("In block ==> '%s'\n", ssGetBlockName(S));
mexPrintf("Simulation aborted!\n");
ssSetErrorStatus(S, errbuf);
return;
} else {
rtsys->nextHit = (rtsys->time + timestep - rtsys->clockOffset) / rtsys->clockDrift;
}
}
}
/* Analog outputs */
for (i=0; i<rtsys->nbrOfOutputs; i++) {
y[i] = rtsys->outputs[i];
}
/* Network send outputs */
for (i=0; i<rtsys->nbrOfNetworks; i++) {
n[i] = rtsys->nwSnd[i];
rtsys->oldnwSnd[i] = rtsys->nwSnd[i];
}
/* Usertask schedule outputs */
i = 0;
dn = (DataNode*) rtsys->taskList->getFirst();
while (dn != NULL) {
t = (UserTask*) dn->data;
if (t->display) {
double val = (double) (i+1);
for (int j = 0; j < rtsys->nbrOfCPUs; j++) {
s[i + j * rtsys->nbrOfSchedTasks] = val;
}
if (t->state == RUNNING) {
val += 0.5;
} else if (t->state == READY) {
val += 0.25;
} else if (t->state == WAITING) {
val += 0.125;
}
s[i + t->affinity * rtsys->nbrOfSchedTasks] = val;
i++;
if (i > rtsys->nbrOfSchedTasks) {
mexPrintf("FATAL ERROR: schedule output port out of bounds!\n");
ssSetErrorStatus(S, "error");
return;
}
}
dn = (DataNode*) dn->getNext();
}
/* Handler schedule outputs */
dn = (DataNode*) rtsys->handlerList->getFirst();
while (dn != NULL) {
hdl = (InterruptHandler*) dn->data;
if (hdl->display) {
double val = (double) (i+1);
if (hdl->state == RUNNING) {
val += 0.5;
//.........这里部分代码省略.........
示例10: mdlTerminate
static void mdlTerminate(SimStruct *S)
{
debugPrintf("'%s': mdlTerminate\n", S->path);
rtsys = (RTsys*) ssGetUserData(S);
if (rtsys == NULL) {
return;
}
// Write task execution logs to the MATLAB workspace
if (rtsys->taskList != NULL) {
DataNode *dn = (DataNode*) rtsys->taskList->getFirst();
while (dn != NULL) {
UserTask *task = (UserTask*) dn->data;
for (int j=0; j<NBRLOGS; j++) {
Log *log = task->logs[j];
if (log) {
mxArray *ptr = mxCreateDoubleMatrix(log->entries, 1, mxREAL);
for (int n=0; n<log->entries; n++) {
mxGetPr(ptr)[n] = log->vals[n];
}
mexMakeArrayPersistent(ptr);
mexPutVariable("base",log->variable,ptr);
}
}
dn = (DataNode*) dn->getNext();
}
}
// Write user-defined logs to the MATLAB workspace
if (rtsys->logList != NULL) {
DataNode *dn = (DataNode*) rtsys->logList->getFirst();
while (dn != NULL) {
Log *log = (Log*) dn->data;
mxArray *ptr = mxCreateDoubleMatrix(log->entries, 1, mxREAL);
for (int n=0; n<log->entries; n++) {
mxGetPr(ptr)[n] = log->vals[n];
}
mexMakeArrayPersistent(ptr);
mexPutVariable("base",log->variable,ptr);
dn = (DataNode*) dn->getNext();
}
}
#ifdef KERNEL_MATLAB
mxDestroyArray(rtsys->segArray);
#else
cleanup();
#endif
// Delete rtsys and all data structures within
delete rtsys;
#ifdef KERNEL_MATLAB
mxArray* rhs[2];
rhs[0] = mxCreateString("global");
rhs[1] = mxCreateString("_rtsys");
mexCallMATLAB(0, NULL, 2, rhs, "clear");
#endif
}
示例11: loadSession
bool AppFrame::loadSession(std::string fileName) {
DataTree l;
if (!l.LoadFromFileXML(fileName)) {
return false;
}
wxGetApp().getDemodMgr().terminateAll();
try {
DataNode *header = l.rootNode()->getNext("header");
std::string version(*header->getNext("version"));
long long center_freq = *header->getNext("center_freq");
std::cout << "Loading " << version << " session file" << std::endl;
std::cout << "\tCenter Frequency: " << center_freq << std::endl;
wxGetApp().setFrequency(center_freq);
DataNode *demodulators = l.rootNode()->getNext("demodulators");
while (demodulators->hasAnother("demodulator")) {
DataNode *demod = demodulators->getNext("demodulator");
if (!demod->hasAnother("bandwidth") || !demod->hasAnother("frequency")) {
continue;
}
long bandwidth = *demod->getNext("bandwidth");
long long freq = *demod->getNext("frequency");
int type = demod->hasAnother("type") ? *demod->getNext("type") : DEMOD_TYPE_FM;
float squelch_level = demod->hasAnother("squelch_level") ? (float) *demod->getNext("squelch_level") : 0;
int squelch_enabled = demod->hasAnother("squelch_enabled") ? (int) *demod->getNext("squelch_enabled") : 0;
int stereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 0;
std::string output_device = demod->hasAnother("output_device") ? string(*(demod->getNext("output_device"))) : "";
float gain = demod->hasAnother("gain") ? (float) *demod->getNext("gain") : 1.0;
DemodulatorInstance *newDemod = wxGetApp().getDemodMgr().newThread();
newDemod->setDemodulatorType(type);
newDemod->setBandwidth(bandwidth);
newDemod->setFrequency(freq);
newDemod->setGain(gain);
newDemod->updateLabel(freq);
if (squelch_enabled) {
newDemod->setSquelchEnabled(true);
newDemod->setSquelchLevel(squelch_level);
}
if (stereo) {
newDemod->setStereo(true);
}
bool found_device = false;
std::map<int, RtAudio::DeviceInfo>::iterator i;
for (i = outputDevices.begin(); i != outputDevices.end(); i++) {
if (i->second.name == output_device) {
newDemod->setOutputDevice(i->first);
found_device = true;
}
}
if (!found_device) {
std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
}
newDemod->run();
newDemod->setActive(false);
wxGetApp().bindDemodulator(newDemod);
std::cout << "\tAdded demodulator at frequency " << freq << " type " << type << std::endl;
std::cout << "\t\tBandwidth: " << bandwidth << std::endl;
std::cout << "\t\tSquelch Level: " << squelch_level << std::endl;
std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl;
std::cout << "\t\tStereo: " << (stereo ? "true" : "false") << std::endl;
std::cout << "\t\tOutput Device: " << output_device << std::endl;
}
} catch (DataInvalidChildException &e) {
std::cout << e.what() << std::endl;
return false;
} catch (DataTypeMismatchException &e) {
std::cout << e.what() << std::endl;
return false;
}
currentSessionFile = fileName;
std::string filePart = fileName.substr(fileName.find_last_of(filePathSeparator) + 1);
GetStatusBar()->SetStatusText(wxString::Format(wxT("Loaded session file: %s"), currentSessionFile.c_str()));
SetTitle(wxString::Format(wxT("%s: %s"), CUBICSDR_TITLE, filePart.c_str()));
return true;
}