| 1 | /**************************************************************************** |
|---|
| 2 | |
|---|
| 3 | Copyright 2006, 2008 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE FileInput. |
|---|
| 6 | |
|---|
| 7 | OSSIE FileInput is free software; you can redistribute it and/or modify |
|---|
| 8 | it under the terms of the GNU General Public License as published by |
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | (at your option) any later version. |
|---|
| 11 | |
|---|
| 12 | OSSIE FileInput is distributed in the hope that it will be useful, |
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | GNU General Public License for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the GNU General Public License |
|---|
| 18 | along with OSSIE FileInput; if not, write to the Free Software |
|---|
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | ****************************************************************************/ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #ifndef FILEINPUT_IMPL_H |
|---|
| 25 | #define FILEINPUT_IMPL_H |
|---|
| 26 | |
|---|
| 27 | #ifdef HAVE_STDLIB_H |
|---|
| 28 | #include <stdlib.h> |
|---|
| 29 | #endif |
|---|
| 30 | #ifdef HAVE_TIME_H |
|---|
| 31 | #include <time.h> |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | #include "ossie/cf.h" |
|---|
| 35 | #include "ossie/PortTypes.h" |
|---|
| 36 | #include "ossie/Resource_impl.h" |
|---|
| 37 | |
|---|
| 38 | #include "standardinterfaces/complexShort_u.h" |
|---|
| 39 | |
|---|
| 40 | class FileInput_i : public virtual Resource_impl |
|---|
| 41 | { |
|---|
| 42 | public: |
|---|
| 43 | FileInput_i(const char *uuid, omni_condition *sem); |
|---|
| 44 | |
|---|
| 45 | void post_constructor(CF::Resource_ptr ref) { myObjectRef = ref; }; |
|---|
| 46 | static void run(void *data) { ((FileInput_i *)data)->process_data(); }; |
|---|
| 47 | |
|---|
| 48 | void start() throw (CF::Resource::StartError, CORBA::SystemException); |
|---|
| 49 | void stop() throw (CF::Resource::StopError, CORBA::SystemException); |
|---|
| 50 | |
|---|
| 51 | CORBA::Object_ptr getPort( const char* portName ) throw (CF::PortSupplier::UnknownPort, CORBA::SystemException); |
|---|
| 52 | |
|---|
| 53 | void releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); |
|---|
| 54 | |
|---|
| 55 | void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException); |
|---|
| 56 | void configure(const CF::Properties&) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration); |
|---|
| 57 | void query (CF::Properties & configProperties) throw (CORBA::SystemException, CF::UnknownProperties); |
|---|
| 58 | |
|---|
| 59 | void runTest (CORBA::ULong _number, CF::Properties & _props) throw (CORBA::SystemException, CF::TestableObject::UnknownTest, CF::UnknownProperties); |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | private: |
|---|
| 63 | FileInput_i(); |
|---|
| 64 | FileInput_i(const FileInput_i&); |
|---|
| 65 | |
|---|
| 66 | void process_data(); |
|---|
| 67 | void process_text_file(); |
|---|
| 68 | void process_binary_file(); |
|---|
| 69 | |
|---|
| 70 | void delay(struct timespec waitTime); |
|---|
| 71 | |
|---|
| 72 | CF::Resource_var myObjectRef; |
|---|
| 73 | |
|---|
| 74 | omni_condition *component_running; //for component shutdown |
|---|
| 75 | omni_thread *processing_thread; //for component writer function |
|---|
| 76 | omni_mutex accessPrivateData; // for access to private data |
|---|
| 77 | |
|---|
| 78 | bool running; |
|---|
| 79 | |
|---|
| 80 | // Values from properties |
|---|
| 81 | std::string fileName; |
|---|
| 82 | std::string fileType; |
|---|
| 83 | unsigned long num_blocks; |
|---|
| 84 | unsigned long file_repeat; |
|---|
| 85 | struct timespec packetDelay; |
|---|
| 86 | unsigned int blockSize; |
|---|
| 87 | |
|---|
| 88 | //list components provides and uses ports |
|---|
| 89 | standardInterfaces_i::complexShort_u *dataOut; |
|---|
| 90 | |
|---|
| 91 | }; |
|---|
| 92 | #endif |
|---|