00001 /*************************************************************************** 00002 dsdk.cpp - Abstract base class for all devices 00003 ------------------- 00004 begin : Wed Jun 9 2004 00005 author : Ioan S. Popescu 00006 00007 Copyright (C) 2004 DATAQ Instruments, Inc. <develop@dataq.com> 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 00012 version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 ***************************************************************************/ 00024 00025 #include "dsdk.h" 00026 #include "../constants.h" // global constants used by all of DataqSDK 00027 00028 dsdk::dsdk() 00029 { 00030 m_ADChannelCount = 1; 00031 m_ADCounter = 0; // check formula 00032 m_BurstCounter = 1; // check formula 00033 m_EventPoint = 0; 00034 m_MaxBurstRate = 1000.00; 00035 m_SampleRate = 1000.00; 00036 m_TrigHysteresisIdx = 0; 00037 m_TrigLevel = 0; 00038 m_TrigMode = 0; 00039 m_TrigScnChnIdx = 0; 00040 m_TrigSlope = 0; 00041 m_TrigPostLength = 100; 00042 m_TrigPreLength = 100; 00043 00044 m_ADChannelList = 0; 00045 m_ADDiffList = 0; 00046 m_ADGainList = 0; 00047 m_ADMethodList = 0; 00048 00049 m_device_file = 0; 00050 m_acquiring_data = false; 00051 m_last_error = 0; 00052 } 00053 00054 dsdk::~dsdk() 00055 { 00056 if(m_ADChannelList != 0) 00057 { 00058 delete [] m_ADChannelList; 00059 m_ADChannelList = 0; 00060 } 00061 if(m_ADDiffList != 0) 00062 { 00063 delete [] m_ADDiffList; 00064 m_ADDiffList = 0; 00065 } 00066 if(m_ADGainList != 0) 00067 { 00068 delete [] m_ADGainList; 00069 m_ADGainList = 0; 00070 } 00071 if(m_ADMethodList != 0) 00072 { 00073 delete [] m_ADMethodList; 00074 m_ADMethodList = 0; 00075 } 00076 if(m_device_file != 0) 00077 { 00078 delete [] m_device_file; 00079 m_device_file = 0; 00080 } 00081 } 00082 00083 // Get Properties 00084 00085 const int dsdk::ADChannelCount() 00086 { 00087 m_last_error = ENOSYS; 00088 return 0; 00089 } 00090 00091 const long int dsdk::ADCounter() 00092 { 00093 m_last_error = ENOSYS; 00094 return 0; 00095 } 00096 00097 const long int dsdk::AvailableData() 00098 { 00099 m_last_error = ENOSYS; 00100 return 0; 00101 } 00102 00103 const long int dsdk::BurstCounter() 00104 { 00105 m_last_error = ENOSYS; 00106 return 0; 00107 } 00108 00109 const char *const dsdk::DeviceFile() 00110 { 00111 return m_device_file; 00112 } 00113 00114 const long int dsdk::EventPoint() 00115 { 00116 m_last_error = ENOSYS; 00117 return 0; 00118 } 00119 00120 const int dsdk::InfoBoardID() 00121 { 00122 m_last_error = ENOSYS; 00123 return 0; 00124 } 00125 00126 const bool dsdk::InfoPGL() 00127 { 00128 m_last_error = ENOSYS; 00129 return false; 00130 } 00131 00132 const int dsdk::InfoRev() 00133 { 00134 m_last_error = ENOSYS; 00135 return 0; 00136 } 00137 00138 const char *const dsdk::InfoSerial() 00139 { 00140 m_last_error = ENOSYS; 00141 return 0; 00142 } 00143 00144 const double dsdk::MaxBurstRate() 00145 { 00146 m_last_error = ENOSYS; 00147 return 0; 00148 } 00149 00150 const double dsdk::SampleRate() 00151 { 00152 m_last_error = ENOSYS; 00153 return 0; 00154 } 00155 00156 const int dsdk::TrigHysteresisIdx() 00157 { 00158 m_last_error = ENOSYS; 00159 return 0; 00160 } 00161 00162 const int dsdk::TrigLevel() 00163 { 00164 m_last_error = ENOSYS; 00165 return 0; 00166 } 00167 00168 const int dsdk::TrigMode() 00169 { 00170 m_last_error = ENOSYS; 00171 return 0; 00172 } 00173 00174 const int dsdk::TrigScnChnIdx() 00175 { 00176 m_last_error = ENOSYS; 00177 return 0; 00178 } 00179 00180 const int dsdk::TrigSlope() 00181 { 00182 m_last_error = ENOSYS; 00183 return 0; 00184 } 00185 00186 const int dsdk::TrigPostLength() 00187 { 00188 m_last_error = ENOSYS; 00189 return 0; 00190 } 00191 00192 const int dsdk::TrigPreLength() 00193 { 00194 m_last_error = ENOSYS; 00195 return 0; 00196 } 00197 00198 // Set Properties 00199 00200 void dsdk::ADChannelCount(const int ChannelCount) 00201 { 00202 m_last_error = ENOSYS; 00203 } 00204 00205 void dsdk::ADCounter(const long int Counter) 00206 { 00207 m_last_error = ENOSYS; 00208 } 00209 00210 void dsdk::BurstCounter(const long int BurstCounter) 00211 { 00212 m_last_error = ENOSYS; 00213 } 00214 00221 void dsdk::DeviceFile(const char *const DeviceFile) 00222 { 00223 // allocate space if necessary 00224 if(m_device_file == 0) 00225 m_device_file = new char[DEV_PATH]; 00226 00227 // copy device file path and name 00228 int i=0; 00229 for(i=0; i<DEV_PATH && DeviceFile[i] != 0; i++) 00230 m_device_file[i] = DeviceFile[i]; 00231 // ensure the string is null terminating 00232 m_device_file[i<DEV_PATH?i:i-1] = 0; 00233 DeviceDisconnect(); 00234 DeviceConnect(); 00235 } 00236 00237 void dsdk::EventPoint(const long int EventPnt) 00238 { 00239 m_last_error = ENOSYS; 00240 } 00241 00242 void dsdk::MaxBurstRate(const double MaxBurstRt) 00243 { 00244 m_last_error = ENOSYS; 00245 } 00246 00247 void dsdk::SampleRate(const double SampleRt) 00248 { 00249 m_last_error = ENOSYS; 00250 } 00251 00252 void dsdk::TrigHysteresisIdx(const int Hidx) 00253 { 00254 m_last_error = ENOSYS; 00255 } 00256 00257 void dsdk::TrigLevel(const int Level) 00258 { 00259 m_last_error = ENOSYS; 00260 } 00261 00262 void dsdk::TrigMode(const int Mode) 00263 { 00264 m_last_error = ENOSYS; 00265 } 00266 00267 void dsdk::TrigScnChnIdx(const int SCidx) 00268 { 00269 m_last_error = ENOSYS; 00270 } 00271 00272 void dsdk::TrigSlope(const int Slope) 00273 { 00274 m_last_error = ENOSYS; 00275 } 00276 00277 void dsdk::TrigPostLength(const int PostLength) 00278 { 00279 m_last_error = ENOSYS; 00280 } 00281 00282 void dsdk::TrigPreLength(const int PreLength) 00283 { 00284 m_last_error = ENOSYS; 00285 } 00286 00287 // Methods 00288 00289 void dsdk::ADChannelList(const int *const ChannelList) 00290 { 00291 m_last_error = ENOSYS; 00292 } 00293 00294 void dsdk::ADDiffList(const int *const DiffList) 00295 { 00296 m_last_error = ENOSYS; 00297 } 00298 00299 void dsdk::ADGainList(const int *const GainList) 00300 { 00301 m_last_error = ENOSYS; 00302 } 00303 00304 void dsdk::ADMethodList(const int *const MethodList) 00305 { 00306 m_last_error = ENOSYS; 00307 } 00308 00309 void dsdk::DAOutput(const int value, const int port) 00310 { 00311 m_last_error = ENOSYS; 00312 } 00313 00314 void dsdk::DeviceConnect() 00315 { 00316 m_last_error = ENOSYS; 00317 } 00318 00319 void dsdk::DeviceDisconnect() 00320 { 00321 m_last_error = ENOSYS; 00322 } 00323 00324 const long int dsdk::DigitalInput() 00325 { 00326 m_last_error = ENOSYS; 00327 return 0; 00328 } 00329 00330 void dsdk::DigitalOutput(const int value) 00331 { 00332 m_last_error = ENOSYS; 00333 } 00334 00335 void dsdk::GetData() 00336 { 00337 m_last_error = ENOSYS; 00338 } 00339 00340 void dsdk::GetDataEx(short int *iArray, const int Count) 00341 { 00342 m_last_error = ENOSYS; 00343 } 00344 00345 void dsdk::GetDataFrame() 00346 { 00347 m_last_error = ENOSYS; 00348 } 00349 00350 void dsdk::GetDataFrameEx(short int *iArray, const int Count) 00351 { 00352 m_last_error = ENOSYS; 00353 } 00354 00355 void dsdk::Start() 00356 { 00357 m_last_error = ENOSYS; 00358 } 00359 00360 void dsdk::Stop() 00361 { 00362 m_last_error = ENOSYS; 00363 } 00364 00365 // "Event Occur" Methods 00366 00372 const bool dsdk::ControlError(long int &Code) 00373 { 00374 if(m_last_error != 0) 00375 { 00376 Code = m_last_error; 00377 m_last_error = 0; 00378 return true; 00379 } 00380 00381 return false; 00382 } 00383 00389 const bool dsdk::NewData(long int &Count) 00390 { 00391 long int bytes = AvailableData(); 00392 00393 if(m_EventPoint != 0 && bytes >= m_EventPoint) 00394 { 00395 Count = bytes; 00396 return true; 00397 } 00398 00399 return false; 00400 } 00401 00413 const bool dsdk::OverRun() 00414 { 00415 m_last_error = ENOSYS; 00416 return false; 00417 } 00418