📄 command.cpp~
字号:
#include "command.h"extern MSpace::Connect net;extern MSpace::Geometry geometry;namespace MSpace {Command::Command(){ lastdrive.sentcycle=0.0;}void Command::Create(std::string TeamName,int Number){ std::stringstream ss; ss<<"A(init (unum "<<Number<<") (teamname "<<TeamName<<"))"; net.PutOutputs(ss.str());}void Command::Done(){ net.PutOutputs("D");}void Command::Kick(Angel ang,float force){ std::stringstream ss; ss << "A(kick "<<ang.angel<<" "<<force<<")"; net.PutOutputs(ss.str()); lastdrive.sentcycle=param.CycleReceive; lastdrive.force=Vec(0,0,0);}void Command::Notify(int time){ std::stringstream ss; ss <<"R"<<time; net.PutOutputs(ss.str());}void Command::Drive(Vec v){ if(v.GetMod()>100)v.SetMod(100); std::stringstream ss; ss << "A(drive " <<v.Vx<<" "<<v.Vy<<" "<<v.Vz<<")"; net.PutOutputs(ss.str()); lastdrive.sentcycle=param.CycleReceive; lastdrive.force=v;}void Command::Beam(Vec v){ std::stringstream ss; ss << "A(beam " <<v.Vx<<" "<<v.Vy<<" "<<v.Vz<<")"; net.PutOutputs(ss.str());}void Command::Catch(){ net.PutOutputs("A(catch)");}void Command::PutKick(Angel ang,float force){ std::stringstream ss; ss << "A(kick "<<ang.angel<<" "<<force<<")"; comq.enQueue(ss.str()); lastdrive.sentcycle=param.CycleReceive; lastdrive.force=Vec(0,0,0);}void Command::PutDrive(Vec v){ if(v.GetMod()>100)v.SetMod(100); std::stringstream ss; ss << "A(drive " <<v.Vx<<" "<<v.Vy<<" "<<v.Vz<<")"; //std::cout<<"string: "<<ss.str()<<std::endl; comq.enQueue(ss.str());}void Command::PutCatch(){ comq.enQueue("A(catch)");}void Command::SentCommand(){ std::string cmd; if(comq.getFront(cmd)!=DOWNFLOW) { net.PutOutputs(cmd); comq.delQueue(); int i=1; if(param.GetString(cmd.c_str(),i)=="drive") { lastdrive.sentcycle=param.CycleReceive; lastdrive.force.Vx=param.GetFloat(cmd.c_str(),i); lastdrive.force.Vy=param.GetFloat(cmd.c_str(),i); //std::cout<<"lastdrive:"<<lastdrive.force<<std::endl; } }}void Command::TurnCamera(Angel pan,Angel tilt){ std::stringstream ss; ss <<"A(pantilt "<<pan.angel<<" "<<tilt.angel<<")"; net.PutOutputs(ss.str()); Angel tempAn(param.pan); tempAn=tempAn+pan; param.pan=tempAn.angel;}void Command::Say(std::string word){ std::stringstream ss; ss <<"A(say "<<word<<")"; net.PutOutputs(ss.str());}Vec Command::GetLastDriveForce(){ return lastdrive.force;} long Command::GetLastDriveCycle(){ return lastdrive.sentcycle;}Command::~Command(){}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -