void ShellSurface::setFullscreen() { m_nextType = Type::Toplevel; m_toplevel.fullscreen = true; m_toplevel.maximized = false; Output *output = selectOutput(); QRect rect = output->geometry(); Debug::debug("Fullscrening surface '{}' on output '{}' with rect {}", surface(), output, rect); sendConfigure(rect.width(), rect.height()); }
void CmfSaver::_writeFloatInRange (Output &output, float v, float min, float range) { if (range > EPSILON) { float v2 = (((v - min) / range) * 65535 + 0.5f); if (v2 < 0 || v2 > 65536) throw Error("Internal error: Value %f is outsize of [%f, %f]", v, min, min + range); output.writeBinaryWord((word)v2); } else output.writeBinaryWord(0); }
void print_method(Output& out, const Func* func) { auto const finfo = find_func_info(func); out.fmtln(".method{} {}({}) {{", opt_attrs(AttrContext::Func, func->attrs()), func->name()->data(), func_param_list(finfo)); indented(out, [&] { print_func_directives(out, func); print_func_body(out, finfo); }); out.fmtln("}}"); }
// ----------------------------------------- // tests // ----------------------------------------- TEST(ExtendedKalmanFilterTest, initialization) { ExtendedKalmanFilter ekf; // check setting required params EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "STM missing" ekf.setStateTransitionModel(f); EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "Jacobian of STM missing" ekf.setJacobianOfStateTransitionModel(df); EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "OM missing" ekf.setObservationModel(h); EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "Jacobian of OM missing" ekf.setJacobianOfObservationModel(dh); EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "PNC missing" MatrixXd Q(1,1); Q << 0.1; ekf.setProcessNoiseCovariance(Q); EXPECT_THROW(ekf.validate(), IEstimator::estimator_error); // "MNC missing" MatrixXd R(1,1); R << 10; ekf.setMeasurementNoiseCovariance(R); EXPECT_NO_THROW(ekf.validate()); // all required params given // check setting optional params // optional params doesn't set new sizes MatrixXd P0_f(2,2); P0_f << 1, 0, 0, 1; ekf.setInitialErrorCovariance(P0_f); EXPECT_NO_THROW(ekf.validate()); EXPECT_EQ(ekf.getState().size(), 1); VectorXd x_f(2); x_f << 0,1; ekf.setInitialState(x_f); EXPECT_NO_THROW(ekf.validate()); EXPECT_NE(ekf.getState().size(), 2); // required param Q sets new size of x and out MatrixXd Q2(2,2); Q2 << 0.1, 0, 0, 0.1; ekf.setProcessNoiseCovariance(Q2); EXPECT_NO_THROW(ekf.validate()); EXPECT_EQ(ekf.getState().size(), 2); EXPECT_EQ(ekf.getLastEstimate().size(), 2); // check initialization of output Output out = ekf.getLastEstimate(); OutputValue defaultOutVal; EXPECT_GT(out.size(), 0); EXPECT_DOUBLE_EQ(out.getValue(), defaultOutVal.getValue()); // check setting the control input InputValue ctrl(0); Input in_ctrl(ctrl); EXPECT_THROW(ekf.setControlInput(in_ctrl), length_error); ekf.setControlInputSize(1); EXPECT_NO_THROW(ekf.setControlInput(in_ctrl)); }
bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw) { const PositionAttitudeTransform& transform = static_cast<const PositionAttitudeTransform&>(obj); fw.indent()<<"position "<<transform.getPosition()<<std::endl; fw.indent()<<"attitude "<<transform.getAttitude()<<std::endl; fw.indent()<<"scale "<<transform.getScale()<<std::endl; fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl; return true; }
void print_cls_inheritance_list(Output& out, const PreClass* cls) { if (!cls->parent()->empty()) { out.fmt(" extends {}", cls->parent()); } if (!cls->interfaces().empty()) { out.fmt(" implements ("); for (auto i = uint32_t{}; i < cls->interfaces().size(); ++i) { out.fmt("{}{}", i != 0 ? " " : "", cls->interfaces()[i].get()); } out.fmt(")"); } }
bool TexGenNode_writeLocalData(const Object& obj, Output& fw) { const TexGenNode& texGenNode = static_cast<const TexGenNode&>(obj); fw.indent()<<"TextureUnit "<<texGenNode.getTextureUnit()<<std::endl; if (texGenNode.getTexGen()) { fw.writeObject(*texGenNode.getTexGen()); } return true; }
bool FrontFace_writeLocalData(const Object &obj, Output &fw) { const FrontFace &frontface = static_cast<const FrontFace&>(obj); switch (frontface.getMode()) { case (FrontFace::CLOCKWISE): fw.indent() << "mode CLOCKWISE" << std::endl; break; case (FrontFace::COUNTER_CLOCKWISE): fw.indent() << "mode COUNTER_CLOCKWISE" << std::endl; break; } return true; }
bool VisibilityGroup_writeLocalData(const Object& obj, Output& fw) { const VisibilityGroup& vg = static_cast<const VisibilityGroup&>(obj); fw.indent()<<"volumeIntersectionMask 0x"<<std::hex<<vg.getVolumeIntersectionMask()<<std::dec<<std::endl; fw.indent()<<"segmentLength "<<vg.getSegmentLength()<<std::endl; fw.indent()<<"visibilityVolume" <<std::endl; fw.moveIn(); fw.writeObject(*vg.getVisibilityVolume()); fw.moveOut(); return true; }
/* Set an output's next value to the value of the sensor */ void action_set_output(int pin, int value, void *arg) { Output *out = (Output *)arg; out->setValue(value); DEBUG3_PRINT("set_output: pin-"); DEBUG3_PRINT(pin); DEBUG3_PRINT(" value-"); DEBUG3_PRINT(value); DEBUG3_PRINT(" outpin-"); DEBUG3_PRINT(out->_value); DEBUG3_PRINT("\n"); }
bool Geode_writeLocalData(const osg::Object& obj, Output& fw) { const Geode& geode = static_cast<const Geode&>(obj); fw.indent() << "num_drawables " << geode.getNumDrawables() << std::endl; for(unsigned int i=0;i<geode.getNumDrawables();++i) { fw.writeObject(*geode.getDrawable(i)); } return true; }
void print_cls_used_traits(Output& out, const PreClass* cls) { auto& traits = cls->usedTraits(); if (traits.empty()) return; out.indent(); out.fmt(".use"); for (auto i = uint32_t{0}; i < traits.size(); ++i) { out.fmt(" {}", traits[i].get()); } auto& precRules = cls->traitPrecRules(); auto& aliasRules = cls->traitAliasRules(); if (precRules.empty() && aliasRules.empty()) { out.fmt(";"); out.nl(); return; } out.fmt(" {{"); out.nl(); indented(out, [&] { for (auto& prec : precRules) { out.fmtln("{}::{} insteadof{};", prec.selectedTraitName()->data(), prec.methodName()->data(), [&]() -> std::string { auto ret = std::string{}; for (auto& name : prec.otherTraitNames()) { ret += folly::format(" {}", name.get()).str(); } return ret; }() ); } for (auto& alias : aliasRules) { out.fmtln("{}{} as{}{};", alias.traitName()->empty() ? std::string{} : folly::format("{}::", alias.traitName()).str(), alias.origMethodName()->data(), opt_attrs(AttrContext::TraitImport, alias.modifiers()), alias.newMethodName() != alias.origMethodName() ? std::string(" ") + alias.newMethodName()->data() : std::string{} ); } }); out.fmtln("}}"); }
RefTargetHandle Output::Clone(RemapDir &remap) { Output *mnew = new Output(); *((MtlBase*)mnew) = *((MtlBase*)this); // copy superclass stuff mnew->ReplaceReference(1,remap.CloneRef(texout)); mnew->ivalid.SetEmpty(); for (int i = 0; i<NSUBTEX; i++) { mnew->subTex[i] = NULL; if (subTex[i]) mnew->ReplaceReference(i,remap.CloneRef(subTex[i])); mnew->mapOn[i] = mapOn[i]; } BaseClone(this, mnew, remap); return (RefTargetHandle)mnew; }
void Dashboard::toggle(Seat *seat) { if (seat->pointer()->isGrabActive()) { return; } m_visible = !m_visible; Output *output = m_shell->selectPrimaryOutput(); View *wsv = workspaceViewForOutput(this, output); Transform tr; tr.translate(m_visible ? 0 : -output->width(), m_visible ? 0 : output->height()); wsv->setTransform(tr, true); }
void ProfilingSystem::_printCounterData (const Record::Data &data, Output &output) { if (data.count == 0) { output.printf("-\t0\t\t\t"); return; } float avg_value = (float)data.value / data.count; // To avoid platform-specific code qwords were casted to doubles double sigma_sq = data.square_sum / data.count - avg_value * avg_value; output.printf("%0.0lf\t%0.0lf\t%0.1f\t%0.1lf\t%0.0lf", (double)data.value, (double)data.count, avg_value, sqrt(sigma_sq), (double)data.max_value); }
bool AnimationManagerBase_writeLocalData(const osgAnimation::AnimationManagerBase &manager, Output &fw) { const osgAnimation::AnimationList &animList = manager.getAnimationList(); fw.indent() << "num_animations " << animList.size() << std::endl; for (osgAnimation::AnimationList::const_iterator it = animList.begin(); it != animList.end(); ++it) { if (!fw.writeObject(**it)) osg::notify(osg::WARN) << "Warning: can't write an animation object" << std::endl; } return true; }
int main(int argc, char *argv[]) { Fraction rate(1, 10); SharedPtr<System> system = new System("Simulation Time System"); Group* group = new Group("Simulation Time Group"); group->setSampleTime(rate); system->setNode(group); SimulationTime* simulationTime = new SimulationTime("Simulation Time"); group->addChild(simulationTime); Output* output = new Output("Simulation Time Output"); group->addChild(output); SharedPtr<CollectOutputCallback> simTimeCallback = new CollectOutputCallback; output->setCallback(simTimeCallback); if (!group->connect(simulationTime->getPort("output"), output->getPort("input"))) { std::cout << "Could not connect ports" << std::endl; return EXIT_FAILURE; } if (!system->init()) { std::cout << "Could not initialize the system" << std::endl; return EXIT_FAILURE; } system->simulate(10); Vector errors(simTimeCallback->values.size()); for (unsigned i = 0; i < simTimeCallback->values.size(); ++i) { errors(i) = simTimeCallback->values[i] - i*rate.getRealValue(); } real_type expectedRoundoff; expectedRoundoff = Limits<real_type>::epsilon()/rate.getRealValue(); real_type error = normInf(errors); if (expectedRoundoff < error) { std::cerr << "Maximum simulation time error " << error << " exceeds limit of expected roundoff " << expectedRoundoff << std::endl; return EXIT_FAILURE; } std::cout << "Maximum simulation time error " << error << " passes limit of expected roundoff " << expectedRoundoff << std::endl; return EXIT_SUCCESS; }
//output of one character with return code true/false for success/failure bool print( char ch) { if ((unsigned char)ch > 127) { if (!output.print( ch)) return false; } else switch (mode) { case Ident: if (!output.print( ch)) return false; break; case Uppercase: if (!output.print( toupper(ch))) return false; break; case Lowercase: if (!output.print( tolower(ch))) return false; break; } return true; }
void print_method(Output& out, const Func* func) { auto const finfo = find_func_info(func); out.fmtln(".method{} {}{}({}){}{{", opt_attrs(AttrContext::Func, func->attrs(), &func->userAttributes()), opt_type_info(func->returnUserType(), func->returnTypeConstraint()), func->name(), func_param_list(finfo), func_flag_list(finfo)); indented(out, [&] { print_func_directives(out, finfo); print_func_body(out, finfo); }); out.fmtln("}}"); }
void print_func_directives(Output& out, const FuncInfo& finfo) { const Func* func = finfo.func; if (auto const niters = func->numIterators()) { out.fmtln(".numiters {};", niters); } if (func->numNamedLocals() > func->numParams()) { std::vector<std::string> locals; for (int i = func->numParams(); i < func->numNamedLocals(); i++) { locals.push_back(loc_name(finfo, i)); } out.fmtln(".declvars {};", folly::join(" ", locals)); } }
// ----------------------------------------- // tests // ----------------------------------------- TEST(KalmanFilterTest, initializationAndValidation) { KalmanFilter kf; // check setting required params EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "STM missing" MatrixXd A_f(2,1); A_f << 1, 0; kf.setStateTransitionModel(A_f); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "OM missing" MatrixXd H(1,2); H << 1,0; kf.setObservationModel(H); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "PNC missing" MatrixXd Q(2,2); Q << 0.1,0,0,0.1; kf.setProcessNoiseCovariance(Q); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "MNC missing" MatrixXd R(1,1); R << 10; kf.setMeasurementNoiseCovariance(R); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "STM invalid size" MatrixXd A(2,2); A << 1,0,0,1; kf.setStateTransitionModel(A); EXPECT_NO_THROW(kf.validate()); // all required params given MatrixXd R_f(2,1); R_f << 10,1; kf.setMeasurementNoiseCovariance(R_f); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "MNC invalid size" kf.setMeasurementNoiseCovariance(R); MatrixXd H_f(3,1); H_f << 1,0,2; kf.setObservationModel(H_f); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "OM invalid size" kf.setObservationModel(H); // check setting optional params MatrixXd B_f(1,1); B_f << 0; kf.setControlInputModel(B_f); EXPECT_THROW(kf.validate(), IEstimator::estimator_error); // "CIM invalid size" MatrixXd B(2,1); B << 0,0; kf.setControlInputModel(B); EXPECT_NO_THROW(kf.validate()); VectorXd x(2); x << 0,1; kf.setInitialState(x); EXPECT_NO_THROW(kf.validate()); // check initialization of output Output out = kf.getLastEstimate(); OutputValue defaultOutVal; EXPECT_GT(out.size(), 0); EXPECT_DOUBLE_EQ(out.getValue(), defaultOutVal.getValue()); }
bool EllipsoidModel_writeLocalData(const Object& obj, Output& fw) { const EllipsoidModel& em = static_cast<const EllipsoidModel&>(obj); int prec = fw.precision(); fw.precision(15); fw.indent()<<"RadiusEquator "<<em.getRadiusEquator()<<std::endl; fw.indent()<<"RadiusPolar "<<em.getRadiusPolar()<<std::endl; fw.precision(prec); return true; }
bool Object_writeLocalData(const Object& obj, Output& fw) { switch(obj.getDataVariance()) { case(osg::Object::STATIC): fw.indent() << "DataVariance STATIC" << std::endl;break; case(osg::Object::DYNAMIC): fw.indent() << "DataVariance DYNAMIC" << std::endl;break; case(osg::Object::UNSPECIFIED): break; // fw.indent() << "DataVariance UNSPECIFIED" << std::endl;break; } if (!obj.getName().empty()) fw.indent() << "name "<<fw.wrapString(obj.getName())<< std::endl; if (obj.getUserData()) { const Object* object = dynamic_cast<const Object*>(obj.getUserData()); if (object) { fw.indent() << "UserData {"<< std::endl; fw.moveIn(); fw.writeObject(*object); fw.moveOut(); fw.indent() << "}"<< std::endl; } } return true; }
bool AutoTransform_writeLocalData(const Object& obj, Output& fw) { const AutoTransform& transform = static_cast<const AutoTransform&>(obj); fw.indent()<<"position "<<transform.getPosition()<<std::endl; fw.indent()<<"rotation "<<transform.getRotation()<<std::endl; fw.indent()<<"scale "<<transform.getScale()<<std::endl; if (transform.getMinimumScale()>0.0) fw.indent()<<"minimumScale "<<transform.getMinimumScale()<<std::endl; if (transform.getMaximumScale()<FLT_MAX) fw.indent()<<"maximumScale "<<transform.getMaximumScale()<<std::endl; fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl; fw.indent()<<"autoUpdateEyeMovementTolerance "<<transform.getAutoUpdateEyeMovementTolerance()<<std::endl; fw.indent()<<"autoRotateMode "; switch(transform.getAutoRotateMode()) { case(osg::AutoTransform::ROTATE_TO_SCREEN): fw<<"ROTATE_TO_SCREEN"<<std::endl; break; case(osg::AutoTransform::ROTATE_TO_CAMERA): fw<<"ROTATE_TO_CAMERA"<<std::endl; break; case(osg::AutoTransform::NO_ROTATION): default: fw<<"NO_ROTATION"<<std::endl; break; } fw.indent()<<"autoScaleToScreen "<<(transform.getAutoScaleToScreen()?"TRUE":"FALSE")<<std::endl; if (transform.getAutoScaleTransitionWidthRatio()!=0.25) { fw.indent()<<"autoScaleTransitionWidthRatio "<<transform.getAutoScaleTransitionWidthRatio()<<std::endl; } return true; }
virtual bool set_path(Output& output, const char* path, bert::Value* val) { if(val->string_p()) { output.ok("value"); if(shared_.config.import(path, val->string())) { output.e().write_atom("ok"); } else { output.e().write_atom("unknown_key"); } } else { output.error("format"); } return true; }
bool Group_writeLocalData(const Object &obj, Output &fw) { const Group &group = static_cast<const Group&>(obj); if (group.getNumChildren() != 0) fw.indent() << "num_children " << group.getNumChildren() << std::endl; for (unsigned int i = 0; i < group.getNumChildren(); ++i) { fw.writeObject(*group.getChild(i)); } return true; }
void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Output const& output) { boost::ignore_unused(caseid, g1, g2, output); #if defined(TEST_WITH_SVG) { typedef typename bg::coordinate_type<G1>::type coordinate_type; typedef typename bg::point_type<G1>::type point_type; bool const ccw = bg::point_order<G1>::value == bg::counterclockwise || bg::point_order<G2>::value == bg::counterclockwise; bool const open = bg::closure<G1>::value == bg::open || bg::closure<G2>::value == bg::open; std::ostringstream filename; filename << "difference_" << caseid << "_" << string_from_type<coordinate_type>::name() << (ccw ? "_ccw" : "") << (open ? "_open" : "") #if defined(BOOST_GEOMETRY_NO_SELF_TURNS) << "_no_self" #endif #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) << "_no_rob" #endif << ".svg"; std::ofstream svg(filename.str().c_str()); bg::svg_mapper<point_type> mapper(svg, 500, 500); mapper.add(g1); mapper.add(g2); mapper.map(g1, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:3"); mapper.map(g2, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:3"); for (typename Output::const_iterator it = output.begin(); it != output.end(); ++it) { mapper.map(*it, //sym ? "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,255,0);stroke:rgb(255,0,255);stroke-width:8" : "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);stroke:rgb(255,0,255);stroke-width:8"); } } #endif }
void GammaControlManager::getGammaControl(wl_client *client, wl_resource *res, uint32_t id, wl_resource *outputRes) { Output *output = Output::fromResource(outputRes); class GammaControl { public: GammaControl(Output *o) : output(o) { } void destroy(wl_client *c, wl_resource *r) { wl_resource_destroy(r); } void setGamma(wl_client *c, wl_resource *res, wl_array *red, wl_array *green, wl_array *blue) { if (red->size != green->size || red->size != blue->size) { wl_resource_post_error(res, GAMMA_CONTROL_ERROR_INVALID_GAMMA, "The gamma ramps don't have the same size"); return; } uint16_t *r = (uint16_t *)red->data; uint16_t *g = (uint16_t *)green->data; uint16_t *b = (uint16_t *)blue->data; output->setGamma(red->size / sizeof(uint16_t), r, g, b); } void resetGamma(wl_client *c, wl_resource *res) { } Output *output; }; static const struct gamma_control_interface implementation = { wrapExtInterface(&GammaControl::destroy), wrapExtInterface(&GammaControl::setGamma), wrapExtInterface(&GammaControl::resetGamma) }; GammaControl *gc = new GammaControl(output); wl_resource *resource = wl_resource_create(client, &gamma_control_interface, wl_resource_get_version(res), id); wl_resource_set_implementation(resource, &implementation, gc, [](wl_resource *r) { delete static_cast<GammaControl *>(wl_resource_get_user_data(r)); }); gamma_control_send_gamma_size(resource, output->gammaSize()); }
RippleCalc::Output RippleCalc::rippleCalculate ( PaymentSandbox& view, // Compute paths using this ledger entry set. Up to caller to actually // apply to ledger. // Issuer: // XRP: xrpAccount() // non-XRP: uSrcAccountID (for any issuer) or another account with // trust node. STAmount const& saMaxAmountReq, // --> -1 = no limit. // Issuer: // XRP: xrpAccount() // non-XRP: uDstAccountID (for any issuer) or another account with // trust node. STAmount const& saDstAmountReq, AccountID const& uDstAccountID, AccountID const& uSrcAccountID, // A set of paths that are included in the transaction that we'll // explore for liquidity. STPathSet const& spsPaths, Logs& l, Input const* const pInputs) { RippleCalc rc ( view, saMaxAmountReq, saDstAmountReq, uDstAccountID, uSrcAccountID, spsPaths, l); if (pInputs != nullptr) { rc.inputFlags = *pInputs; } auto result = rc.rippleCalculate (); Output output; output.setResult (result); output.actualAmountIn = rc.actualAmountIn_; output.actualAmountOut = rc.actualAmountOut_; output.pathStateList = rc.pathStateList_; return output; }
virtual void set(Output& output, bert::Value* val) { GlobalLock::LockGuard guard(state_->global_lock()); if(val->string_p()) { output.ok("value"); String* path = String::create(state_, val->string()); if(RTEST(System::vm_dump_heap(state_, path))) { output.e().write_atom("ok"); } else { output.e().write_atom("error"); } } else { output.error("format"); } }