static char *getPlot3d(char *pAxeUID, scicos_block * block) { char *pPlot3d; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return NULL; } // fast path for an existing object if (sco->scope.cachedPlot3dUID != NULL) { return sco->scope.cachedPlot3dUID; } pPlot3d = findChildWithKindAt(pAxeUID, __GO_PLOT3D__, 0); /* * Allocate if necessary */ if (pPlot3d == NULL) { pPlot3d = createGraphicObject(__GO_PLOT3D__); if (pPlot3d != NULL) { createDataObject(pPlot3d, __GO_PLOT3D__); setGraphicObjectRelationship(pAxeUID, pPlot3d); } } /* * Setup on first access */ if (pPlot3d != NULL) { setBounds(block, pAxeUID, pPlot3d); setPlot3dSettings(pPlot3d); setDefaultValues(block, pPlot3d); { int iClipState = 1; //on setGraphicObjectProperty(pPlot3d, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with a local storage */ if (pPlot3d != NULL && sco->scope.cachedPlot3dUID == NULL) { sco->scope.cachedPlot3dUID = strdup(pPlot3d); releaseGraphicObjectProperty(__GO_PARENT__, pPlot3d, jni_string, 1); } return sco->scope.cachedPlot3dUID; }
static int getGrayplot(int iAxeUID, scicos_block * block) { int iGrayplot; int i__0 = 0; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedGrayplotUID) { return sco->scope.cachedGrayplotUID; } iGrayplot = findChildWithKindAt(iAxeUID, __GO_GRAYPLOT__, 0); /* * Allocate if necessary */ if (iGrayplot == 0) { iGrayplot = createGraphicObject(__GO_GRAYPLOT__); if (iGrayplot != 0) { createDataObject(iGrayplot, __GO_GRAYPLOT__); setGraphicObjectRelationship(iAxeUID, iGrayplot); } else { return 0; } } /* * Setup on first access */ setGraphicObjectProperty(iGrayplot, __GO_DATA_MAPPING__, &i__0, jni_int, 1); setBounds(block, iAxeUID, iGrayplot); setDefaultValues(block, iGrayplot); { int iClipState = 1; //on setGraphicObjectProperty(iGrayplot, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedGrayplotUID = iGrayplot; return sco->scope.cachedGrayplotUID; }
static int getPlot3d(int iAxeUID, scicos_block * block) { int iPlot3d; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedPlot3dUID) { return sco->scope.cachedPlot3dUID; } iPlot3d = findChildWithKindAt(iAxeUID, __GO_PLOT3D__, 0); /* * Allocate if necessary */ if (iPlot3d == 0) { iPlot3d = createGraphicObject(__GO_PLOT3D__); if (iPlot3d != 0) { createDataObject(iPlot3d, __GO_PLOT3D__); setGraphicObjectRelationship(iAxeUID, iPlot3d); } else { return 0; } } /* * Setup on first access */ setBounds(block, iAxeUID, iPlot3d); setPlot3dSettings(iPlot3d); setDefaultValues(block, iPlot3d); { int iClipState = 1; //on setGraphicObjectProperty(iPlot3d, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedPlot3dUID = iPlot3d; return sco->scope.cachedPlot3dUID; }
// Instructions if the OK-Button has been pressed. void NetCdfConfigureDialog::accept() { QMessageBox valueErrorBox; if (_currentVar->num_dims() < 3) { valueErrorBox.setText("Selected Variable has not enough dimensions."); valueErrorBox.exec(); } else if (doubleSpinBoxDim2Start->value() == doubleSpinBoxDim2Start->maximum()) { valueErrorBox.setText("Lon has invalid extend."); valueErrorBox.exec(); } else if(doubleSpinBoxDim1Start->value() == doubleSpinBoxDim1Start->maximum()) { valueErrorBox.setText("Lat has invalid extend."); valueErrorBox.exec(); } else { createDataObject(); delete _currentFile; this->done(QDialog::Accepted); } }
static int getSegs(int iAxeUID, scicos_block * block, int input) { int iSegs; BOOL b__true = TRUE; double d__1 = 1.0; double d__0 = 0.0; int color; sco_data *sco = getScoData(block); // assert the sco is not NULL if (sco == NULL || sco->scope.cachedSegsUIDs == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedSegsUIDs[input]) { return sco->scope.cachedSegsUIDs[input]; } iSegs = findChildWithKindAt(iAxeUID, __GO_SEGS__, input); /* * Allocate if necessary */ if (iSegs == 0) { iSegs = createGraphicObject(__GO_SEGS__); if (iSegs != 0) { createDataObject(iSegs, __GO_SEGS__); setGraphicObjectRelationship(iAxeUID, iSegs); } else { return 0; } } /* * Setup on first access */ setGraphicObjectProperty(iSegs, __GO_NUMBER_ARROWS__, &sco->internal.maxNumberOfPoints[input], jni_int, 1); // Setup properties setGraphicObjectProperty(iSegs, __GO_LINE_THICKNESS__, &d__1, jni_double, 1); setGraphicObjectProperty(iSegs, __GO_ARROW_SIZE__, &d__0, jni_double, 1); color = block->ipar[2 + input]; if (color > 0) { setGraphicObjectProperty(iSegs, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(iSegs, __GO_SEGS_COLORS__, &color, jni_int_vector, 1); } else { int iMarkSize = 4; color = -color; setGraphicObjectProperty(iSegs, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(iSegs, __GO_MARK_STYLE__, &color, jni_int, 1); setGraphicObjectProperty(iSegs, __GO_MARK_SIZE__, &iMarkSize, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(iSegs, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedSegsUIDs[input] = iSegs; return sco->scope.cachedSegsUIDs[input]; }
static char *getPolyline(char *pAxeUID, scicos_block * block, int row) { char *pPolyline; static double d__0 = 0.0; static BOOL b__true = TRUE; int color; int markSize; double lineThickness; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return NULL; } // fast path for an existing object if (sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[row] != NULL) { return sco->scope.cachedPolylinesUIDs[row]; } pPolyline = findChildWithKindAt(pAxeUID, __GO_POLYLINE__, row); /* * Allocate if necessary */ if (pPolyline == NULL) { pPolyline = createGraphicObject(__GO_POLYLINE__); if (pPolyline != NULL) { createDataObject(pPolyline, __GO_POLYLINE__); setGraphicObjectRelationship(pAxeUID, pPolyline); } } /* * Setup on first access */ if (pPolyline != NULL) { /* * Default setup of the nGons property */ { int nGons = 1; setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_NUM_GONS__, &nGons, jni_int, 1); } color = block->ipar[3 + row]; markSize = block->ipar[3 + block->ipar[1] + row]; lineThickness = (double)markSize; if (color > 0) { setGraphicObjectProperty(pPolyline, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_COLOR__, &color, jni_int, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_THICKNESS__, &lineThickness, jni_double, 1); } else { color = -color; setGraphicObjectProperty(pPolyline, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_STYLE__, &color, jni_int, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_SIZE__, &markSize, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(pPolyline, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with a local storage */ if (pPolyline != NULL && sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[row] == NULL) { sco->scope.cachedPolylinesUIDs[row] = strdup(pPolyline); releaseGraphicObjectProperty(__GO_PARENT__, pPolyline, jni_string, 1); } return sco->scope.cachedPolylinesUIDs[row]; }
static char *getPolyline(char *pAxeUID, scicos_block * block, int input, int row) { char *pPolyline; double d__0 = 0.0; BOOL b__true = TRUE; int color; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return NULL; } // fast path for an existing object if (sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[input] != NULL && sco->scope.cachedPolylinesUIDs[input][row] != NULL) { return sco->scope.cachedPolylinesUIDs[input][row]; } pPolyline = findChildWithKindAt(pAxeUID, __GO_POLYLINE__, row); /* * Allocate if necessary */ if (pPolyline == NULL) { pPolyline = createGraphicObject(__GO_POLYLINE__); if (pPolyline != NULL) { createDataObject(pPolyline, __GO_POLYLINE__); setGraphicObjectRelationship(pAxeUID, pPolyline); } } /* * Setup on first access */ if (pPolyline != NULL) { /* * Default setup (will crash if removed) */ { int polylineSize[2] = { 1, block->ipar[2] }; setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, polylineSize, jni_int_vector, 2); } setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_X__, &d__0, jni_double_vector, 1); setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_Y__, &d__0, jni_double_vector, 1); // ipar=[win;size(in,'*');N;wpos(:);wdim(:);in(:);clrs(:);heritance] // 1 1 1 2 2 nin nin 1 color = block->ipar[7 + block->nin + input + row]; if (color > 0) { LOG("%s: %s at %d at %d to %d\n", "cmscope", "set lines mode", input, row, color); setGraphicObjectProperty(pPolyline, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_COLOR__, &color, jni_int, 1); } else { color = -color; LOG("%s: %s at %d at %d to %d\n", "cmscope", "set mark mode", input, row, -color); setGraphicObjectProperty(pPolyline, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_STYLE__, &color, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(pPolyline, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with local storage */ if (sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[input] != NULL) { sco->scope.cachedPolylinesUIDs[input][row] = strdup(pPolyline); releaseGraphicObjectProperty(__GO_PARENT__, pPolyline, jni_string, 1); } return sco->scope.cachedPolylinesUIDs[input][row]; }
/** * selfTest() depends upon periodic purging. Every call, it will first fill up the database, taking memory snapshots, * then purge, taking more memory snapshots. It creates a number of random data objects, inserts them into the system, * and records current memory usage into a file called 'mem.results', for every interation. It does in the following steps: * * 1. Add, approximately, 20 DO's per second, done every poll period (e.g. 10 seconds, means add 200 for that interval). * * 2. When the number of DO's in the system match the threshold setting, we drop the threshold by the same number * we increased it in step 1. In this case, we decrease it by 20, allowing the memory threshold purger to do its job. * * 3. Repeat step 1. * * 4. Repeat step 2. * * 5. Reset system functions to original defaults. * * This allows the system to approach maximum usage, drop to zero, back to maximum usage, then back to zero. * The file can be parse into a plot showing how much memory is freed. This test works regardless of using * in memory database, the improved all memory database, or disk based database. * * WARNING: We use mallinfo() to determine the amount of memory used and released, as the system does NOT * see any memory freed at all, due to the fact dlmallopt(-1) is set in main.cpp. This tells free to not * return freed memory to the system. Thus, using mallinfo is the only means available to show how much * memory is actually freed to the application (but not to the system). * * */ void CacheStrategyUtility::selfTest() { static int init=0; static float amount_do=0; static int count=0; char countStr[50]; static float threshold_backup; static char *direction; if (!init) { init=1; threshold_backup=db_size_threshold; amount_do=20.0*pollPeriodMs/1000; //20 per second seems reasonable if (amount_do > db_size_threshold/10) { amount_do = db_size_threshold/10; } direction="Start"; } // JM: Start DB purging // JM: Testing code only, to prove it works. Lets do linear testing. struct mallinfo mi=mallinfo(); //Due to file permission difficulties in android, we'll write it as a log HAGGLE_DBG("\nThreshold(%s): %lld/%d -- Used bytes: %d, Free bytes: %d, SQL: %lld\n\n", direction, db_size_threshold,current_num_do, mi.uordblks, mi.fordblks, sqlite3_memory_used()); //send db_size_threshold DO's //init = 1 means send DO's //init = 2 means we are in purging mode if ((init == 1) || (init == 3)) { float upperlimit=current_num_do+amount_do; if (upperlimit > db_size_threshold) { upperlimit = db_size_threshold+1; init++; } if (init ==1) { direction="Up1"; } else if (init == 3) { direction="Up2"; } else { direction="StateChangeFromUp"; } for(int i=current_num_do; i<upperlimit; i++) { DataObjectRef dObj = createDataObject(2); dObj->addAttribute("ContentOriginator", "self"); dObj->addAttribute("ContentType", "DelByRelTTL"); dObj->addAttribute("ContentType2", "DelByAbsTTL"); dObj->addAttribute("purge_by_timestamp", "2000000000"); dObj->addAttribute("purge_after_seconds", "2000000000"); char buffer[1025]; snprintf(buffer, 1024, "%llu", (unsigned long long)time(NULL)); sprintf(countStr, "%d", count++); dObj->addAttribute("ContentCreationTime", buffer); dObj->addAttribute("count", countStr); dObj->calcId(); _handleNewDataObject(dObj); } } else if ((init == 2) || (init == 4)) { //init==2, reduction db_size_threshold -= amount_do; if (db_size_threshold < 0.0) { init++; db_size_threshold=threshold_backup; } if (init == 2) { direction="Down1"; } else if (init == 4) { direction="Down2"; } else { direction="StateChangeFromDown"; } } else { //if (init == 5) //clear seltTest? self_test = false; db_size_threshold=threshold_backup; HAGGLE_DBG("Self Test completed!\n"); //remove any last DO's //write any STAT information getKernel()->shutdown(); //return; } // JM: End testing }