00001 #include <ocl/OCL.hpp> 00002 #include <rtt/os/StartStopManager.hpp> 00003 #include <rtt/Logger.hpp> 00004 00005 #include "dev/ComediDevice.hpp" 00006 #include "dev/ComediSubDeviceAOut.hpp" 00007 #include "dev/ComediSubDeviceDOut.hpp" 00008 #include "dev/ComediSubDeviceDIn.hpp" 00009 #include "dev/ComediEncoder.hpp" 00010 00011 #ifndef __COMEDIDEVICES__ 00012 #define __COMEDIDEVICES__ 00013 00014 namespace OCL{ 00015 using namespace RTT; 00016 00017 #if (defined OROPKG_OS_LXRT) 00018 class ComediLoader{ 00019 private: 00020 static ComediLoader* mt; 00021 00022 ComediDevice *ni6713,*ni6527,*ni6602; 00023 00024 AnalogOutInterface* SubAOut; 00025 DigitalInInterface* SubDIn; 00026 DigitalOutInterface* SubDOut; 00027 EncoderInterface *enc1,*enc2,*enc3,*enc4,*enc5,*enc6,*enc7,*enc8; 00028 00029 unsigned int in_use; 00030 00031 public: 00032 ComediLoader(){ 00033 in_use=0; 00034 } 00035 00036 static inline ComediLoader* Instance(){ 00037 if ( mt==NULL) 00038 mt = new ComediLoader(); 00039 return mt; 00040 } 00041 00042 void CreateComediDevices(void){ 00043 if(in_use++==0){ 00044 log(Info)<<"CreateComediDevices"<<endlog(); 00045 00046 ni6713 = new ComediDevice(0); 00047 ni6527 = new ComediDevice(1); 00048 ni6602 = new ComediDevice(2); 00049 00050 SubAOut = new ComediSubDeviceAOut(ni6713,"AnalogOut",1); 00051 SubDIn = new ComediSubDeviceDIn(ni6527,"DigitalIn",0); 00052 SubDOut = new ComediSubDeviceDOut(ni6527,"DigitalOut",1); 00053 00054 enc1 = new ComediEncoder(ni6602,2,"Counter0"); 00055 enc2 = new ComediEncoder(ni6602,3,"Counter1"); 00056 enc3 = new ComediEncoder(ni6602,4,"Counter2"); 00057 enc4 = new ComediEncoder(ni6602,5,"Counter3"); 00058 enc5 = new ComediEncoder(ni6602,6,"Counter4"); 00059 enc6 = new ComediEncoder(ni6602,7,"Counter5"); 00060 enc7 = new ComediEncoder(ni6602,8,"Counter6"); 00061 enc8 = new ComediEncoder(ni6602,9,"Counter7"); 00062 00063 }else 00064 in_use++; 00065 }; 00066 00067 void DestroyComediDevices(void){ 00068 if(--in_use==0){ 00069 log(Info)<<"DestroyComediDevices"<<endlog(); 00070 00071 delete enc1; 00072 delete enc2; 00073 delete enc3; 00074 delete enc4; 00075 delete enc5; 00076 delete enc6; 00077 delete enc7; 00078 delete enc8; 00079 00080 delete SubDOut; 00081 delete SubDIn; 00082 delete SubAOut; 00083 00084 delete ni6713; 00085 delete ni6527; 00086 delete ni6602; 00087 00088 delete mt; 00089 mt = NULL; 00090 } 00091 }; 00092 }; 00093 ComediLoader* ComediLoader::mt=NULL; 00094 #endif 00095 } 00096 #endif