Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

StringInputControl.cc

Go to the documentation of this file.
00001 #include "StringInputControl.h"
00002 #include "Wireless/Wireless.h"
00003 #include "Motion/MMAccessor.h"
00004 #include "Motion/MotionManager.h"
00005 #include <sstream>
00006 #include <algorithm>
00007 
00008 /*ControlBase* StringInputControl::activate(MC_ID disp_id, Socket* gui) {
00009   display_id=disp_id;
00010   gui_comm=gui;
00011   return doReadStdIn(userPrompt);
00012   }*/
00013 
00014 void StringInputControl::refresh() {
00015   ControlBase::refresh();
00016   doReadStdIn(userPrompt);
00017 }
00018 
00019 ControlBase* StringInputControl::doReadStdIn(const std::string& prompt/*=std::string()*/) {
00020   if(gui_comm!=NULL && wireless->isConnected(gui_comm->sock)) {
00021     //    cout << "REFRESHING " << getName() << endl;
00022     //try to get it all in one packet for better performance
00023     std::stringstream ss;
00024     ss << "refresh\n"
00025        << getName() << '\n'
00026        << "1\n"
00027        << "0\n"
00028        << "0\n"
00029        << "Waiting for input...\n"
00030        << std::count(userPrompt.begin(),userPrompt.end(),'\n') << '\n'
00031        << userPrompt << "\n";
00032     gui_comm->write((const byte*)ss.str().c_str(),ss.str().size());
00033   }
00034   
00035   if(prompt.size()==0)
00036     return ControlBase::doReadStdIn(userPrompt);
00037   else
00038     return ControlBase::doReadStdIn(prompt);
00039 }
00040 
00041 /*! @file
00042  * @brief Implements StringInputControl, which prompts for and stores a string from the user
00043  * @author ejt (Creator)
00044  */
00045 

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:51 2016 by Doxygen 1.6.3