AgentManagerB.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef BEOSUB_BEEBRAIN_AGENT_MANAGER_B_H_DEFINED
00039 #define BEOSUB_BEEBRAIN_AGENT_MANAGER_B_H_DEFINED
00040
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043
00044 #include "Raster/Raster.H"
00045 #include "Image/Image.H"
00046 #include "Image/Pixels.H"
00047 #include "Image/CutPaste.H"
00048
00049 #include "GUI/XWinManaged.H"
00050 #include "BeoSub/BeeBrain/Globals.H"
00051
00052 #include "BeoSub/BeeBrain/DownwardVision.H"
00053 #include "BeoSub/BeeBrain/SonarListen.H"
00054
00055 #include "BeoSub/BeeBrain/AgentManagerCommand.H"
00056
00057 #include "Util/Timer.H"
00058
00059 #include <pthread.h>
00060
00061 class DownwardVisionAgent;
00062 class SonarListenAgent;
00063
00064 class AgentManagerB : public ModelComponent
00065 {
00066 public:
00067
00068
00069
00070
00071
00072
00073 AgentManagerB(OptionManager& mgr,
00074 const std::string& descrName = "Agent Manager B",
00075 const std::string& tagName = "Agent Manager B");
00076
00077
00078 virtual ~AgentManagerB();
00079
00080
00081
00082
00083
00084
00085
00086
00087 void setCurrentImage(Image<PixRGB<byte> > image, uint fNum);
00088 void setCurrentImageB(Image<PixRGB<byte> > image, uint fNum);
00089
00090 inline void setWindow(rutz::shared_ptr<XWinManaged> win,
00091 Image<PixRGB<byte> > ima);
00092 inline void setWindowB(rutz::shared_ptr<XWinManaged> win,
00093 Image<PixRGB<byte> > ima);
00094
00095 void pushResult(CommandType cmdType,
00096 DataTypes dataType,
00097 rutz::shared_ptr<OceanObject> oceanObject);
00098
00099
00100 inline Image<PixRGB<byte> > getCurrentImage();
00101
00102
00103 inline uint getCurrentFrameNumber();
00104
00105 rutz::shared_ptr<DownwardVisionAgent> getDownwardVisionAgent();
00106
00107 rutz::shared_ptr<SonarListenAgent> getSonarListenAgent();
00108
00109 uint getNumResults();
00110
00111 std::pair<rutz::shared_ptr<AgentManagerCommand>,
00112 rutz::shared_ptr<OceanObject> >
00113 popResult();
00114
00115 void drawImage(Image<PixRGB<byte> > ima, Point2D<int> point);
00116 void drawImageB(Image<PixRGB<byte> > ima, Point2D<int> point);
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 private:
00127
00128
00129 rutz::shared_ptr<XWinManaged> itsWindow;
00130 Image<PixRGB<byte> > itsDisplayImage;
00131 pthread_mutex_t itsDisplayLock;
00132
00133
00134 Image<PixRGB<byte> > itsCurrentImage;
00135 uint itsFrameNumber;
00136 rutz::shared_ptr<Timer> itsInputImageTimer;
00137 std::vector<uint64> itsFrameDuration;
00138 pthread_mutex_t itsCurrentImageLock;
00139
00140
00141 rutz::shared_ptr<XWinManaged> itsWindowB;
00142 Image<PixRGB<byte> > itsDisplayImageB;
00143 pthread_mutex_t itsDisplayLockB;
00144
00145
00146 Image<PixRGB<byte> > itsCurrentImageB;
00147 uint itsFrameNumberB;
00148 rutz::shared_ptr<Timer> itsInputImageTimerB;
00149 std::vector<uint64> itsFrameDurationB;
00150 pthread_mutex_t itsCurrentImageLockB;
00151
00152
00153 rutz::shared_ptr<DownwardVisionAgent> itsDownwardVisionAgent;
00154 pthread_t itsDownwardVisionAgentThread;
00155
00156
00157 rutz::shared_ptr<SonarListenAgent> itsSonarListenAgent;
00158 pthread_t itsSonarListenAgentThread;
00159
00160
00161 std::list<std::pair<rutz::shared_ptr<AgentManagerCommand>,
00162 rutz::shared_ptr<OceanObject> > > itsResults;
00163 pthread_mutex_t itsResultsLock;
00164
00165 };
00166
00167
00168 inline void AgentManagerB::setWindow(rutz::shared_ptr<XWinManaged> win,
00169 Image<PixRGB<byte> > ima)
00170 {
00171 itsWindow = win;
00172 itsDisplayImage = ima;
00173 }
00174
00175
00176
00177 inline void AgentManagerB::setWindowB(rutz::shared_ptr<XWinManaged> win,
00178 Image<PixRGB<byte> > ima)
00179 {
00180 itsWindowB = win;
00181 itsDisplayImageB = ima;
00182 }
00183
00184
00185 inline Image<PixRGB<byte> > AgentManagerB::getCurrentImage()
00186 {
00187 Image<PixRGB<byte> > image;
00188 pthread_mutex_lock(&itsCurrentImageLock);
00189 image = itsCurrentImage;
00190 pthread_mutex_unlock(&itsCurrentImageLock);
00191 return image;
00192 }
00193
00194
00195 inline uint AgentManagerB::getCurrentFrameNumber()
00196 {
00197 uint fNum;
00198 pthread_mutex_lock(&itsCurrentImageLock);
00199 fNum = itsFrameNumber;
00200 pthread_mutex_unlock(&itsCurrentImageLock);
00201 return fNum;
00202 }
00203
00204 #endif
00205
00206
00207
00208
00209
00210