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


C++ Program::Devices方法代码示例

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


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

示例1: GetProcessStatus

string GetProcessStatus( string query, string id )
{
	// string programName = GetRequestProgramName( query );
	Program* program = ProgramManager::Instance()->GetRunningProgram( atoi( id.c_str() ) );
	string jsonDescr;

	if( program == NULL ) {
		// the program is not started
		jsonDescr += "{\"Status\":\"NotAvailable\"}";
		return jsonDescr;
	}

	string deviceStatus;
	string propertyName = "Value";
	DeviceParameter value;
	char deviceId[16];
	string status = "not set";
	char buffer[32];

	string deviceIp = WebServer::Instance()->Ip();
	int devicePort = WebServer::Instance()->Port();
	sprintf( buffer, "%d", devicePort );

	string processResource = "http://" + deviceIp + ":" + (string)buffer + "/Processes/" + id;
	string projectResource = "http://" + deviceIp + ":" + (string)buffer + "/Projects/" + id;
	string operation = GetProgramStatusOperation;
	jsonDescr = "{\"ResourceId\":\"" + processResource + "\",\"ProjectResourceId\":\"" + projectResource + "\",\"Devices\":[";
	string deviceUrl;
	string propertyUrl;

	list<BaseDevice*>::iterator it;

	for( it = program->Devices()->begin(); it != program->Devices()->end(); it++ )
	{
		value = ( *it )->GetParameter( propertyName );

		if ( value.IsInitialized() == true )
		{
			status = value.StringValue();
		}
		else
		{
			continue;
		}

		sprintf( deviceId, "%d", (*it)->Id() );
		// sprintf( status, "%d", statusValue );

		deviceUrl = processResource + "/Devices/" + (string)deviceId;
		deviceStatus = "{\"ResourceId\":\"" + deviceUrl + "\",\"Properties\":[{\"ResourceId\":\"" + deviceUrl + "/Properties/" + propertyName + "\",\"devkey\":\"" +
				propertyName + "\",\"devtype\":\"int\",\"devvalue\":\"" +  status + "\"}]},";
		jsonDescr += deviceStatus;
	}

	jsonDescr = jsonDescr.substr( 0, jsonDescr.length() - 1 ); // remove the last comma
 	jsonDescr += "],\"Status\":\"Running\"}";

	return jsonDescr;
}
开发者ID:IndigoVerge,项目名称:Agilart-Run-Time,代码行数:59,代码来源:WebServer.cpp

示例2: GetDevicePropery

string GetDevicePropery( string query )
{
	string result = "";

	int programId = atoi( strtok( (char*)query.c_str(), "." ) );
	int deviceId = atoi( strtok( NULL, "." ) );
	char* propertyName = strtok( NULL, "." );

	string propertyValue = "";

	Program* program = ProgramManager::Instance()->GetRunningProgram( programId );
	if ( program == NULL )
	{
		cout<< "Program with id: "<<programId<<" is not started.\n";
		EventLogger::Instance()->WriteVerbose( "Program with id: %d is not started.", programId );

		return "";
	}

	list<BaseDevice*>::iterator it;

	for ( it = program->Devices()->begin(); it != program->Devices()->end(); it++ )
	{
		if ( ( *it )->Id() == deviceId )
		{
			//we have found the device we want -> set the Property we need
			DeviceParameter value = ( *it )->GetParameter( propertyName );

			if( value.IsInitialized() == true )
			{
				propertyValue = Convert::ToString( value.Value(), value.AgilartType() );
			}
			else
			{
				propertyValue = "0";
			}

			if ( result != "" )
				result += "-";

			result += propertyValue;

			break;
		}
	}

	return result;
}
开发者ID:IndigoVerge,项目名称:Agilart-Run-Time,代码行数:48,代码来源:WebServer.cpp

示例3: SetScreenDeviceStatus

void SetScreenDeviceStatus( string query )
{
	char *key = strtok( (char*)query.c_str(), "=" );
	char *value = strtok( NULL, ";" );

	int programId = atoi( strtok( key, "." ) );
	int deviceId = atoi( strtok( NULL, "." ) );
	char* propertyName = strtok( NULL, "." );

	bool isFound = false;

	Program* program = ProgramManager::Instance()->GetRunningProgram( programId );
	if ( program == NULL )
	{
		cout<< "Program with id: "<<programId<<" is not started.\n";
		EventLogger::Instance()->WriteVerbose("Program with id: %d is not started.", programId );

		return;
	}

	list<BaseDevice*>::iterator it;

	for ( it = program->Devices()->begin(); it != program->Devices()->end(); it++ )
	{
		if ( ( *it )->Id() == deviceId )
		{
			isFound = true;
			//we have found the device we want -> set the Property we need
			void* statusValue = new string( value );
			( *it )->SetParameter( propertyName, statusValue );

			break;
		}
	}

	if ( isFound == false )
	{
		cout<< "Device with id: "<<deviceId<<" is not available in program with id: "<<programId<<endl;
		EventLogger::Instance()->WriteVerbose("Device with id: %d is not available in program with id: %d", deviceId, programId );
	}
}
开发者ID:IndigoVerge,项目名称:Agilart-Run-Time,代码行数:41,代码来源:WebServer.cpp


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