int forceReadNoLock(CAMERA_DATA_TYPE_ENUM nvRamId, int sensorDev) { int err; int u4SensorID; err = getSensorID((CAMERA_DUAL_CAMERA_SENSOR_ENUM)sensorDev, u4SensorID); if(err!=0) return err; void* buf; err = getMem(nvRamId, (CAMERA_DUAL_CAMERA_SENSOR_ENUM)sensorDev, buf); if(err!=0) return err; int nvSize; err = getNvSize(nvRamId, nvSize); if(err!=0) return err; NvramDrvBase* nvDrv; nvDrv = NvramDrvBase::createInstance(); err = nvDrv->readNvram ( (CAMERA_DUAL_CAMERA_SENSOR_ENUM)sensorDev, u4SensorID, nvRamId, buf, nvSize ); nvDrv->destroyInstance(); return err; }
int main(int argc, char* argv[]) { int i = 0; // indice usato per i cicli for int n = 0; // variabile per il numero di sensori xQueueHandle queue[NUM_PRIORITIES]; Sync_Init sync_sensor; initNode(); initSensors(); // initNetwork(); funzione fornita dal livello rete if ( join(getID()) == 0) { // supponendo sia questa la firma // scrive nel log che si e' verificato un errore di autenticazione while(1); } for (i = 0; i < NUM_PRIORITIES; i++) queue[i] = xQueueCreate(MAX_QUEUE_LENGTH, sizeof(Message)); if (xTaskCreate(asyncRequestManage,// nome della funzione "Gestione richieste asincrone", configMINIMAL_STACK_SIZE, queue(1), // parametri della funzione: queue(1) 3) != pdTRUE) { // scrive nel log che si `e verificato un errore di gestione della memoria while(1); } n = getNumSensors(); for (i = 0; i < n; i++) { if (getPeriod(getSensorID(i)) > 0) { sync_sensor.ID = getSensorID(i); sync_sensor.period = getPeriod(getSensorID(i)); if (xTaskCreate(syncSensorManage,// nome della funzione "Task di gestione di un sensore sincrono ", configMINIMAL_STACK_SIZE, (void *)&sync_sensor, // parametri della funzione 2) != pdTRUE) { // scrive nel log che si `e verificato un errore di gestione della memoria while(1); } } } if (xTaskCreate(sendOverNetwork,// nome della funzione "Task per l'invio dei messaggi", configMINIMAL_STACK_SIZE, (void *)queue, // parametri della funzione 1) != pdTRUE) { // scrive nel log che si `e verificato un errore di gestione della memoria while(1); } vTaskStartScheduler(); while (1); }
bool rspfNitfRpcModel::parseImageHeader(const rspfNitfImageHeader* ih) { if (getRpcData(ih) == false) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } rspfString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); rspf_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } theImageID = ih->getImageId(); rspfIrect imageRect = ih->getImageRect(); theImageSize.line = static_cast<rspf_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<rspf_int32>(imageRect.width() / theDecimation); getSensorID(ih); theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; theImageClipRect = rspfDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); rspfGpt v0, v1, v2, v3; rspfDpt ip0 (0.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); rspfDpt ip1 (theImageSize.samp-1.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); rspfDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); rspfDpt ip3 (0.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = rspfPolygon (rspfDpt(v0), rspfDpt(v1), rspfDpt(v2), rspfDpt(v3)); updateModel(); rspfRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } try { computeGsd(); } catch (const rspfException& e) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { rspfNotify(rspfNotifyLevel_DEBUG) << "DEBUG rspfNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
int OemCamDrv::readOem(CAMERA_DUAL_CAMERA_SENSOR_ENUM a_eSensorType, unsigned long u4SensorID, CAMERA_DATA_TYPE_ENUM nvRamId, void *a_pNvramData, unsigned long a_u4NvramDataSize, int a_version) { logI("readOem ln=%d sensorDev=%d id=%d",__LINE__, a_eSensorType, nvRamId); Mutex::Autolock _l(gLock); readCommonOem(); if(gIsOemExist==0) { int err; NvramDrvBase* nvDrv; nvDrv = NvramDrvBase::createInstance(); err = nvDrv->readDefaultData ( (CAMERA_DUAL_CAMERA_SENSOR_ENUM)a_eSensorType, u4SensorID, nvRamId, a_pNvramData ); nvDrv->destroyInstance(); return 0; } logI("readOem ln=%d",__LINE__); //===================================== if(nvRamId == CAMERA_OEM_COMMON) { memcpy(a_pNvramData, &gCamCommon, sizeof(OEM_CAMERA_COMMON)); return 0; } logI("readOem ln=%d",__LINE__); char fname[e_MaxPathSize+20]; strcpy(fname, gOemItemDres[nvRamId].path); if(gOemItemDres[nvRamId].sensorDevRelation==e_SensorRelation) { if(a_eSensorType == DUAL_CAMERA_MAIN_SENSOR) strcat(fname, "_main"); else if(a_eSensorType == DUAL_CAMERA_SUB_SENSOR) strcat(fname, "_sub"); else //if(a_eSensorType == DUAL_CAMERA_MAIN2_SENSOR) strcat(fname, "_main2"); } int id=0; getSensorID(a_eSensorType, id); logI("readOem getSensorID ln=%d id=%d",__LINE__,id); if(gOemItemDres[nvRamId].componentRelation == e_SensorRelation) { if(a_eSensorType == DUAL_CAMERA_MAIN_SENSOR) { int i; int oemId=0; char s[20]; for(i=0;i<10;i++) { if( id == gCamCommon.OemMainSensorId[i]) { oemId=i; break; } } sprintf(s,"_%d",oemId); strcat(fname, s); } else if(a_eSensorType == DUAL_CAMERA_SUB_SENSOR) { int i; int oemId=0; char s[20]; for(i=0;i<10;i++) { if( id == gCamCommon.OemSubSensorId[i]) { oemId=i; break; } } sprintf(s,"_%d",oemId); strcat(fname, s); } } logI("readOem ln=%d nvRamId=%d fname=%s",__LINE__,nvRamId, fname); FILE* fp; fp = fopen(fname, "rb"); if(fp==0) { int err; NvramDrvBase* nvDrv; nvDrv = NvramDrvBase::createInstance(); err = nvDrv->readDefaultData ( (CAMERA_DUAL_CAMERA_SENSOR_ENUM)a_eSensorType, u4SensorID, nvRamId, a_pNvramData ); nvDrv->destroyInstance(); return 0; } logI("readOem ln=%d",__LINE__); fread(a_pNvramData, 1, a_u4NvramDataSize, fp); fclose(fp); logI("readOem ln=%d",__LINE__); return 0; }
bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih) { // Do this first so we don't waste time if not rpc image. if (getRpcData(ih) == false) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } //--- // Get the decimation if any from the header "IMAG" field. // // Look for string like: // "/2" = 1/2 // "/4 = 1/4 // ... // "/16 = 1/16 // If it is full resolution it should be "1.0" //--- ossimString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); ossim_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } //*** // Fetch Image ID: //*** theImageID = ih->getImageId(); ossimIrect imageRect = ih->getImageRect(); //--- // Fetch Image Size: //--- theImageSize.line = static_cast<ossim_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<ossim_int32>(imageRect.width() / theDecimation); // Search for the STDID Tag to fetch mission (satellite) name: getSensorID(ih); //*** // Assign other data members: //*** theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // Assign the bounding ground polygon: // // NOTE: We will use the base ossimRpcModel for transformation since all // of our calls are in full image space (not decimated). //--- ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. ossimRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimNitfRpcModel::parseFile: returning..." << std::endl; } return true; }