Main Page | Class Hierarchy | Class List | File List | Class Members

MipBus.h

00001 // Copyright (c) 2004, Thomas Lochmatter, thl@lothosoft.ch 00002 00003 #ifndef classMipBus 00004 #define classMipBus 00005 00006 class MipBus; 00007 00008 #include <string> 00009 #include "IOInterfaceSerial.h" 00010 #include "MipMessage.h" 00011 #include "MipDevice.h" 00012 #include "MipCommand.h" 00013 #include "MipLogInterface.h" 00014 #include "EventInterface.h" 00015 00017 00024 class MipBus: public IOInterfaceSerial, public EventInterface { 00025 friend class MipManager; 00026 00027 protected: 00029 static const int mMipDeviceMax=128; 00031 MipDevice *mMipDevice[mMipDeviceMax]; 00032 00034 MipCommand *mCurrentMipCommand; 00036 int mTimeout; 00038 int mNextMipDeviceIndex; 00039 00041 MipLogInterface *mMipLogInterface; 00042 00044 bool GetNextCommand(int from, int to); 00045 00047 void SendPacket(unsigned char *packet, int len) const; 00048 00049 public: 00051 MipBus(IOInterfaceList *iolist, EventInterfaceList *evlist, const std::string &device, int baudrate=19200); 00052 00053 // Overwritten IOInterface methods 00054 virtual void OnDataArrival(unsigned char *data, int len); 00055 virtual void OnClose() {} 00056 00057 // Overwritten IOInterfaceSerial methods 00058 virtual void OnBeforeClose(); 00059 virtual void OnAfterOpen(); 00060 virtual void OnAfterOpenError(); 00061 00062 // Overwritten EventInterface methods 00063 void OnEvent(); 00064 00066 void SetLogInterface(MipLogInterface *miplog) {mMipLogInterface=miplog;} 00068 MipLogInterface *GetLogInterface() {return mMipLogInterface;} 00069 00071 int GetMipDeviceMax() {return mMipDeviceMax;} 00073 MipDevice *GetMipDevice(int i) {return mMipDevice[i];} 00075 bool AddMipDevice(MipDevice *mip); 00077 bool RemoveMipDevice(MipDevice *mip); 00079 bool IsIdle() {return mCurrentMipCommand==0;} 00081 MipCommand *GetCurrentCommand() {return mCurrentMipCommand;} 00083 void SendNextCommand(); 00085 void CancelCommand(); 00087 void CancelAllCommands(); 00088 00090 void CheckOnline(); 00091 00093 void Report(const std::string &name, std::ostream &out, int ccindent=0) const; 00094 }; 00095 00096 #endif

Generated on Wed Jun 1 09:19:07 2005 for libmip by doxygen 1.3.8