void operator()( boost::property_tree::ptree & state, const device_free_space< IntType, OrderTag > & obj ) {
//        state.put( "total", obj.total);
//
        typedef device_free_space< IntType, OrderTag > space_type;
        typedef typename space_type::int_type  int_type;

        state_getter < device_event_space< IntType, OrderTag > > base_getter;
        base_getter( state, obj );

        state.put( "fixed_count", obj.fixed_count );
        state.put( "size", obj.size );
        state.put( "capacity", obj.capacity );

        if( obj.free_list == NULL ) {
            state.put( "free_list", "" );
            state.put( "free_map", "" );
            state.put( "fixed_list", "" );
            state.put( "lost_list", "" );
            return;
        }

        unsigned int nInts = obj.size / space_type::OBJECTS_PER_INT;
        int_type * flist = new int_type[ nInts ];

        copy_heap_data( flist, obj.free_list, nInts );

        boost::property_tree::ptree fl, xl, ll;
        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( fl, oss.str() );
        }

        copy_heap_data( flist, obj.fixed_list, nInts );

        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( xl, oss.str() );
        }

        copy_heap_data( flist, obj.lost_list, nInts );

        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( ll, oss.str() );
        }

        unsigned int * fmap = new unsigned int[ obj.size ];

        copy_heap_data( fmap, obj.free_map, obj.size );

        boost::property_tree::ptree fm;
        for( unsigned int i = 0; i < obj.size; ++i ) {
            clotho::utility::add_value_array( fm, fmap[i] );
        }

        state.add_child( "free_list", fl );
        state.add_child( "free_map", fm );
        state.add_child( "lost_list", ll );
        state.add_child( "fixed_list", xl );

        delete flist;
        delete fmap;
    }
Example #2
0
 void populate(boost::property_tree::ptree& tree, Key&& key, Value&& value, Remaining&&... args)
 {
     this->properties.insert(std::make_pair(key, std::make_pair(tree.get(key, value), value)));
     populate(tree, args...);
 }
 void GunneboReaderUnitConfiguration::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
Example #4
0
void stInventory::serialize(boost::property_tree::ptree &node)
{
    node.put("score", score);
    node.put("extralifeat", extralifeat);

    node.put("charges", charges);
    node.put("lives", lives);
    node.put("HasPogo", HasPogo);
    node.put("HasCardYellow", HasCardYellow);
    node.put("HasCardRed", HasCardRed);
    node.put("HasCardGreen", HasCardGreen);
    node.put("HasCardBlue", HasCardBlue);

    node.put("HasJoystick",HasJoystick);
    node.put("HasWiskey",HasWiskey);
    node.put("HasBattery",HasBattery);
    node.put("HasVacuum",HasVacuum);

    node.put("canlooseitem1", canlooseitem[0]);
    node.put("canlooseitem2", canlooseitem[1]);
    node.put("canlooseitem3", canlooseitem[2]);
    node.put("canlooseitem4", canlooseitem[3]);
}
Example #5
0
void logMutationBinFrequencies( boost::property_tree::ptree & p, std::vector< size_t > & frequencies, unsigned int bin_count, typename locus_bitset::alphabet_t::pointer alpha ) {
    boost::property_tree::ptree v, _v0, _v1, _v2;
    std::string key = "genome_bin";
    _v0.put("", "Bin");
    _v1.put("", "Offset");
    _v2.put("", "Frequency");
    v.push_back( std::make_pair("", _v0));
    v.push_back( std::make_pair("", _v1));
    v.push_back( std::make_pair("", _v2));
    p.add_child( key +".y.smps", v);

    boost::property_tree::ptree x, _x0, _x1, _x2;
    _x0.put("", "Bin index" );
    _x1.put("", "Genomic offset relative to bin" );
    _x2.put("", "Frequency of allele in population" );
    x.push_back( std::make_pair("", _x0 ) );
    x.push_back( std::make_pair("", _x1 ) );
    x.push_back( std::make_pair("", _x2 ) );

    p.add_child( key + ".x.Description", x);

    boost::property_tree::ptree d,s;

    typename locus_bitset::alphabet_t::active_iterator alpha_it = alpha->active_begin();

    typedef  std::vector< std::map< double, size_t > > bin_freq_type;
    bin_freq_type bin_freq( bin_count, std::map<double, size_t>() );

    for( std::vector< size_t >::iterator it = frequencies.begin(); it != frequencies.end(); ++it ) {
        if( *it > 0 ) {
            assert( alpha->checkFreeStatus( it - frequencies.begin()) );
            unsigned int bin_idx = alpha_it->first * bin_count;

            double lo = (double)(bin_idx) / (double) bin_count;

            double offset = alpha_it->first - lo;

            bin_freq[bin_idx].insert( std::make_pair( offset, (*it)));
        }
        ++alpha_it;
    }

    unsigned int bin_idx = 0;
    for( bin_freq_type::iterator it = bin_freq.begin(); it != bin_freq.end(); ++it ) {
        double lo = (double)(bin_idx) / (double) bin_count;
        boost::property_tree::ptree w;
        w.put( "", lo);
        unsigned int offset = 0;
        for( std::map< double, size_t >::iterator it2 = it->begin(); it2 != it->end(); ++it2 ) {
            boost::property_tree::ptree x,y,z, _s;
            x.put( "", it2->first);
            y.put( "", it2->second);
            z.push_back( std::make_pair("", w ));
            z.push_back( std::make_pair("", x ));
            z.push_back( std::make_pair("", y ));

            d.push_back( std::make_pair("", z ));

            std::ostringstream oss;
            oss << bin_idx << "_" << offset++;
            _s.put("", oss.str());
            s.push_back( std::make_pair("", _s));
        }
        ++bin_idx;
    }

    p.add_child( key + ".y.vars", s );
    p.add_child( key + ".y.data", d );

    boost::property_tree::ptree graph_opts;

    graph_opts.put("graphType", "Scatter3D");

    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Bin");
        tmp.push_back( std::make_pair("", t ) );
        graph_opts.add_child("xAxis", tmp);
    }
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Offset");
        tmp.push_back( std::make_pair( "",t));
        graph_opts.add_child("zAxis", tmp);
    }
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Frequency");
        tmp.push_back( std::make_pair("", t ));
        graph_opts.add_child("yAxis", tmp);
    }
    graph_opts.put( "title", "Mutation Distribution grouped by bin" );

    p.add_child( key + ".graph_opts", graph_opts );
}
 void MifareUltralightAccessInfo::unSerialize(boost::property_tree::ptree& node)
 {
     lockPage = node.get_child("LockPage").get_value<bool>();
 }
 void MifareUltralightLocation::unSerialize(boost::property_tree::ptree& node)
 {
     page = node.get_child("Page").get_value<int>();
     byte = node.get_child("Byte").get_value<int>();
 }
Example #8
0
void utility::setup(const boost::property_tree::ptree &ptree) {
  if (!ptree.empty()) BOOST_THROW_EXCEPTION(error("not implemented"));
}
Example #9
0
 MMT_data_t(const boost::property_tree::ptree& pt) :
     base_t(pt.get<int>("N"), pt.get<int>("S"),
         base::context_t(pt.get_child("creation_context")), "MMT") { 
     base_t::build();
 }
Example #10
0
MLC_Config::MLC_Config(const boost::property_tree::ptree& pt, const char* name)
{
    mConfigSet = pt.get_child(name);
}
Example #11
0
void Pack::initialize(const std::string& name,
                      const std::string& source,
                      const pt::ptree& tree) {
  name_ = name;
  source_ = source;
  discovery_queries_.clear();
  if (tree.count("discovery") > 0) {
    for (const auto& item : tree.get_child("discovery")) {
      discovery_queries_.push_back(item.second.get_value<std::string>());
    }
  }

  discovery_cache_ = std::make_pair<int, bool>(0, false);
  stats_ = {0, 0, 0};

  platform_.clear();
  if (tree.count("platform") > 0) {
    platform_ = tree.get<std::string>("platform", "");
  }

  version_.clear();
  if (tree.count("version") > 0) {
    version_ = tree.get<std::string>("version", "");
  }

  schedule_.clear();
  if (tree.count("queries") == 0) {
    // This pack contained no queries.
    return;
  }

  // If the splay percent is less than 1 reset to a sane estimate.
  if (FLAGS_schedule_splay_percent <= 1) {
    FLAGS_schedule_splay_percent = 10;
  }

  // Iterate the queries (or schedule) and check platform/version/sanity.
  for (const auto& q : tree.get_child("queries")) {
    if (q.second.count("platform")) {
      if (!checkPlatform(q.second.get<std::string>("platform", ""))) {
        continue;
      }
    }

    if (q.second.count("version")) {
      if (!checkVersion(q.second.get<std::string>("version", ""))) {
        continue;
      }
    }

    ScheduledQuery query;
    query.query = q.second.get<std::string>("query", "");
    query.interval = q.second.get("interval", FLAGS_schedule_default_interval);
    if (query.interval <= 0 || query.query.empty()) {
      // Invalid pack query.
      continue;
    }

    query.splayed_interval = restoreSplayedValue(q.first, query.interval);
    query.options["snapshot"] = q.second.get<bool>("snapshot", false);
    query.options["removed"] = q.second.get<bool>("removed", true);
    schedule_[q.first] = query;
  }
}
    void NFCReaderUnit::unSerialize(boost::property_tree::ptree& node)
    {
		d_name = node.get_child("Name").get_value<std::string>();
        ReaderUnit::unSerialize(node);
    }
Example #13
0
Status serializeDistributedQueryRequest(const DistributedQueryRequest& r,
                                        pt::ptree& tree) {
  tree.put("query", r.query);
  tree.put("id", r.id);
  return Status(0, "OK");
}
Example #14
0
void Agent::setProperties(const boost::property_tree::ptree& properties) {
    static const std::string LOG_LEVEL("log.level");
    static const std::string ENDPOINT_SOURCE_PATH("endpoint-sources.filesystem");
    static const std::string SERVICE_SOURCE_PATH("service-sources.filesystem");
    static const std::string OPFLEX_PEERS("opflex.peers");
    static const std::string OPFLEX_SSL_MODE("opflex.ssl.mode");
    static const std::string OPFLEX_SSL_CA_STORE("opflex.ssl.ca-store");
    static const std::string OPFLEX_SSL_CERT_PATH("opflex.ssl.client-cert.path");
    static const std::string OPFLEX_SSL_CERT_PASS("opflex.ssl.client-cert.password");
    static const std::string HOSTNAME("hostname");
    static const std::string PORT("port");
    static const std::string OPFLEX_INSPECTOR("opflex.inspector.enabled");
    static const std::string OPFLEX_INSPECTOR_SOCK("opflex.inspector.socket-name");
    static const std::string OPFLEX_NOTIF("opflex.notif.enabled");
    static const std::string OPFLEX_NOTIF_SOCK("opflex.notif.socket-name");
    static const std::string OPFLEX_NOTIF_OWNER("opflex.notif.socket-owner");
    static const std::string OPFLEX_NOTIF_GROUP("opflex.notif.socket-group");
    static const std::string OPFLEX_NOTIF_PERMS("opflex.notif.socket-permissions");

    static const std::string OPFLEX_NAME("opflex.name");
    static const std::string OPFLEX_DOMAIN("opflex.domain");

    static const std::string RENDERERS_STITCHED_MODE("renderers.stitched-mode");

    optional<std::string> logLvl =
        properties.get_optional<std::string>(LOG_LEVEL);
    if (logLvl) {
        setLoggingLevel(logLvl.get());
    }

    boost::optional<std::string> ofName =
        properties.get_optional<std::string>(OPFLEX_NAME);
    if (ofName) opflexName = ofName;
    boost::optional<std::string> ofDomain =
        properties.get_optional<std::string>(OPFLEX_DOMAIN);
    if (ofDomain) opflexDomain = ofDomain;

    boost::optional<bool> enabInspector =
        properties.get_optional<bool>(OPFLEX_INSPECTOR);
    boost::optional<std::string> inspSocket =
        properties.get_optional<std::string>(OPFLEX_INSPECTOR_SOCK);
    if (enabInspector) enableInspector = enabInspector;
    if (inspSocket) inspectorSock = inspSocket;

    boost::optional<bool> enabNotif =
        properties.get_optional<bool>(OPFLEX_NOTIF);
    boost::optional<std::string> notSocket =
        properties.get_optional<std::string>(OPFLEX_NOTIF_SOCK);
    boost::optional<std::string> notOwner =
        properties.get_optional<std::string>(OPFLEX_NOTIF_OWNER);
    boost::optional<std::string> notGrp =
        properties.get_optional<std::string>(OPFLEX_NOTIF_GROUP);
    boost::optional<std::string> notPerms =
        properties.get_optional<std::string>(OPFLEX_NOTIF_PERMS);
    if (enabNotif) enableNotif = enabNotif;
    if (notSocket) notifSock = notSocket;
    if (notOwner) notifOwner = notOwner;
    if (notGrp) notifGroup = notGrp;
    if (notPerms) notifPerms = notPerms;

    optional<const ptree&> endpointSource =
        properties.get_child_optional(ENDPOINT_SOURCE_PATH);

    if (endpointSource) {
        for (const ptree::value_type &v : endpointSource.get())
            endpointSourcePaths.insert(v.second.data());
    }

    optional<const ptree&> serviceSource =
        properties.get_child_optional(SERVICE_SOURCE_PATH);

    if (serviceSource) {
        for (const ptree::value_type &v : serviceSource.get())
            serviceSourcePaths.insert(v.second.data());
    }

    optional<const ptree&> peers =
        properties.get_child_optional(OPFLEX_PEERS);
    if (peers) {
        for (const ptree::value_type &v : peers.get()) {
            optional<std::string> h =
                v.second.get_optional<std::string>(HOSTNAME);
            optional<int> p =
                v.second.get_optional<int>(PORT);
            if (h && p) {
                opflexPeers.insert(make_pair(h.get(), p.get()));
            }
        }
    }

    boost::optional<std::string> confSslMode =
        properties.get_optional<std::string>(OPFLEX_SSL_MODE);
    boost::optional<std::string> confsslCaStore =
        properties.get_optional<std::string>(OPFLEX_SSL_CA_STORE);
    boost::optional<std::string> confsslClientCert =
        properties.get_optional<std::string>(OPFLEX_SSL_CERT_PATH);
    boost::optional<std::string> confsslClientCertPass =
        properties.get_optional<std::string>(OPFLEX_SSL_CERT_PASS);
    if (confSslMode)
        sslMode = confSslMode;
    if (confsslCaStore)
        sslCaStore = confsslCaStore;
    if (confsslClientCert)
        sslClientCert = confsslClientCert;
    if (confsslClientCertPass)
        sslClientCertPass = confsslClientCertPass;

    typedef Renderer* (*rend_create)(Agent&);
    typedef std::unordered_map<std::string, rend_create> rend_map_t;
    static rend_map_t rend_map =
        boost::assign::map_list_of(RENDERERS_STITCHED_MODE,
                                   StitchedModeRenderer::create);

    for (rend_map_t::value_type& v : rend_map) {
        optional<const ptree&> rtree =
            properties.get_child_optional(v.first);
        if (rtree) {
            Renderer* r = v.second(*this);
            renderers.push_back(r);
            r->setProperties(rtree.get());
        }
    }
}
Example #15
0
 void TwicLocation::unSerialize(boost::property_tree::ptree& node)
 {
     dataObject = node.get_child("DataObject").get_value<uint64_t>();
 }
 void NXPAV1KeyDiversification::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
 void MifareUltralightAccessInfo::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     node.put("LockPage", lockPage);
     parentNode.add_child(MifareUltralightAccessInfo::getDefaultXmlNodeName(), node);
 }
bool ProduceExcelWorkbook(Excel::_WorkbookPtr &pXLBook,
	const std::wstring &wstrFilename,
	const std::string &strPropellant,
	bool bMetric,
	const boost::property_tree::ptree &tree,
	const std::vector<std::tuple<double, double, double, double, double> > &vReadings,
	std::map<std::wstring, std::wstring> &mapProperties)
{
	if(vReadings.empty())
	{
		return false;
	}
	// Get the active Worksheet and set its name.
	Excel::_WorksheetPtr pXLSheet = pXLBook->ActiveSheet;
	_ASSERT(pXLSheet);
	if(nullptr == pXLSheet)
	{
		return false;
	}

	//
	// Get Max Pressure to calculate the 10% line
	double dPmaxtime = 0.0f;
	double dPmax = GetPmax(dPmaxtime, vReadings);
	double dpTenPercent = dPmax * 0.10f;

	//
	// Need to know the start and stop burn time based on 10% of Pmax:
	double dBurnStartTime = 0.0f;
	double dBurnEndTime = 0.0f;
	LONG lIndexBurnStart = 0;
	LONG lIndexBurnEnd = 0;
	LONG lExcelIndex = 1;
	bool bHaveEndTime = false;
	for(auto entry : vReadings)
	{
		double dPressure = std::get<ePressure>(entry);
		double dTime = std::get<eTime>(entry);
		++lExcelIndex;
		if(dTime <= dPmaxtime)
		{
			if(dPressure < dpTenPercent)
			{
				continue;
			}
			if(0 == lIndexBurnStart)
			{
				dBurnStartTime = dTime;
				lIndexBurnStart = lExcelIndex;
			}
		}
		else
		{
			// Watching the curve downward...
			lIndexBurnEnd = lExcelIndex;
			if(dPressure < dpTenPercent)
			{
				break;
			}
			dBurnEndTime = dTime;
		}
	}
	double dBurnTime = dBurnEndTime - dBurnStartTime;

	//
	// Convert name to a wide string and assign it to the sheet
	std::wstring wstrTabName(wstrFilename);
	SanitizeStringName(wstrTabName);

	//
	// Remove any math operators from the name:
	_bstr_t bstrTabName(SysAllocString(wstrTabName.c_str()));
	pXLSheet->Name = bstrTabName;

	std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
	// std::wstring wstrPropellantName(converter.from_bytes(strPropellant.c_str()));

	//
	// Create seven columns of data: Time, Thrust (LBS), Thrust (N), and Pressure (PSI), ...
	// Construct a safearray of the data
	LONG lIndex = 2;		// Note, 1 based not 0 - will contain # of rows...
	VARIANT saData;
	VARIANT saDataReferences;
	saData.vt = VT_ARRAY | VT_VARIANT;
	saDataReferences.vt = VT_ARRAY | VT_VARIANT;
	{
		SAFEARRAYBOUND sab[2];
		sab[0].lLbound = 1;
		sab[0].cElements = vReadings.size() + 2;
		sab[1].lLbound = 1;
		sab[1].cElements = 7;
		saData.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
		if(saData.parray == nullptr)
		{
			MessageBoxW(HWND_TOP, L"Unable to create safearray for passing data to Excel.", L"Memory error...", MB_TOPMOST | MB_ICONERROR);
			return false;
		}

		//
		// Clean-up safe array when done...
		auto cleanArray = std::experimental::make_scope_exit([&saData]() -> void
		{
			VariantClear(&saData);
		});

		sab[0].lLbound = 1;
		sab[0].cElements = vReadings.size() + 2;
		sab[1].lLbound = 1;
		sab[1].cElements = 5;
		saDataReferences.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
		if(saDataReferences.parray == nullptr)
		{
			MessageBoxW(HWND_TOP, L"Unable to create safearray for passing data to Excel.", L"Memory error...", MB_TOPMOST | MB_ICONERROR);
			return false;
		}

		//
		// Clean-up safe array when done...
		auto cleanRefArray = std::experimental::make_scope_exit([&saDataReferences]() -> void
		{
			VariantClear(&saDataReferences);
		});

		//
		// Labels:
		SafeArrayPutString(*saData.parray, 1, 1, L"Time");
		SafeArrayPutString(*saData.parray, 1, 2, L"Thrust\n(lbs.)");
		SafeArrayPutString(*saData.parray, 1, 3, L"Thrust\n(N)");
		SafeArrayPutString(*saData.parray, 1, 4, L"Pressure\n(PSI)");
		SafeArrayPutString(*saData.parray, 1, 5, L"Threshold");
		SafeArrayPutString(*saData.parray, 1, 6, L"Time\nDelta");
		SafeArrayPutString(*saData.parray, 1, 7, L"Thrust Element\n(N)");

		//
		// Labels for reference data
		SafeArrayPutString(*saDataReferences.parray, 1, 1, L"Time Delta");				// AA
		SafeArrayPutString(*saDataReferences.parray, 1, 2, L"Thrust\n(lbs.)");			// AB
		SafeArrayPutString(*saDataReferences.parray, 1, 3, L"Thrust\n(N)");				// AC
		SafeArrayPutString(*saDataReferences.parray, 1, 4, L"Pressure\n(PSI)");			// AD
		SafeArrayPutString(*saDataReferences.parray, 1, 5, L"Thrust Element\n(N)");		// AE

		LONG lIndexBurnStart = lIndex;
		LONG lIndexBurnEnd = lIndex;
		for(auto data : vReadings)
		{
			double dTime = std::get<eTime>(data);
			double dThrust = std::get<eThrust>(data);
			double dPressure = std::get<ePressure>(data);
			double dThrustLBS = bMetric ? dThrust / g_dNewtonsPerPound : dThrust;
			double dThrustN = bMetric ? dThrust : dThrust * g_dNewtonsPerPound;
			double dTimeDelta = std::get<eTimeDelta>(data);
			double dThrustElementN = std::get<eThrustElementN>(data);

			SafeArrayPutDouble(*saData.parray, lIndex, 1, dTime);			// A
			SafeArrayPutDouble(*saData.parray, lIndex, 2, dThrustLBS);		// B
			SafeArrayPutDouble(*saData.parray, lIndex, 3, dThrustN);		// C
			SafeArrayPutDouble(*saData.parray, lIndex, 4, dPressure);		// D
			std::wstring wstrPmaxCalcCell(L"=IF($D$");
			wstrPmaxCalcCell += std::to_wstring(lIndex);
			wstrPmaxCalcCell += L"<$Q$35,0,$Q$35";
			SafeArrayPutString(*saData.parray, lIndex, 5, wstrPmaxCalcCell);// E (pMax threshold)
			SafeArrayPutDouble(*saData.parray, lIndex, 6, dTimeDelta);		// F
			SafeArrayPutDouble(*saData.parray, lIndex, 7, dThrustElementN);	// G

			//
			// Generate a set of data (to be hidden) which is blank when the real value is below the threshold
			auto fnGenThresholdIFStatement = ([lIndex](std::wstring &wstrStatement, wchar_t wcCol)
			{
				wstrStatement = L"=IF($E$";
				wstrStatement += std::to_wstring(lIndex);
				wstrStatement += L",$";
				wstrStatement += wcCol;
				wstrStatement += L"$";
				wstrStatement += std::to_wstring(lIndex);
				wstrStatement += L",\"\")";
			});

			//
			// Now the references to included data  =IF($E$n,$F$n,"")
			std::wstring wstrRef;
			fnGenThresholdIFStatement(wstrRef, L'F');
			SafeArrayPutString(*saDataReferences.parray, lIndex, 1, wstrRef);// AA (Time Delta)
			fnGenThresholdIFStatement(wstrRef, L'B');
			SafeArrayPutString(*saDataReferences.parray, lIndex, 2, wstrRef);// AB (Thrust LBS.)
			fnGenThresholdIFStatement(wstrRef, L'C');
			SafeArrayPutString(*saDataReferences.parray, lIndex, 3, wstrRef);// AC (Thrust N.)
			fnGenThresholdIFStatement(wstrRef, L'D');
			SafeArrayPutString(*saDataReferences.parray, lIndex, 4, wstrRef);// AD (Pressure)
			fnGenThresholdIFStatement(wstrRef, L'G');
			SafeArrayPutString(*saDataReferences.parray, lIndex, 5, wstrRef);// AE (Thrust Element)

			++lIndex;
		}

		//
		// Insert the data into A1-Gx
		std::wstring wstrDataRange(L"A1:G");
		wstrDataRange += std::to_wstring(lIndex);

		Excel::RangePtr pXLRange = pXLSheet->Range[_variant_t(wstrDataRange.c_str())];
		_ASSERT(pXLRange);
		if(nullptr == pXLRange)
		{
			return false;
		}
		pXLRange->Value2 = saData;

		//
		// Insert the Reference Data in AA - EE
		std::wstring wstrDataRangeRef(L"AA1:AE");
		wstrDataRangeRef += std::to_wstring(lIndex);

		Excel::RangePtr pXLRangeRef = pXLSheet->Range[_variant_t(wstrDataRangeRef.c_str())];
		_ASSERT(pXLRangeRef);
		if(nullptr == pXLRangeRef)
		{
			return false;
		}
		pXLRangeRef->Value2 = saDataReferences;
	}

	//
	// Create a chart showing pressure and thrust curves
	// With a secondary axis for thrust so that curves are near in scale
	// e.g. "ASBLUE3_16!$A$1:$B$457,ASBLUE3_16!$D$1:$D$457"
	std::wstring wstrChartRange(wstrTabName + L"!$A$1:$B$");
	wstrChartRange += std::to_wstring(lIndex);
	wstrChartRange += L",";
	wstrChartRange += wstrTabName;
	wstrChartRange += L"!$D$1:$D$";
	wstrChartRange += std::to_wstring(lIndex);
	_variant_t varChartRangeString(wstrChartRange.c_str());

	//
	// Create the range...
	Excel::RangePtr pChartRange = pXLSheet->Range[varChartRangeString];
	_ASSERT(pChartRange);
	if(nullptr == pChartRange)
	{
		return false;
	}

	//
	// Create the chart -- odd, but this the method for getting it embedded on
	// the same page as the data...
	auto pShapes = pXLSheet->GetShapes();
	_ASSERT(pShapes);
	if(nullptr == pShapes)
	{
		return false;
	}

	// auto pChartShape = pShapes->AddChart2(240, Excel::xlXYScatter); <- Requires Excel 2013
	auto pChartShape = pShapes->AddChart(Excel::xlXYScatter);
	_ASSERT(pChartShape);
	if(nullptr == pChartShape)
	{
		return false;
	}
	pChartShape->Select();

	//
	// With the newly created Chart Shape we can access it's chart with Workbook::GetActiveChart()
	// And set the source data to the range created previously...
	auto pChart = pXLBook->GetActiveChart();
	_ASSERT(pChart);
	if(nullptr == pChart)
	{
		return false;
	}
	pChart->SetSourceData(pChartRange);

	//
	// Set the Chart Title
	pChart->PutHasTitle(LOCALE_USER_DEFAULT, VARIANT_TRUE);
	auto pChartTitle = pChart->ChartTitle;
	_ASSERT(pChartTitle);
	if(nullptr != pChartTitle)
	{
		pChartTitle->Select();
		pChartTitle->Text = _bstr_t(L"Pressure and Thrust");
	}

	//
	// Setup as a custom chart with stacked lines and a secondary axis
	Excel::SeriesPtr pFSC1 = pChart->SeriesCollection(variant_t(1));
	Excel::SeriesPtr pFSC2 = pChart->SeriesCollection(variant_t(2));
	_ASSERT(pFSC1);
	_ASSERT(pFSC2);
	if(nullptr == pFSC1 || nullptr == pFSC2)
	{
		return false;
	}
	pFSC1->ChartType = Excel::xlLineStacked;
	pFSC1->AxisGroup = Excel::xlSecondary;
	pFSC2->ChartType = Excel::xlLineStacked;
	pFSC2->AxisGroup = Excel::xlPrimary;

	//
	// Make the axis labels appear (left for PSI, bottom for time, and right for thrust)
	pChart->SetElement(Office::msoElementPrimaryCategoryAxisTitleAdjacentToAxis);
	pChart->SetElement(Office::msoElementPrimaryValueAxisTitleRotated);
	pChart->SetElement(Office::msoElementSecondaryValueAxisTitleAdjacentToAxis);

	//
	// Set the bottom (Primary - Category) axis title to "time":
	Excel::AxisPtr pPrimaryAxes = pChart->Axes(Excel::xlCategory, Excel::xlPrimary);
	_ASSERT(pPrimaryAxes);
	if(nullptr == pPrimaryAxes)
	{
		return false;
	}

	Excel::AxisTitlePtr pPrimaryAxisTitle = pPrimaryAxes->AxisTitle;
	_ASSERT(pPrimaryAxisTitle);
	if(nullptr == pPrimaryAxisTitle)
	{
		return false;
	}
	pPrimaryAxisTitle->Select();
	_bstr_t bstrTime(L"Time");
	pPrimaryAxisTitle->Text = bstrTime;

	//
	// Set the left (Primary - Value) axis title to "PSI":
	_bstr_t bstrPSI(L"PSI");
	Excel::AxisPtr pPrimaryVAxes = pChart->Axes(Excel::xlValue, Excel::xlPrimary);
	_ASSERT(pPrimaryVAxes);
	if(nullptr == pPrimaryVAxes)
	{
		return false;
	}
	Excel::AxisTitlePtr pPrimaryVAxisTitle = pPrimaryVAxes->AxisTitle;
	_ASSERT(pPrimaryVAxisTitle);
	if(nullptr == pPrimaryVAxisTitle)
	{
		return false;
	}
	pPrimaryVAxisTitle->Select();
	pPrimaryVAxisTitle->Text = bstrPSI;

	//
	// Set the right (Secondary - Value) axis title to "Pounds of Thrust"
	Excel::AxisPtr pSecondaryAxes = pChart->Axes(Excel::xlValue, Excel::xlSecondary);
	_ASSERT(pSecondaryAxes);
	if(nullptr == pSecondaryAxes)
	{
		return false;
	}
	Excel::AxisTitlePtr pSecondaryAxisTitle = pSecondaryAxes->AxisTitle;
	_ASSERT(pSecondaryAxisTitle);
	if(nullptr == pSecondaryAxisTitle)
	{
		return false;
	}
	pSecondaryAxisTitle->Text = _bstr_t(L"Pounds of Thrust");

	//
	// Move chart into place and give a good size:
	Excel::ChartAreaPtr pChartArea = pChart->GetChartArea(0);
	_ASSERT(pChartArea);
	if(nullptr == pChartArea)
	{
		return false;
	}
	pChartArea->PutLeft(365.0f);
	pChartArea->PutTop(52.0f);
	pChartArea->PutHeight(300.0f);
	pChartArea->PutWidth(500.0f);

	//
	// Set Gridlines
	pChart->SetElement(Office::msoElementPrimaryCategoryGridLinesNone);
	pChart->SetElement(Office::msoElementPrimaryValueGridLinesNone);
	pChart->SetElement(Office::msoElementPrimaryValueGridLinesMajor);
	pChart->SetElement(Office::msoElementPrimaryValueGridLinesNone);
	pChart->SetElement(Office::msoElementPrimaryValueGridLinesMinor);

	//
	// Add the 10% Pmax line:
	Excel::SeriesCollectionPtr pSeriesCol = pChart->SeriesCollection();
	_ASSERT(pSeriesCol);
	if(nullptr == pSeriesCol)
	{
		return false;
	}
	Excel::SeriesPtr pPmaxSeries = pSeriesCol->NewSeries();
	_ASSERT(pPmaxSeries);
	if(nullptr == pPmaxSeries)
	{
		return false;
	}
	pPmaxSeries->Name = _bstr_t(L"Action Time");

	std::wstring wstrPmaxValue(L"=");
	wstrPmaxValue += wstrTabName;
	std::wstring wstrPmaxXValue(wstrPmaxValue);
	wstrPmaxValue += L"!$E$2:$E$";
	wstrPmaxXValue += L"!$A$2:$A$";
	wstrPmaxValue += std::to_wstring(lIndex);
	wstrPmaxXValue += std::to_wstring(lIndex);
	pPmaxSeries->Values = _bstr_t(wstrPmaxValue.c_str());
	pPmaxSeries->XValues = _bstr_t(wstrPmaxXValue.c_str());
	pPmaxSeries->ChartType = Excel::xlLine;
	pPmaxSeries->AxisGroup = Excel::xlPrimary;

	std::wstring wstrPressureRange(L"(D2:D");
	wstrPressureRange += std::to_wstring(lIndex);
	wstrPressureRange += L")";

	//
	// Display other file data...
	const std::string strGrains(tree.get("Document.MotorData.Grains", "0"));
	const std::string strCaseDiameter(tree.get("Document.MotorData.CaseDiameter", "0 mm"));
	const std::string strNozzleThroat(tree.get("Document.MotorData.NozzleThroatDiameter", "0"));
	std::string strInfo(strGrains + " grain " + strCaseDiameter + " " + strPropellant + " with " + strNozzleThroat + "\" throat 'nozzle'");
	std::wstring wstrInfo(converter.from_bytes(strInfo.c_str()));
	std::wstring wstrInfoRange(L"K1");

	Excel::RangePtr pInfoRange = pXLSheet->Range[_variant_t(wstrInfoRange.c_str())];
	_ASSERT(pInfoRange);
	if(nullptr == pInfoRange)
	{
		return false;
	}
	pInfoRange->Value2 = _bstr_t(wstrInfo.c_str());

	//
	// Add calculated data: ???  5% line and other calculated data...
	// <doc name, display name, display location row letter, display location cell number, metric conversion>
	std::vector<std::tuple<std::string, std::wstring, wchar_t, int, bool> > vFileItemDisplay;
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.MaxThrust", L"Maximum Thrust:", L'K', 25, true));
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.AvgThrust", L"Average Thrust:", L'K', 26, true));
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.MaxPressure", L"Maximum Pressure:", L'K', 28, false));
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.AvgPressure", L"Average Pressure:", L'K', 29, false));
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.BurnTime", L"Burn Time:", L'K', 31, false));
	vFileItemDisplay.push_back(std::make_tuple("Document.MotorData.Impuse", L"Impulse:", L'K', 32, false));	// NOTE: Spelling mistake in the TC Logger data!

	PlaceStringInCell(pXLSheet, L'L', 24, L"TC Logger File Data:");
	for(auto entry : vFileItemDisplay)
	{
		std::wstring wstrDisplay(std::get<1>(entry));

		double dData = tree.get(std::get<0>(entry).c_str(), 0.0f);
		bool bConversion = std::get<4>(entry);

		const wchar_t wcColumn = std::get<2>(entry);
		const wchar_t wcDataColumn = wcColumn + 2;
		int row = std::get<3>(entry);

		PlaceStringInCell(pXLSheet, wcColumn, row, wstrDisplay);
		if(bConversion)
		{
			double dThrustLBS = bMetric ? dData / g_dNewtonsPerPound : dData;
			double dThrustN = bMetric ? dData : dData * g_dNewtonsPerPound;

			PlaceStringInCell(pXLSheet, wcDataColumn, row, std::to_wstring(dThrustLBS));
			PlaceStringInCell(pXLSheet, wcDataColumn + 1, row, L"LBS.");
			PlaceStringInCell(pXLSheet, wcDataColumn + 2, row, std::to_wstring(dThrustN));
			PlaceStringInCell(pXLSheet, wcDataColumn + 3, row, L"N");
		}
		else
		{
			PlaceStringInCell(pXLSheet, wcDataColumn, row, std::to_wstring(dData));
		}
	}

	PlaceStringInCell(pXLSheet, L'I', 34, L"VARIABLES:");
	//
	// Percent of Pmax used for calculations
	PlaceStringInCell(pXLSheet, L'I', 35, L"% Pmax for Burn threshold:");
	PlaceStringInCell(pXLSheet, L'L', 35, mapProperties[L"PmaxThreshold"]);		// 10% by default gives Action Time according to Sutton
	PlaceStringInCell(pXLSheet, L'M', 35, L"Pmax:");
	std::wstring wstrPmaxCalc(L"=MAX");
	wstrPmaxCalc += wstrPressureRange;
	PlaceStringInCell(pXLSheet, L'N', 35, wstrPmaxCalc);
	PlaceStringInCell(pXLSheet, L'O', 35, L"Pmax Threshold:");
	PlaceStringInCell(pXLSheet, L'Q', 35, L"=($N$35*($L$35/100))");		// Q35

	//
	// Grain Weight (g):			[178]
	PlaceStringInCell(pXLSheet, L'I', 36, L"Grain Weight (g):");
	PlaceStringInCell(pXLSheet, L'L', 36, mapProperties[L"GrainWeight"]);

	// Liner Weight g/in:			[ 1.9197342 ] or [ 3.030928 ]
	PlaceStringInCell(pXLSheet, L'I', 37, L"Casting Tube Weight (g/in.):");
	PlaceStringInCell(pXLSheet, L'L', 37, mapProperties[L"CastingTubeWeight"]);
	// PlaceStringInCell(pXLSheet, L'M', 37, L"White 54mm casting tube: 1.9197342 g/in.  Tru-Core Waxy 54mm: 3.030928 g/in");

	// Grain Length:				[ 3.0625 ]
	PlaceStringInCell(pXLSheet, L'I', 38, L"Grain Length (in.):");
	PlaceStringInCell(pXLSheet, L'L', 38, mapProperties[L"GrainLength"]);

	// Grain Diameter (in.):		[ 1.75 ]
	PlaceStringInCell(pXLSheet, L'I', 39, L"Grain Diameter (in.):");
	PlaceStringInCell(pXLSheet, L'L', 39, mapProperties[L"GrainDiameter"]);

	// Grain Core (in.):			[ 0.625 ]
	PlaceStringInCell(pXLSheet, L'I', 40, L"Grain Core (in.):");
	PlaceStringInCell(pXLSheet, L'L', 40, mapProperties[L"GrainCore"]);

	//
	// Our calculations (using Excel formulas so input can be changed)...
	PlaceStringInCell(pXLSheet, L'I', 42, L"Calculations based on Pmax Threshold:");

	// Density:
	PlaceStringInCell(pXLSheet, L'I', 43, L"Density:");
	PlaceStringInCell(pXLSheet, L'L', 43, L"=((L36-(L38*L37))/453.59237)/(((((L39/2)^2)-(L40/2)^2))*PI()*L38)");

	// Web
	PlaceStringInCell(pXLSheet, L'I', 44, L"Web:");
	PlaceStringInCell(pXLSheet, L'L', 44, L"=(L39-L40)/2");

	// Burn Time (s)
	PlaceStringInCell(pXLSheet, L'I', 45, L"Burn Time (s):");
	std::wstring wstrBurnTime(L"=SUM(AA1:AA");
	wstrBurnTime += std::to_wstring(lIndex);
	PlaceStringInCell(pXLSheet, L'L', 45, wstrBurnTime);
	PlaceStringInCell(pXLSheet, L'M', 45, std::wstring(L"10% = " + std::to_wstring(dBurnTime)));

	// Max Pressure
	PlaceStringInCell(pXLSheet, L'I', 46, L"Max Pressure (PSI):");
	std::wstring wstrBtPressureRange(L"(AD1:AD");
	wstrBtPressureRange += std::to_wstring(lIndex);
	wstrBtPressureRange += L")";

	std::wstring wstrMaxPressure(L"=MAX");
	wstrMaxPressure += wstrBtPressureRange;
	PlaceStringInCell(pXLSheet, L'L', 46, wstrMaxPressure);

	// Average Pressure
	PlaceStringInCell(pXLSheet, L'I', 47, L"Average Pressure (PSI):");
	std::wstring wstrAvgPressure(L"=AVERAGE");
	wstrAvgPressure += wstrBtPressureRange;
	PlaceStringInCell(pXLSheet, L'L', 47, wstrAvgPressure);

	std::wstring wstrThrustRange(L"(AB1:AB");
	std::wstring wstrThrustRangeN(L"(AC1:AC");
	std::wstring wstrThrustElementRangeN(L"(AE1:AE");
	wstrThrustRange += std::to_wstring(lIndex);
	wstrThrustRangeN += std::to_wstring(lIndex);
	wstrThrustElementRangeN += std::to_wstring(lIndex);
	wstrThrustRange += L")";
	wstrThrustRangeN += L")";
	wstrThrustElementRangeN += L")";

	// Max Thrust (LBS)
	PlaceStringInCell(pXLSheet, L'I', 48, L"Max Thrust (LBS):");
	std::wstring wstrMaxThrust(L"=MAX");
	wstrMaxThrust += wstrThrustRange;
	PlaceStringInCell(pXLSheet, L'L', 48, wstrMaxThrust);

	// Max Thrust (N)
	PlaceStringInCell(pXLSheet, L'I', 49, L"Max Thrust (N):");
	std::wstring wstrMaxThrustN(L"=MAX");
	wstrMaxThrustN += wstrThrustRangeN;
	PlaceStringInCell(pXLSheet, L'L', 49, wstrMaxThrustN);

	// Average Thrust (LBS)
	PlaceStringInCell(pXLSheet, L'I', 50, L"Average Thrust (LBS):");
	std::wstring wstrAvgThrust(L"=AVERAGE");
	wstrAvgThrust += wstrThrustRange;
	PlaceStringInCell(pXLSheet, L'L', 50, wstrAvgThrust);

	// Average Thrust (N)
	PlaceStringInCell(pXLSheet, L'I', 51, L"Average Thrust (N):");
	std::wstring wstrAvgThrustN(L"=AVERAGE");
	wstrAvgThrustN += wstrThrustRangeN;
	PlaceStringInCell(pXLSheet, L'L', 51, wstrAvgThrustN);

	// Total Thrust:
	PlaceStringInCell(pXLSheet, L'I', 52, L"Total Thrust (N):");
	std::wstring wstrTotalThrustN(L"=SUM");
	wstrTotalThrustN += wstrThrustElementRangeN;
	PlaceStringInCell(pXLSheet, L'L', 52, wstrTotalThrustN);

	// Grain Weight minus Liner:
	PlaceStringInCell(pXLSheet, L'I', 53, L"Propellant Weight (g):");
	PlaceStringInCell(pXLSheet, L'L', 53, L"=(L36-(L38*L37))");

	// ISP:
	PlaceStringInCell(pXLSheet, L'I', 55, L"ISP:");
	PlaceStringInCell(pXLSheet, L'L', 55, L"=L52/(9.8*(L53/1000))");

	// Burn Rate:
	PlaceStringInCell(pXLSheet, L'I', 56, L"Burn Rate:");
	PlaceStringInCell(pXLSheet, L'L', 56, L"=(L44/L45)");

	//
	// Make the INPUT area GREEN:
	Excel::RangePtr pVariableRange = pXLSheet->Range[_variant_t(L"I35:L40")];
	_ASSERT(pVariableRange);
	if(nullptr == pVariableRange)
	{
		return false;
	}
	Excel::InteriorPtr pIntVarRange = pVariableRange->Interior;
	_ASSERT(pIntVarRange);
	if(nullptr == pIntVarRange)
	{
		return false;
	}
	pIntVarRange->Pattern = xlSolid;
	pIntVarRange->PatternColorIndex = Excel::xlAutomatic;
	pIntVarRange->Color = 5287936;
	pIntVarRange->TintAndShade = 0;
	pIntVarRange->PatternTintAndShade = 0;

	//
	// Output Area
	Excel::RangePtr pCalcRange = pXLSheet->Range[_variant_t(L"I43:L56")];
	_ASSERT(pCalcRange);
	if(nullptr == pCalcRange)
	{
		return false;
	}
	Excel::InteriorPtr pIntCalcRange = pCalcRange->Interior;
	_ASSERT(pIntCalcRange);
	if(nullptr == pIntCalcRange)
	{
		return false;
	}
	pIntCalcRange->PatternColorIndex = Excel::xlAutomatic;
	pIntCalcRange->Color = 7373816;
	pIntCalcRange->TintAndShade = 0;
	pIntCalcRange->PatternTintAndShade = 0;

	return true;
}
 void RFIDeasReaderUnit::unSerialize(boost::property_tree::ptree& node)
 {
     d_readerUnitConfig->unSerialize(node.get_child(d_readerUnitConfig->getDefaultXmlNodeName()));
 }
Example #20
0
void set_attr(boost::property_tree::ptree & pt, std::string const& name, T const& v)
{
    pt.put("<xmlattr>." + name, v);
}
void SInit::fromPT(const boost::property_tree::ptree& _pt)
{
    const ptree& pt = _pt.get_child("dds.plug-in");
    m_id = pt.get<string>("id");
}
 void BinaryDataField::unSerialize(boost::property_tree::ptree& node)
 {
     ValueDataField::unSerialize(node);
     d_value = BinaryFieldValue(node.get_child("Value").get_value<std::string>());
     d_padding = node.get_child("Padding").get_value<unsigned char>();
 }
Example #23
0
void logMutationFrequencies( boost::property_tree::ptree & p, std::vector< size_t > & frequencies, std::map< size_t, size_t > & freq_dist, typename locus_bitset::alphabet_t::pointer alpha ) {
    boost::property_tree::ptree v, _v0, _v1;
    _v0.put("", "Allele");
    _v1.put("", "Frequency");
    v.push_back( std::make_pair("", _v0));
    v.push_back( std::make_pair("", _v1));
    p.add_child("frequency.y.smps", v);

    boost::property_tree::ptree x, _x0, _x1;
    _x0.put("", "Region relative position of Allele" );
    _x1.put("", "Frequency of allele in population" );
    x.push_back( std::make_pair("", _x0 ) );
    x.push_back( std::make_pair("", _x1 ) );
    p.add_child( "frequency.x.Description", x);

    boost::property_tree::ptree d,s;

    locus_bitset::alphabet_t::active_iterator alpha_it = alpha->active_begin();
    for( std::vector< size_t >::iterator it = frequencies.begin(); it != frequencies.end(); ++it ) {
        if( *it > 0 ) {
            assert( alpha->checkFreeStatus( it - frequencies.begin()) );
            boost::property_tree::ptree x,y,z, _s;
            x.put( "", alpha_it->first);
            y.put( "", (*it));

            z.push_back( std::make_pair("", x ));
            z.push_back( std::make_pair("", y ));

            std::ostringstream oss;
            oss << (it - frequencies.begin() );

            _s.put("", oss.str());
            s.push_back( std::make_pair("", _s));
            d.push_back( std::make_pair("", z ));

            std::map< size_t, size_t >::iterator it2 = freq_dist.find((*it));
            if( it2 == freq_dist.end() ) {
                freq_dist.insert( std::make_pair( (*it), 1 ) );
            } else {
                ++it2->second;
            }
        }
        ++alpha_it;
    }

    p.add_child( "frequency.y.vars", s );
    p.add_child( "frequency.y.data", d );

    boost::property_tree::ptree graph_opts;
    graph_opts.put("graphType", "Scatter2D");
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Allele");
        tmp.push_back( std::make_pair("", t ) );
        graph_opts.add_child("xAxis", tmp);
    }
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Frequency");
        tmp.push_back( std::make_pair( "",t));
        graph_opts.add_child("yAxis", tmp);
    }
    graph_opts.put( "title", "Allele Frequency" );
    p.add_child( "frequency.graph_opts", graph_opts );
}
 void BinaryFieldValue::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     Key::serialize(node);
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
void merge(boost::property_tree::ptree &dest, bool ignoreEmptyUpdates, const boost::property_tree::ptree::path_type &childPath, const boost::property_tree::ptree &child) {
    if(ignoreEmptyUpdates && (child.data().empty() || child.data().find_first_not_of(" \n\t\r") == std::string::npos)) return;
    dest.put(childPath, child.data());
}
Example #26
0
 Status serialize(const boost::property_tree::ptree& params,
                  std::string& serialized) {
   serialized = params.get("copy", "");
   return Status(0, "OK");
 }
	void UdpDataTransport::unSerialize(boost::property_tree::ptree& node)
	{
		d_ipAddress = node.get_child("IpAddress").get_value<std::string>();
		d_port = node.get_child("Port").get_value<int>();
	}
 void ComputerMemoryKeyStorage::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
std::string ConfigurationReader::GetStringValue(const boost::property_tree::ptree& root, std::string path, std::string defaultValue) {
	return root.get(path, defaultValue);
}
    /* static */ bool Parser::parse_calib_result(CalibResult & calib_result, boost::property_tree::ptree const & root, bool & has_calib_result)
    {
        OptionalPTree values = root.get_child_optional("values");
        has_calib_result = false;

        if (!values)
        {
            return true;
        }

        OptionalPTree calibresult = values->get_child("calibresult");

        if(!calibresult)
        {
            return false;
        }

        calib_result.result = calibresult->get<bool>("result");
        calib_result.deg = calibresult->get<float>("deg");
        calib_result.degl = calibresult->get<float>("degl");
        calib_result.degr = calibresult->get<float>("degr");

        OptionalPTree calibpoints = calibresult->get_child_optional("calibpoints");

        if(!calibpoints)
        {
            return false;
        }

        std::vector<CalibPoint> calibpoints_vector;
        calibpoints_vector.reserve(calibpoints->size());
        boost::property_tree::ptree::const_iterator it = calibpoints->begin();
        boost::property_tree::ptree::const_iterator end = calibpoints->end();

        for (; it != end ; ++it)
        {
            CalibPoint calib_point;

            calib_point.state = it->second.get<int>("state");
            parse_point2d(calib_point.cp, it->second.get_child("cp"));
            parse_point2d(calib_point.mecp, it->second.get_child("mecp"));

            PTree const & acd = it->second.get_child("acd");
            calib_point.acd.ad = acd.get<float>("ad");
            calib_point.acd.adl = acd.get<float>("adl");
            calib_point.acd.adr = acd.get<float>("adr");

            PTree const & mepix = it->second.get_child("mepix");
            calib_point.mepix.mep = mepix.get<float>("mep");
            calib_point.mepix.mepl = mepix.get<float>("mepl");
            calib_point.mepix.mepr = mepix.get<float>("mepr");

            PTree const & asdp = it->second.get_child("asdp");
            calib_point.asdp.asd = asdp.get<float>("asd");
            calib_point.asdp.asdl = asdp.get<float>("asdl");
            calib_point.asdp.asdr = asdp.get<float>("asdr");

            calibpoints_vector.push_back(calib_point);
        }

        has_calib_result = true;
        return true;
    }