int Catoms2DBlock::getCWMovePivotId() { for (int j = 5; j >= 0; j--) { P2PNetworkInterface *p2pPivot = getInterface((HLattice::Direction)j); if (p2pPivot->connectedInterface) { // cout << j << ".isConnected: "; bool res = true; for (int i = 1; i < 4; i++) { int index = ((j + i)%6 + 6)%6; P2PNetworkInterface *p2pIf = getInterface((HLattice::Direction)index); if (p2pIf->connectedInterface) { // cout << index << ".false "; res = false; } else { // cout << index << ".true "; } } if (res) { Catoms2DBlock *piv = static_cast<Catoms2DBlock*>(p2pPivot->connectedInterface->hostBlock); int idDestIf = ((piv->getDirection(p2pPivot->connectedInterface) - 1)%6 + 6)%6; Cell3DPosition dest = piv->getPosition((HLattice::Direction)idDestIf); if (getWorld()->lattice->isInGrid(dest)) { // cout << "Block " << position << " wants to CW MOVEP: " << dest << endl; return p2pPivot->getConnectedBlockId(); } else { // cout << "CW Destination " << dest << " not in grid" << endl; } } } } return -1; }
bool saveTextureHost( const std::string & filename, const dp::sg::core::TextureHostSharedPtr & tih ) { // load the saver plug-in - this should be configured dp::util::UPIID piid = dp::util::UPIID(dp::util::getFileExtension( filename ).c_str(), dp::util::UPITID(UPITID_TEXTURE_SAVER, UPITID_VERSION) ); dp::util::FileFinder fileFinder( dp::util::getCurrentPath() ); fileFinder.addSearchPath( dp::util::getModulePath() ); bool retval = false; // // MMM - TODO - Update me for stereo images // { dp::util::PlugInSharedPtr plug; if ( getInterface( fileFinder, piid, plug ) ) { TextureSaverSharedPtr ts = std::static_pointer_cast<TextureSaver>(plug); retval = ts->save( tih, filename ); } } // FIXME interface needs to be released since the cleanup order (first dp::sg::core, then dp::util) causes problems upon destruction. dp::util::releaseInterface(piid); return retval; }
dp::sg::core::TextureHostSharedPtr loadTextureHost( const std::string & filename, dp::util::FileFinder const& fileFinder ) { dp::sg::core::TextureHostSharedPtr tih; dp::util::FileFinder localFF( fileFinder ); localFF.addSearchPath( dp::util::getCurrentPath() ); localFF.addSearchPath( dp::util::getModulePath() ); std::string foundFile = localFF.find( filename ); if (!foundFile.empty()) { std::string ext = dp::util::getFileExtension( filename ); dp::util::UPIID piid = dp::util::UPIID( ext.c_str(), dp::util::UPITID(UPITID_TEXTURE_LOADER, UPITID_VERSION) ); // TODO - Update me for stereo images { dp::util::PlugInSharedPtr plug; if ( getInterface( fileFinder, piid, plug ) ) { TextureLoaderSharedPtr tl = std::static_pointer_cast<TextureLoader>(plug); tih = tl->load( foundFile ); } } // FIXME interface needs to be released since the cleanup order (first dp::sg::core, then dp::util) causes problems upon destruction. dp::util::releaseInterface(piid); } return tih; }
bool saveTextureHost( const std::string & filename, const dp::sg::core::TextureHostSharedPtr & tih ) { // load the saver plug-in - this should be configured dp::util::UPIID piid = dp::util::UPIID(dp::util::getFileExtension( filename ).c_str(), dp::util::UPITID(UPITID_TEXTURE_SAVER, UPITID_VERSION) ); dp::util::PlugIn * plug = 0; std::vector<std::string> searchPaths; searchPaths.push_back( dp::util::getCurrentPath() ); searchPaths.push_back( dp::util::getModulePath() ); // // MMM - TODO - Update me for stereo images // TextureSaver * ts; if ( getInterface( searchPaths, piid, plug ) ) { ts = reinterpret_cast<TextureSaver *>(plug); } else { // signal some kind of error return false; } bool retval; // save the file retval = ts->save( tih, filename ); return retval; }
bool saveScene( std::string const& filename, dp::sg::ui::ViewStateSharedPtr const& viewState, dp::util::PlugInCallback *callback ) { bool result = false; // define a unique plug-interface ID for SceneLoader const dp::util::UPITID PITID_SCENE_SAVER(UPITID_SCENE_SAVER, UPITID_VERSION); dp::util::FileFinder fileFinder( dp::util::getCurrentPath() ); fileFinder.addSearchPath( dp::util::getModulePath() ); #if defined(DP_OS_WINDOWS) fileFinder.addSearchPath( dp::util::getModulePath( reinterpret_cast<HMODULE>(&__ImageBase) ) ); #endif dp::util::UPIID piid = dp::util::UPIID(dp::util::getFileExtension( filename ).c_str(), PITID_SCENE_SAVER); { dp::util::PlugInSharedPtr plug; if ( getInterface( fileFinder, piid, plug ) ) { SceneSaverSharedPtr ss = std::static_pointer_cast<SceneSaver>(plug); try { dp::sg::core::SceneSharedPtr scene( viewState->getScene() ); // DAR HACK Change SceneSaver interface later. result = ss->save( scene, viewState, filename ); } catch(...) // catch all others { } } } // FIXME interface needs to be released since the cleanup order (first dp::sg::core, then dp::util) causes problems upon destruction. dp::util::releaseInterface(piid); return result; }
void CoreService::ready() { _settings.beginGroup("data"); QString profileData = _settings.value("profile").toString(); QStringList leagues = _settings.value("leagues").toStringList(); _settings.endGroup(); qDebug() << leagues; getPluginManager()->loadPlugins(); qInfo() << qPrintable("Adamant Started!"); getInterface()->registerPages(); // Set page to home getInterface()->window()->setPageIndex(0); }
dp::sg::core::TextureHostSharedPtr loadTextureHost( const std::string & filename, const std::vector<std::string> &searchPaths ) { dp::sg::core::TextureHostSharedPtr tih; // appropriate search paths for the loader dll and the sample file. vector<string> binSearchPaths = searchPaths; std::string curDir = dp::util::getCurrentPath(); if ( find( binSearchPaths.begin(), binSearchPaths.end(), curDir ) == binSearchPaths.end() ) { binSearchPaths.push_back(curDir); } std::string modulePath = dp::util::getModulePath(); if ( find( binSearchPaths.begin(), binSearchPaths.end(), modulePath ) == binSearchPaths.end() ) { binSearchPaths.push_back(modulePath); } std::string ext = dp::util::getFileExtension( filename ); dp::util::UPIID piid = dp::util::UPIID( ext.c_str(), dp::util::UPITID(UPITID_TEXTURE_LOADER, UPITID_VERSION) ); dp::util::PlugIn * plug = 0; // TODO - Update me for stereo images TextureLoader * tls; if ( getInterface( binSearchPaths, piid, plug ) && dp::util::fileExists( filename ) ) { tls = reinterpret_cast<TextureLoader *>(plug); tih = tls->load( filename ); } return tih; }
std::size_t InterfaceAddress::hashCode() const { std::size_t seed = 0; boost::hash_combine(seed, getDomain()); boost::hash_combine(seed, getInterface()); return seed; }
gl::GLint Program::getInterface(gl::GLenum programInterface, gl::GLenum pname) const { checkDirty(); gl::GLint result; getInterface(programInterface, pname, &result); return result; }
int Caen785Module::acquireSingleEventMBLT() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; uint32_t nofRead; addr = conf.base_addr + CAEN785_MEB; ret = iface->readA32MBLT64(addr,data,34,&nofRead); // 455 ms //ret = iface->readA32BLT32(addr,data,34,&nofRead); // 455 ms if(!nofRead && ret && !getInterface ()->isBusError (ret)) { printf("Error %d at CAEN785_MEB readA32MBLT64\n",ret);fflush(stdout); return -1; } //printf("Read %d words\n",nofRead);fflush(stdout); return nofRead; }
// Set the interface of the component void UvmComponentWithInterface::setInterface(UvmInterface *interface) { UvmComponent* comp = getInterface(); int i; if(comp == 0) { children.append(interface); } else { i = children.indexOf(comp); children.replace(i, interface); } }
// PTHY: TODO: Can be genericized in BuildingBlocks int Catoms2DBlock::getDirection(P2PNetworkInterface *p2p) { if (!p2p) { return HLattice::Direction(0); } for (int i = 0; i < HLattice::MAX_NB_NEIGHBORS; ++i) { if (getInterface(HLattice::Direction(i)) == p2p) { return HLattice::Direction(i); } } return HLattice::Direction(0); }
void CoreService::loggedMessage(const QString &message, QtMsgType type) { QString sType; switch (type) { case QtDebugMsg: sType = "DEB"; break; case QtInfoMsg: sType = "LOG"; break; case QtWarningMsg: sType = "WAR"; break; case QtCriticalMsg: sType = "ERR"; break; case QtFatalMsg: sType = "FAT"; break; } getInterface()->window()->appendScriptOutput(message, sType); }
int Caen785Module::readStatus2() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; addr = conf.base_addr + CAEN785_STAT2; ret = iface->readA32D16(addr,&status2); if(ret != 0) printf("Error %d at CAEN785_STAT2 read\n",ret); return ret; }
frl::String ServerConnection::getServerErrorString( HRESULT error_id ) { FRL_EXCEPT_GUARD(); boost::mutex::scoped_lock guard( scope_guard ); checkIsConnect(); ComPtr<IOPCCommon> comm; getInterface( IID_IOPCCommon, comm ); LPWSTR str_tmp; comm->GetErrorString( error_id, &str_tmp ); String ret_str = similarCompatibility( str_tmp ); os::win32::com::freeMemory( str_tmp ); return ret_str; }
int Caen785Module::readInfo() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; addr = conf.base_addr + CAEN785_FIRMWARE; ret = iface->readA32D16(addr,&firmware); if(ret != 0) printf("Error %d at CAEN785_FIRMWARE read\n",ret); return ret; }
bool CCapPktRaw::Compare(CCapPktRaw * obj,int dump,double dsec){ if (pkt_len != obj->pkt_len) { if ( dump ){ printf(" ERROR len is not eq \n"); } return (false); } if ( getInterface() != obj->getInterface() ){ printf(" ERROR original packet from if=%d and cur packet from if=%d \n",getInterface(),obj->getInterface()); return (false); } CPktNsecTimeStamp t1(time_sec,time_nsec); CPktNsecTimeStamp t2(obj->time_sec,obj->time_nsec); if ( t1.diff(t2) > dsec ){ if ( dump ){ printf(" ERROR diff of 1 msec in time \n"); } return (false); } if ( memcmp(raw,obj->raw,pkt_len) == 0 ){ return (true); }else{ if ( dump ){ fprintf(stdout," ERROR buffer not the same \n"); fprintf(stdout," B1 \n"); fprintf(stdout," ---------------\n"); utl_DumpBuffer(stdout,raw,pkt_len,0); fprintf(stdout," B2 \n"); fprintf(stdout," ---------------\n"); utl_DumpBuffer(stdout,obj->raw,obj->pkt_len,0); } return (false); } }
extern "C" void RISCV_set_configuration(AttributeType *cfg) { IClass *icls; IService *iserv; Config_.clone(cfg); if (!Config_.is_dict()) { RISCV_error("Wrong configuration.", NULL); return; } AttributeType &Services = Config_["Services"]; if (Services.is_list()) { for (unsigned i = 0; i < Services.size(); i++) { icls = static_cast<IClass *>( RISCV_get_class(Services[i]["Class"].to_string())); if (icls == NULL) { RISCV_error("Class %s not found", Services[i]["Class"].to_string()); continue; } AttributeType &Instances = Services[i]["Instances"]; for (unsigned n = 0; n < Instances.size(); n++) { iserv = icls->createService(Instances[n]["Name"].to_string()); iserv->initService(&Instances[n]["Attr"]); } } } // Post initialization for (unsigned i = 0; i < listClasses_.size(); i++) { icls = static_cast<IClass *>(listClasses_[i].to_iface()); icls->postinitServices(); } RISCV_printf(getInterface(IFACE_SERVICE), 0, "%s", "\n**********************************************************\n" " RISC-V debugger\n" " Author: Sergey Khabarov - [email protected]\n" " Copyright 2016 GNSS Sensor Ltd. All right reserved.\n" "**********************************************************"); IHap *ihap; for (unsigned i = 0; i < listHap_.size(); i++) { ihap = static_cast<IHap *>(listHap_[i].to_iface()); if (ihap->getType() == HAP_ConfigDone) { ihap->hapTriggered(HAP_ConfigDone); } } }
int Caen785Module::counterReset() { AbstractInterface *iface = getInterface (); int ret; uint32_t addr; uint16_t data; // Counter reset addr = conf.base_addr + CAEN785_EVCNT_RST; data = 0x0; ret = iface->writeA32D16(addr,data); if(ret != 0) printf("Error %d at CAEN785_EVCNT_RST\n",ret); return ret; }
void launcher_class_init(as_object &obj) { // GNASH_REPORT_FUNCTION; // This is going to be the global "class"/"function" static boost::intrusive_ptr<builtin_function> cl; if (cl == NULL) { Global_as* gl = getGlobal(global); as_object* proto = getInterface(); cl = gl->createClass(&launcher_ctor, proto); // // replicate all interface to class, to be able to access // // all methods as static functions attachInterface(cl.get()); } obj.init_member("Launcher", cl.get()); }
int Caen785Module::acquireSingleEventFIFO() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; uint32_t nofRead; addr = conf.base_addr + CAEN785_MEB; ret = iface->readA32FIFO(addr,data,34,&nofRead); // 527 ms if(ret != 0) { printf("Error %d at CAEN785_MEB readA32MBLT64\n",ret); return -1; } return nofRead; }
int Caen785Module::acquireSingleEvent() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; int i = 0; addr = conf.base_addr + CAEN785_MEB; while(i < 34) { ret = iface->readA32D32(addr,&data[i]); if(ret != 0) printf("Error %d at CAEN785_MEB read %d\n",ret,i); i++; } return 34; }
bool BaseEvents::loadFromXml() { std::string scriptsName = getScriptBaseName(); if(m_loaded) { std::clog << "[Error - BaseEvents::loadFromXml] " << scriptsName << " interface already loaded!" << std::endl; return false; } std::string path = getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/")); if(!getInterface().loadDirectory(path, false, true)) std::clog << "[Warning - BaseEvents::loadFromXml] Cannot load " << path << std::endl; #ifdef _MULTIPLATFORM76 path = getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/" + scriptsName + ".xml")); #else path = getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/" + ITEMS_PATH + "/" + scriptsName + ".xml")); #endif xmlDocPtr doc = xmlParseFile(path.c_str()); if(!doc) { std::clog << "[Warning - BaseEvents::loadFromXml] Cannot open " << path << " file." << std::endl; std::clog << getLastXMLError() << std::endl; return false; } xmlNodePtr root = xmlDocGetRootElement(doc); if(xmlStrcmp(root->name, (const xmlChar*)scriptsName.c_str())) { std::clog << "[Error - BaseEvents::loadFromXml] Malformed " << path << " file." << std::endl; xmlFreeDoc(doc); return false; } path = getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/")); for(xmlNodePtr p = root->children; p; p = p->next) parseEventNode(p, path, false); xmlFreeDoc(doc); m_loaded = true; return m_loaded; }
bool saveScene( std::string const& filename, dp::sg::ui::ViewStateSharedPtr const& viewState, dp::util::PlugInCallback *callback ) { bool result = false; // define a unique plug-interface ID for SceneLoader const dp::util::UPITID PITID_SCENE_SAVER(UPITID_SCENE_SAVER, UPITID_VERSION); vector<string> searchPaths; searchPaths.push_back( dp::util::getCurrentPath() ); std::string modulePath = dp::util::getModulePath(); if ( std::find( searchPaths.begin(), searchPaths.end(), modulePath ) == searchPaths.end() ) { searchPaths.push_back( modulePath ); } #if defined(DP_OS_WINDOWS) modulePath = dp::util::getModulePath( reinterpret_cast<HMODULE>(&__ImageBase) ); if ( std::find( searchPaths.begin(), searchPaths.end(), modulePath ) == searchPaths.end() ) { searchPaths.push_back( modulePath ); } #endif dp::util::UPIID piid = dp::util::UPIID(dp::util::getFileExtension( filename ).c_str(), PITID_SCENE_SAVER); dp::util::PlugIn * plug; if ( getInterface( searchPaths, piid, plug ) ) { SceneSaver *ss = reinterpret_cast<SceneSaver *>(plug); try { dp::sg::core::SceneSharedPtr scene( viewState->getScene() ); // DAR HACK Change SceneSaver interface later. result = ss->save( scene, viewState, filename ); } catch(...) // catch all others { } } return result; }
void SocketHelper::loadJavaMethod() { void *libm_handle = NULL; JavaMethodInterface *(*getInterface)(void); libm_handle = dlopen("libnotify.so", RTLD_NOW); if (libm_handle == NULL) { LOGE("%s: dlopen failed: %s", __func__, dlerror()); return; } getInterface = (JavaMethodInterface *(*)(void)) dlsym(libm_handle, "getJavaMethodInterface"); if (getInterface == NULL) { LOGE("%s: dlsym failed: %s", __func__, dlerror()); dlclose(libm_handle); return; } javaMethodInterface = getInterface(); javaMethodInterface->initJavaVM(javaVM); javaMethodInterface->setCallback(callbackObj); }
int Caen785Module::dataReset() { AbstractInterface *iface = getInterface (); int ret; uint32_t addr; uint16_t data; // Data reset addr = conf.base_addr + CAEN785_BIT_SET2; data = (1 << 2); ret = iface->writeA32D16(addr,data); if(ret != 0) printf("Error %d at CAEN785_BIT_SET2\n",ret); addr = conf.base_addr + CAEN785_BIT_CLR2; data = (1 << 2); ret = iface->writeA32D16(addr,data); if(ret != 0) printf("Error %d at CAEN785_BIT_SET2\n",ret); return ret; }
bool BaseEvents::loadFromXml() { std::string scriptsName = getScriptBaseName(); if(m_loaded) { std::clog << "[Error - BaseEvents::loadFromXml] " << scriptsName << " interface already loaded!" << std::endl; return false; } if(!getInterface().loadDirectory(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/")))) std::clog << "[Warning - BaseEvents::loadFromXml] Cannot load " << scriptsName << "/lib/" << std::endl; xmlDocPtr doc = xmlParseFile(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/" + scriptsName + ".xml")).c_str()); if(!doc) { std::clog << "[Warning - BaseEvents::loadFromXml] Cannot open " << scriptsName << ".xml file." << std::endl; std::clog << getLastXMLError() << std::endl; return false; } xmlNodePtr p, root = xmlDocGetRootElement(doc); if(xmlStrcmp(root->name,(const xmlChar*)scriptsName.c_str())) { std::clog << "[Error - BaseEvents::loadFromXml] Malformed " << scriptsName << ".xml file." << std::endl; xmlFreeDoc(doc); return false; } std::string scriptsPath = getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/")); p = root->children; while(p) { parseEventNode(p, scriptsPath, false); p = p->next; } xmlFreeDoc(doc); m_loaded = true; return m_loaded; }
std::vector< String > ServerConnection::getItemsList( OPCBROWSEFILTER type, const String& from_branch, const String& name_filter, const String& vendor_filter ) { FRL_EXCEPT_GUARD(); checkIsConnect(); ComPtr<IOPCBrowse> br_ptr; getInterface( IID_IOPCBrowse, br_ptr ); LPWSTR item_id = util::duplicateString( unicodeCompatibility( from_branch ) ); LPWSTR cont_pint = NULL; LPWSTR name_filter_str = util::duplicateString( unicodeCompatibility( name_filter ) ); LPWSTR vendor_filter_str = util::duplicateString( unicodeCompatibility( vendor_filter ) ); DWORD *property_ids = os::win32::com::allocMemory<DWORD>(); DWORD count; OPCBROWSEELEMENT *browse_elements; BOOL m = FALSE; HRESULT val = br_ptr->Browse( item_id, &cont_pint, 0, type, name_filter_str, vendor_filter_str, FALSE, FALSE, 0, property_ids, &m, &count, &browse_elements ); if( FAILED( val ) ) { os::win32::com::freeMemory( property_ids ); os::win32::com::freeMemory( item_id ); os::win32::com::freeMemory( name_filter_str ); os::win32::com::freeMemory( vendor_filter_str ); FRL_THROW_OPC( val ); } std::vector< String > ret_vec( count ); for( DWORD i = 0; i < count; ++i ) { ret_vec[i] = similarCompatibility( browse_elements[i].szName ); os::win32::com::freeMemory( browse_elements[i].szName ); os::win32::com::freeMemory( browse_elements[i].szItemID ); os::win32::com::freeMemory( browse_elements[i].ItemProperties.pItemProperties ); } os::win32::com::freeMemory( property_ids ); os::win32::com::freeMemory( item_id ); os::win32::com::freeMemory( name_filter_str ); os::win32::com::freeMemory( vendor_filter_str ); os::win32::com::freeMemory( browse_elements ); return ret_vec; }
P2PNetworkInterface* Catoms2DBlock::getNextInterface(RelativeDirection::Direction dir, P2PNetworkInterface *p2p, bool connected) { P2PNetworkInterface *next = NULL; int d = getDirection(p2p); do { if (dir == RelativeDirection::CW) { if (d == HLattice::Right) { d= HLattice::BottomRight; } else { d--; } } else { d = (d+1)%HLattice::MAX_NB_NEIGHBORS; } next = getInterface((HLattice::Direction)d); if (!connected) { break; } } while((next->connectedInterface == NULL) && (next != p2p)); return next; }
int Caen785Module::readStatus() { AbstractInterface *iface = getInterface (); int ret = 0; uint32_t addr; uint16_t data; addr = conf.base_addr + CAEN785_BIT_SET1; ret = iface->readA32D16(addr,&bit1); if(ret != 0) printf("Error %d at CAEN785_BIT_SET1 read\n",ret); addr = conf.base_addr + CAEN785_BIT_SET2; ret = iface->readA32D16(addr,&bit2); if(ret != 0) printf("Error %d at CAEN785_BIT_SET2 read\n",ret); ret = readStatus1(); ret = readStatus2(); addr = conf.base_addr + CAEN785_EVCNT_H; ret = iface->readA32D16(addr,&data); if(ret != 0) printf("Error %d at CAEN785_EVCNT_H read\n",ret); evcntr = 0x0 | (data << 16); addr = conf.base_addr + CAEN785_EVCNT_L; ret = iface->readA32D16(addr,&data); if(ret != 0) printf("Error %d at CAEN785_EVCNT_L read\n",ret); evcntr |= data; // printf("bit1 %08x\n",bit1); // printf("bit2 %08x\n",bit2); // printf("status1 %08x\n",status1); // printf("status2 %08x\n",status2); // printf("CAEN785_EVCNT_H %08x\n",data); // printf("CAEN785_EVCNT_L %08x\n",data); return ret; }