Esempio n. 1
0
void file_path_and_guard_expander::
expand(const formatters::repository& frp, const locator& l, model& fm) const {

    const auto safba(frp.stock_artefact_formatters_by_archetype());
    for (auto& pair : fm.formattables()) {
        const auto id(pair.first);
        auto& formattable(pair.second);

        /*
         * It doesn't really matter which segment we choose here since
         * they are both mapped to the same name.
         */
        const auto& e(*formattable.master_segment());
        const auto n(e.name());
        auto& eprops(formattable.element_properties());

        /*
         * Go thorough all the artefact properties and, for each, find
         * the associated formatter.
         */
        for (auto& pair : eprops.artefact_properties()) {
            const auto arch(pair.first);
            auto& art_props(pair.second);

            const auto i(safba.find(arch));
            if (i == safba.end()) {
                BOOST_LOG_SEV(lg, error) << missing_archetype << arch;
                BOOST_THROW_EXCEPTION(
                    expansion_error(missing_archetype + arch));
            }

            /*
             * Ask the formatter to generate the full path for the
             * artefact.
             */
            const auto& fmt(i->second);
            art_props.file_path(fmt->full_path(l, n));

            /*
             * If the formatter supports inclusion, we need to compute
             * the header guard as well.
             */
            const auto ns(formatters::inclusion_support_types::not_supported);
            if (fmt->inclusion_support_type() != ns) {
                const auto ip(fmt->inclusion_path(l, n));
                art_props.header_guard(to_header_guard(ip));
            }
        }
    }
}
Esempio n. 2
0
    Scalar calculateGradientFirst(Geometry1& point, Geometry2& line, Derivative1& dpoint) {
        if(dist.norm() == 0)
            return 1.;

        const Vector3 d_dist = -dpoint.point() + dpoint.point().dot(line.direction())*line.direction();
        const Scalar res = dist.dot(d_dist)/dist.norm();
#ifdef DCM_USE_LOGGING
        if(!boost::math::isfinite(res))
            BOOST_LOG_SEV(log, details::error) << "Unnormal first cluster gradient detected: "<<res
                           <<" with point: "<<point.point().transpose()<<", line: "<<line.point().transpose()
                           << line.direction().transpose() <<" and dpoint: "<<dpoint.point().transpose();
#endif
        return res;
    };
Esempio n. 3
0
std::unordered_map<std::string, annotation_group> annotation_groups_factory::
make(const std::unordered_map<std::string, scribble_group>&
     scribble_groups) const {

    std::unordered_map<std::string, annotation_group> r;
    for (const auto& pair : scribble_groups) {
        const auto id(pair.first);
        BOOST_LOG_SEV(lg, debug) << "Processing scribble group: " << id;
        const auto& sgrp(pair.second);
        const auto ag(make(sgrp));
        r[id] = ag;
    }
    return r;
}
Esempio n. 4
0
void annotation_groups_factory::validate_scope(const type& t,
        const scope_types current_scope) const {
    if (t.scope() != scope_types::any &&
            t.scope() != scope_types::not_applicable &&
            t.scope() != current_scope) {

        std::stringstream s;
        s << field_used_in_invalid_scope << t.name().qualified()
          << expected_scope << t.scope()
          << actual_scope << current_scope;
        BOOST_LOG_SEV(lg, error) << s.str();
        BOOST_THROW_EXCEPTION(building_error(s.str()));
    }
}
Esempio n. 5
0
void merger::add_target(const model& target) {
    require_not_has_target(target.name().simple_name());

    has_target_ = true;
    merged_model_.name(target.name());
    merged_model_.documentation(target.documentation());
    merged_model_.leaves(target.leaves());
    merged_model_.modules(target.modules());
    merged_model_.references(target.references());

    add(target);
    BOOST_LOG_SEV(lg, debug) << "added target model: "
                             << target.name().simple_name();
}
Esempio n. 6
0
bool generalization_indexer::is_leaf(const object& o) const {
    // FIXME: massive hack. must not add leafs for services.
    const auto uds(object_types::user_defined_service);
    const bool is_service(o.object_type() == uds);
    if (o.is_parent() || !o.is_child() || is_service) {
        BOOST_LOG_SEV(lg, debug)
            << "Type is not in a generalization relationship."
            << " is parent: " << o.is_parent()
            << " is child: " << o.is_child()
            << " is service: " << is_service;
        return false;
    }
    return true;
}
Esempio n. 7
0
void utility_formatter::insert_quote(const quote_types qt) const {
    switch(qt) {
    case quote_types::single_quote:
        stream_ << single_quote;
        return;
    case quote_types::double_quote:
        stream_ << double_quote;
        return;
    default:
        BOOST_LOG_SEV(lg, error) << unsupported_quote_type << qt;
        BOOST_THROW_EXCEPTION(formatting_error(
                unsupported_quote_type + boost::lexical_cast<std::string>(qt)));
    }
}
Esempio n. 8
0
int main(int, char*[])
{
#if defined(BOOST_LOG_USE_NATIVE_SYSLOG)
    init_native_syslog();
#elif !defined(BOOST_LOG_NO_ASIO)
    init_builtin_syslog();
#endif

    BOOST_LOG_SCOPED_THREAD_TAG("MyLevel", std::string, "warning");
    src::severity_logger< > lg;
    BOOST_LOG_SEV(lg, 3) << "Hello world!";

    return 0;
}
Esempio n. 9
0
std::list<field_definition>
instantiator::instantiate(const field_definition& fd) const {
    validate(fd);

    BOOST_LOG_SEV(lg, debug) << "Instantiating template: " << fd;

    std::list<field_definition> r;
    const auto dt(fd.definition_type());
    if (dt == field_definition_types::global_template)
        r = instantiate_global_template(fd);
    else if (dt == field_definition_types::facet_template)
        r = instantiate_facet_template(fd);
    else if (dt == field_definition_types::formatter_template)
        r = instantiate_formatter_template(fd);
    else {
        BOOST_LOG_SEV(lg, error) << unsupported_definition_type << dt;
        BOOST_THROW_EXCEPTION(instantiation_error(unsupported_definition_type +
                boost::lexical_cast<std::string>(dt)));
    }

    BOOST_LOG_SEV(lg, debug) << "Instantiation result: " << r;
    return r;
}
Esempio n. 10
0
void validator::validate_yarn(const processed_object& po) const {
    if (po.yarn_object_type() == yarn_object_types::object)
        return; // nothing to validate for yarn objects.

    /*
     * Non-yarn objects are not allowed to have stereotypes.
     */
    if (!po.stereotypes().empty()) {
        BOOST_LOG_SEV(lg, error) << stereotypes_require_yarn_object << ": "
                                 << po.stereotypes();
        BOOST_THROW_EXCEPTION(
            validation_error(stereotypes_require_yarn_object));
    }
}
helper_configuration helper_expander::
make_configuration(const feature_group& fg, const model& fm) const {
    BOOST_LOG_SEV(lg, debug) << "Started making the configuration.";
    helper_configuration r;
    r.streaming_properties(fm.streaming_properties());

    for (auto& pair : fm.formattables()) {
        const auto id(pair.first);
        BOOST_LOG_SEV(lg, debug) << "Procesing element: " << id;

        auto& formattable(pair.second);
        auto& segment(*formattable.master_segment());
        const auto& cfg(*segment.configuration());
        const variability::helpers::configuration_selector s(cfg);
        const auto fam(s.get_text_content_or_default(fg.family));
        r.helper_families()[id] = fam;
    }

    BOOST_LOG_SEV(lg, debug) << "Finished making the configuration. Result:"
                             << r;

    return r;
}
Esempio n. 12
0
void comment_formatter::validate() const {
    bool is_syle_supported(
        style_ == comment_styles::c_style ||
        style_ == comment_styles::shell_style ||
        style_ == comment_styles::sql_style ||
        style_ == comment_styles::csharp_style ||
        style_ == comment_styles::cpp_style);

    if (!is_syle_supported) {
        const auto s(boost::lexical_cast<std::string>(style_));
        BOOST_LOG_SEV(lg, error) << unsupported_style << s;
        BOOST_THROW_EXCEPTION(formatting_error(unsupported_style + s));
    }
}
Esempio n. 13
0
    Master::Master(const std::shared_ptr<Library>& library, const MasterParameters& parameters):
	_library(library),
	_parameters(parameters),
	nodeAcceptor(library->ioService(), parseTcpEndpoint(parameters.nodeEndpoint)),
	clientAcceptor(library->ioService(), parseTcpEndpoint(parameters.clientEndpoint)),
	heartbeatTimer(library->ioService()),
	heartbeatRunning(true),
	_sslContext(ssl::context::tlsv1),
	disposed(false),
	nodeAcceptorRunning(true),
	clientAcceptorRunning(true)
	{
		// Setup SSL
		std::string pw = parameters.sslPassword;
		sslContext().set_password_callback([pw](std::size_t, ssl::context::password_purpose) { return pw; });
		
		try {
			BOOST_LOG_SEV(log, LogLevel::Info) <<
			format("Using %s as the certificate chain file.") % parameters.sslCertificateFile;
			
			sslContext().use_certificate_chain_file(parameters.sslCertificateFile);
		} catch (const std::exception& ex) {
			MSCThrow(InvalidDataException
			(str(format("Error occured while attempting to use '%s' as the "
						"certificate chain file: %s") %
				 parameters.sslCertificateFile % ex.what())));
		}
		try {
			BOOST_LOG_SEV(log, LogLevel::Info) <<
			format("Using %s as the private key file.") % parameters.sslPrivateKeyFile;
			
			sslContext().use_private_key_file(parameters.sslPrivateKeyFile, boost::asio::ssl::context::pem);
		} catch (const std::exception& ex) {
			MSCThrow(InvalidDataException
			(str(format("Error occured while attempting to use '%s' as the "
						"private key file: %s") %
				 parameters.sslPrivateKeyFile % ex.what())));
		}
		
		BOOST_LOG_SEV(log, LogLevel::Debug) << "SSL is ready.";
		
		// Prepare to accept the first client and node
		BOOST_LOG_SEV(log, LogLevel::Debug) << "Preparing to accept clients and nodes.";
		waitingNodeConnection = std::make_shared<MasterNodeConnection>(*this);
		waitingClient = std::make_shared<MasterClient>(*this, 1,
													   _parameters.allowVersionSpecification);
		
        acceptNodeConnectionAsync(true);
        acceptClientAsync(true);

		// Start heartbeat
		BOOST_LOG_SEV(log, LogLevel::Debug) << "Starting heartbeat.";
        doHeartbeat(boost::system::error_code());
		
		BOOST_LOG_SEV(log, LogLevel::Info) <<
		format("Merlion Master Server Core (%s) running.") % MSC_VERSION_STRING;
    }
void voice_card_control::cti_callout(boost::shared_ptr<cti_call_out_param> cti_call_out_param_)
{
	std::size_t chID;
	try
	{
		chID = m_channel_queue.take();
	}
	catch (std::out_of_range)
	{
		BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "业务流水:" << cti_call_out_param_->m_transId << " 获取通道失败, 通道全部繁忙";
		//继续下一次呼叫
		cti_callout_again(cti_call_out_param_);
		return;
	}
	BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "业务流水:" << cti_call_out_param_->m_transId << " 获取到得通道状态为:" << SsmChkAutoDial(chID) << ", 通道号码:" << chID;
	SsmSetTxCallerId(chID, cti_call_out_param_->m_authCode.c_str());
	if (SsmAutoDial(chID, cti_call_out_param_->m_pn.c_str()) == 0){
		BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "业务流水:" << cti_call_out_param_->m_transId << " 已发送请求, 已将此通道对应状态清空, 通道号码:" << chID;
		boost::shared_ptr<trunk> t = m_trunk_vector.at(chID);
		boost::unique_lock<boost::mutex> unique_lock_(t->m_trunk_mutex, boost::defer_lock);
		if (unique_lock_.try_lock())
		{
			t->m_client_socket = cti_call_out_param_->m_base_client;
			t->m_transId = cti_call_out_param_->m_transId;
			t->m_caller_id = cti_call_out_param_->m_authCode;
			t->m_called_id = cti_call_out_param_->m_pn;
			t->m_hungup_by_echo_tone = cti_call_out_param_->m_hungup_by_echo_tone;
			t->m_step = TRK_CALLOUT_DAIL;
			t->m_callTime.restart();
		}
		else
		{
			BOOST_LOG_SEV(cia_g_logger, Critical) << "业务流水:" << cti_call_out_param_->m_transId << ", 严重异常, 被分配的语音通道处于占用状态, 请程序猿通宵解决问题";
		}
	}
	else {
		m_channel_queue.put(chID);
		//上一次呼叫失败,继续呼叫
		if (cti_call_out_param_->m_repeat_call_out)
		{
			cti_call_out_param_->m_repeat_call_out = false;
			BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "业务流水:" << cti_call_out_param_->m_transId << "上一次呼叫失败,继续呼叫";
			cti_callout_again(cti_call_out_param_);
		}
		//已经连续两次呼叫失败, 直接返回失败
		else
		{
			BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "业务流水:" << cti_call_out_param_->m_transId << "已经连续两次呼叫失败, 直接返回失败";
			ciaMessage msg;
			msg.set_type(CIA_CALL_RESPONSE);
			msg.set_transid(cti_call_out_param_->m_transId);
			msg.set_status(CIA_CALL_FAIL);
			cti_call_out_param_->m_base_client->do_write(chat_message(msg));
			return;
		}
	}
}
std::unordered_map<std::string, std::list<std::string> >
generate(const inclusion_dependencies_builder_factory& f,
    std::forward_list<
        boost::shared_ptr<
            inclusion_dependencies_provider_interface<SmlEntity>
            >
        > providers, const SmlEntity& e) {

    const auto n(sml::string_converter::convert(e.name()));
    BOOST_LOG_SEV(lg, debug) << "Creating inclusion dependencies for: " << n;

    std::unordered_map<std::string, std::list<std::string> > r;
    for (const auto p : providers) {
        BOOST_LOG_SEV(lg, debug) << "Providing for: " << p->formatter_name();
        auto id(p->provide(f, e));

        if (!id)
            continue;

        id->sort(include_directive_comparer);
        id->unique();
        const auto id_pair(std::make_pair(p->formatter_name(), *id));
        const bool inserted(r.insert(id_pair).second);
        if (!inserted) {
            BOOST_LOG_SEV(lg, error) << duplicate_formatter_name
                                     << p->formatter_name()
                                     << " for type: " << n;
            BOOST_THROW_EXCEPTION(building_error(duplicate_formatter_name +
                    p->formatter_name()));
        }
    }

    BOOST_LOG_SEV(lg, debug) << "Finished creating inclusion dependencies for: "
                             << n;

    return r;
}
Esempio n. 16
0
void workflow::initialise_context_activity(const std::string& model_name,
    const std::string& external_modules, bool is_target) {

    context_ = context();
    auto& m(context_.model());
    m.name(create_name_for_model(model_name, external_modules));
    m.original_model_name(model_name);
    BOOST_LOG_SEV(lg, debug) << "Model name: " << m.name().qualified();

    m.origin_type(yarn::origin_types::user);
    m.is_target(is_target);

    const auto mm(create_module_for_model(m.name(), is_target));
    m.modules().insert(std::make_pair(mm.name().qualified(), mm));
}
Esempio n. 17
0
    Scalar calculateGradientSecond(const E::MatrixBase<DerivedA>& point,
                                   const E::MatrixBase<DerivedB>& segment,
                                   const E::MatrixBase<DerivedC>& dsegment) {

        const Vector3 d_cross = - (dsegment.template head<3>().cross(v02) + v01.cross(dsegment.template tail<3>()));
        const Vector3 d_v12   = dsegment.template head<3>() - dsegment.template tail<3>();
        const Scalar res = cross.dot(d_cross)/(cross_n*v12_n) - v12.dot(d_v12)*cross_v12_n;
#ifdef DCM_USE_LOGGING
        if(!boost::math::isfinite(res))
            BOOST_LOG_SEV(log, error) << "Unnormal second cluster gradient detected: "<<res
                           <<" with point: "<<point.transpose()<<", segment: "<<segment.transpose()
                           << "and dsegment: "<<dsegment.transpose();
#endif
        return res;
    };
bool HibernationEnabled()
{
    #pragma warning (push, 4)
    #pragma warning( disable : 4800 )
    BOOST_LOG_SEV(logger(), debug) << "IsPwrHibernateAllowed(): " << (bool)IsPwrHibernateAllowed();
    BOOST_LOG_SEV(logger(), debug) << "IsPwrShutdownAllowed(): " << (bool)IsPwrShutdownAllowed();
    BOOST_LOG_SEV(logger(), debug) << "IsPwrSuspendAllowed(): " << (bool)IsPwrSuspendAllowed();
    #pragma warning (pop)

    SYSTEM_POWER_CAPABILITIES systemPowerCapabilities = {0};
    if (!GetPwrCapabilities(&systemPowerCapabilities)) {
        DWORD last_error = GetLastError();
        std::string msg = Utilities::MakeString() << "GetPwrCapabilities() failed. Reason: " << last_error;
        BOOST_LOG_SEV(logger(), error) << msg;
        return false;
    }

    #pragma warning (push, 4)
    #pragma warning( disable : 4800 )
    BOOST_LOG_SEV(logger(), debug) << "systemPowerCapabilities.Hiberboot: " << (bool)systemPowerCapabilities.Hiberboot;
    #pragma warning (pop)

    return !!systemPowerCapabilities.Hiberboot;
}
Esempio n. 19
0
void Module3D<Typelist, ID>::type<Sys>::Geometry3D_base<Derived>::set(const T& geometry) {

    m_geometry = geometry;
    //first init, so that the geometry internal vector has the right size
    Base::template init< typename geometry_traits<T>::tag >();
    //now write the value;
    (typename geometry_traits<T>::modell()).template extract<Scalar,
    typename geometry_traits<T>::accessor >(geometry, Base::getValue());

#ifdef DCM_USE_LOGGING
    BOOST_LOG_SEV(Base::log, information) << "Set global Value: " << Base::getValue().transpose();
#endif
    
    reset();
};
Esempio n. 20
0
void merger::add_target(const model& target) {
    const auto qn(target.name().qualified());
    require_not_has_target(qn);

    has_target_ = true;
    merged_model_.name(target.name());
    merged_model_.documentation(target.documentation());
    merged_model_.leaves(target.leaves());
    merged_model_.modules(target.modules());
    merged_model_.references(target.references());
    merged_model_.extensions(target.extensions());
    merged_model_.is_target(true);

    BOOST_LOG_SEV(lg, debug) << "added target model: " << qn;
}
void voice_card_control::init_cti()
{
	BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "读取语音卡配置文件";
	if (SsmStartCti("ShConfig.ini", "ShIndex.ini") != 0)
	{
		show_error();
		BOOST_LOG_SEV(cia_g_logger, Critical) << "读取语音卡配置文件失败";
		throw std::runtime_error("读取语音卡配置文件失败");
	}
	else{
		BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "语音卡配置文件读取成功";
	}
	//设置驱动程序抛出事件的模式

	EVENT_SET_INFO EventMode;
	EventMode.dwWorkMode = EVENT_CALLBACK;                               // 事件回调模式
	EventMode.lpHandlerParam = (LPVOID)voice_card_control::cti_callback; // 注册回调函数

	SsmSetEvent(0xffff, -1, true, &EventMode);	                         // 启动事件触发模式

	//如果要在程序中获取SS7消息, 则需要同时注意以下两点
	//配置文件 ShConfig.ini 中, GetMsuOnAutoHandle = 1
	//程序中: SsmSetEvent(E_RCV_Ss7Msu, -1, true, &EventMode);
	SsmSetEvent(E_RCV_Ss7Msu, -1, true, &EventMode);

	BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "正在初始化语音卡通道, 预期耗时15秒";
	//	为了兼容1号信令,注释以下代码,改为sleep 15秒
	//while (SsmSearchIdleCallOutCh(160, 0x1E0000) < 0){	                 // 循环等待, 直到能够获取语音卡空闲通道号, 语音卡初始化完毕
	//	boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
	//}
	boost::this_thread::sleep_for(boost::chrono::seconds(15));
	BOOST_LOG_SEV(cia_g_logger, RuntimeInfo) << "语音卡通道初始化完毕";
	for (std::size_t i = 0; i < m_numChannelCount; i++){
		m_channel_queue.put(i);
	}
}
Esempio n. 22
0
void grapher::
process_child_node(const vertex_descriptor_type& v, const processed_object& o) {
    if (!o.child_node_id().empty()) {
        const std::string id(o.child_node_id());
        const vertex_descriptor_type cv(vertex_for_id(id));
        boost::add_edge(v, cv, graph_);
        BOOST_LOG_SEV(lg, debug) << "Creating edge between '"
                                 << o.id() << "' and '" << id << "'";

        const auto k(orphanage_.find(id));
        if (k != orphanage_.end()) {
            BOOST_LOG_SEV(lg, debug) << "Object is no longer orphan: "
                                     << id << "'";
            orphanage_.erase(k);
        }
        connected_ids_.insert(id);
    }

    if (connected_ids_.find(o.id()) == connected_ids_.end()) {
        orphanage_.insert(std::make_pair(o.id(), v));
        BOOST_LOG_SEV(lg, debug) << "Vertex for object joined orphanage: "
                                 << o.id();
    }
}
Esempio n. 23
0
    bool CameraGigeAravis::setSize(int width, int height, bool customSize) {

        if(customSize) {

            arv_camera_set_region(camera, 0, 0,width,height);
            arv_camera_get_region (camera, NULL, NULL, &mWidth, &mHeight);
            BOOST_LOG_SEV(logger, notification) << "Camera region size : " << mWidth << "x" << mHeight;

        // Default is maximum size
        }else {

            int sensor_width, sensor_height;

            arv_camera_get_sensor_size(camera, &sensor_width, &sensor_height);
            BOOST_LOG_SEV(logger, notification) << "Camera sensor size : " << sensor_width << "x" << sensor_height;

            arv_camera_set_region(camera, 0, 0,sensor_width,sensor_height);
            arv_camera_get_region (camera, NULL, NULL, &mWidth, &mHeight);

        }

        return true;

    }
Esempio n. 24
0
void injector::inject_visitors(intermediate_model& m) {
    BOOST_LOG_SEV(lg, debug) << "Injecting visitors.";

    std::list<visitor> visitors;
    for (auto& pair : m.objects()) {
        auto& o(pair.second);

        if (!o.is_visitable())
            continue;

        if (o.leaves().empty()) {
            const auto qn(o.name().qualified());
            BOOST_LOG_SEV(lg, error) << zero_leaves << qn;
            BOOST_THROW_EXCEPTION(injection_error(zero_leaves + qn));
        }

        const auto v(create_visitor(o, o.leaves()));
        inject_visitable_by(o, o.leaves(), v.name(), m);
        visitors.push_back(v);
    }

    for (const auto v : visitors) {
        BOOST_LOG_SEV(lg, debug) << "Adding visitor: "
                                 << v.name().qualified();

        const auto pair(std::make_pair(v.name().qualified(), v));
        const auto i(m.visitors().insert(pair));
        if (!i.second) {
            const auto qn(v.name().qualified());
            BOOST_LOG_SEV(lg, error) << duplicate_name << qn;
            BOOST_THROW_EXCEPTION(injection_error(duplicate_name + qn));
        }
    }

    BOOST_LOG_SEV(lg, debug) << "Done injecting visitors.";
}
Esempio n. 25
0
layer hydrator::read_layer() {
    validate_current_element(dia_layer);

    layer layer;
    layer.name(read_xml_string_attribute(dia_name));
    layer.visible(try_read_xml_bool_attribute(dia_layer_visible));
    layer.active(try_read_xml_bool_attribute(dia_layer_active));
    BOOST_LOG_SEV(lg, debug) << "Reading layer: " << layer.name();

    std::vector<object> objects;
    const bool is_self_closing(reader_.is_empty());

    reader_.read();
    if (!is_self_closing) {
        do {
            objects.push_back(read_object());
        } while (!is_end_element(dia_layer));
        reader_.read();
    }

    layer.objects(objects);
    BOOST_LOG_SEV(lg, debug) << "Read layer: " << layer.name();
    return layer;
}
Esempio n. 26
0
    Scalar calculateGradientFirst(const E::MatrixBase<DerivedA>& point,
                                  const E::MatrixBase<DerivedB>& segment,
                                  const E::MatrixBase<DerivedC>& dpoint) {

        const Vector3 d_point = dpoint; //eigen only acceppts vector3 for cross product
        const Vector3 d_cross = d_point.cross(v02) + v01.cross(d_point);
        const Scalar res = cross.dot(d_cross)/(cross_n*v12_n);
#ifdef DCM_USE_LOGGING
        if(!boost::math::isfinite(res))
            BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<res
                           <<" with point: "<<point.transpose()<<", segment: "<<segment.transpose()
                           <<" and dpoint: "<<dpoint.transpose();
#endif
        return res;
    };
Esempio n. 27
0
bool Linklet::messageParsed(Message &msg)
{
  if (m_state == State::IntroWait) {
    // We have received the hello message, extract information and detach
    Protocol::Interplex::Hello hello = message_cast<Protocol::Interplex::Hello>(msg);
    Contact peerContact = Contact::fromMessage(hello.local_contact());
    if (peerContact.isNull()) {
      BOOST_LOG_SEV(m_logger, log::error) << "Invalid peer contact in hello message!";
      return false;
    }

    m_peerContact = peerContact;

    // Perform additional verification on the peer before transitioning into
    // the connected state
    if (!signalVerifyPeer(shared_from_this()) || !m_manager.verifyPeer(peerContact)) {
      BOOST_LOG_SEV(m_logger, log::error) << "Peer verificaton has failed!";
      return false;
    }

    BOOST_LOG_SEV(m_logger, log::normal) << "Introductory phase with " << peerContact.nodeId().hex() << " completed.";
    m_state = State::Connected;
    signalConnectionSuccess(shared_from_this());

    // The above signal may close this linklet, in this case we should not start reading,
    // otherwise this will cause a segmentation fault
    if (m_state != State::Connected)
      return false;
  } else {
    // Payload has been read, emit message and detach
    signalMessageReceived(shared_from_this(), msg);
  }

  msg.detach();
  return true;
}
formattables::path_derivatives
inclusion_directives_factory::path_derivatives_for_formatter_name(
    const std::unordered_map<std::string,
    formattables::path_derivatives>& pd,
    const std::string& formatter_name) const {

    const auto i(pd.find(formatter_name));
    if (i == pd.end()) {
        BOOST_LOG_SEV(lg, error) << formatter_name_not_found
                                 << formatter_name;
        BOOST_THROW_EXCEPTION(
            building_error(formatter_name_not_found + formatter_name));
    }
    return i->second;
}
Esempio n. 29
0
	void NodeVersionLoader::receiveHeader()
	{
		auto self = shared_from_this();
		checkThread();
		
		auto& item = currentDownloadItem();
		
		state = State::ReceivingHeader;
		
		auto buf = std::make_shared<std::uint64_t>();
		
		timer.expires_from_now(boost::posix_time::seconds(8));
		timer.async_wait([this, self] (const error_code& error) {
			if (error) {
				return;
			}
			if (disposed) {
				return;
			}
			if (state == State::ReceivingHeader) {
				BOOST_LOG_SEV(log, LogLevel::Warn) <<
				"Timed out.";
				socket.cancel();
			}
		});
		
		asio::async_read(socket, asio::buffer(buf.get(), 8), [this, self, &item, buf](const error_code& error, std::size_t) {
			checkThread();
			
			if (disposed) {
				downloadCancelled();
				return;
			}
			if (error) {
				downloadFailed(error.message());
				return;
			}
			timer.cancel();
			
			auto size = *buf;
			if (size == 0) {
				downloadFailed("Version cannot be downloaded for some reason.");
				return;
			}
			
			receiveData(size);
		});
	}
Esempio n. 30
0
void workflow::report_exception_common() const {
    if (can_log_) {
        BOOST_LOG_SEV(lg, warn) << stitcher_product << errors_msg;
        std::cerr << log_file_name_.string() << ":0: " << log_file_msg
                  << std::endl;

            // << log_file_msg << "'" << log_file_name_.string()
            //       << "' " << std::endl;
    }

    if (template_name_.empty())
        return;

    std::cerr << "Failed to generate template: '" << template_name_ << "'."
              << std::endl;
}