/* * Driver initialisation at IOC startup (ecAsynInit) * * path - location of Unix Domain Socket, must match the scanner's * max_message - maximum size of messages between scanner and ioc * This must be able to accommodate the configuration * of the chain that is transferred from the scanner to * the ioc. */ static void makePorts(char * path, int max_message) { ENGINE_USER * usr = (ENGINE_USER *)callocMustSucceed (1, sizeof(ENGINE_USER), "can't allocate socket engine private data"); ellInit(&usr->ports); usr->master = new ecMaster((char *)"MASTER0"); ellAdd(&usr->ports, &usr->master->node); usr->config_ready = rtMessageQueueCreate(1, sizeof(int)); // TODO - no assert for runtime errors, so what should we use to throw? assert(usr->config_ready != NULL); usr->config = (EC_CONFIG *)callocMustSucceed (1, sizeof(EC_CONFIG), "can't allocate chain config lists"); usr->writeq = rtMessageQueueCreate(1, max_message); assert(usr->writeq != NULL); ENGINE * engine = new_engine(max_message); engine->path = strdup(path); engine->connect = client_connect; engine->on_connect = receive_config_on_connect; engine->send_message = ioc_send; engine->receive_message = ioc_receive; engine->usr = usr; engine_start(engine); new_timer(1000000000, usr->writeq, 0, MSG_HEARTBEAT); int ack; rtMessageQueueReceive(usr->config_ready, &ack, sizeof(int)); }
/** * \class ds::App */ App::App(const RootList& roots) : mInitializer(getAppPath().generic_string()) , mShowConsole(false) , mEngineSettings() , mEngineData(mEngineSettings) , mEngine(new_engine(*this, mEngineSettings, mEngineData, roots)) , mCtrlDown(false) , mSecondMouseDown(false) , mQKeyEnabled(true) , mEscKeyEnabled(true) , mArrowKeyCameraStep(mEngineSettings.getFloat("camera:arrow_keys", 0, -1.0f)) , mArrowKeyCameraControl(mArrowKeyCameraStep > 0.025f) { add_dll_path(); // Initialize each sprite type with a unique blob handler for network communication. mEngine.installSprite( [](ds::BlobRegistry& r){ds::ui::Sprite::installAsServer(r);}, [](ds::BlobRegistry& r){ds::ui::Sprite::installAsClient(r);}); mEngine.installSprite( [](ds::BlobRegistry& r){ds::ui::Gradient::installAsServer(r);}, [](ds::BlobRegistry& r){ds::ui::Gradient::installAsClient(r);}); mEngine.installSprite( [](ds::BlobRegistry& r){ds::ui::Image::installAsServer(r);}, [](ds::BlobRegistry& r){ds::ui::Image::installAsClient(r);}); mEngine.installSprite( [](ds::BlobRegistry& r){ds::ui::NinePatch::installAsServer(r);}, [](ds::BlobRegistry& r){ds::ui::NinePatch::installAsClient(r);}); mEngine.installSprite( [](ds::BlobRegistry& r){ds::ui::Text::installAsServer(r);}, [](ds::BlobRegistry& r){ds::ui::Text::installAsClient(r);}); mEngine.installSprite( [](ds::BlobRegistry& r){EngineStatsView::installAsServer(r);}, [](ds::BlobRegistry& r){EngineStatsView::installAsClient(r);}); // Initialize the engine image generator typess. ds::ui::ImageArc::install(mEngine.getImageRegistry()); ds::ui::ImageFile::install(mEngine.getImageRegistry()); ds::ui::ImageGlsl::install(mEngine.getImageRegistry()); ds::ui::ImageResource::install(mEngine.getImageRegistry()); // Install the framework services mEngine.addService(ds::glsl::IMAGE_SERVICE, *(new ds::glsl::ImageService(mEngine))); mEngine.addService(ds::MESH_CACHE_SERVICE_NAME, *(new ds::MeshCacheService())); if (mArrowKeyCameraControl) { // Currently this is necessary for the keyboard commands // that change the screen rect. I don't understand things // well enough to know why this is a problem or what turning // it off could be doing, but everything LOOKS fine. mEngine.setToUserCamera(); } // Verify that the application has included the framework resources. try { ci::DataSourceRef ds = loadResource(RES_ARC_DROPSHADOW); } catch (std::exception&) { std::cout << "ERROR Failed to load framework resource -- did you include FrameworkResources.rc in your application project?" << std::endl; } // Run all the statically-created initialization code. std::vector<std::function<void(ds::Engine&)>>& startups = get_startups(); for (auto it=startups.begin(), end=startups.end(); it!=end; ++it) { if (*it) (*it)(mEngine); } startups.clear(); }