本文整理汇总了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++)
{
//.........这里部分代码省略.........
示例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
//.........这里部分代码省略.........
示例3: getDeviceDriverName
inline const string& getDeviceDriverName( ) const
{ return devDriver.getValue(); }
示例4: getFirmwareLevel
inline const string& getFirmwareLevel( ) const
{ return mFirmwareLevel.getValue(); }
示例5: getManufacturer
inline const string& getManufacturer( ) const
{ return mManufacturer.getValue(); }
示例6: getFRU
inline const string& getFRU( ) const
{ return mFRU.getValue(); }
示例7: getFirmwareVersion
inline const string& getFirmwareVersion( ) const
{ return mFirmwareVersion.getValue(); }
示例8: getSerialNumber
inline const string& getSerialNumber( ) const
{ return mSerialNumber.getValue(); }
示例9: getPartNumber
inline const string& getPartNumber( ) const
{ return mPartNumber.getValue(); }
示例10: getRecordType
inline const string& getRecordType( ) const
{ return mRecordType.getValue( ); }
示例11: getDescription
//The Get Value methods
inline const string& getDescription( ) const
{ return mDescription.getValue(); }
示例12: getClassNode
/**
* getClassNode
* @brief Returns the full path for the device in the /sys/class
*/
inline string getClassNode( )
{
return mDevClass.getValue();
}