MoNet.h

Go to the documentation of this file.
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 #ifndef MoNet_h_DEFINED
00013 #define MoNet_h_DEFINED
00014 
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include <OPENR/ODataArchive.h>
00019 #include <MoNetData.h>
00020 #include <ODA.h>
00021 #include "MoNetCommandInfoManager.h"
00022 #include "DirectedGraph.h"
00023 #include "CommandNode.h"
00024 #include "CommandArc.h"
00025 #include "def.h"
00026 
00027 enum MoNetState {
00028     MNS_IDLE,
00029     MNS_START,
00030     MNS_AGENT_RUNNING
00031 };
00032 
00033 class MoNet : public OObject {
00034 public:
00035     MoNet();
00036     virtual ~MoNet() {}
00037 
00038     OSubject*  subject[numOfSubject];
00039     OObserver* observer[numOfObserver];
00040 
00041     virtual OStatus DoInit   (const OSystemEvent& event);
00042     virtual OStatus DoStart  (const OSystemEvent& event);
00043     virtual OStatus DoStop   (const OSystemEvent& event);
00044     virtual OStatus DoDestroy(const OSystemEvent& event);
00045 
00046     void NotifyClientCommand(const ONotifyEvent& event);
00047     void NotifyAgentResult(const ONotifyEvent& event);
00048 
00049 private:
00050     void LoadMotionODA();
00051     void LoadSoundODA();
00052     void ReadMoNetConfig(const char* path);
00053     void ReadMoNetCommandConfig(const char* path);
00054 
00055     MoNetAgentID ToMoNetAgentID(char* agt);
00056     int          ToCommandIndex(const ODA& oda, char* cmd, char* idx);
00057     MoNetPosture ToStartPosture(char* cmd);
00058     MoNetPosture ToEndPosture(char* cmd);
00059 
00060     MoNetPosture ToPosture(char* pos);
00061 
00062     MoNetCommandID Execute(MoNetCommandID id);
00063     void ExecuteCommandInfo(MoNetCommandInfo* cinfo);
00064     int  NewAndDivideSyncKey(int ndivkey, OVRSyncKey* divkey);
00065 
00066     void ReplyClientResult(MoNetCommandID id,
00067                            MoNetStatus st, MoNetPosture pos);
00068 
00069     static const size_t LINEBUFSIZE = 256;
00070     static const size_t NUMBUFSIZE  = 8;
00071 
00072     MoNetState moNetState;
00073     MoNetCommandInfoManager moNetCommandInfoManager;
00074     DirectedGraph<CommandNode, CommandArc> moNet;
00075     list<CommandArc> commandArcPath;
00076     MoNetCommandID currentCommandID;
00077     MoNetPosture   currentPosture;
00078     ODesignDataID  motionDataID;
00079     ODesignDataID  soundDataID;
00080     ODA motionODA;
00081     ODA soundODA;
00082 };
00083 
00084 #endif // MoNet_h_DEFINED

Generated on Sun Dec 2 23:04:29 2007 for openSDK by  doxygen 1.3.9.1