//--------------------------------------------------------- bool CFilter_Rank::On_Execute(void) { //----------------------------------------------------- if( !m_Kernel.Set_Parameters(Parameters) ) { Error_Set(_TL("could not initialize kernel")); return( false ); } double Rank = Parameters("RANK")->asDouble() / 100.0; //----------------------------------------------------- m_pInput = Parameters("INPUT")->asGrid(); CSG_Grid Result, *pResult = Parameters("RESULT")->asGrid(); if( !pResult || pResult == m_pInput ) { pResult = &Result; pResult->Create(m_pInput); } else { pResult->Fmt_Name("%s [%s: %.1f]", m_pInput->Get_Name(), _TL("Rank"), 100.0 * Rank); pResult->Set_NoData_Value(m_pInput->Get_NoData_Value()); DataObject_Set_Parameters(pResult, m_pInput); } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double Value; if( Get_Value(x, y, Rank, Value) ) { pResult->Set_Value(x, y, Value); } else { pResult->Set_NoData(x, y); } } } //------------------------------------------------- if( pResult == &Result ) { CSG_MetaData History = m_pInput->Get_History(); m_pInput->Assign(pResult); m_pInput->Get_History() = History; DataObject_Update(m_pInput); Parameters("RESULT")->Set_Value(m_pInput); } m_Kernel.Destroy(); return( true ); }
//--------------------------------------------------------- bool CKriging_Base::On_Execute(void) { bool bResult = false; //----------------------------------------------------- m_Block = Parameters("BLOCK" )->asBool() ? Parameters("DBLOCK")->asDouble() / 2.0 : 0.0; m_bStdDev = Parameters("TQUALITY")->asInt() == 0; m_bLog = Parameters("LOG" )->asBool(); m_pPoints = Parameters("POINTS" )->asShapes(); m_zField = Parameters("ZFIELD" )->asInt(); if( m_pPoints->Get_Count() <= 1 ) { SG_UI_Msg_Add(_TL("not enough points for interpolation"), true); return( false ); } //----------------------------------------------------- CSG_Table Variogram; if( SG_UI_Get_Window_Main() ) { static CVariogram_Dialog dlg; if( dlg.Execute(m_pPoints, m_zField, m_bLog, &Variogram, &m_Model) ) { bResult = true; } } else { int nSkip = Parameters("VAR_NSKIP" )->asInt(); int nClasses = Parameters("VAR_NCLASSES")->asInt(); double maxDistance = Parameters("VAR_MAXDIST" )->asDouble(); m_Model.Set_Formula(Parameters("VAR_MODEL")->asString()); if( CSG_Variogram::Calculate(m_pPoints, m_zField, m_bLog, &Variogram, nClasses, maxDistance, nSkip) ) { m_Model.Clr_Data(); for(int i=0; i<Variogram.Get_Count(); i++) { CSG_Table_Record *pRecord = Variogram.Get_Record(i); m_Model.Add_Data(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE), pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP)); } bResult = m_Model.Get_Trend() || m_Model.Get_Parameter_Count() == 0; } } //----------------------------------------------------- if( bResult && (bResult = _Initialise_Grids() && On_Initialize()) ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("variogram model"), m_Model.Get_Formula(SG_TREND_STRING_Formula_Parameters).c_str()), false); for(int y=0; y<m_pGrid->Get_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++) { #pragma omp parallel for for(int x=0; x<m_pGrid->Get_NX(); x++) { double z, v; if( Get_Value(m_pGrid->Get_System().Get_Grid_to_World(x, y), z, v) ) { Set_Value(x, y, z, v); } else { Set_NoData(x, y); } } } } //----------------------------------------------------- m_Model.Clr_Data(); On_Finalize(); return( bResult ); }
//--------------------------------------------------------- bool CFilter_LoG::On_Execute(void) { //----------------------------------------------------- if( !Initialise() ) { return( false ); } //----------------------------------------------------- m_pInput = Parameters("INPUT")->asGrid(); CSG_Grid Result, *pResult = Parameters("RESULT")->asGrid(); if( !pResult || pResult == m_pInput ) { pResult = &Result; pResult->Create(m_pInput); } else { pResult->Fmt_Name("%s [%s]", m_pInput->Get_Name(), _TL("Laplace Filter")); pResult->Set_NoData_Value(m_pInput->Get_NoData_Value()); } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( m_pInput->is_InGrid(x, y) ) { pResult->Set_Value(x, y, Get_Value(x, y)); } else { pResult->Set_NoData(x, y); } } } //----------------------------------------------------- if( pResult == &Result ) { CSG_MetaData History = m_pInput->Get_History(); m_pInput->Assign(pResult); m_pInput->Get_History() = History; DataObject_Update(m_pInput); Parameters("RESULT")->Set_Value(m_pInput); } DataObject_Set_Colors(pResult, 100, SG_COLORS_BLACK_WHITE); m_Kernel.Destroy(); return( true ); }
//--------------------------------------------------------- CSG_Shape * CSG_PointCloud::_Set_Shape(int iPoint) { SG_UI_Progress_Lock(true); CSG_Shape *pShape = m_Shapes.Get_Shape(0); if( pShape->is_Modified() && m_Shapes_Index >= 0 && m_Shapes_Index < Get_Count() ) { m_Cursor = m_Points[m_Shapes_Index]; for(int i=0; i<Get_Field_Count(); i++) { switch( Get_Field_Type(i) ) { default: Set_Value(i, pShape->asDouble(i)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: Set_Value(i, pShape->asString(i)); break; } } Set_Value(0, pShape->Get_Point(0).x); Set_Value(1, pShape->Get_Point(0).y); Set_Value(2, pShape->Get_Z (0) ); } if( iPoint >= 0 && iPoint < Get_Count() ) { if( iPoint != m_Shapes_Index ) { m_Cursor = m_Points[iPoint]; pShape->Set_Point(Get_X(), Get_Y(), 0, 0); pShape->Set_Z (Get_Z() , 0, 0); for(int i=0; i<Get_Field_Count(); i++) { switch( Get_Field_Type(i) ) { default: pShape->Set_Value(i, Get_Value(i)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: { CSG_String s; Get_Value(i, s); pShape->Set_Value(i, s); } break; } } m_Shapes_Index = iPoint; } m_Shapes.Set_Modified(false); SG_UI_Progress_Lock(false); return( pShape ); } m_Shapes_Index = -1; SG_UI_Progress_Lock(false); return( NULL ); }
void cfu_sim_parser(char *filename) { int i; char core_name[128]; multi_sim_arg.boot.share_mode = Get_Value(filename, "BOOT_OPTION", "SHARE_MODE", 0); //CFU_SHM_NAME if (Get_String(filename, "BOOT_OPTION", "CFU_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.cfu_shm_name, Get_String(filename, "BOOT_OPTION", "CFU_SHM_NAME")); } //SOC_SHM_NAME if (Get_String(filename, "BOOT_OPTION", "CORE_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.core_shm_name, Get_String(filename, "BOOT_OPTION", "CORE_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "M2_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.m2_shm_name, Get_String(filename, "BOOT_OPTION", "M2_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "DDR_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.ddr_shm_name, Get_String(filename, "BOOT_OPTION", "DDR_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "SYSDMA_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.sysdma_shm_name, Get_String(filename, "BOOT_OPTION", "SYSDMA_SHM_NAME")); } for (i = 0; i< DSPNUM; i++) { sprintf(core_name, "CORE%d", i); multi_sim_arg.pacdsp[i].core_base = Get_Value(filename, core_name, "BASE", 0); //M1 multi_sim_arg.pacdsp[i].m1_mem.dmem_m1_offset = Get_Value(filename, core_name, "M1_MEM_OFFSET", 0); multi_sim_arg.pacdsp[i].m1_mem.dmem_m1_size = Get_Value(filename, core_name, "M1_MEM_SIZE", 0); multi_sim_arg.pacdsp[i].m1_mem.m1_rd_delay = Get_Value(filename, core_name, "M1_MEM_RD_DELAY", 0); multi_sim_arg.pacdsp[i].m1_mem.m1_wr_delay = Get_Value(filename, core_name, "M1_MEM_WR_DELAY", 0); //Res1 multi_sim_arg.pacdsp[i].res1.res1_offset = Get_Value(filename, core_name, "RES1_OFFSET", 0); multi_sim_arg.pacdsp[i].res1.res1_size = Get_Value(filename, core_name, "RES1_SIZE", 0); //L1 multi_sim_arg.pacdsp[i].l1_cache.l1_cache_type = Get_Value(filename, core_name, "L1_CACHE_LINE_TYPE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_cache_size = Get_Value(filename, core_name, "L1_CACHE_SIZE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_cache_line_size = Get_Value(filename, core_name, "L1_CACHE_LINE_SIZE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_rd_delay = Get_Value(filename, core_name, "L1_CACHE_LINE_RD_DELAY", 0); //CORE BIU multi_sim_arg.pacdsp[i].biu.biu_offset = Get_Value(filename, core_name, "BIU_OFFSET", 0); multi_sim_arg.pacdsp[i].biu.biu_size = Get_Value(filename, core_name, "BIU_SIZE", 0); multi_sim_arg.pacdsp[i].biu.biu_rd_delay = Get_Value(filename, core_name, "BIU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].biu.biu_wr_delay = Get_Value(filename, core_name, "BIU_WR_DELAY", 0); //CORE ICU multi_sim_arg.pacdsp[i].icu.icu_offset = Get_Value(filename, core_name, "ICU_OFFSET", 0); multi_sim_arg.pacdsp[i].icu.icu_size = Get_Value(filename, core_name, "ICU_SIZE", 0); multi_sim_arg.pacdsp[i].icu.icu_rd_delay = Get_Value(filename, core_name, "ICU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].icu.icu_wr_delay = Get_Value(filename, core_name, "ICU_WR_DELAY", 0); //CORE DMU multi_sim_arg.pacdsp[i].dmu.dmu_offset = Get_Value(filename, core_name, "DMU_OFFSET", 0); multi_sim_arg.pacdsp[i].dmu.dmu_size = Get_Value(filename, core_name, "DMU_SIZE", 0); multi_sim_arg.pacdsp[i].dmu.dmu_rd_delay = Get_Value(filename, core_name, "DMU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].dmu.dmu_wr_delay = Get_Value(filename, core_name, "DMU_WR_DELAY", 0); //CORE DMA multi_sim_arg.pacdsp[i].dma.dma_offset = Get_Value(filename, core_name, "DMA_OFFSET", 0); multi_sim_arg.pacdsp[i].dma.dma_size = Get_Value(filename, core_name, "DMA_SIZE", 0); multi_sim_arg.pacdsp[i].dma.dma_rd_delay = Get_Value(filename, core_name, "DMA_RD_DELAY", 0); multi_sim_arg.pacdsp[i].dma.dma_wr_delay = Get_Value(filename, core_name, "DMA_WR_DELAY", 0); //CORE Res2 multi_sim_arg.pacdsp[i].res2.res2_offset = Get_Value(filename, core_name, "RES2_OFFSET", 0); multi_sim_arg.pacdsp[i].res2.res2_size = Get_Value(filename, core_name, "RES2_SIZE", 0); } //M2 multi_sim_arg.m2_mem.dmem_m2_base = Get_Value(filename, "M2_MEM", "BASE", 0); multi_sim_arg.m2_mem.dmem_m2_size = Get_Value(filename, "M2_MEM", "SIZE", 0); multi_sim_arg.m2_mem.m2_rd_delay = Get_Value(filename, "M2_MEM", "RD_DELAY", 0); multi_sim_arg.m2_mem.m2_wr_delay = Get_Value(filename, "M2_MEM", "WR_DELAY", 0); //L2 multi_sim_arg.l2_cache.l2_cache_type = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_TYPE", 0); multi_sim_arg.l2_cache.l2_cache_size = Get_Value(filename, "L2_CACHE", "L2_CACHE_SIZE", 0); multi_sim_arg.l2_cache.l2_cache_line_size = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_SIZE", 0); multi_sim_arg.l2_cache.l2_rd_delay = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_RD_DELAY", 0); //L2 ICU multi_sim_arg.l2_icu.l2_icu_base = Get_Value(filename, "L2_ICU", "BASE", 0); multi_sim_arg.l2_icu.l2_icu_size = Get_Value(filename, "L2_ICU", "SIZE", 0); multi_sim_arg.l2_icu.l2_icu_rd_delay = Get_Value(filename, "L2_ICU", "RD_DELAY", 0); multi_sim_arg.l2_icu.l2_icu_wr_delay = Get_Value(filename, "L2_ICU", "WR_DELAY", 0); //M2 DMU multi_sim_arg.m2_dmu.m2_dmu_base = Get_Value(filename, "M2_DMU", "BASE", 0); multi_sim_arg.m2_dmu.m2_dmu_size = Get_Value(filename, "M2_DMU", "SIZE", 0); multi_sim_arg.m2_dmu.m2_dmu_rd_delay = Get_Value(filename, "M2_DMU", "RD_DELAY", 0); multi_sim_arg.m2_dmu.m2_dmu_wr_delay = Get_Value(filename, "M2_DMU", "WR_DELAY", 0); //M2 DMA multi_sim_arg.m2_dma.m2_dma_base = Get_Value(filename, "M2_DMA", "BASE", 0); multi_sim_arg.m2_dma.m2_dma_size = Get_Value(filename, "M2_DMA", "SIZE", 0); multi_sim_arg.m2_dma.m2_dma_rd_delay = Get_Value(filename, "M2_DMA", "RD_DELAY", 0); multi_sim_arg.m2_dma.m2_dma_wr_delay = Get_Value(filename, "M2_DMA", "WR_DELAY", 0); //SEM multi_sim_arg.sem.sem_base = Get_Value(filename, "SEMAPHORE", "BASE", 0); multi_sim_arg.sem.sem_size = Get_Value(filename, "SEMAPHORE", "SIZE", 0); multi_sim_arg.sem.sem_rd_delay = Get_Value(filename, "SEMAPHORE", "RD_DELAY", 0); multi_sim_arg.sem.sem_wr_delay = Get_Value(filename, "SEMAPHORE", "WR_DELAY", 0); //C2CC multi_sim_arg.c2cc.c2cc_base = Get_Value(filename, "C2CC_INTERFACE", "BASE", 0); multi_sim_arg.c2cc.c2cc_size = Get_Value(filename, "C2CC_INTERFACE", "SIZE", 0); multi_sim_arg.c2cc.c2cc_rd_delay = Get_Value(filename, "C2CC_INTERFACE", "RD_DELAY", 0); multi_sim_arg.c2cc.c2cc_wr_delay = Get_Value(filename, "C2CC_INTERFACE", "WR_DELAY", 0); //DDR multi_sim_arg.ddr_mem.ddr_memory_base = Get_Value(filename, "DDR", "BASE", 0); multi_sim_arg.ddr_mem.ddr_memory_size = Get_Value(filename, "DDR", "SIZE", 0); multi_sim_arg.ddr_mem.ddr_shm_base = Get_Value(filename, "DDR", "DDR_SHM_BASE", 0); multi_sim_arg.ddr_mem.ddr_shm_size = Get_Value(filename, "DDR", "DDR_SHM_SIZE", 0); multi_sim_arg.ddr_mem.ddr_rd_delay = Get_Value(filename, "DDR", "RD_DELAY", 0); multi_sim_arg.ddr_mem.ddr_wr_delay = Get_Value(filename, "DDR", "WR_DELAY", 0); //BIU multi_sim_arg.biu.biu_rd_delay = Get_Value(filename, "BIU", "RD_DELAY", 0); multi_sim_arg.biu.biu_wr_delay = Get_Value(filename, "BIU", "WR_DELAY", 0); //SYS_DMA multi_sim_arg.sys_dma.sys_dma_base = Get_Value(filename, "SYS_DMA", "BASE", 0); multi_sim_arg.sys_dma.sys_dma_size = Get_Value(filename, "SYS_DMA", "SIZE", 0); multi_sim_arg.sys_dma.sys_dma_rd_delay = Get_Value(filename, "SYS_DMA", "RD_DELAY", 0); multi_sim_arg.sys_dma.sys_dma_wr_delay = Get_Value(filename, "SYS_DMA", "WR_DELAY", 0); //OTHER multi_sim_arg.other.sim_time_unit = Get_Value(filename, "OTHER", "SIM_TIME_UNIT", 0); }