本文整理汇总了C++中MessageManager类的典型用法代码示例。如果您正苦于以下问题:C++ MessageManager类的具体用法?C++ MessageManager怎么用?C++ MessageManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Forwarder
void* Forwarder(void* ignored)
{
MessageManager mm;
SDMData dat;
mm.Async_Init(MYPORT2);
char buf[BUFSIZE];
SDMComponent_ID Receiver;
Receiver.setAddress(inet_addr("127.0.0.1"));
Receiver.setPort(MYPORT);
while(1)
{
if (mm.IsReady())
{
if (mm.GetMessage(buf) == SDM_Data)
{
SDMData received;
long Length = received.Unmarshal(buf);
printf("(Forwarder) Received SDMData with timestamp %ld, %ld length is %ld.\n",received.GetSecondsStamp(), received.GetSubSecondsStamp(), Length);
Length = received.Forward(Receiver);
printf("(Forwarder) Forwarding message length is %ld.\n", Length);
fflush(NULL);
}
else
printf("(Forwarder) Unknown message received.\n");
}
sleep(1);
}
return NULL;
}
示例2: spinFunc
// wrapper around MessageManager::spin() that can be passed to
// pthread_create()
void*
spinFunc(void* arg)
{
MessageManager* mgr = (MessageManager*)arg;
mgr->spin();
return NULL;
}
示例3: main
int main(int argc, char** argv)
{
// Initialize ROS node "sm_talker"
ros::init(argc, argv, "sm_listener");
// Required to start timers for non-node ROS use.
ros::Time::init();
// Little message to know she's started
ROS_INFO_STREAM("STARTING SM_MANAGER");
// Create and execute manager
// * Create a TCP server connection on TCP_PORT (see common.h)
// * Initialize manager using server connection
// * Initialize handler using server connection
// * Add handler to manager
// * Execute manager spin loop
TcpServer server;
server.init(TCP_PORT);
MessageManager manager;
MyHandler handler;
manager.init(&server);
// Handler initilaized with reply connection (typically the same as
// incoming connection but now always)
handler.init(&server);
manager.add(&handler);
manager.spin();
return 0;
}
示例4: TEST
TEST(MessageManagerSuite, init)
{
MessageManager manager;
TestClient client;
EXPECT_TRUE(manager.init(&client));
EXPECT_FALSE(manager.init(NULL));
}
示例5: main
int main(int argc,char** argv)
{
MessageManager mm;
SDMData dat;
SDMRegInfo info;
SDMReqReg req_reg;
char buf[BUFSIZE];
long length;
//initialize consumer
SDMInit(argc,argv);
my_port = getPort();
mm.Async_Init(my_port);
signal(SIGINT, SigHandler);
printf("%s listening on port %ld\n",argv[0],my_port);
while(1)
{
if (mm.IsReady())
{
switch(mm.GetMessage(buf,length))
{
case SDM_Data:
dat.Unmarshal(buf,length);
DataHandler(dat,length);
break;
case SDM_RegInfo:
if(info.Unmarshal(buf)!=SDM_NO_FURTHER_DATA_PROVIDER)
{
RegInfoHandler(info);
}
break;
default:
printf("Unexpected message\n");
}
}
else
{ //check for data and service providers
if(consume_msgs[0].source.getSensorID() == 0)
{
//request info on integer data providers
//Set variable name
strcpy(req_reg.item_name,"Total_Messages_Recd");
//Set the quallist can be empty
strcpy(req_reg.quallist,"< format=\"UINT32\"/>");
req_reg.reply = SDM_REQREG_CURRENT_FUTURE_AND_CANCELLATIONS;
req_reg.destination.setPort(my_port);
req_reg.id = DATA_PROVIDER;
req_reg.Send();
printf("Searching for new data provider\n");
sleep(2);
}
usleep(1000);
}
}
}
示例6: processBlock
void NewProjectAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
if(editorIsReady)
newNotesFromAnalyser->sendActionMessage("N");
if(analyseNewFile){
analyseNewFile = false;
MessageManager* mm = MessageManager::getInstance();
void* dummy = this;
void* d = mm->callFunctionOnMessageThread(loadNewWaveFile, dummy);
}
// This is the place where you'd normally do the guts of your plugin's
// audio processing...
for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
}
// In case we have more outputs than inputs, we'll clear any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
{
buffer.clear (i, 0, buffer.getNumSamples());
}
AudioPlayHead* playHead = getPlayHead();
AudioPlayHead::CurrentPositionInfo info;
playHead->getCurrentPosition(info);
float* channelData = buffer.getSampleData (0);
if(soundEditor != 0 && !loadingNewComponent)
soundEditor->getAudioSamplesToPlay(buffer, info.ppqPositionOfLastBarStart, getSampleRate(), currentSamplesPerBlock);
}
示例7: Listener
void* Listener(void * args)
{
char buf[BUFSIZE];
SDMSubreqst sub;
SDMDeletesub del;
MessageManager mm;
mm.Async_Init(my_port);
// Send one hearbeat, let the app fail
SendHeartbeat();
while(1)
{
if(mm.IsReady())
{
//SendHeartbeat();
#ifdef WIN32
switch(mm.GetMsg(buf))
#else
switch(mm.GetMessage(buf))
#endif
{
case SDM_Subreqst:
sub.Unmarshal(buf);
printf("Subscription Rec'd for %d\n",sub.msg_id.getInterfaceMessagePair()); fflush(NULL);
pthread_mutex_lock(&subscription_mutex);
subscriptions.AddSubscription(sub);
pthread_mutex_unlock(&subscription_mutex);
break;
case SDM_Deletesub:
printf("Cancel Rec'd\n");
del.Unmarshal(buf);
pthread_mutex_lock(&subscription_mutex);
subscriptions.RemoveSubscription(del);
pthread_mutex_unlock(&subscription_mutex);
break;
default:
printf("Invalid Message found!\n");
fflush(NULL);
break;
}
}
else
{
usleep(100000);
}
}
return NULL;
}
示例8: triggerShutdown
//
/// NAME
//
/// SHORT DESCRIPTION
//
/// Description:
/// LONG DESCRIPTION
///
/// Return
/// VALUE and DESCRIPTION
//
STATUS SystemManager::triggerShutdown(void)
{
SystemManagerMessage message;
MessageManager<SystemManagerMessage> messageManager;
// Post an activate message
message.major_type = SYSTEM_TRANSITION_TO_SHUTDOWN;
messageManager.postMessage(SystemManager::queue_id, message, QUEUE_TIMEOUT_INFINITE);
// Post an activate message
message.major_type = SYSTEM_SHUTDOWN;
messageManager.postMessage(SystemManager::queue_id, message, QUEUE_TIMEOUT_INFINITE);
return STATUS_SUCCESS;
}
示例9: strDirPath
/* -------------------------------------------------------------------------- */
void ImageManager::ShowMessageFromDirectory(const char* dirPath)
{
if( imgTree.empty())
return;
tVecStr fileList = FileSystem::GetFiles(dirPath,File);
if(fileList.empty())
return;
std::list<string> listNameMsg;
string strDirPath(dirPath);
StrToken::FormatPath(strDirPath);
for( unsigned int i=0; i<fileList.size(); i++)
{
string fullPath = strDirPath + fileList[i];
KeyStr key(fileList[i]);
ValueInt* vInt = dynamic_cast<ValueInt*>(imgTree.find(key));
if( vInt == NULL)
continue;
ImgRegistry* imgReg = dynamic_cast<ImgRegistry*>(orgImages.GetRegistry(vInt->getValue()));
tRegisterList* listIdMsg = this->orgListMsgs.GetList(imgReg->GetPtrFreeSpaceList());
if( listIdMsg != NULL )
{
itRegisterList it;
MessageManager* messageManager = MessageManager::GetInstance();
for( it=listIdMsg->begin(); it != listIdMsg->end(); it++ )
{
ListMsgRegistry* listMsgReg = dynamic_cast<ListMsgRegistry*>(*it);
ID_type idMsg = listMsgReg->GetIDMessage();
std::string nameMsg = messageManager->GetNameMessage(idMsg);
listNameMsg.push_back(nameMsg);
delete listMsgReg;
}
delete listIdMsg;
}
delete vInt;
delete imgReg;
delete listIdMsg;
}
listNameMsg.unique();
std::list<string>::iterator it;
for(it=listNameMsg.begin(); it != listNameMsg.end(); it++)
{
std::cout << (*it) << "\n";
}
}
示例10: main
int main(int argc, char** argv)
{
SDMInit(argc,argv);
MessageManager mm;
mm.Async_Init(my_port);
signal(SIGINT,SigHandler);
SDMReqReg request;
SDMRegInfo info;
char buf[BUFSIZE];
long length;
request.destination.setPort(my_port);
request.id = 1;
request.reply = SDM_REQREG_CURRENT_FUTURE_AND_CANCELLATIONS;
printf("Sending ReqReg for Message_Count.\n");
strcpy(request.item_name,"Message_Count");
strcpy(request.quallist,"</>");
request.Send();
printf("Sending ReqReg for Enable_Logging.\n");
strcpy(request.item_name,"Enable_Logging");
request.Send();
printf("Sending ReqReg for faults.\n");
strcpy(request.item_name,"faultdata");
request.Send();
while(1)
{
if (mm.IsReady())
{
mm.GetMessage(buf,length);
if (info.Unmarshal(buf) > 0)
{
printf("RegInfo received\n%s\n\n",info.msg_def);
}
}
else
{
printf(".");
sleep(1);
}
}
request.reply = SDM_REQREG_CANCEL;
request.Send();
return 1;
}
示例11: Sender
void* Sender(void* ignored)
{
MessageManager mm;
SDMData dat;
for (int i = 0; i < 256; i++)
dat.msg[i] = 0x45;
dat.length = 256;
mm.Async_Init(MYPORT);
char buf[BUFSIZE];
SDMComponent_ID Receiver;
Receiver.setAddress(inet_addr("127.0.0.1"));
Receiver.setPort(MYPORT2);
while(1)
{
if (mm.IsReady())
{
if (mm.GetMessage(buf) == SDM_Data)
{
SDMData received;
received.Unmarshal(buf);
printf("(Sender) Received SDMData with timestamp %ld, %ld.\n",received.GetSecondsStamp(), received.GetSubSecondsStamp());
fflush(NULL);
if (!DataCheck(received))
{
printf("(Sender) ERROR message doesn't match!\n");
}
}
else
printf("(Sender) Unknown message received.\n");
}
// Send the message
printf("(Sender) Sending message...\n");
dat.SendTo(Receiver);
sleep(1);
}
return NULL;
}
示例12: DeleteImage
/* -------------------------------------------------------------------------- */
void ImageManager::DeleteImage(ID_type idImg, tVecStr* imgErasedList, bool filterAll, bool removetoTree){
ImgRegistry* img=dynamic_cast<ImgRegistry*>(orgImages.GetRegistry(idImg));
FreeSpaceManager* fsManager = FreeSpaceManager::GetInstance();
MessageManager* msgManager = MessageManager::GetInstance();
//Obtener la lista de mensajes.
if( img->GetPtrMsgList() > 0 )
{
tRegisterList* msgList = this->orgListMsgs.GetList(img->GetPtrMsgList());
itRegisterList it = msgList->begin();
//Eliminar mensajes asociados.
while(it != msgList->end())
{
ListMsgRegistry* msgReg = dynamic_cast<ListMsgRegistry*>(*it);
if(filterAll)
msgManager->DeleteMessage(msgReg->GetIDMessage(),false, imgErasedList);
else
msgManager->DeleteMessage(msgReg->GetIDMessage(),true, imgErasedList);
it++;
}
}
//Eliminar Path
string path=orgNamesImages.GetText(img->GetIDImagePath());
orgNamesImages.DeleteText(img->GetIDImagePath());
//Eliminar el espacio libre disponible.
delete img;
img = dynamic_cast<ImgRegistry*>(orgImages.GetRegistry(idImg));
fsManager->RemoveFreeSpaceList(img->GetPtrFreeSpaceList());
//Eliminar Registro Imagen.
this->orgImages.DeleteRegistry(idImg);
//Eliminar el arbol.
KeyStr kImgTree(path.c_str());
if (!imgTree.empty() && removetoTree)
if (imgTree.exists(kImgTree))
imgTree.remove(kImgTree);
}
示例13: main
int main(int argc, char** argv)
{
char ip[1024] = "192.168.0.50"; // Robot IP address
TcpClient connection;
MessageManager manager;
ros::init(argc, argv, "state_interface");
ros::NodeHandle n;
JointRelayHandler jr_handler(n);
ROS_INFO("Setting up client");
connection.init(ip, StandardSocketPorts::STATE);
connection.makeConnect();
jr_handler.init(&connection);
manager.init(&connection);
manager.add(&jr_handler);
manager.spin();
}
示例14: Listener
void* Listener(void * args)
{
char buf[BUFSIZE];
SDMSubreqst sub;
SDMDeletesub del;
MessageManager mm;
mm.Async_Init(myPort);
while(1)
{
pthread_testcancel();
if(mm.IsReady())
{
SendHeartbeat();
#ifdef WIN32
switch(mm.GetMsg(buf))
#else
switch(mm.GetMessage(buf))
#endif
{
case SDM_ACK:
printf("SDMAck received\n");
helloReply = true;
break;
case SDM_Register:
printf("SDMRegister received\n");
waitForReg = false;
break;
case SDM_ID:
printf("SDMID received\n");
myID.Unmarshal(buf);
printf("CompID: \n");
printf(" SensorID: %li\n", myID.destination.getSensorID());
printf(" Address: %lx\n", myID.destination.getAddress());
printf(" Port: %i\n", myID.destination.getPort());
waitForID = false;
break;
case SDM_Subreqst:
sub.Unmarshal(buf);
printf("Subscription Rec'd for %d\n",sub.msg_id.getInterfaceMessagePair());
pthread_mutex_lock(&subscription_mutex);
subscriptions.AddSubscription(sub);
pthread_mutex_unlock(&subscription_mutex);
break;
case SDM_Deletesub:
printf("Cancel Rec'd\n");
del.Unmarshal(buf);
pthread_mutex_lock(&subscription_mutex);
subscriptions.RemoveSubscription(del);
pthread_mutex_unlock(&subscription_mutex);
break;
default:
printf("Invalid Message found!\n");
break;
}
}
else
{
usleep(100000);
}
}
return NULL;
}
示例15: printToOutputPane
void MessageManagerPrototype::printToOutputPane(const QString &text, bool bringToForeground)
{
MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
QTC_ASSERT(mm, return);
mm->printToOutputPane(text, bringToForeground);
}