/* save new ve_private & ve_root in config */ int VEObj::updateConfig(const char *param, const char *data) { int err, rc = 0; struct vzctl_config *cfg; cfg = vzctl2_conf_open(confPath().c_str(), VZCTL_CONF_SKIP_GLOBAL, &err); if (err) return putErr(MIG_ERR_VZCTL, "vzctl2_conf_open(%s) error: %s", confPath().c_str(), vzctl2_get_last_error()); if (vzctl2_conf_set_param(cfg, param, data)){ rc = putErr(MIG_ERR_VZCTL, "vzctl2_conf_set_param(%s) error: %s", param, vzctl2_get_last_error()); goto cleanup; } if (vzctl2_conf_save(cfg, confPath().c_str())) { rc = putErr(MIG_ERR_VZCTL, "vzctl2_conf_save() error: %s", vzctl2_get_last_error()); goto cleanup; } cleanup: vzctl2_conf_close(cfg); return rc; }
RobotOnPlane::RobotOnPlane(ConfigurationManager& params) : Robot(params) , m_color(ConfigurationHelper::getString(configurationManager(), confPath() + "color")) { if (!m_color.isValid()) { ConfigurationHelper::throwUserConfigError(confPath() + "color", configurationManager().getValue(confPath() + "color"), "The value of the \"color\" parameter is not a valid color"); } }
/* For new layout only After rsync we have 2 config on destination node: valid, in /etc/ and invalid (rsynced), in private area. Rewrote config in private by valid config content, remove config from etc and 'register' VE. */ int VEObj::veRegister() { int rc; char tmpfile[PATH_MAX + 1]; struct stat st; tmpfile[0] = 0; if (stat(confRealPath().c_str(), &st) == 0) { /* to save origin config (https://jira.sw.ru/browse/PSBM-10260) */ snprintf(tmpfile, sizeof(tmpfile), "%s.XXXXXX", confRealPath().c_str()); mktemp(tmpfile); if (rename(confRealPath().c_str(), tmpfile)) return putErr(MIG_ERR_SYSTEM, "rename(%s, %s) : %m", confRealPath().c_str(), tmpfile); } /* rewrite private config */ if ((rc = move_file(confRealPath().c_str(), confPath().c_str()))) { if (tmpfile[0]) rename(tmpfile, confRealPath().c_str()); return rc; } if (tmpfile[0]) unlink(tmpfile); /* vzctl register for new layout VE */ return registration(); }
KheperaMotor::KheperaMotor(ConfigurationManager& params) : AbstractControllerOutput(params) , m_kheperaResource(ConfigurationHelper::getString(configurationManager(), confPath() + "khepera")) { // Declaring the resources that are needed here addNotifiedResource(m_kheperaResource); }
void VEObj::clean() { int i; string path; for (i = 0; actionScripts[i]; i++) { path = scriptPath(actionScripts[i]); unlink(path.c_str()); } // clean config ::unlink(confPath().c_str()); }
Component::Component(ConfigurationManager& params) : ResourceAccessor(params, params.getConfigurationNodeForCurrentComponent()) , m_type(params.getTypeForCurrentComponent()) , m_configurationNode(params.getConfigurationNodeForCurrentComponent()) , m_prefix(params.getPrefixForCurrentComponent()) { // Telling the ConfigurationManager that the object for the group in prefix is about // to be created m_confManager->setComponentFromGroupStatusToCreating(m_prefix, this); // Declaring self as a resource of ours declareResource(ConfigurationNode::separateLastElement(confPath()).element, this); }
Khepera::Khepera(World* world, SharedDataWrapper<Shared> shared, ConfigurationManager& params) : RobotOnPlane(params) , PhyKhepera(world, shared) { setName(m_initialName); setMatrix(m_initialTm); doKinematicSimulation(ConfigurationHelper::getBool(configurationManager(), confPath() + "kinematicRobot")); const bool enableWheels = ConfigurationHelper::getBool(configurationManager(), confPath() + "enableWheels"); const bool enableProximityIR = ConfigurationHelper::getBool(configurationManager(), confPath() + "enableProximityIR"); const bool drawProximityIR = ConfigurationHelper::getBool(configurationManager(), confPath() + "drawProximityIR"); const bool drawIRRays = ConfigurationHelper::getBool(configurationManager(), confPath() + "drawIRRays"); const bool drawIRRaysRange = ConfigurationHelper::getBool(configurationManager(), confPath() + "drawIRRaysRange"); wheelsController()->setEnabled(enableWheels); proximityIRSensorController()->setEnabled(enableProximityIR); setProximityIRSensorsGraphicalProperties(drawProximityIR, drawIRRays, drawIRRaysRange); setDrawFrontMarker(true); // Setting the color of the robot setColor(configuredRobotColor()); }
Robot::Robot(ConfigurationManager& params) : Component(params) , m_initialName(extractRobotName(configurationManager(), confPath())) , m_initialTm(extractRobotTranformation(configurationManager(), confPath())) { }
void KheperaWheelVelocityMotor::resourceChanged(QString name, Component*, ResourceChangeType changeType) { if (name != m_kheperaResource) { Logger::info("Unknown resource " + name + " for KheperaWheelVelocityMotor in configuration path \"" + confPath() + "\""); return; } if ((changeType == ResourceDeleted) && (changeType == ResourceDeclaredAsNull)) { m_robot = nullptr; } else { m_robot = getResource<PhyKhepera>(); } }