00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #include <stdincl.h> 00024 //#include <libiotm.h> 00025 00026 #include "defaults.h" 00027 #include "events/Map.h" 00028 #include "Map.h" 00029 #include "ConnectThread.h" 00030 #include "EventFactory.h" 00031 00032 #include "EventThread.h" 00033 00034 00035 EventThread::EventThread() : Thread() 00036 ,m_pclConnectThread(NULL) 00037 { 00038 printf("Event thread constructor\n"); 00039 } 00040 00041 00042 EventThread::~EventThread() 00043 { 00044 DEB(printf("~EventThread()\n");) 00045 } 00046 00047 00048 void EventThread::SetConnectThread(ConnectThread *pclThread) 00049 { 00050 m_pclConnectThread = pclThread; 00051 } 00052 00053 00054 void EventThread::Run() 00055 { 00056 while (IsRunning()) 00057 { 00058 SDL_Delay(20); // 20 ms 00059 if (m_pclConnectThread) 00060 { 00061 // DEB(printf("m_pclConnectThread: %d bytes waiting\n",m_pclConnectThread -> get_iq());) 00062 m_ef.StateMachine( m_pclConnectThread ); 00063 } 00064 if (m_pclConnectThread && !m_pclConnectThread -> IsRunning()) 00065 { 00066 SetRunning(false); 00067 } 00068 } 00069 00070 // All done. 00071 SetRunning(false); 00072 } 00073 00074 00075 iotm::IOMessage *EventThread::GetClass(IO_IDTYPE id) 00076 { 00077 return m_ef.GetClass(id); 00078 }