00001 // 00002 // Copyright 2002 Sony Corporation 00003 // 00004 // Permission to use, copy, modify, and redistribute this software for 00005 // non-commercial use is hereby granted. 00006 // 00007 // This software is provided "as is" without warranty of any kind, 00008 // either expressed or implied, including but not limited to the 00009 // implied warranties of fitness for a particular purpose. 00010 // 00011 00012 #include "MoNetCommandInfo.h" 00013 00014 MoNetCommandInfo::MoNetCommandInfo(bool syncKey) : useSyncKey(syncKey), 00015 numAgentCommands(0) 00016 { 00017 for (int i = 0; i < MAXNUM_AGENT_COMMANDS; i++) { 00018 status[i] = monetUNDEF; 00019 agentCommand[i].Clear(); 00020 } 00021 } 00022 00023 bool 00024 MoNetCommandInfo::SetAgentCommand(MoNetAgentID agent, int index, 00025 MoNetPosture start, MoNetPosture end) 00026 { 00027 if (numAgentCommands == MAXNUM_AGENT_COMMANDS) return false; 00028 00029 agentCommand[numAgentCommands].agent = agent; 00030 agentCommand[numAgentCommands].index = index; 00031 agentCommand[numAgentCommands].startPosture = start; 00032 agentCommand[numAgentCommands].endPosture = end; 00033 numAgentCommands++; 00034 return true; 00035 } 00036 00037 void 00038 MoNetCommandInfo::SetAgentResult(MoNetAgentID agt, int idx, MoNetStatus st) 00039 { 00040 for (int i = 0; i < numAgentCommands; i++) { 00041 if (agentCommand[i].agent == agt && agentCommand[i].index == idx) { 00042 status[i] = st; 00043 return; 00044 } 00045 } 00046 } 00047 00048 void 00049 MoNetCommandInfo::ClearAgentResult() 00050 { 00051 for (int i = 0; i < numAgentCommands; i++) { 00052 status[i] = monetUNDEF; 00053 } 00054 } 00055 00056 bool 00057 MoNetCommandInfo::IsDone() 00058 { 00059 for (int i = 0; i < numAgentCommands; i++) { 00060 if (status[i] == monetUNDEF) return false; 00061 } 00062 00063 return true; 00064 } 00065 00066 MoNetPosture 00067 MoNetCommandInfo::StartPosture() 00068 { 00069 MoNetPosture pos = monetpostureUNDEF; 00070 00071 for (int i = 0; i < NumAgentCommands(); i++) { 00072 if (agentCommand[i].agent == monetagentSOUND) { 00073 pos = agentCommand[i].startPosture; 00074 } else { 00075 return agentCommand[i].startPosture; 00076 } 00077 } 00078 00079 return pos; 00080 } 00081 00082 MoNetPosture 00083 MoNetCommandInfo::EndPosture() 00084 { 00085 MoNetPosture pos = monetpostureUNDEF; 00086 00087 for (int i = 0; i < NumAgentCommands(); i++) { 00088 if (agentCommand[i].agent == monetagentSOUND) { 00089 pos = agentCommand[i].endPosture; 00090 } else { 00091 return agentCommand[i].endPosture; 00092 } 00093 } 00094 00095 return pos; 00096 }