当前位置: 首页>>代码示例>>C++>>正文


C++ DataItem类代码示例

本文整理汇总了C++中DataItem的典型用法代码示例。如果您正苦于以下问题:C++ DataItem类的具体用法?C++ DataItem怎么用?C++ DataItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataItem类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getDeviceByName

int AgentMgr::thread(int aArgc, const char *aArgv[])
{
	//sLogger << LENTRY  << "MTConnect Agent Service Started " << nowtimestamp() << "\n";

#ifdef OBSERVER
	// Test out observer functionality
	Device *dev = getDeviceByName(devicename);
	DataItem *di = dev->getDeviceDataItem("Xabs");
	di->addObserver(new  BusyObserver("Xabs", di));
#endif
	try{

		clear();
		_group= new boost::thread_group();
		_agent = new AgentConfiguration();

		int nPort=7878;
		std::string cfgfile;
		if(aArgc > 0)
		{
			cfgfile= aArgv[0];
		}
		else
			cfgfile= ::ExeDirectory() + "VirtualFactoryTestbed.xml";
		
		char result[ MAX_PATH ];
		std::string path( result, GetModuleFileName( NULL, result, MAX_PATH ) );
		std::string inifile =  path.substr(0,path.find_last_of(".")) + ".ini";


		if(GetFileAttributesA(inifile.c_str())== INVALID_FILE_ATTRIBUTES)
			throw std::exception(("No " + inifile + " file").c_str());
		config.load(inifile);
		_devicexmlpath =  config.GetSymbolValue("CONFIG.DevicesFolder", ::ExeDirectory()).c_str();
		_devicefile =  config.GetSymbolValue("CONFIG.DevicesFile", "Devices.xml").c_str();
		_cfgfile =  config.GetSymbolValue("CONFIG.CfgFile","Agent.cfg").c_str();
		_httpPort =  config.GetSymbolValue("CONFIG.HttpPort","81").toNumber<int>();
		_debugSimulation =  config.GetSymbolValue("CONFIG.DebugSimulation","1").toNumber<int>();
		_cmdAgentCfg.SetDevicesXmlFolder(_devicexmlpath);
		_cmdAgentCfg.SetHttpPort(_httpPort);
		_cmdAgentCfg.SetXmlFile(_devicefile);
		_cmdAgentCfg.SetCfgFile(_cfgfile);
		_cmdAgentCfg.SetDestinationFolder(::ExeDirectory());
		SetCurrentDirectory(::ExeDirectory().c_str()); // fixes Agent file lookup issue

	
	//	if( GetFileAttributesA(cfgfile.c_str())!= INVALID_FILE_ATTRIBUTES)
		{
			for(int i=0 ; i< cmsd.resources->size(); i++)
			{
				Resource * r = (Resource *) cmsd.resources->at(i).get();
				std::string name = (LPCSTR) r->name;
				if(name.empty() || name == "None")  // something wrong
					continue; 

				_cmdAgentCfg.AddDevice(name,  // M1, M2
					"Command", // lookup name in devices.xml folder
					"",  // no ip required for SHDR, will talk directly to agent
					"0");			//writing to agent will be done using thread pointer not SHDR

				_devicesAgentCfg.AddDevice(name,  // M1, M2
					"Generic", // lookup name in devices.xml folder
					"127.0.0.1", 
					StdStringFormat("%d", nPort++));

				//spinup.AddDevice("herbie",
				//	name,
				//	GetHostName(),
				//	nPort-1,
				//	GetHostName() + ":81"
				//	);

				CResourceHandler *  _resourceHandler = new CResourceHandler(_agent, this,r, &cmsd);
				_resourceHandlers.push_back(_resourceHandler);
				_resourceHandlers.back()->Configure( config,(LPCSTR) r->identifier,  name, "Command", "127.0.0.1:80/"+name,_devicexmlpath);

			}

			for(int i=0 ; i< cmsd.cells->size(); i++)
			{
				Cell * c = (Cell *) cmsd.cells->at(i).get();
				std::string name = (LPCSTR) c->name;
				CCellHandler *  _cellHandler = new CCellHandler((AgentMgr * ) this, c,&cmsd);
				_cellHandlers.push_back(_cellHandler);
				for(int j=0; j< c-> resourceIds.size(); j++)
				{
					CResourceHandler * r  =  findResource((LPCSTR) c-> resourceIds[j]) ;
					if(r!=NULL)
						_cellHandler->_resources.push_back(r);
				}
			}
		}
		_cmdAgentCfg.Start(_agent);
		::Sleep(1000);

		/*for(int i=0; i< _resourceHandlers.size(); i++)
			_group->create_thread(boost::bind(&CResourceHandler::Thread, _resourceHandlers[i]));
*/
	/*	for(int i=0 ; i< cmsd.jobs->size(); i++)
		{		
//.........这里部分代码省略.........
开发者ID:johnmichaloski,项目名称:CMSD,代码行数:101,代码来源:MTCAgentCmd.cpp

示例2: THROW_IF_XML2_NULL

string XmlPrinter::printSample (const unsigned int       instanceId,
                                const unsigned int       bufferSize,
                                const uint64_t           nextSeq,
                                const uint64_t           firstSeq,
                                const uint64_t           lastSeq,
                                ComponentEventPtrArray & results
                                )
{
    xmlTextWriterPtr writer;
    xmlBufferPtr     buf;
    string           ret;

    try
    {
        THROW_IF_XML2_NULL(buf = xmlBufferCreate( ));
        THROW_IF_XML2_NULL(writer = xmlNewTextWriterMemory(buf, 0));
        THROW_IF_XML2_ERROR(xmlTextWriterSetIndent(writer, 1));
        THROW_IF_XML2_ERROR(xmlTextWriterSetIndentString(writer, BAD_CAST "  "));

        initXmlDoc(writer, eSTREAMS,
                   instanceId,
                   bufferSize,
                   0, 0,
                   nextSeq,
                   firstSeq,
                   lastSeq);

        THROW_IF_XML2_ERROR(xmlTextWriterStartElement(writer, BAD_CAST "Streams"));

        // Sort the vector by category.
        if ( results.size( ) > 1 )
        {
            dlib::qsort_array<ComponentEventPtrArray, EventComparer>(results, 0, results.size( ) - 1, EventCompare);
        }

        Device *   lastDevice    = NULL;
        Component *lastComponent = NULL;
        int        lastCategory  = -1;

        for ( unsigned int i = 0; i < results.size( ); i++ )
        {
            ComponentEventPtr result    = results[i];
            DataItem *        dataItem  = result->getDataItem( );
            Component *       component = dataItem->getComponent( );
            Device *          device    = component->getDevice( );

            if ( device != lastDevice )
            {
                if ( lastDevice != NULL )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // DeviceStream
                }
                lastDevice = device;

                if ( lastComponent != NULL )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // ComponentStream
                }
                lastComponent = NULL;

                if ( lastCategory != -1 )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
                }
                lastCategory = -1;
                addDeviceStream(writer, device);
            }

            if ( component != lastComponent )
            {
                if ( lastComponent != NULL )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // ComponentStream
                }
                lastComponent = component;

                if ( lastCategory != -1 )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
                }
                lastCategory = -1;
                addComponentStream(writer, component);
            }

            if ( lastCategory != dataItem->getCategory( ) )
            {
                if ( lastCategory != -1 )
                {
                    THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
                }
                lastCategory = dataItem->getCategory( );
                addCategory(writer, dataItem->getCategory( ));
            }

            addEvent(writer, result);
        }

        if ( lastCategory != -1 )
        {
            THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
//.........这里部分代码省略.........
开发者ID:johnmichaloski,项目名称:MTConnectToolbox,代码行数:101,代码来源:xml_printer.cpp

示例3: getDeviceDriverName

			inline const string& getDeviceDriverName( ) const
			{ return devDriver.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例4: getFirmwareLevel

			inline const string& getFirmwareLevel( ) const
			{ return mFirmwareLevel.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例5: getManufacturer

			inline const string& getManufacturer( ) const
			{ return mManufacturer.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例6: getFRU

			inline const string& getFRU( ) const
			{ return mFRU.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例7: getFirmwareVersion

			inline const string& getFirmwareVersion( ) const
			{ return mFirmwareVersion.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例8: getSerialNumber

			inline const string& getSerialNumber( ) const
			{ return mSerialNumber.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例9: getPartNumber

			inline const string& getPartNumber( ) const
			{ return mPartNumber.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例10: getRecordType

			inline const string& getRecordType( ) const
			{ return mRecordType.getValue( ); }
开发者ID:jananive,项目名称:libvpd,代码行数:2,代码来源:component.hpp

示例11: getDescription

			//The Get Value methods
			inline const string& getDescription( ) const
			{ return mDescription.getValue(); }
开发者ID:jananive,项目名称:libvpd,代码行数:3,代码来源:component.hpp

示例12: getClassNode

			/**
			 * getClassNode
			 * @brief Returns the full path for the device in the /sys/class
			 */
			inline string getClassNode( )
			{
				return mDevClass.getValue();
			}
开发者ID:jananive,项目名称:libvpd,代码行数:8,代码来源:component.hpp


注:本文中的DataItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。