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


C++ Capability::getMotionVector方法代码示例

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


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

示例1: AckTrainMessage

void Robot01BlockCode::sendLinkTrainMessages(P2PNetworkInterface *sender) {
	if (possibleMotions && !possibleMotions->empty()) {
		Capability *firstCondition = possibleMotions->back()->capa;
		motionVector = firstCondition->getMotionVector(0,1);
		nextMotionVector = firstCondition->getMotionVector(1);
		// si ce n'est pas une queue de train, on propage au suivant
		stringstream info;
		info.str("");
		info << "FirstCondifition :"<< firstCondition->isHead << ":" << firstCondition->isEnd << firstCondition->name;
		scheduler->trace(info.str(),hostBlock->blockId,DARKORANGE);

		PointRel3D pos;
		if (firstCondition->isEnd) {
			pos = *firstCondition->linkPrevPos;
			P2PNetworkInterface *p2p = robotBlock->getP2PNetworkInterfaceByRelPos(
				Cell3DPosition(pos.x,pos.y,pos.z));
			AckTrainMessage *message = new AckTrainMessage(currentTrainGain>0);
			scheduler->schedule(new NetworkInterfaceEnqueueOutgoingEvent(scheduler->now() + COM_DELAY, message,p2p));
			stringstream info;
			info.str("");
			info << "send AckTrainMessage("<< int(currentTrainGain>0) << ") to " << p2p->connectedInterface->hostBlock->blockId;
			scheduler->trace(info.str(),hostBlock->blockId,GREEN);
			trainNext = NULL;
			trainPrevious = currentTrainGain>0?p2p->connectedInterface:NULL;
			robotBlock->setPrevNext(trainPrevious,trainNext);
		} else {
			pos = *firstCondition->linkNextPos;
			P2PNetworkInterface *p2p = robotBlock->getP2PNetworkInterfaceByRelPos(
				Cell3DPosition(pos.x,pos.y,pos.z));
			// si c'est la tête du train on envoie la nouvelle position
			// sinon on transmet celle recue
			TrainMessage *message;
			stringstream info;
			if (sender==NULL) {
				PointRel3D pos;
				pos.x = robotBlock->position[0]+motionVector.x;
				pos.y = robotBlock->position[1]+motionVector.y;
				pos.z = robotBlock->position[2]+motionVector.z;
				info.str("");
				info << "send TrainMessage("<<pos<<",1) to " << p2p->connectedInterface->hostBlock->blockId;
				message = new TrainMessage(pos,1);
			} else {
				message = new TrainMessage(currentTrainGoal,currentTrainGain+2*possibleMotions->back()->gain);
				info.str("");
				info << "send TrainMessage("<<currentTrainGoal<<","<<currentTrainGain+2*possibleMotions->back()->gain<<") to " << p2p->connectedInterface->hostBlock->blockId;
			}
			scheduler->schedule(new NetworkInterfaceEnqueueOutgoingEvent(scheduler->now() + COM_DELAY, message, p2p));
			scheduler->trace(info.str(),hostBlock->blockId,GREEN);

			trainNext = p2p->connectedInterface;
			robotBlock->setPrevNext(trainPrevious,trainNext);
		}
	} else if (sender) {
		AckTrainMessage *message = new AckTrainMessage(false);
		scheduler->schedule(new NetworkInterfaceEnqueueOutgoingEvent(scheduler->now() + COM_DELAY, message,sender));
		stringstream info;
		info.str("");
		info << "send AckTrainMessage(false) to " << sender->connectedInterface->hostBlock->blockId;
		scheduler->trace(info.str(),hostBlock->blockId,GREEN);
		trainNext = NULL;
		trainPrevious = NULL;
		robotBlock->setPrevNext(trainPrevious,trainNext);
	}
}
开发者ID:claytronics,项目名称:visiblesim,代码行数:64,代码来源:robot01BlockCode.cpp


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