├── .gitignore ├── LICENSE ├── README.md ├── adi ├── ADIDatCAPI_mex.h ├── ADIDatIOWin.dll ├── ADIDatIOWin.lib ├── ADIDatIOWin64.dll ├── ADIDatIOWin64.lib ├── Release │ ├── _adi_cffi.cp310-win_amd64.exp │ ├── _adi_cffi.cp310-win_amd64.lib │ ├── _adi_cffi.cp311-win_amd64.exp │ ├── _adi_cffi.cp311-win_amd64.lib │ ├── _adi_cffi.cp312-win_amd64.exp │ ├── _adi_cffi.cp312-win_amd64.lib │ ├── _adi_cffi.cp313-win_amd64.exp │ ├── _adi_cffi.cp313-win_amd64.lib │ ├── _adi_cffi.cp36-win_amd64.exp │ ├── _adi_cffi.cp36-win_amd64.lib │ ├── _adi_cffi.cp37-win_amd64.exp │ ├── _adi_cffi.cp37-win_amd64.lib │ ├── _adi_cffi.cp38-win32.exp │ ├── _adi_cffi.cp38-win32.lib │ ├── _adi_cffi.cp38-win_amd64.exp │ ├── _adi_cffi.cp38-win_amd64.lib │ ├── _adi_cffi.cp39-win32.exp │ ├── _adi_cffi.cp39-win32.lib │ ├── _adi_cffi.cp39-win_amd64.exp │ ├── _adi_cffi.cp39-win_amd64.lib │ ├── _adi_cffi.obj │ ├── _adi_cffi2.cp312-win_amd64.exp │ ├── _adi_cffi2.cp312-win_amd64.lib │ ├── _adi_cffi2.cp38-win32.exp │ ├── _adi_cffi2.cp38-win32.lib │ ├── _adi_cffi2.cp39-win32.exp │ ├── _adi_cffi2.cp39-win32.lib │ └── _adi_cffi2.obj ├── __init__.py ├── _adi_cffi.c ├── _adi_cffi.cp310-win_amd64.pyd ├── _adi_cffi.cp311-win_amd64.pyd ├── _adi_cffi.cp312-win_amd64.pyd ├── _adi_cffi.cp313-win_amd64.pyd ├── _adi_cffi.cp36-win_amd64.pyd ├── _adi_cffi.cp37-win_amd64.pyd ├── _adi_cffi.cp38-win_amd64.pyd ├── _adi_cffi.cp39-win_amd64.pyd ├── _adi_cffi2.c ├── _adi_cffi2.cp38-win32.pyd ├── _adi_cffi2.cp39-win32.pyd ├── cffi_build.py ├── cffi_build_win32.py └── read.py ├── docs └── notes_for_pypi_build.txt ├── manifest.in └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | 4 | !adi/Release/_adi_cffi.cp36-win_amd64.lib 5 | !adi/ADIDatIOWin64.dll 6 | !adi/ADIDatIOWin64.lib 7 | *.bak 8 | /build/* 9 | /dist/* 10 | adi_reader.egg-info/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jim Hokanson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # adinstruments_sdk_python 2 | 3 | Use this code to read .adicht (Labchart) files into Python. Interfacing with the ADIstruments DLL is done via [cffi](https://cffi.readthedocs.io/en/latest/). 4 | 5 | - The code utilizes the SDK from ADIstruments to read files in Python as NumPy arrays. 6 | - **Currently only works for Windows. Not fixable by me, requires changes by ADInstruments** 7 | - A slightly more fleshed out Matlab version can be found [here](https://github.com/JimHokanson/adinstruments_sdk_matlab). 8 | - Currently requires Python 3.6-3.11 with some of the newer versions requiring 64 bit Python (this can change but requires some work on my end) 9 | 10 | --- 11 | 12 | ## Installation ## 13 | 14 | pip install adi-reader 15 | 16 | ---- 17 | 18 | ## Test code ## 19 | 20 | ```python 21 | import adi 22 | f = adi.read_file(r'C:\Users\RNEL\Desktop\test\test_file.adicht') 23 | # All id numbering is 1 based, first channel, first block 24 | # When indexing in Python we need to shift by 1 for 0 based indexing 25 | # Functions however respect the 1 based notation ... 26 | 27 | # These may vary for your file ... 28 | channel_id = 2 29 | record_id = 1 30 | data = f.channels[channel_id-1].get_data(record_id) 31 | import matplotlib.pyplot as plt 32 | plt.plot(data) 33 | plt.show() 34 | ``` 35 | ---- 36 | 37 | ## Dependencies ## 38 | - [cffi](https://cffi.readthedocs.io/en/latest/) 39 | - [NumPy](https://numpy.org/) 40 | - Python 3.6-3.11 41 | ---- 42 | 43 | ## Setup for other Python versions ## 44 | 45 | - Running the code might require compiling the cffi code depending on your Python version. 46 | - This requires running cffi_build.py in the adi package. 47 | - This might require installing cffi as well as some version of Visual Studio. 48 | - The currently released code was compiled for Python 3.6-3.9 on Visual Studio 14.0 or greater was required. 49 | 50 | For upgrading to 3.8, I installed Python 3.8. Within the interpreter I ran the following: 51 | 52 | - Jim note to self, rather than installing Anaconda I simply: 53 | - download Python from https://www.python.org/downloads/windows/ 54 | - cd to Python directory or run directly, these go to something like: `C:\Users\RNEL\AppData\Local\Programs\Python\Python39-32\python` 55 | - Note the above path is specific to my computer, might need to change user name 56 | - This has result in an error that I need MS C++ Build tools : "Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/" Ultimately I had to install the package along with the correct OS SDK (Windows 10 SDK for me). 57 | 58 | ![image](https://github.com/JimHokanson/adinstruments_sdk_python/assets/1593287/c94114a7-4cc1-4c59-a25a-f319d02402d9) 59 | 60 | 61 | ```python 62 | import subprocess 63 | import sys 64 | 65 | #https://stackoverflow.com/questions/12332975/installing-python-module-within-code 66 | def install(package): 67 | subprocess.call([sys.executable, "-m", "pip", "install", package]) 68 | 69 | install("setuptools") 70 | install("cffi") 71 | 72 | import os 73 | #This would need to be changed based on where you keep the code 74 | os.chdir('E:/repos/python/adinstruments_sdk_python/adi') 75 | 76 | # For 64 bit windows 77 | exec(open("cffi_build.py").read()) 78 | 79 | 80 | 81 | #------------------------- ONLY IF 32 BIT WINDOWS ------------------- 82 | # For 32 bit windows 83 | exec(open("cffi_build_win32.py").read()) 84 | ``` 85 | ---- 86 | 87 | ## PyPi Notes ## 88 | 89 | - update version in setup.py 90 | - update Python version in setup.py 91 | - from Anaconda I ran the command line in my enviroment and made sure twine was installed `pip install twine`. Then I changed my drive `e:` changes to the E drive and then cd'd to the directory to run: 92 | - `python setup.py sdist bdist_wheel` 93 | - `twine upload dist/*` 94 | 95 | 96 | ## Improvements ## 97 | 98 | This was written extremely quickly and is missing some features. Feel free to open pull requests or to open issues. 99 | -------------------------------------------------------------------------------- /adi/ADIDatCAPI_mex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2012 ADInstruments. All rights reserved. 3 | * 4 | * \ADIDatFileSDK_license_start 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. The name of ADInstruments may not be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * 3. This is an unsupported product which you use at your own risk. For unofficial 16 | * technical support, please use http://www.adinstruments.com/forum . 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY ADINSTRUMENTS "AS IS" AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 21 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ADINSTRUMENTS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * \ADIDatFileSDK_license_end 30 | */ 31 | 32 | //JAH Modifications 33 | //==================================================== 34 | //- removed trailing comma in enumerations 35 | //- made enumerations typedef and added explicit alias 36 | 37 | 38 | #ifndef ADIDatCAPI_H__ 39 | #define ADIDatCAPI_H__ 40 | 41 | 42 | #ifdef ADIDATIOWIN_EXPORTS 43 | #define DLLEXPORT __declspec(dllexport) 44 | #else 45 | #define DLLEXPORT 46 | #endif 47 | 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | 54 | // Result code values 55 | typedef enum ADIResultCode 56 | { 57 | //Win32 error codes (HRESULTs) 58 | kResultSuccess = 0, // operation succeeded 59 | kResultErrorFlagBit = 0x80000000L, // high bit set if operation failed 60 | kResultInvalidArg = 0x80070057L, // invalid argument. One (or more) of the arguments is invalid 61 | kResultFail = 0x80004005L, // Unspecified error 62 | kResultFileNotFound = 0x80030002L, // failure to find the specified file (check the path) 63 | 64 | 65 | //Start of error codes specific to this API 66 | kResultADICAPIMsgBase = 0xA0049000L, 67 | 68 | kResultFileIOError = kResultADICAPIMsgBase, // file IO error - could not read/write file 69 | kResultFileOpenFail, // file failed to open 70 | kResultInvalidFileHandle, // file handle is invalid 71 | kResultInvalidPosition, // pos specified is outside the bounds of the record or file 72 | kResultInvalidCommentNum, // invalid commentNum. Comment could not be found 73 | kResultNoData, // the data requested was not present (e.g. no more comments in the record). 74 | kResultBufferTooSmall // the buffer passed to a function to receive data (e.g. comment text) was not big enough to receive all the data. 75 | 76 | // new result codes must be added at the end 77 | } ADIResultCode; 78 | 79 | 80 | // File open modes 81 | typedef enum ADIFileOpenMode 82 | { 83 | kOpenFileForReadOnly = 0, // opens the file as read-only, so data cannot be written 84 | kOpenFileForReadAndWrite // opens the file as read/write 85 | } ADIFileOpenMode; 86 | 87 | 88 | // Data Types : ADICDataFlags 89 | typedef enum ADICDataFlags 90 | { 91 | kADICDataAtSampleRate = 0, // specifies that the function uses samples 92 | kADICDataAtTickRate = 0x80000000 // specifies that the function uses ticks 93 | } ADICDataFlags; 94 | 95 | 96 | //Struct holding maximum and minimum values between which valid 97 | //data values in a channel fall. 98 | typedef struct ADIDataLimits 99 | { 100 | float mMaxLimit; 101 | float mMinLimit; 102 | } ADIDataLimits; 103 | 104 | // Handles - essentially void* with a little added type safety. 105 | struct ADI_FileHandle__ { int unused; }; typedef struct ADI_FileHandle__ *ADI_FileHandle; 106 | struct ADI_WriterHandle__ { int unused; }; typedef struct ADI_WriterHandle__ *ADI_WriterHandle; 107 | struct ADI_CommentsHandle__ { int unused; }; typedef struct ADI_CommentsHandle__ *ADI_CommentsHandle; 108 | 109 | // Define ADI_USELOADIDATDLL to link explicitly to the ADIDatDll. To link implicitly using the 110 | // import library leave this undefined. 111 | #ifndef ADI_USELOADIDATDLL 112 | 113 | 114 | //-------------------- 115 | // General Operations: 116 | // 117 | 118 | 119 | // Opens an existing *.adidat file for read and write operations and returns a pointer 120 | // to it. 121 | // If operation is successful, 'fileH' param will be be a handle to the file, else 0. 122 | // Params: path - absolute, delimited path to the file, 123 | // e.g. "C:\\MyData\\TestFile.adidat" 124 | // fileH - pointer to an ADI_FileHandle object [outparam] 125 | // mode - ADIFileOpenMode option for controlling the how the file is to be opened 126 | // Return: a ADIResultCode for result of the operation 127 | DLLEXPORT ADIResultCode ADI_OpenFile(const wchar_t* path, ADI_FileHandle* fileH, ADIFileOpenMode mode); 128 | 129 | 130 | // Creates a new *.adidat file for write operations at the specified location and 131 | // returns a pointer to it. 132 | // If operation is successful, 'file' param will be be a handle to the file, else 0. 133 | // Params: path - absolute, delimited path to the file, 134 | // e.g. "C:\\MyData\\NewFile.adidat" 135 | // fileH - pointer to an ADI_FileHandle object [outparam] 136 | // Return: a ADIResultCode for result of the operation 137 | DLLEXPORT ADIResultCode ADI_CreateFile(const wchar_t* path, ADI_FileHandle* fileH); 138 | 139 | 140 | // Retrieves a text description of a result code returned from an API call. 141 | // Params: code - an ADIResultCode value 142 | // message - null-terminated text for the error message [outparam] 143 | // maxChars - the size used for the buffer. Must not exceed this when copying 144 | // text into the buffer 145 | // textLen - receives the number of characters needed to hold the full comment text, 146 | // even if parameter text is NULL (optional, may be NULL) [outparam] 147 | // Return: returns kResultBufferTooSmall if maxChars was too small to receive the full title text. 148 | // Return: a ADIResultCode for result of the operation 149 | DLLEXPORT ADIResultCode ADI_GetErrorMessage(ADIResultCode code, wchar_t* messageOut, 150 | long maxChars, long *textLen); 151 | 152 | 153 | // Converts a tick position to a sample position for a given channel. 154 | // Params: fileH - ADI_FileHandle for the open file 155 | // channel - the channel index (starting from 0) 156 | // record - the record index (starting from 0) 157 | // tickInRecord - the tick position to be converted 158 | // samplePosInRecord - the converted sample position [outparam] 159 | // Return: a ADIResultCode for result of the operation 160 | DLLEXPORT ADIResultCode ADI_TickToSamplePos(ADI_FileHandle fileH, long channel, long record, 161 | long tickInRecord, double* samplePosInRecord); 162 | 163 | 164 | // Converts a sample position to a tick position for a given channel. 165 | // Params: fileH - ADI_FileHandle for the open file 166 | // channel - the channel index (starting from 0) 167 | // record - the record index (starting from 0) 168 | // samplePosInRecord - the tick position to be converted 169 | // tickInRecord - the converted sample position [outparam] 170 | // Return: a ADIResultCode for result of the operation 171 | DLLEXPORT ADIResultCode ADI_SamplePosToTick(ADI_FileHandle fileH, long channel, long record, 172 | double samplePosInRecord, double* tickInRecord); 173 | 174 | 175 | //----------------- 176 | // Read Operations: 177 | // 178 | 179 | 180 | // Retrieves the number of records in the file. 181 | // Params: fileH - ADI_FileHandle for the open file 182 | // nRecords - the number of records in the file [outparam] 183 | // Return: a ADIResultCode for result of the operation 184 | DLLEXPORT ADIResultCode ADI_GetNumberOfRecords(ADI_FileHandle fileH, long* nRecords); 185 | 186 | 187 | // Retrieves the number of channels in the file. 188 | // Params: fileH - ADI_FileHandle for the open file 189 | // nChannels - the number of channels in the file [outparam] 190 | // Return: a ADIResultCode for result of the operation 191 | DLLEXPORT ADIResultCode ADI_GetNumberOfChannels(ADI_FileHandle fileH, long* nChannels); 192 | 193 | 194 | // Retrieves the number of ticks in the specified record. 195 | // Params: fileH - ADI_FileHandle for the open file 196 | // record - the record index (starting from 0) 197 | // nTicks - the number of ticks in the record [outparam] 198 | // Return: a ADIResultCode for result of the operation 199 | DLLEXPORT ADIResultCode ADI_GetNumTicksInRecord(ADI_FileHandle fileH, long record, long* nTicks); 200 | 201 | 202 | // Retrieves the tick period for the specified record and channel. 203 | // Params: fileH - ADI_FileHandle for the open file 204 | // channel - the channel in the record (starting from 0) 205 | // record - the record index (starting from 0) 206 | // secsPerTick - the tick period for the record [outparam] 207 | // Return: a ADIResultCode for result of the operation 208 | DLLEXPORT ADIResultCode ADI_GetRecordTickPeriod(ADI_FileHandle fileH, long channel, long record, 209 | double* secsPerTick); 210 | 211 | 212 | // Retrieves the number of samples in the specified record. 213 | // Params: fileH - ADI_FileHandle for the open file 214 | // channel - the channel in the record (starting from 0) 215 | // record - the record index (starting from 0) 216 | // nSamples - the number of samples in the record [outparam] 217 | // Return: a ADIResultCode for result of the operation 218 | DLLEXPORT ADIResultCode ADI_GetNumSamplesInRecord(ADI_FileHandle fileH, long channel, long record, 219 | long* nSamples); 220 | 221 | 222 | // Retrieves the sample period for the specified record. 223 | // Params: fileH - ADI_FileHandle for the open file 224 | // channel - the channel in the record (starting from 0) 225 | // record - the record index (starting from 0) 226 | // secsPerSample - the sample period for the record [outparam] 227 | // Return: a ADIResultCode for result of the operation 228 | DLLEXPORT ADIResultCode ADI_GetRecordSamplePeriod(ADI_FileHandle fileH, long channel, long record, 229 | double* secsPerSample); 230 | 231 | 232 | //Retrieves time information about the specified record. 233 | //The trigger time is the time origin of the record and may differ from the start time if 234 | //there is a pre or post trigger delay, as specified by the trigMinusRecStart parameter. 235 | // Params: fileH - ADI_FileHandle for the open file 236 | // record - the record index (starting from 0) 237 | // triggerTime - time_t receives the date and time of the trigger 238 | // position for the new record. Measured as number of 239 | // seconds from 1 Jan 1970 240 | // fracSecs - receives the fractional seconds part of 241 | // the record trigger time ('triggerTime' parameter) 242 | // trigMinusRecStart - trigger-time-minus-record-start-ticks. Receives the 243 | // difference between the time of trigger tick and the first 244 | // tick in the record. This +ve for pre-trigger delay and 245 | // -ve for post-trigger delay. 246 | // Return: a ADIResultCode for result of the operation 247 | DLLEXPORT ADIResultCode ADI_GetRecordTime(ADI_FileHandle fileH, long record, time_t *triggerTime, 248 | double *fracSecs, long *triggerMinusStartTicks); 249 | 250 | 251 | // Creates a comments accessor handle for the specified record. 252 | // Params: fileH - ADI_FileHandle for the open file 253 | // record - the record index (starting from 0) 254 | // commentsH - handle to the new comments accessor for the record [outparam] 255 | // Return: a ADIResultCode for result of the operation 256 | DLLEXPORT ADIResultCode ADI_CreateCommentsAccessor(ADI_FileHandle fileH, long record, 257 | ADI_CommentsHandle* commentsH); 258 | 259 | 260 | // Closes the comments accessor, releasing the memory it used. 261 | // Sets the ADI_CommentsHandle to 0. 262 | // Params: ADI_CommentsHandle - handle to a comments accessor 263 | // Return: a ADIResultCode for result of the operation 264 | DLLEXPORT ADIResultCode ADI_CloseCommentsAccessor(ADI_CommentsHandle *commentsH); 265 | 266 | 267 | // Retrieves information from the comment currently referenced by the comments accessor. 268 | // Params: ADI_CommentsHandle - handle to a comments accessor 269 | // tickPos - receives the tick position of the comment in the record [outparam] 270 | // commentNum - receives the number of the comment [outparam] 271 | // channel - receives the channel of the comment (-1 for all channel comments) [outparam] 272 | // text - buffer to receive null terminated text for the comment (optional, may be NULL) [outparam] 273 | // maxChars - the size of the text buffer in wchar_t s. The text will be truncated to fit in this size 274 | // textLen - receives the number of characters needed to hold the full comment text, 275 | // even if parameter text is NULL (optional, may be NULL) [outparam] 276 | // Return: returns kResultBufferTooSmall if maxChars was too small to receive the full comment text. 277 | // Returns kResultNoData if this accessor has reached the end of the comments in the record. 278 | DLLEXPORT ADIResultCode ADI_GetCommentInfo(ADI_CommentsHandle commentsH, long *tickPos, long *channel, long *commentNum, wchar_t* text, 279 | long maxChars, long *textLen); 280 | 281 | 282 | // Advances the comments accessor to the next comment in the record 283 | // Params: ADI_CommentsHandle - handle to a comments accessor 284 | // Returns kResultNoData if this accessor has reached the end of the comments in the record. 285 | DLLEXPORT ADIResultCode ADI_NextComment(ADI_CommentsHandle commentsH); 286 | 287 | 288 | // Retrieves a block of sample data from the file into a buffer. Samples are in physical 289 | // prefixed units. 290 | // Params: fileH - ADI_FileHandle for the open file 291 | // channel - the channel containing the desired data (starting from 0) 292 | // record - the record containing the start position of the desired data 293 | // (starting from 0) 294 | // startPos - the start position as an offset from the start of the record (0) 295 | // nLength - number of elements (ticks/samples) to retrieve 296 | // dataType - specifies the type of data (ticks or samples) to retrieve 297 | // data - pointer to a float array of 'nLength' in size 298 | // e.g. float* data=(float*)malloc(sizeof(float*kDataSize)); [outparam] 299 | // returned - the number of samples actually returned by the function (may be less 300 | // than the amount requested) [outparam] 301 | // Return: a ADIResultCode for result of the operation 302 | DLLEXPORT ADIResultCode ADI_GetSamples(ADI_FileHandle fileH, long channel, long record, long startPos, 303 | ADICDataFlags dataType, long nLength, float* data, long* returned); 304 | 305 | 306 | // Retrieves the prefixed units of a channel, as a string. 307 | // Params: fileH - ADI_FileHandle for the open file 308 | // channel - the unit's channel (starting from 0) 309 | // record - the unit's record (starting from 0) 310 | // units - buffer to receive null terminated text for the units name (optional, may be NULL) [outparam] 311 | // maxChars - the size of the text buffer in wchar_t s. The text will be truncated to fit in this size 312 | // textLen - receives the number of characters needed to hold the full comment text, 313 | // even if parameter text is NULL (optional, may be NULL) [outparam] 314 | // Return: returns kResultBufferTooSmall if maxChars was too small to receive the full comment text. 315 | // Return: a ADIResultCode for result of the operation 316 | DLLEXPORT ADIResultCode ADI_GetUnitsName(ADI_FileHandle fileH, long channel, long record, wchar_t* units, 317 | long maxChars, long *textLen); 318 | 319 | 320 | // Retrieves the name of a channel, as a string. 321 | // Params: fileH - ADI_FileHandle for the open file 322 | // channel - the channel index (starting from 0) 323 | // name - null-terminated text for the name [outparam] 324 | // maxChars - the size used for the buffer. Must not exceed this when copying 325 | // text into the buffer 326 | // textLen - receives the number of characters needed to hold the full comment text, 327 | // even if parameter text is NULL (optional, may be NULL) [outparam] 328 | // Return: returns kResultBufferTooSmall if maxChars was too small to receive the full title text. 329 | // Return: a ADIResultCode for result of the operation 330 | DLLEXPORT ADIResultCode ADI_GetChannelName(ADI_FileHandle fileH, long channel, wchar_t* name, 331 | long maxChars, long *textLen); 332 | 333 | 334 | //------------------ 335 | // Write Operations: 336 | // 337 | 338 | // Sets the name of the specified channel. 339 | // Params: file - ADI_FileHandle for the open file 340 | // channel - the channel to set the name (starting from 0) 341 | // name - null-terminated text string with the channel name 342 | // Return: a ADIResultCode for result of the operation 343 | DLLEXPORT ADIResultCode ADI_SetChannelName(ADI_FileHandle fileH, long channel, const wchar_t* name); 344 | 345 | 346 | // Creates a new writer session for writing new data and returns a handle to that open writer for use in 347 | // other related functions. 348 | // Params: fileH - ADI_FileHandle for the open file 349 | // writerH - ADI_WriterHandle for the new writing session [outparam] 350 | // Return: a ADIResultCode for result of the operation 351 | DLLEXPORT ADIResultCode ADI_CreateWriter(ADI_FileHandle fileH, ADI_WriterHandle* writerH); 352 | 353 | 354 | // Sets the channel information for the specified channel in a new record to be written by the writer session. 355 | // Params: writerH - ADI_WriterHandle for the writing session 356 | // channel - the channel to receive the new info (starting from 0) 357 | // enabled - boolean value set true (1) if data is to be added to this channel in the new record 358 | // secondsPerSample - new sample period for this channel in the new record 359 | // unitsName - null-terminated text string units for the channel record 360 | // limits - Optional pointer to a struct holding maximum and minimum values between which valid 361 | // data values in the channel fall. 362 | // If NULL, the limits are +ve and -ve infinity. 363 | // 364 | // Return: a ADIResultCode for result of the operation 365 | DLLEXPORT ADIResultCode ADI_SetChannelInfo(ADI_WriterHandle writerH, long channel, int enabled, 366 | double secondsPerSample, const wchar_t* units, const ADIDataLimits *limits); 367 | 368 | 369 | //Starts the writer recording a new record, setting the trigger time. 370 | //The trigger time is the time origin of the record and may differ from the start time if 371 | //there is a pre or post trigger delay, as specified by the trigMinusRecStart parameter. 372 | // writerH - ADI_WriterHandle for the writing session 373 | // triggerTime - time_t specifying the date and time of the trigger 374 | // position for the new record. Measured as number of 375 | // seconds from 1 Jan 1970 376 | // fracSecs - Provides fraction-resolution to the start position of 377 | // the record ('triggerTime' parameter) 378 | // trigMinusRecStart - trigger-time-minus-record-start-ticks. Specifies the 379 | // difference between the time of trigger tick and the first 380 | // tick in the record. This +ve for pre-trigger delay and 381 | // -ve for post-trigger delay. 382 | // Return: a ADIResultCode for result of the operation 383 | DLLEXPORT ADIResultCode ADI_StartRecord(ADI_WriterHandle writerH, time_t triggerTime, 384 | double fracSecs, long triggerMinusStartTicks); 385 | 386 | 387 | // Writes new data samples into the specified channel record. 388 | // Params: writerH - ADI_WriterHandle for the writing session 389 | // channel - the channel to receive the new data (starting from 0) 390 | // data - an array of new float data 391 | // e.g. float* data = (float*)malloc(sizeof(float * numSamples)); 392 | // dataType - specifies the type of data (ticks or samples) being added 393 | // nSamples - number of samples in the array 394 | // newTicksAdded - number of ticks by which the record increased as a result of adding these samples. 395 | // This will usually be 0 for channels other than the first to which samples are added. 396 | // In the multi-rate case, this can be greater than the number of samples added if 397 | // the channel has a sample rate lower than the tick rate. 398 | // Return: a ADIResultCode for result of the operation 399 | DLLEXPORT ADIResultCode ADI_AddChannelSamples(ADI_WriterHandle writerH, long channel, 400 | float* data, long nSamples, long *newTicksAdded); 401 | 402 | 403 | // Ends the current record being written by the writer. 404 | // Params: writerH - ADI_WriterHandle for the writer session 405 | // Return: a ADIResultCode for result of the operation 406 | DLLEXPORT ADIResultCode ADI_FinishRecord(ADI_WriterHandle writerH); 407 | 408 | // Ensures all changes to the file made via the writer session are written to the file. 409 | // Params: writerH - ADI_WriterHandle for the writer session 410 | // Return: a ADIResultCode for result of the operation 411 | DLLEXPORT ADIResultCode ADI_CommitFile(ADI_WriterHandle writerH, long flags); 412 | 413 | // Terminates the writer session and releases resources used by the session. 414 | // Sets the ADI_WriterHandle to 0. 415 | // Also calls ADI_CommitFile() to ensure all changes to the file made via the 416 | //writer session are written to the file. 417 | // Params: writerH - ADI_WriterHandle for the writer session 418 | // Return: a ADIResultCode for result of the operation 419 | DLLEXPORT ADIResultCode ADI_CloseWriter(ADI_WriterHandle *writerH); 420 | 421 | 422 | // Adds a new comment at the specified position in the existing data. 423 | // Params: file - ADI_FileHandle for the open file 424 | // channel - the channel to add the comment into, or -1 for all-channel comment 425 | // record - the record containing the desired position of the new comment 426 | // (starting from 0) 427 | // tickPos - the tick position of the comment as an offset from the start of 428 | // the record (0) 429 | // text - the null-terminated text string for the new comment 430 | // commentNum - the number of the newly added comment (optional, may be NULL) [outparam] 431 | // Return: a ADIResultCode for result of the operation 432 | DLLEXPORT ADIResultCode ADI_AddComment(ADI_FileHandle fileH, long channel, long record, long tickPos, 433 | const wchar_t* text, long* commentNum); 434 | 435 | 436 | // Deletes a comment from the specified position in the existing data. 437 | // Params: file - ADI_FileHandle for the open file 438 | // commentNum - the number of the comment to delete 439 | // Return: a ADIResultCode for result of the operation 440 | DLLEXPORT ADIResultCode ADI_DeleteComment(ADI_FileHandle fileH, long commentNum); 441 | 442 | 443 | // Closes the open file and releases memory. 444 | // If operation is successful, 'fileH' param will be be 0. 445 | // Params: fileH - pointer to an ADI_FileHandle object [in/outparam] 446 | // Return: a ADIResultCode for result of the operation 447 | DLLEXPORT ADIResultCode ADI_CloseFile(ADI_FileHandle* fileH); 448 | 449 | #endif //ADI_USELOADIDATDLL 450 | 451 | #ifdef __cplusplus 452 | } 453 | #endif 454 | 455 | #endif -------------------------------------------------------------------------------- /adi/ADIDatIOWin.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/ADIDatIOWin.dll -------------------------------------------------------------------------------- /adi/ADIDatIOWin.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/ADIDatIOWin.lib -------------------------------------------------------------------------------- /adi/ADIDatIOWin64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/ADIDatIOWin64.dll -------------------------------------------------------------------------------- /adi/ADIDatIOWin64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/ADIDatIOWin64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp310-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp310-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp310-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp310-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp311-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp311-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp311-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp311-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp312-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp312-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp312-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp312-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp313-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp313-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp313-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp313-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp36-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp36-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp36-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp36-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp37-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp37-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp37-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp37-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp38-win32.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp38-win32.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp38-win32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp38-win32.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp38-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp38-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp38-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp38-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp39-win32.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp39-win32.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp39-win32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp39-win32.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp39-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp39-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.cp39-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.cp39-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi.obj -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp312-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp312-win_amd64.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp312-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp312-win_amd64.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp38-win32.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp38-win32.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp38-win32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp38-win32.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp39-win32.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp39-win32.exp -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.cp39-win32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.cp39-win32.lib -------------------------------------------------------------------------------- /adi/Release/_adi_cffi2.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/Release/_adi_cffi2.obj -------------------------------------------------------------------------------- /adi/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .read import read_file 4 | -------------------------------------------------------------------------------- /adi/_adi_cffi.c: -------------------------------------------------------------------------------- 1 | #define _CFFI_ 2 | 3 | /* We try to define Py_LIMITED_API before including Python.h. 4 | 5 | Mess: we can only define it if Py_DEBUG, Py_TRACE_REFS and 6 | Py_REF_DEBUG are not defined. This is a best-effort approximation: 7 | we can learn about Py_DEBUG from pyconfig.h, but it is unclear if 8 | the same works for the other two macros. Py_DEBUG implies them, 9 | but not the other way around. 10 | 11 | The implementation is messy (issue #350): on Windows, with _MSC_VER, 12 | we have to define Py_LIMITED_API even before including pyconfig.h. 13 | In that case, we guess what pyconfig.h will do to the macros above, 14 | and check our guess after the #include. 15 | 16 | Note that on Windows, with CPython 3.x, you need >= 3.5 and virtualenv 17 | version >= 16.0.0. With older versions of either, you don't get a 18 | copy of PYTHON3.DLL in the virtualenv. We can't check the version of 19 | CPython *before* we even include pyconfig.h. ffi.set_source() puts 20 | a ``#define _CFFI_NO_LIMITED_API'' at the start of this file if it is 21 | running on Windows < 3.5, as an attempt at fixing it, but that's 22 | arguably wrong because it may not be the target version of Python. 23 | Still better than nothing I guess. As another workaround, you can 24 | remove the definition of Py_LIMITED_API here. 25 | 26 | See also 'py_limited_api' in cffi/setuptools_ext.py. 27 | */ 28 | #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API) 29 | # ifdef _MSC_VER 30 | # if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API) 31 | # define Py_LIMITED_API 32 | # endif 33 | # include 34 | /* sanity-check: Py_LIMITED_API will cause crashes if any of these 35 | are also defined. Normally, the Python file PC/pyconfig.h does not 36 | cause any of these to be defined, with the exception that _DEBUG 37 | causes Py_DEBUG. Double-check that. */ 38 | # ifdef Py_LIMITED_API 39 | # if defined(Py_DEBUG) 40 | # error "pyconfig.h unexpectedly defines Py_DEBUG, but Py_LIMITED_API is set" 41 | # endif 42 | # if defined(Py_TRACE_REFS) 43 | # error "pyconfig.h unexpectedly defines Py_TRACE_REFS, but Py_LIMITED_API is set" 44 | # endif 45 | # if defined(Py_REF_DEBUG) 46 | # error "pyconfig.h unexpectedly defines Py_REF_DEBUG, but Py_LIMITED_API is set" 47 | # endif 48 | # endif 49 | # else 50 | # include 51 | # if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API) 52 | # define Py_LIMITED_API 53 | # endif 54 | # endif 55 | #endif 56 | 57 | #include 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | #include 62 | 63 | /* This part is from file 'cffi/parse_c_type.h'. It is copied at the 64 | beginning of C sources generated by CFFI's ffi.set_source(). */ 65 | 66 | typedef void *_cffi_opcode_t; 67 | 68 | #define _CFFI_OP(opcode, arg) (_cffi_opcode_t)(opcode | (((uintptr_t)(arg)) << 8)) 69 | #define _CFFI_GETOP(cffi_opcode) ((unsigned char)(uintptr_t)cffi_opcode) 70 | #define _CFFI_GETARG(cffi_opcode) (((intptr_t)cffi_opcode) >> 8) 71 | 72 | #define _CFFI_OP_PRIMITIVE 1 73 | #define _CFFI_OP_POINTER 3 74 | #define _CFFI_OP_ARRAY 5 75 | #define _CFFI_OP_OPEN_ARRAY 7 76 | #define _CFFI_OP_STRUCT_UNION 9 77 | #define _CFFI_OP_ENUM 11 78 | #define _CFFI_OP_FUNCTION 13 79 | #define _CFFI_OP_FUNCTION_END 15 80 | #define _CFFI_OP_NOOP 17 81 | #define _CFFI_OP_BITFIELD 19 82 | #define _CFFI_OP_TYPENAME 21 83 | #define _CFFI_OP_CPYTHON_BLTN_V 23 // varargs 84 | #define _CFFI_OP_CPYTHON_BLTN_N 25 // noargs 85 | #define _CFFI_OP_CPYTHON_BLTN_O 27 // O (i.e. a single arg) 86 | #define _CFFI_OP_CONSTANT 29 87 | #define _CFFI_OP_CONSTANT_INT 31 88 | #define _CFFI_OP_GLOBAL_VAR 33 89 | #define _CFFI_OP_DLOPEN_FUNC 35 90 | #define _CFFI_OP_DLOPEN_CONST 37 91 | #define _CFFI_OP_GLOBAL_VAR_F 39 92 | #define _CFFI_OP_EXTERN_PYTHON 41 93 | 94 | #define _CFFI_PRIM_VOID 0 95 | #define _CFFI_PRIM_BOOL 1 96 | #define _CFFI_PRIM_CHAR 2 97 | #define _CFFI_PRIM_SCHAR 3 98 | #define _CFFI_PRIM_UCHAR 4 99 | #define _CFFI_PRIM_SHORT 5 100 | #define _CFFI_PRIM_USHORT 6 101 | #define _CFFI_PRIM_INT 7 102 | #define _CFFI_PRIM_UINT 8 103 | #define _CFFI_PRIM_LONG 9 104 | #define _CFFI_PRIM_ULONG 10 105 | #define _CFFI_PRIM_LONGLONG 11 106 | #define _CFFI_PRIM_ULONGLONG 12 107 | #define _CFFI_PRIM_FLOAT 13 108 | #define _CFFI_PRIM_DOUBLE 14 109 | #define _CFFI_PRIM_LONGDOUBLE 15 110 | 111 | #define _CFFI_PRIM_WCHAR 16 112 | #define _CFFI_PRIM_INT8 17 113 | #define _CFFI_PRIM_UINT8 18 114 | #define _CFFI_PRIM_INT16 19 115 | #define _CFFI_PRIM_UINT16 20 116 | #define _CFFI_PRIM_INT32 21 117 | #define _CFFI_PRIM_UINT32 22 118 | #define _CFFI_PRIM_INT64 23 119 | #define _CFFI_PRIM_UINT64 24 120 | #define _CFFI_PRIM_INTPTR 25 121 | #define _CFFI_PRIM_UINTPTR 26 122 | #define _CFFI_PRIM_PTRDIFF 27 123 | #define _CFFI_PRIM_SIZE 28 124 | #define _CFFI_PRIM_SSIZE 29 125 | #define _CFFI_PRIM_INT_LEAST8 30 126 | #define _CFFI_PRIM_UINT_LEAST8 31 127 | #define _CFFI_PRIM_INT_LEAST16 32 128 | #define _CFFI_PRIM_UINT_LEAST16 33 129 | #define _CFFI_PRIM_INT_LEAST32 34 130 | #define _CFFI_PRIM_UINT_LEAST32 35 131 | #define _CFFI_PRIM_INT_LEAST64 36 132 | #define _CFFI_PRIM_UINT_LEAST64 37 133 | #define _CFFI_PRIM_INT_FAST8 38 134 | #define _CFFI_PRIM_UINT_FAST8 39 135 | #define _CFFI_PRIM_INT_FAST16 40 136 | #define _CFFI_PRIM_UINT_FAST16 41 137 | #define _CFFI_PRIM_INT_FAST32 42 138 | #define _CFFI_PRIM_UINT_FAST32 43 139 | #define _CFFI_PRIM_INT_FAST64 44 140 | #define _CFFI_PRIM_UINT_FAST64 45 141 | #define _CFFI_PRIM_INTMAX 46 142 | #define _CFFI_PRIM_UINTMAX 47 143 | #define _CFFI_PRIM_FLOATCOMPLEX 48 144 | #define _CFFI_PRIM_DOUBLECOMPLEX 49 145 | #define _CFFI_PRIM_CHAR16 50 146 | #define _CFFI_PRIM_CHAR32 51 147 | 148 | #define _CFFI__NUM_PRIM 52 149 | #define _CFFI__UNKNOWN_PRIM (-1) 150 | #define _CFFI__UNKNOWN_FLOAT_PRIM (-2) 151 | #define _CFFI__UNKNOWN_LONG_DOUBLE (-3) 152 | 153 | #define _CFFI__IO_FILE_STRUCT (-1) 154 | 155 | 156 | struct _cffi_global_s { 157 | const char *name; 158 | void *address; 159 | _cffi_opcode_t type_op; 160 | void *size_or_direct_fn; // OP_GLOBAL_VAR: size, or 0 if unknown 161 | // OP_CPYTHON_BLTN_*: addr of direct function 162 | }; 163 | 164 | struct _cffi_getconst_s { 165 | unsigned long long value; 166 | const struct _cffi_type_context_s *ctx; 167 | int gindex; 168 | }; 169 | 170 | struct _cffi_struct_union_s { 171 | const char *name; 172 | int type_index; // -> _cffi_types, on a OP_STRUCT_UNION 173 | int flags; // _CFFI_F_* flags below 174 | size_t size; 175 | int alignment; 176 | int first_field_index; // -> _cffi_fields array 177 | int num_fields; 178 | }; 179 | #define _CFFI_F_UNION 0x01 // is a union, not a struct 180 | #define _CFFI_F_CHECK_FIELDS 0x02 // complain if fields are not in the 181 | // "standard layout" or if some are missing 182 | #define _CFFI_F_PACKED 0x04 // for CHECK_FIELDS, assume a packed struct 183 | #define _CFFI_F_EXTERNAL 0x08 // in some other ffi.include() 184 | #define _CFFI_F_OPAQUE 0x10 // opaque 185 | 186 | struct _cffi_field_s { 187 | const char *name; 188 | size_t field_offset; 189 | size_t field_size; 190 | _cffi_opcode_t field_type_op; 191 | }; 192 | 193 | struct _cffi_enum_s { 194 | const char *name; 195 | int type_index; // -> _cffi_types, on a OP_ENUM 196 | int type_prim; // _CFFI_PRIM_xxx 197 | const char *enumerators; // comma-delimited string 198 | }; 199 | 200 | struct _cffi_typename_s { 201 | const char *name; 202 | int type_index; /* if opaque, points to a possibly artificial 203 | OP_STRUCT which is itself opaque */ 204 | }; 205 | 206 | struct _cffi_type_context_s { 207 | _cffi_opcode_t *types; 208 | const struct _cffi_global_s *globals; 209 | const struct _cffi_field_s *fields; 210 | const struct _cffi_struct_union_s *struct_unions; 211 | const struct _cffi_enum_s *enums; 212 | const struct _cffi_typename_s *typenames; 213 | int num_globals; 214 | int num_struct_unions; 215 | int num_enums; 216 | int num_typenames; 217 | const char *const *includes; 218 | int num_types; 219 | int flags; /* future extension */ 220 | }; 221 | 222 | struct _cffi_parse_info_s { 223 | const struct _cffi_type_context_s *ctx; 224 | _cffi_opcode_t *output; 225 | unsigned int output_size; 226 | size_t error_location; 227 | const char *error_message; 228 | }; 229 | 230 | struct _cffi_externpy_s { 231 | const char *name; 232 | size_t size_of_result; 233 | void *reserved1, *reserved2; 234 | }; 235 | 236 | #ifdef _CFFI_INTERNAL 237 | static int parse_c_type(struct _cffi_parse_info_s *info, const char *input); 238 | static int search_in_globals(const struct _cffi_type_context_s *ctx, 239 | const char *search, size_t search_len); 240 | static int search_in_struct_unions(const struct _cffi_type_context_s *ctx, 241 | const char *search, size_t search_len); 242 | #endif 243 | 244 | /* this block of #ifs should be kept exactly identical between 245 | c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py 246 | and cffi/_cffi_include.h */ 247 | #if defined(_MSC_VER) 248 | # include /* for alloca() */ 249 | # if _MSC_VER < 1600 /* MSVC < 2010 */ 250 | typedef __int8 int8_t; 251 | typedef __int16 int16_t; 252 | typedef __int32 int32_t; 253 | typedef __int64 int64_t; 254 | typedef unsigned __int8 uint8_t; 255 | typedef unsigned __int16 uint16_t; 256 | typedef unsigned __int32 uint32_t; 257 | typedef unsigned __int64 uint64_t; 258 | typedef __int8 int_least8_t; 259 | typedef __int16 int_least16_t; 260 | typedef __int32 int_least32_t; 261 | typedef __int64 int_least64_t; 262 | typedef unsigned __int8 uint_least8_t; 263 | typedef unsigned __int16 uint_least16_t; 264 | typedef unsigned __int32 uint_least32_t; 265 | typedef unsigned __int64 uint_least64_t; 266 | typedef __int8 int_fast8_t; 267 | typedef __int16 int_fast16_t; 268 | typedef __int32 int_fast32_t; 269 | typedef __int64 int_fast64_t; 270 | typedef unsigned __int8 uint_fast8_t; 271 | typedef unsigned __int16 uint_fast16_t; 272 | typedef unsigned __int32 uint_fast32_t; 273 | typedef unsigned __int64 uint_fast64_t; 274 | typedef __int64 intmax_t; 275 | typedef unsigned __int64 uintmax_t; 276 | # else 277 | # include 278 | # endif 279 | # if _MSC_VER < 1800 /* MSVC < 2013 */ 280 | # ifndef __cplusplus 281 | typedef unsigned char _Bool; 282 | # endif 283 | # endif 284 | # define _cffi_float_complex_t _Fcomplex /* include for it */ 285 | # define _cffi_double_complex_t _Dcomplex /* include for it */ 286 | #else 287 | # include 288 | # if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux) 289 | # include 290 | # endif 291 | # define _cffi_float_complex_t float _Complex 292 | # define _cffi_double_complex_t double _Complex 293 | #endif 294 | 295 | #ifdef __GNUC__ 296 | # define _CFFI_UNUSED_FN __attribute__((unused)) 297 | #else 298 | # define _CFFI_UNUSED_FN /* nothing */ 299 | #endif 300 | 301 | #ifdef __cplusplus 302 | # ifndef _Bool 303 | typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ 304 | # endif 305 | #endif 306 | 307 | /********** CPython-specific section **********/ 308 | #ifndef PYPY_VERSION 309 | 310 | 311 | #if PY_MAJOR_VERSION >= 3 312 | # define PyInt_FromLong PyLong_FromLong 313 | #endif 314 | 315 | #define _cffi_from_c_double PyFloat_FromDouble 316 | #define _cffi_from_c_float PyFloat_FromDouble 317 | #define _cffi_from_c_long PyInt_FromLong 318 | #define _cffi_from_c_ulong PyLong_FromUnsignedLong 319 | #define _cffi_from_c_longlong PyLong_FromLongLong 320 | #define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong 321 | #define _cffi_from_c__Bool PyBool_FromLong 322 | 323 | #define _cffi_to_c_double PyFloat_AsDouble 324 | #define _cffi_to_c_float PyFloat_AsDouble 325 | 326 | #define _cffi_from_c_int(x, type) \ 327 | (((type)-1) > 0 ? /* unsigned */ \ 328 | (sizeof(type) < sizeof(long) ? \ 329 | PyInt_FromLong((long)x) : \ 330 | sizeof(type) == sizeof(long) ? \ 331 | PyLong_FromUnsignedLong((unsigned long)x) : \ 332 | PyLong_FromUnsignedLongLong((unsigned long long)x)) : \ 333 | (sizeof(type) <= sizeof(long) ? \ 334 | PyInt_FromLong((long)x) : \ 335 | PyLong_FromLongLong((long long)x))) 336 | 337 | #define _cffi_to_c_int(o, type) \ 338 | ((type)( \ 339 | sizeof(type) == 1 ? (((type)-1) > 0 ? (type)_cffi_to_c_u8(o) \ 340 | : (type)_cffi_to_c_i8(o)) : \ 341 | sizeof(type) == 2 ? (((type)-1) > 0 ? (type)_cffi_to_c_u16(o) \ 342 | : (type)_cffi_to_c_i16(o)) : \ 343 | sizeof(type) == 4 ? (((type)-1) > 0 ? (type)_cffi_to_c_u32(o) \ 344 | : (type)_cffi_to_c_i32(o)) : \ 345 | sizeof(type) == 8 ? (((type)-1) > 0 ? (type)_cffi_to_c_u64(o) \ 346 | : (type)_cffi_to_c_i64(o)) : \ 347 | (Py_FatalError("unsupported size for type " #type), (type)0))) 348 | 349 | #define _cffi_to_c_i8 \ 350 | ((int(*)(PyObject *))_cffi_exports[1]) 351 | #define _cffi_to_c_u8 \ 352 | ((int(*)(PyObject *))_cffi_exports[2]) 353 | #define _cffi_to_c_i16 \ 354 | ((int(*)(PyObject *))_cffi_exports[3]) 355 | #define _cffi_to_c_u16 \ 356 | ((int(*)(PyObject *))_cffi_exports[4]) 357 | #define _cffi_to_c_i32 \ 358 | ((int(*)(PyObject *))_cffi_exports[5]) 359 | #define _cffi_to_c_u32 \ 360 | ((unsigned int(*)(PyObject *))_cffi_exports[6]) 361 | #define _cffi_to_c_i64 \ 362 | ((long long(*)(PyObject *))_cffi_exports[7]) 363 | #define _cffi_to_c_u64 \ 364 | ((unsigned long long(*)(PyObject *))_cffi_exports[8]) 365 | #define _cffi_to_c_char \ 366 | ((int(*)(PyObject *))_cffi_exports[9]) 367 | #define _cffi_from_c_pointer \ 368 | ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10]) 369 | #define _cffi_to_c_pointer \ 370 | ((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11]) 371 | #define _cffi_get_struct_layout \ 372 | not used any more 373 | #define _cffi_restore_errno \ 374 | ((void(*)(void))_cffi_exports[13]) 375 | #define _cffi_save_errno \ 376 | ((void(*)(void))_cffi_exports[14]) 377 | #define _cffi_from_c_char \ 378 | ((PyObject *(*)(char))_cffi_exports[15]) 379 | #define _cffi_from_c_deref \ 380 | ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16]) 381 | #define _cffi_to_c \ 382 | ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17]) 383 | #define _cffi_from_c_struct \ 384 | ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18]) 385 | #define _cffi_to_c_wchar_t \ 386 | ((_cffi_wchar_t(*)(PyObject *))_cffi_exports[19]) 387 | #define _cffi_from_c_wchar_t \ 388 | ((PyObject *(*)(_cffi_wchar_t))_cffi_exports[20]) 389 | #define _cffi_to_c_long_double \ 390 | ((long double(*)(PyObject *))_cffi_exports[21]) 391 | #define _cffi_to_c__Bool \ 392 | ((_Bool(*)(PyObject *))_cffi_exports[22]) 393 | #define _cffi_prepare_pointer_call_argument \ 394 | ((Py_ssize_t(*)(struct _cffi_ctypedescr *, \ 395 | PyObject *, char **))_cffi_exports[23]) 396 | #define _cffi_convert_array_from_object \ 397 | ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24]) 398 | #define _CFFI_CPIDX 25 399 | #define _cffi_call_python \ 400 | ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX]) 401 | #define _cffi_to_c_wchar3216_t \ 402 | ((int(*)(PyObject *))_cffi_exports[26]) 403 | #define _cffi_from_c_wchar3216_t \ 404 | ((PyObject *(*)(int))_cffi_exports[27]) 405 | #define _CFFI_NUM_EXPORTS 28 406 | 407 | struct _cffi_ctypedescr; 408 | 409 | static void *_cffi_exports[_CFFI_NUM_EXPORTS]; 410 | 411 | #define _cffi_type(index) ( \ 412 | assert((((uintptr_t)_cffi_types[index]) & 1) == 0), \ 413 | (struct _cffi_ctypedescr *)_cffi_types[index]) 414 | 415 | static PyObject *_cffi_init(const char *module_name, Py_ssize_t version, 416 | const struct _cffi_type_context_s *ctx) 417 | { 418 | PyObject *module, *o_arg, *new_module; 419 | void *raw[] = { 420 | (void *)module_name, 421 | (void *)version, 422 | (void *)_cffi_exports, 423 | (void *)ctx, 424 | }; 425 | 426 | module = PyImport_ImportModule("_cffi_backend"); 427 | if (module == NULL) 428 | goto failure; 429 | 430 | o_arg = PyLong_FromVoidPtr((void *)raw); 431 | if (o_arg == NULL) 432 | goto failure; 433 | 434 | new_module = PyObject_CallMethod( 435 | module, (char *)"_init_cffi_1_0_external_module", (char *)"O", o_arg); 436 | 437 | Py_DECREF(o_arg); 438 | Py_DECREF(module); 439 | return new_module; 440 | 441 | failure: 442 | Py_XDECREF(module); 443 | return NULL; 444 | } 445 | 446 | 447 | #ifdef HAVE_WCHAR_H 448 | typedef wchar_t _cffi_wchar_t; 449 | #else 450 | typedef uint16_t _cffi_wchar_t; /* same random pick as _cffi_backend.c */ 451 | #endif 452 | 453 | _CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o) 454 | { 455 | if (sizeof(_cffi_wchar_t) == 2) 456 | return (uint16_t)_cffi_to_c_wchar_t(o); 457 | else 458 | return (uint16_t)_cffi_to_c_wchar3216_t(o); 459 | } 460 | 461 | _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x) 462 | { 463 | if (sizeof(_cffi_wchar_t) == 2) 464 | return _cffi_from_c_wchar_t((_cffi_wchar_t)x); 465 | else 466 | return _cffi_from_c_wchar3216_t((int)x); 467 | } 468 | 469 | _CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o) 470 | { 471 | if (sizeof(_cffi_wchar_t) == 4) 472 | return (int)_cffi_to_c_wchar_t(o); 473 | else 474 | return (int)_cffi_to_c_wchar3216_t(o); 475 | } 476 | 477 | _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(unsigned int x) 478 | { 479 | if (sizeof(_cffi_wchar_t) == 4) 480 | return _cffi_from_c_wchar_t((_cffi_wchar_t)x); 481 | else 482 | return _cffi_from_c_wchar3216_t((int)x); 483 | } 484 | 485 | union _cffi_union_alignment_u { 486 | unsigned char m_char; 487 | unsigned short m_short; 488 | unsigned int m_int; 489 | unsigned long m_long; 490 | unsigned long long m_longlong; 491 | float m_float; 492 | double m_double; 493 | long double m_longdouble; 494 | }; 495 | 496 | struct _cffi_freeme_s { 497 | struct _cffi_freeme_s *next; 498 | union _cffi_union_alignment_u alignment; 499 | }; 500 | 501 | _CFFI_UNUSED_FN static int 502 | _cffi_convert_array_argument(struct _cffi_ctypedescr *ctptr, PyObject *arg, 503 | char **output_data, Py_ssize_t datasize, 504 | struct _cffi_freeme_s **freeme) 505 | { 506 | char *p; 507 | if (datasize < 0) 508 | return -1; 509 | 510 | p = *output_data; 511 | if (p == NULL) { 512 | struct _cffi_freeme_s *fp = (struct _cffi_freeme_s *)PyObject_Malloc( 513 | offsetof(struct _cffi_freeme_s, alignment) + (size_t)datasize); 514 | if (fp == NULL) 515 | return -1; 516 | fp->next = *freeme; 517 | *freeme = fp; 518 | p = *output_data = (char *)&fp->alignment; 519 | } 520 | memset((void *)p, 0, (size_t)datasize); 521 | return _cffi_convert_array_from_object(p, ctptr, arg); 522 | } 523 | 524 | _CFFI_UNUSED_FN static void 525 | _cffi_free_array_arguments(struct _cffi_freeme_s *freeme) 526 | { 527 | do { 528 | void *p = (void *)freeme; 529 | freeme = freeme->next; 530 | PyObject_Free(p); 531 | } while (freeme != NULL); 532 | } 533 | 534 | /********** end CPython-specific section **********/ 535 | #else 536 | _CFFI_UNUSED_FN 537 | static void (*_cffi_call_python_org)(struct _cffi_externpy_s *, char *); 538 | # define _cffi_call_python _cffi_call_python_org 539 | #endif 540 | 541 | 542 | #define _cffi_array_len(array) (sizeof(array) / sizeof((array)[0])) 543 | 544 | #define _cffi_prim_int(size, sign) \ 545 | ((size) == 1 ? ((sign) ? _CFFI_PRIM_INT8 : _CFFI_PRIM_UINT8) : \ 546 | (size) == 2 ? ((sign) ? _CFFI_PRIM_INT16 : _CFFI_PRIM_UINT16) : \ 547 | (size) == 4 ? ((sign) ? _CFFI_PRIM_INT32 : _CFFI_PRIM_UINT32) : \ 548 | (size) == 8 ? ((sign) ? _CFFI_PRIM_INT64 : _CFFI_PRIM_UINT64) : \ 549 | _CFFI__UNKNOWN_PRIM) 550 | 551 | #define _cffi_prim_float(size) \ 552 | ((size) == sizeof(float) ? _CFFI_PRIM_FLOAT : \ 553 | (size) == sizeof(double) ? _CFFI_PRIM_DOUBLE : \ 554 | (size) == sizeof(long double) ? _CFFI__UNKNOWN_LONG_DOUBLE : \ 555 | _CFFI__UNKNOWN_FLOAT_PRIM) 556 | 557 | #define _cffi_check_int(got, got_nonpos, expected) \ 558 | ((got_nonpos) == (expected <= 0) && \ 559 | (got) == (unsigned long long)expected) 560 | 561 | #ifdef MS_WIN32 562 | # define _cffi_stdcall __stdcall 563 | #else 564 | # define _cffi_stdcall /* nothing */ 565 | #endif 566 | 567 | #ifdef __cplusplus 568 | } 569 | #endif 570 | 571 | /************************************************************/ 572 | 573 | 574 | #include "ADIDatCAPI_mex.h" // the C header of the library 575 | 576 | 577 | /************************************************************/ 578 | 579 | static void *_cffi_types[] = { 580 | /* 0 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(ADIResultCode, wchar_t *, long, long *) 581 | /* 1 */ _CFFI_OP(_CFFI_OP_ENUM, 2), // ADIResultCode 582 | /* 2 */ _CFFI_OP(_CFFI_OP_POINTER, 92), // wchar_t * 583 | /* 3 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), // long 584 | /* 4 */ _CFFI_OP(_CFFI_OP_POINTER, 3), // long * 585 | /* 5 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 586 | /* 6 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_CommentsHandle__ * *) 587 | /* 7 */ _CFFI_OP(_CFFI_OP_POINTER, 10), // struct ADI_CommentsHandle__ * * 588 | /* 8 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 589 | /* 9 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_CommentsHandle__ *) 590 | /* 10 */ _CFFI_OP(_CFFI_OP_POINTER, 90), // struct ADI_CommentsHandle__ * 591 | /* 11 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 592 | /* 12 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_CommentsHandle__ *, long *, long *, long *, wchar_t *, long, long *) 593 | /* 13 */ _CFFI_OP(_CFFI_OP_NOOP, 10), 594 | /* 14 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 595 | /* 15 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 596 | /* 16 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 597 | /* 17 */ _CFFI_OP(_CFFI_OP_NOOP, 2), 598 | /* 18 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 599 | /* 19 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 600 | /* 20 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 601 | /* 21 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ * *) 602 | /* 22 */ _CFFI_OP(_CFFI_OP_POINTER, 25), // struct ADI_FileHandle__ * * 603 | /* 23 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 604 | /* 24 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long *) 605 | /* 25 */ _CFFI_OP(_CFFI_OP_POINTER, 91), // struct ADI_FileHandle__ * 606 | /* 26 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 607 | /* 27 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 608 | /* 28 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long *) 609 | /* 29 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 610 | /* 30 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 611 | /* 31 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 612 | /* 32 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 613 | /* 33 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long *, double *, long *) 614 | /* 34 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 615 | /* 35 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 616 | /* 36 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 617 | /* 37 */ _CFFI_OP(_CFFI_OP_POINTER, 87), // double * 618 | /* 38 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 619 | /* 39 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 620 | /* 40 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long, double *) 621 | /* 41 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 622 | /* 42 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 623 | /* 43 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 624 | /* 44 */ _CFFI_OP(_CFFI_OP_NOOP, 37), 625 | /* 45 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 626 | /* 46 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long, long *) 627 | /* 47 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 628 | /* 48 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 629 | /* 49 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 630 | /* 50 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 631 | /* 51 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 632 | /* 52 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long, long, ADICDataFlags, long, float *, long *) 633 | /* 53 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 634 | /* 54 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 635 | /* 55 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 636 | /* 56 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 637 | /* 57 */ _CFFI_OP(_CFFI_OP_ENUM, 0), // ADICDataFlags 638 | /* 58 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 639 | /* 59 */ _CFFI_OP(_CFFI_OP_POINTER, 88), // float * 640 | /* 60 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 641 | /* 61 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 642 | /* 62 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, long, wchar_t *, long, long *) 643 | /* 63 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 644 | /* 64 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 645 | /* 65 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 646 | /* 66 */ _CFFI_OP(_CFFI_OP_NOOP, 2), 647 | /* 67 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 648 | /* 68 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 649 | /* 69 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 650 | /* 70 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, struct ADI_CommentsHandle__ * *) 651 | /* 71 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 652 | /* 72 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 653 | /* 73 */ _CFFI_OP(_CFFI_OP_NOOP, 7), 654 | /* 74 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 655 | /* 75 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(struct ADI_FileHandle__ *, long, wchar_t *, long, long *) 656 | /* 76 */ _CFFI_OP(_CFFI_OP_NOOP, 25), 657 | /* 77 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 658 | /* 78 */ _CFFI_OP(_CFFI_OP_NOOP, 2), 659 | /* 79 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 9), 660 | /* 80 */ _CFFI_OP(_CFFI_OP_NOOP, 4), 661 | /* 81 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 662 | /* 82 */ _CFFI_OP(_CFFI_OP_FUNCTION, 1), // ADIResultCode()(wchar_t const *, struct ADI_FileHandle__ * *, ADIFileOpenMode) 663 | /* 83 */ _CFFI_OP(_CFFI_OP_POINTER, 92), // wchar_t const * 664 | /* 84 */ _CFFI_OP(_CFFI_OP_NOOP, 22), 665 | /* 85 */ _CFFI_OP(_CFFI_OP_ENUM, 1), // ADIFileOpenMode 666 | /* 86 */ _CFFI_OP(_CFFI_OP_FUNCTION_END, 0), 667 | /* 87 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 14), // double 668 | /* 88 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 13), // float 669 | /* 89 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 7), // int 670 | /* 90 */ _CFFI_OP(_CFFI_OP_STRUCT_UNION, 0), // struct ADI_CommentsHandle__ 671 | /* 91 */ _CFFI_OP(_CFFI_OP_STRUCT_UNION, 1), // struct ADI_FileHandle__ 672 | /* 92 */ _CFFI_OP(_CFFI_OP_PRIMITIVE, 16), // wchar_t 673 | }; 674 | 675 | static int _cffi_const_kADICDataAtSampleRate(unsigned long long *o) 676 | { 677 | int n = (kADICDataAtSampleRate) <= 0; 678 | *o = (unsigned long long)((kADICDataAtSampleRate) | 0); /* check that kADICDataAtSampleRate is an integer */ 679 | return n; 680 | } 681 | 682 | static int _cffi_const_kADICDataAtTickRate(unsigned long long *o) 683 | { 684 | int n = (kADICDataAtTickRate) <= 0; 685 | *o = (unsigned long long)((kADICDataAtTickRate) | 0); /* check that kADICDataAtTickRate is an integer */ 686 | return n; 687 | } 688 | 689 | static int _cffi_const_kOpenFileForReadOnly(unsigned long long *o) 690 | { 691 | int n = (kOpenFileForReadOnly) <= 0; 692 | *o = (unsigned long long)((kOpenFileForReadOnly) | 0); /* check that kOpenFileForReadOnly is an integer */ 693 | return n; 694 | } 695 | 696 | static int _cffi_const_kOpenFileForReadAndWrite(unsigned long long *o) 697 | { 698 | int n = (kOpenFileForReadAndWrite) <= 0; 699 | *o = (unsigned long long)((kOpenFileForReadAndWrite) | 0); /* check that kOpenFileForReadAndWrite is an integer */ 700 | return n; 701 | } 702 | 703 | static int _cffi_const_kResultSuccess(unsigned long long *o) 704 | { 705 | int n = (kResultSuccess) <= 0; 706 | *o = (unsigned long long)((kResultSuccess) | 0); /* check that kResultSuccess is an integer */ 707 | return n; 708 | } 709 | 710 | static int _cffi_const_kResultErrorFlagBit(unsigned long long *o) 711 | { 712 | int n = (kResultErrorFlagBit) <= 0; 713 | *o = (unsigned long long)((kResultErrorFlagBit) | 0); /* check that kResultErrorFlagBit is an integer */ 714 | return n; 715 | } 716 | 717 | static int _cffi_const_kResultInvalidArg(unsigned long long *o) 718 | { 719 | int n = (kResultInvalidArg) <= 0; 720 | *o = (unsigned long long)((kResultInvalidArg) | 0); /* check that kResultInvalidArg is an integer */ 721 | return n; 722 | } 723 | 724 | static int _cffi_const_kResultFail(unsigned long long *o) 725 | { 726 | int n = (kResultFail) <= 0; 727 | *o = (unsigned long long)((kResultFail) | 0); /* check that kResultFail is an integer */ 728 | return n; 729 | } 730 | 731 | static int _cffi_const_kResultFileNotFound(unsigned long long *o) 732 | { 733 | int n = (kResultFileNotFound) <= 0; 734 | *o = (unsigned long long)((kResultFileNotFound) | 0); /* check that kResultFileNotFound is an integer */ 735 | return n; 736 | } 737 | 738 | static int _cffi_const_kResultADICAPIMsgBase(unsigned long long *o) 739 | { 740 | int n = (kResultADICAPIMsgBase) <= 0; 741 | *o = (unsigned long long)((kResultADICAPIMsgBase) | 0); /* check that kResultADICAPIMsgBase is an integer */ 742 | return n; 743 | } 744 | 745 | static int _cffi_const_kResultFileIOError(unsigned long long *o) 746 | { 747 | int n = (kResultFileIOError) <= 0; 748 | *o = (unsigned long long)((kResultFileIOError) | 0); /* check that kResultFileIOError is an integer */ 749 | return n; 750 | } 751 | 752 | static int _cffi_const_kResultFileOpenFail(unsigned long long *o) 753 | { 754 | int n = (kResultFileOpenFail) <= 0; 755 | *o = (unsigned long long)((kResultFileOpenFail) | 0); /* check that kResultFileOpenFail is an integer */ 756 | return n; 757 | } 758 | 759 | static int _cffi_const_kResultInvalidFileHandle(unsigned long long *o) 760 | { 761 | int n = (kResultInvalidFileHandle) <= 0; 762 | *o = (unsigned long long)((kResultInvalidFileHandle) | 0); /* check that kResultInvalidFileHandle is an integer */ 763 | return n; 764 | } 765 | 766 | static int _cffi_const_kResultInvalidPosition(unsigned long long *o) 767 | { 768 | int n = (kResultInvalidPosition) <= 0; 769 | *o = (unsigned long long)((kResultInvalidPosition) | 0); /* check that kResultInvalidPosition is an integer */ 770 | return n; 771 | } 772 | 773 | static int _cffi_const_kResultInvalidCommentNum(unsigned long long *o) 774 | { 775 | int n = (kResultInvalidCommentNum) <= 0; 776 | *o = (unsigned long long)((kResultInvalidCommentNum) | 0); /* check that kResultInvalidCommentNum is an integer */ 777 | return n; 778 | } 779 | 780 | static int _cffi_const_kResultNoData(unsigned long long *o) 781 | { 782 | int n = (kResultNoData) <= 0; 783 | *o = (unsigned long long)((kResultNoData) | 0); /* check that kResultNoData is an integer */ 784 | return n; 785 | } 786 | 787 | static int _cffi_const_kResultBufferTooSmall(unsigned long long *o) 788 | { 789 | int n = (kResultBufferTooSmall) <= 0; 790 | *o = (unsigned long long)((kResultBufferTooSmall) | 0); /* check that kResultBufferTooSmall is an integer */ 791 | return n; 792 | } 793 | 794 | static ADIResultCode _cffi_d_ADI_CloseCommentsAccessor(struct ADI_CommentsHandle__ * * x0) 795 | { 796 | return ADI_CloseCommentsAccessor(x0); 797 | } 798 | #ifndef PYPY_VERSION 799 | static PyObject * 800 | _cffi_f_ADI_CloseCommentsAccessor(PyObject *self, PyObject *arg0) 801 | { 802 | struct ADI_CommentsHandle__ * * x0; 803 | Py_ssize_t datasize; 804 | struct _cffi_freeme_s *large_args_free = NULL; 805 | ADIResultCode result; 806 | PyObject *pyresult; 807 | 808 | datasize = _cffi_prepare_pointer_call_argument( 809 | _cffi_type(7), arg0, (char **)&x0); 810 | if (datasize != 0) { 811 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_CommentsHandle__ * *)alloca((size_t)datasize) : NULL; 812 | if (_cffi_convert_array_argument(_cffi_type(7), arg0, (char **)&x0, 813 | datasize, &large_args_free) < 0) 814 | return NULL; 815 | } 816 | 817 | Py_BEGIN_ALLOW_THREADS 818 | _cffi_restore_errno(); 819 | { result = ADI_CloseCommentsAccessor(x0); } 820 | _cffi_save_errno(); 821 | Py_END_ALLOW_THREADS 822 | 823 | (void)self; /* unused */ 824 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 825 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 826 | return pyresult; 827 | } 828 | #else 829 | # define _cffi_f_ADI_CloseCommentsAccessor _cffi_d_ADI_CloseCommentsAccessor 830 | #endif 831 | 832 | static ADIResultCode _cffi_d_ADI_CloseFile(struct ADI_FileHandle__ * * x0) 833 | { 834 | return ADI_CloseFile(x0); 835 | } 836 | #ifndef PYPY_VERSION 837 | static PyObject * 838 | _cffi_f_ADI_CloseFile(PyObject *self, PyObject *arg0) 839 | { 840 | struct ADI_FileHandle__ * * x0; 841 | Py_ssize_t datasize; 842 | struct _cffi_freeme_s *large_args_free = NULL; 843 | ADIResultCode result; 844 | PyObject *pyresult; 845 | 846 | datasize = _cffi_prepare_pointer_call_argument( 847 | _cffi_type(22), arg0, (char **)&x0); 848 | if (datasize != 0) { 849 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ * *)alloca((size_t)datasize) : NULL; 850 | if (_cffi_convert_array_argument(_cffi_type(22), arg0, (char **)&x0, 851 | datasize, &large_args_free) < 0) 852 | return NULL; 853 | } 854 | 855 | Py_BEGIN_ALLOW_THREADS 856 | _cffi_restore_errno(); 857 | { result = ADI_CloseFile(x0); } 858 | _cffi_save_errno(); 859 | Py_END_ALLOW_THREADS 860 | 861 | (void)self; /* unused */ 862 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 863 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 864 | return pyresult; 865 | } 866 | #else 867 | # define _cffi_f_ADI_CloseFile _cffi_d_ADI_CloseFile 868 | #endif 869 | 870 | static ADIResultCode _cffi_d_ADI_CreateCommentsAccessor(struct ADI_FileHandle__ * x0, long x1, struct ADI_CommentsHandle__ * * x2) 871 | { 872 | return ADI_CreateCommentsAccessor(x0, x1, x2); 873 | } 874 | #ifndef PYPY_VERSION 875 | static PyObject * 876 | _cffi_f_ADI_CreateCommentsAccessor(PyObject *self, PyObject *args) 877 | { 878 | struct ADI_FileHandle__ * x0; 879 | long x1; 880 | struct ADI_CommentsHandle__ * * x2; 881 | Py_ssize_t datasize; 882 | struct _cffi_freeme_s *large_args_free = NULL; 883 | ADIResultCode result; 884 | PyObject *pyresult; 885 | PyObject *arg0; 886 | PyObject *arg1; 887 | PyObject *arg2; 888 | 889 | if (!PyArg_UnpackTuple(args, "ADI_CreateCommentsAccessor", 3, 3, &arg0, &arg1, &arg2)) 890 | return NULL; 891 | 892 | datasize = _cffi_prepare_pointer_call_argument( 893 | _cffi_type(25), arg0, (char **)&x0); 894 | if (datasize != 0) { 895 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 896 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 897 | datasize, &large_args_free) < 0) 898 | return NULL; 899 | } 900 | 901 | x1 = _cffi_to_c_int(arg1, long); 902 | if (x1 == (long)-1 && PyErr_Occurred()) 903 | return NULL; 904 | 905 | datasize = _cffi_prepare_pointer_call_argument( 906 | _cffi_type(7), arg2, (char **)&x2); 907 | if (datasize != 0) { 908 | x2 = ((size_t)datasize) <= 640 ? (struct ADI_CommentsHandle__ * *)alloca((size_t)datasize) : NULL; 909 | if (_cffi_convert_array_argument(_cffi_type(7), arg2, (char **)&x2, 910 | datasize, &large_args_free) < 0) 911 | return NULL; 912 | } 913 | 914 | Py_BEGIN_ALLOW_THREADS 915 | _cffi_restore_errno(); 916 | { result = ADI_CreateCommentsAccessor(x0, x1, x2); } 917 | _cffi_save_errno(); 918 | Py_END_ALLOW_THREADS 919 | 920 | (void)self; /* unused */ 921 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 922 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 923 | return pyresult; 924 | } 925 | #else 926 | # define _cffi_f_ADI_CreateCommentsAccessor _cffi_d_ADI_CreateCommentsAccessor 927 | #endif 928 | 929 | static ADIResultCode _cffi_d_ADI_GetChannelName(struct ADI_FileHandle__ * x0, long x1, wchar_t * x2, long x3, long * x4) 930 | { 931 | return ADI_GetChannelName(x0, x1, x2, x3, x4); 932 | } 933 | #ifndef PYPY_VERSION 934 | static PyObject * 935 | _cffi_f_ADI_GetChannelName(PyObject *self, PyObject *args) 936 | { 937 | struct ADI_FileHandle__ * x0; 938 | long x1; 939 | wchar_t * x2; 940 | long x3; 941 | long * x4; 942 | Py_ssize_t datasize; 943 | struct _cffi_freeme_s *large_args_free = NULL; 944 | ADIResultCode result; 945 | PyObject *pyresult; 946 | PyObject *arg0; 947 | PyObject *arg1; 948 | PyObject *arg2; 949 | PyObject *arg3; 950 | PyObject *arg4; 951 | 952 | if (!PyArg_UnpackTuple(args, "ADI_GetChannelName", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) 953 | return NULL; 954 | 955 | datasize = _cffi_prepare_pointer_call_argument( 956 | _cffi_type(25), arg0, (char **)&x0); 957 | if (datasize != 0) { 958 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 959 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 960 | datasize, &large_args_free) < 0) 961 | return NULL; 962 | } 963 | 964 | x1 = _cffi_to_c_int(arg1, long); 965 | if (x1 == (long)-1 && PyErr_Occurred()) 966 | return NULL; 967 | 968 | datasize = _cffi_prepare_pointer_call_argument( 969 | _cffi_type(2), arg2, (char **)&x2); 970 | if (datasize != 0) { 971 | x2 = ((size_t)datasize) <= 640 ? (wchar_t *)alloca((size_t)datasize) : NULL; 972 | if (_cffi_convert_array_argument(_cffi_type(2), arg2, (char **)&x2, 973 | datasize, &large_args_free) < 0) 974 | return NULL; 975 | } 976 | 977 | x3 = _cffi_to_c_int(arg3, long); 978 | if (x3 == (long)-1 && PyErr_Occurred()) 979 | return NULL; 980 | 981 | datasize = _cffi_prepare_pointer_call_argument( 982 | _cffi_type(4), arg4, (char **)&x4); 983 | if (datasize != 0) { 984 | x4 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 985 | if (_cffi_convert_array_argument(_cffi_type(4), arg4, (char **)&x4, 986 | datasize, &large_args_free) < 0) 987 | return NULL; 988 | } 989 | 990 | Py_BEGIN_ALLOW_THREADS 991 | _cffi_restore_errno(); 992 | { result = ADI_GetChannelName(x0, x1, x2, x3, x4); } 993 | _cffi_save_errno(); 994 | Py_END_ALLOW_THREADS 995 | 996 | (void)self; /* unused */ 997 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 998 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 999 | return pyresult; 1000 | } 1001 | #else 1002 | # define _cffi_f_ADI_GetChannelName _cffi_d_ADI_GetChannelName 1003 | #endif 1004 | 1005 | static ADIResultCode _cffi_d_ADI_GetCommentInfo(struct ADI_CommentsHandle__ * x0, long * x1, long * x2, long * x3, wchar_t * x4, long x5, long * x6) 1006 | { 1007 | return ADI_GetCommentInfo(x0, x1, x2, x3, x4, x5, x6); 1008 | } 1009 | #ifndef PYPY_VERSION 1010 | static PyObject * 1011 | _cffi_f_ADI_GetCommentInfo(PyObject *self, PyObject *args) 1012 | { 1013 | struct ADI_CommentsHandle__ * x0; 1014 | long * x1; 1015 | long * x2; 1016 | long * x3; 1017 | wchar_t * x4; 1018 | long x5; 1019 | long * x6; 1020 | Py_ssize_t datasize; 1021 | struct _cffi_freeme_s *large_args_free = NULL; 1022 | ADIResultCode result; 1023 | PyObject *pyresult; 1024 | PyObject *arg0; 1025 | PyObject *arg1; 1026 | PyObject *arg2; 1027 | PyObject *arg3; 1028 | PyObject *arg4; 1029 | PyObject *arg5; 1030 | PyObject *arg6; 1031 | 1032 | if (!PyArg_UnpackTuple(args, "ADI_GetCommentInfo", 7, 7, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6)) 1033 | return NULL; 1034 | 1035 | datasize = _cffi_prepare_pointer_call_argument( 1036 | _cffi_type(10), arg0, (char **)&x0); 1037 | if (datasize != 0) { 1038 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_CommentsHandle__ *)alloca((size_t)datasize) : NULL; 1039 | if (_cffi_convert_array_argument(_cffi_type(10), arg0, (char **)&x0, 1040 | datasize, &large_args_free) < 0) 1041 | return NULL; 1042 | } 1043 | 1044 | datasize = _cffi_prepare_pointer_call_argument( 1045 | _cffi_type(4), arg1, (char **)&x1); 1046 | if (datasize != 0) { 1047 | x1 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1048 | if (_cffi_convert_array_argument(_cffi_type(4), arg1, (char **)&x1, 1049 | datasize, &large_args_free) < 0) 1050 | return NULL; 1051 | } 1052 | 1053 | datasize = _cffi_prepare_pointer_call_argument( 1054 | _cffi_type(4), arg2, (char **)&x2); 1055 | if (datasize != 0) { 1056 | x2 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1057 | if (_cffi_convert_array_argument(_cffi_type(4), arg2, (char **)&x2, 1058 | datasize, &large_args_free) < 0) 1059 | return NULL; 1060 | } 1061 | 1062 | datasize = _cffi_prepare_pointer_call_argument( 1063 | _cffi_type(4), arg3, (char **)&x3); 1064 | if (datasize != 0) { 1065 | x3 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1066 | if (_cffi_convert_array_argument(_cffi_type(4), arg3, (char **)&x3, 1067 | datasize, &large_args_free) < 0) 1068 | return NULL; 1069 | } 1070 | 1071 | datasize = _cffi_prepare_pointer_call_argument( 1072 | _cffi_type(2), arg4, (char **)&x4); 1073 | if (datasize != 0) { 1074 | x4 = ((size_t)datasize) <= 640 ? (wchar_t *)alloca((size_t)datasize) : NULL; 1075 | if (_cffi_convert_array_argument(_cffi_type(2), arg4, (char **)&x4, 1076 | datasize, &large_args_free) < 0) 1077 | return NULL; 1078 | } 1079 | 1080 | x5 = _cffi_to_c_int(arg5, long); 1081 | if (x5 == (long)-1 && PyErr_Occurred()) 1082 | return NULL; 1083 | 1084 | datasize = _cffi_prepare_pointer_call_argument( 1085 | _cffi_type(4), arg6, (char **)&x6); 1086 | if (datasize != 0) { 1087 | x6 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1088 | if (_cffi_convert_array_argument(_cffi_type(4), arg6, (char **)&x6, 1089 | datasize, &large_args_free) < 0) 1090 | return NULL; 1091 | } 1092 | 1093 | Py_BEGIN_ALLOW_THREADS 1094 | _cffi_restore_errno(); 1095 | { result = ADI_GetCommentInfo(x0, x1, x2, x3, x4, x5, x6); } 1096 | _cffi_save_errno(); 1097 | Py_END_ALLOW_THREADS 1098 | 1099 | (void)self; /* unused */ 1100 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1101 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1102 | return pyresult; 1103 | } 1104 | #else 1105 | # define _cffi_f_ADI_GetCommentInfo _cffi_d_ADI_GetCommentInfo 1106 | #endif 1107 | 1108 | static ADIResultCode _cffi_d_ADI_GetErrorMessage(ADIResultCode x0, wchar_t * x1, long x2, long * x3) 1109 | { 1110 | return ADI_GetErrorMessage(x0, x1, x2, x3); 1111 | } 1112 | #ifndef PYPY_VERSION 1113 | static PyObject * 1114 | _cffi_f_ADI_GetErrorMessage(PyObject *self, PyObject *args) 1115 | { 1116 | ADIResultCode x0; 1117 | wchar_t * x1; 1118 | long x2; 1119 | long * x3; 1120 | Py_ssize_t datasize; 1121 | struct _cffi_freeme_s *large_args_free = NULL; 1122 | ADIResultCode result; 1123 | PyObject *pyresult; 1124 | PyObject *arg0; 1125 | PyObject *arg1; 1126 | PyObject *arg2; 1127 | PyObject *arg3; 1128 | 1129 | if (!PyArg_UnpackTuple(args, "ADI_GetErrorMessage", 4, 4, &arg0, &arg1, &arg2, &arg3)) 1130 | return NULL; 1131 | 1132 | if (_cffi_to_c((char *)&x0, _cffi_type(1), arg0) < 0) 1133 | return NULL; 1134 | 1135 | datasize = _cffi_prepare_pointer_call_argument( 1136 | _cffi_type(2), arg1, (char **)&x1); 1137 | if (datasize != 0) { 1138 | x1 = ((size_t)datasize) <= 640 ? (wchar_t *)alloca((size_t)datasize) : NULL; 1139 | if (_cffi_convert_array_argument(_cffi_type(2), arg1, (char **)&x1, 1140 | datasize, &large_args_free) < 0) 1141 | return NULL; 1142 | } 1143 | 1144 | x2 = _cffi_to_c_int(arg2, long); 1145 | if (x2 == (long)-1 && PyErr_Occurred()) 1146 | return NULL; 1147 | 1148 | datasize = _cffi_prepare_pointer_call_argument( 1149 | _cffi_type(4), arg3, (char **)&x3); 1150 | if (datasize != 0) { 1151 | x3 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1152 | if (_cffi_convert_array_argument(_cffi_type(4), arg3, (char **)&x3, 1153 | datasize, &large_args_free) < 0) 1154 | return NULL; 1155 | } 1156 | 1157 | Py_BEGIN_ALLOW_THREADS 1158 | _cffi_restore_errno(); 1159 | { result = ADI_GetErrorMessage(x0, x1, x2, x3); } 1160 | _cffi_save_errno(); 1161 | Py_END_ALLOW_THREADS 1162 | 1163 | (void)self; /* unused */ 1164 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1165 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1166 | return pyresult; 1167 | } 1168 | #else 1169 | # define _cffi_f_ADI_GetErrorMessage _cffi_d_ADI_GetErrorMessage 1170 | #endif 1171 | 1172 | static ADIResultCode _cffi_d_ADI_GetNumSamplesInRecord(struct ADI_FileHandle__ * x0, long x1, long x2, long * x3) 1173 | { 1174 | return ADI_GetNumSamplesInRecord(x0, x1, x2, x3); 1175 | } 1176 | #ifndef PYPY_VERSION 1177 | static PyObject * 1178 | _cffi_f_ADI_GetNumSamplesInRecord(PyObject *self, PyObject *args) 1179 | { 1180 | struct ADI_FileHandle__ * x0; 1181 | long x1; 1182 | long x2; 1183 | long * x3; 1184 | Py_ssize_t datasize; 1185 | struct _cffi_freeme_s *large_args_free = NULL; 1186 | ADIResultCode result; 1187 | PyObject *pyresult; 1188 | PyObject *arg0; 1189 | PyObject *arg1; 1190 | PyObject *arg2; 1191 | PyObject *arg3; 1192 | 1193 | if (!PyArg_UnpackTuple(args, "ADI_GetNumSamplesInRecord", 4, 4, &arg0, &arg1, &arg2, &arg3)) 1194 | return NULL; 1195 | 1196 | datasize = _cffi_prepare_pointer_call_argument( 1197 | _cffi_type(25), arg0, (char **)&x0); 1198 | if (datasize != 0) { 1199 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1200 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1201 | datasize, &large_args_free) < 0) 1202 | return NULL; 1203 | } 1204 | 1205 | x1 = _cffi_to_c_int(arg1, long); 1206 | if (x1 == (long)-1 && PyErr_Occurred()) 1207 | return NULL; 1208 | 1209 | x2 = _cffi_to_c_int(arg2, long); 1210 | if (x2 == (long)-1 && PyErr_Occurred()) 1211 | return NULL; 1212 | 1213 | datasize = _cffi_prepare_pointer_call_argument( 1214 | _cffi_type(4), arg3, (char **)&x3); 1215 | if (datasize != 0) { 1216 | x3 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1217 | if (_cffi_convert_array_argument(_cffi_type(4), arg3, (char **)&x3, 1218 | datasize, &large_args_free) < 0) 1219 | return NULL; 1220 | } 1221 | 1222 | Py_BEGIN_ALLOW_THREADS 1223 | _cffi_restore_errno(); 1224 | { result = ADI_GetNumSamplesInRecord(x0, x1, x2, x3); } 1225 | _cffi_save_errno(); 1226 | Py_END_ALLOW_THREADS 1227 | 1228 | (void)self; /* unused */ 1229 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1230 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1231 | return pyresult; 1232 | } 1233 | #else 1234 | # define _cffi_f_ADI_GetNumSamplesInRecord _cffi_d_ADI_GetNumSamplesInRecord 1235 | #endif 1236 | 1237 | static ADIResultCode _cffi_d_ADI_GetNumTicksInRecord(struct ADI_FileHandle__ * x0, long x1, long * x2) 1238 | { 1239 | return ADI_GetNumTicksInRecord(x0, x1, x2); 1240 | } 1241 | #ifndef PYPY_VERSION 1242 | static PyObject * 1243 | _cffi_f_ADI_GetNumTicksInRecord(PyObject *self, PyObject *args) 1244 | { 1245 | struct ADI_FileHandle__ * x0; 1246 | long x1; 1247 | long * x2; 1248 | Py_ssize_t datasize; 1249 | struct _cffi_freeme_s *large_args_free = NULL; 1250 | ADIResultCode result; 1251 | PyObject *pyresult; 1252 | PyObject *arg0; 1253 | PyObject *arg1; 1254 | PyObject *arg2; 1255 | 1256 | if (!PyArg_UnpackTuple(args, "ADI_GetNumTicksInRecord", 3, 3, &arg0, &arg1, &arg2)) 1257 | return NULL; 1258 | 1259 | datasize = _cffi_prepare_pointer_call_argument( 1260 | _cffi_type(25), arg0, (char **)&x0); 1261 | if (datasize != 0) { 1262 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1263 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1264 | datasize, &large_args_free) < 0) 1265 | return NULL; 1266 | } 1267 | 1268 | x1 = _cffi_to_c_int(arg1, long); 1269 | if (x1 == (long)-1 && PyErr_Occurred()) 1270 | return NULL; 1271 | 1272 | datasize = _cffi_prepare_pointer_call_argument( 1273 | _cffi_type(4), arg2, (char **)&x2); 1274 | if (datasize != 0) { 1275 | x2 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1276 | if (_cffi_convert_array_argument(_cffi_type(4), arg2, (char **)&x2, 1277 | datasize, &large_args_free) < 0) 1278 | return NULL; 1279 | } 1280 | 1281 | Py_BEGIN_ALLOW_THREADS 1282 | _cffi_restore_errno(); 1283 | { result = ADI_GetNumTicksInRecord(x0, x1, x2); } 1284 | _cffi_save_errno(); 1285 | Py_END_ALLOW_THREADS 1286 | 1287 | (void)self; /* unused */ 1288 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1289 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1290 | return pyresult; 1291 | } 1292 | #else 1293 | # define _cffi_f_ADI_GetNumTicksInRecord _cffi_d_ADI_GetNumTicksInRecord 1294 | #endif 1295 | 1296 | static ADIResultCode _cffi_d_ADI_GetNumberOfChannels(struct ADI_FileHandle__ * x0, long * x1) 1297 | { 1298 | return ADI_GetNumberOfChannels(x0, x1); 1299 | } 1300 | #ifndef PYPY_VERSION 1301 | static PyObject * 1302 | _cffi_f_ADI_GetNumberOfChannels(PyObject *self, PyObject *args) 1303 | { 1304 | struct ADI_FileHandle__ * x0; 1305 | long * x1; 1306 | Py_ssize_t datasize; 1307 | struct _cffi_freeme_s *large_args_free = NULL; 1308 | ADIResultCode result; 1309 | PyObject *pyresult; 1310 | PyObject *arg0; 1311 | PyObject *arg1; 1312 | 1313 | if (!PyArg_UnpackTuple(args, "ADI_GetNumberOfChannels", 2, 2, &arg0, &arg1)) 1314 | return NULL; 1315 | 1316 | datasize = _cffi_prepare_pointer_call_argument( 1317 | _cffi_type(25), arg0, (char **)&x0); 1318 | if (datasize != 0) { 1319 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1320 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1321 | datasize, &large_args_free) < 0) 1322 | return NULL; 1323 | } 1324 | 1325 | datasize = _cffi_prepare_pointer_call_argument( 1326 | _cffi_type(4), arg1, (char **)&x1); 1327 | if (datasize != 0) { 1328 | x1 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1329 | if (_cffi_convert_array_argument(_cffi_type(4), arg1, (char **)&x1, 1330 | datasize, &large_args_free) < 0) 1331 | return NULL; 1332 | } 1333 | 1334 | Py_BEGIN_ALLOW_THREADS 1335 | _cffi_restore_errno(); 1336 | { result = ADI_GetNumberOfChannels(x0, x1); } 1337 | _cffi_save_errno(); 1338 | Py_END_ALLOW_THREADS 1339 | 1340 | (void)self; /* unused */ 1341 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1342 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1343 | return pyresult; 1344 | } 1345 | #else 1346 | # define _cffi_f_ADI_GetNumberOfChannels _cffi_d_ADI_GetNumberOfChannels 1347 | #endif 1348 | 1349 | static ADIResultCode _cffi_d_ADI_GetNumberOfRecords(struct ADI_FileHandle__ * x0, long * x1) 1350 | { 1351 | return ADI_GetNumberOfRecords(x0, x1); 1352 | } 1353 | #ifndef PYPY_VERSION 1354 | static PyObject * 1355 | _cffi_f_ADI_GetNumberOfRecords(PyObject *self, PyObject *args) 1356 | { 1357 | struct ADI_FileHandle__ * x0; 1358 | long * x1; 1359 | Py_ssize_t datasize; 1360 | struct _cffi_freeme_s *large_args_free = NULL; 1361 | ADIResultCode result; 1362 | PyObject *pyresult; 1363 | PyObject *arg0; 1364 | PyObject *arg1; 1365 | 1366 | if (!PyArg_UnpackTuple(args, "ADI_GetNumberOfRecords", 2, 2, &arg0, &arg1)) 1367 | return NULL; 1368 | 1369 | datasize = _cffi_prepare_pointer_call_argument( 1370 | _cffi_type(25), arg0, (char **)&x0); 1371 | if (datasize != 0) { 1372 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1373 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1374 | datasize, &large_args_free) < 0) 1375 | return NULL; 1376 | } 1377 | 1378 | datasize = _cffi_prepare_pointer_call_argument( 1379 | _cffi_type(4), arg1, (char **)&x1); 1380 | if (datasize != 0) { 1381 | x1 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1382 | if (_cffi_convert_array_argument(_cffi_type(4), arg1, (char **)&x1, 1383 | datasize, &large_args_free) < 0) 1384 | return NULL; 1385 | } 1386 | 1387 | Py_BEGIN_ALLOW_THREADS 1388 | _cffi_restore_errno(); 1389 | { result = ADI_GetNumberOfRecords(x0, x1); } 1390 | _cffi_save_errno(); 1391 | Py_END_ALLOW_THREADS 1392 | 1393 | (void)self; /* unused */ 1394 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1395 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1396 | return pyresult; 1397 | } 1398 | #else 1399 | # define _cffi_f_ADI_GetNumberOfRecords _cffi_d_ADI_GetNumberOfRecords 1400 | #endif 1401 | 1402 | static ADIResultCode _cffi_d_ADI_GetRecordSamplePeriod(struct ADI_FileHandle__ * x0, long x1, long x2, double * x3) 1403 | { 1404 | return ADI_GetRecordSamplePeriod(x0, x1, x2, x3); 1405 | } 1406 | #ifndef PYPY_VERSION 1407 | static PyObject * 1408 | _cffi_f_ADI_GetRecordSamplePeriod(PyObject *self, PyObject *args) 1409 | { 1410 | struct ADI_FileHandle__ * x0; 1411 | long x1; 1412 | long x2; 1413 | double * x3; 1414 | Py_ssize_t datasize; 1415 | struct _cffi_freeme_s *large_args_free = NULL; 1416 | ADIResultCode result; 1417 | PyObject *pyresult; 1418 | PyObject *arg0; 1419 | PyObject *arg1; 1420 | PyObject *arg2; 1421 | PyObject *arg3; 1422 | 1423 | if (!PyArg_UnpackTuple(args, "ADI_GetRecordSamplePeriod", 4, 4, &arg0, &arg1, &arg2, &arg3)) 1424 | return NULL; 1425 | 1426 | datasize = _cffi_prepare_pointer_call_argument( 1427 | _cffi_type(25), arg0, (char **)&x0); 1428 | if (datasize != 0) { 1429 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1430 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1431 | datasize, &large_args_free) < 0) 1432 | return NULL; 1433 | } 1434 | 1435 | x1 = _cffi_to_c_int(arg1, long); 1436 | if (x1 == (long)-1 && PyErr_Occurred()) 1437 | return NULL; 1438 | 1439 | x2 = _cffi_to_c_int(arg2, long); 1440 | if (x2 == (long)-1 && PyErr_Occurred()) 1441 | return NULL; 1442 | 1443 | datasize = _cffi_prepare_pointer_call_argument( 1444 | _cffi_type(37), arg3, (char **)&x3); 1445 | if (datasize != 0) { 1446 | x3 = ((size_t)datasize) <= 640 ? (double *)alloca((size_t)datasize) : NULL; 1447 | if (_cffi_convert_array_argument(_cffi_type(37), arg3, (char **)&x3, 1448 | datasize, &large_args_free) < 0) 1449 | return NULL; 1450 | } 1451 | 1452 | Py_BEGIN_ALLOW_THREADS 1453 | _cffi_restore_errno(); 1454 | { result = ADI_GetRecordSamplePeriod(x0, x1, x2, x3); } 1455 | _cffi_save_errno(); 1456 | Py_END_ALLOW_THREADS 1457 | 1458 | (void)self; /* unused */ 1459 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1460 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1461 | return pyresult; 1462 | } 1463 | #else 1464 | # define _cffi_f_ADI_GetRecordSamplePeriod _cffi_d_ADI_GetRecordSamplePeriod 1465 | #endif 1466 | 1467 | static ADIResultCode _cffi_d_ADI_GetRecordTickPeriod(struct ADI_FileHandle__ * x0, long x1, long x2, double * x3) 1468 | { 1469 | return ADI_GetRecordTickPeriod(x0, x1, x2, x3); 1470 | } 1471 | #ifndef PYPY_VERSION 1472 | static PyObject * 1473 | _cffi_f_ADI_GetRecordTickPeriod(PyObject *self, PyObject *args) 1474 | { 1475 | struct ADI_FileHandle__ * x0; 1476 | long x1; 1477 | long x2; 1478 | double * x3; 1479 | Py_ssize_t datasize; 1480 | struct _cffi_freeme_s *large_args_free = NULL; 1481 | ADIResultCode result; 1482 | PyObject *pyresult; 1483 | PyObject *arg0; 1484 | PyObject *arg1; 1485 | PyObject *arg2; 1486 | PyObject *arg3; 1487 | 1488 | if (!PyArg_UnpackTuple(args, "ADI_GetRecordTickPeriod", 4, 4, &arg0, &arg1, &arg2, &arg3)) 1489 | return NULL; 1490 | 1491 | datasize = _cffi_prepare_pointer_call_argument( 1492 | _cffi_type(25), arg0, (char **)&x0); 1493 | if (datasize != 0) { 1494 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1495 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1496 | datasize, &large_args_free) < 0) 1497 | return NULL; 1498 | } 1499 | 1500 | x1 = _cffi_to_c_int(arg1, long); 1501 | if (x1 == (long)-1 && PyErr_Occurred()) 1502 | return NULL; 1503 | 1504 | x2 = _cffi_to_c_int(arg2, long); 1505 | if (x2 == (long)-1 && PyErr_Occurred()) 1506 | return NULL; 1507 | 1508 | datasize = _cffi_prepare_pointer_call_argument( 1509 | _cffi_type(37), arg3, (char **)&x3); 1510 | if (datasize != 0) { 1511 | x3 = ((size_t)datasize) <= 640 ? (double *)alloca((size_t)datasize) : NULL; 1512 | if (_cffi_convert_array_argument(_cffi_type(37), arg3, (char **)&x3, 1513 | datasize, &large_args_free) < 0) 1514 | return NULL; 1515 | } 1516 | 1517 | Py_BEGIN_ALLOW_THREADS 1518 | _cffi_restore_errno(); 1519 | { result = ADI_GetRecordTickPeriod(x0, x1, x2, x3); } 1520 | _cffi_save_errno(); 1521 | Py_END_ALLOW_THREADS 1522 | 1523 | (void)self; /* unused */ 1524 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1525 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1526 | return pyresult; 1527 | } 1528 | #else 1529 | # define _cffi_f_ADI_GetRecordTickPeriod _cffi_d_ADI_GetRecordTickPeriod 1530 | #endif 1531 | 1532 | static ADIResultCode _cffi_d_ADI_GetRecordTime(struct ADI_FileHandle__ * x0, long x1, long * x2, double * x3, long * x4) 1533 | { 1534 | return ADI_GetRecordTime(x0, x1, x2, x3, x4); 1535 | } 1536 | #ifndef PYPY_VERSION 1537 | static PyObject * 1538 | _cffi_f_ADI_GetRecordTime(PyObject *self, PyObject *args) 1539 | { 1540 | struct ADI_FileHandle__ * x0; 1541 | long x1; 1542 | long * x2; 1543 | double * x3; 1544 | long * x4; 1545 | Py_ssize_t datasize; 1546 | struct _cffi_freeme_s *large_args_free = NULL; 1547 | ADIResultCode result; 1548 | PyObject *pyresult; 1549 | PyObject *arg0; 1550 | PyObject *arg1; 1551 | PyObject *arg2; 1552 | PyObject *arg3; 1553 | PyObject *arg4; 1554 | 1555 | if (!PyArg_UnpackTuple(args, "ADI_GetRecordTime", 5, 5, &arg0, &arg1, &arg2, &arg3, &arg4)) 1556 | return NULL; 1557 | 1558 | datasize = _cffi_prepare_pointer_call_argument( 1559 | _cffi_type(25), arg0, (char **)&x0); 1560 | if (datasize != 0) { 1561 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1562 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1563 | datasize, &large_args_free) < 0) 1564 | return NULL; 1565 | } 1566 | 1567 | x1 = _cffi_to_c_int(arg1, long); 1568 | if (x1 == (long)-1 && PyErr_Occurred()) 1569 | return NULL; 1570 | 1571 | datasize = _cffi_prepare_pointer_call_argument( 1572 | _cffi_type(4), arg2, (char **)&x2); 1573 | if (datasize != 0) { 1574 | x2 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1575 | if (_cffi_convert_array_argument(_cffi_type(4), arg2, (char **)&x2, 1576 | datasize, &large_args_free) < 0) 1577 | return NULL; 1578 | } 1579 | 1580 | datasize = _cffi_prepare_pointer_call_argument( 1581 | _cffi_type(37), arg3, (char **)&x3); 1582 | if (datasize != 0) { 1583 | x3 = ((size_t)datasize) <= 640 ? (double *)alloca((size_t)datasize) : NULL; 1584 | if (_cffi_convert_array_argument(_cffi_type(37), arg3, (char **)&x3, 1585 | datasize, &large_args_free) < 0) 1586 | return NULL; 1587 | } 1588 | 1589 | datasize = _cffi_prepare_pointer_call_argument( 1590 | _cffi_type(4), arg4, (char **)&x4); 1591 | if (datasize != 0) { 1592 | x4 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1593 | if (_cffi_convert_array_argument(_cffi_type(4), arg4, (char **)&x4, 1594 | datasize, &large_args_free) < 0) 1595 | return NULL; 1596 | } 1597 | 1598 | Py_BEGIN_ALLOW_THREADS 1599 | _cffi_restore_errno(); 1600 | { result = ADI_GetRecordTime(x0, x1, x2, x3, x4); } 1601 | _cffi_save_errno(); 1602 | Py_END_ALLOW_THREADS 1603 | 1604 | (void)self; /* unused */ 1605 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1606 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1607 | return pyresult; 1608 | } 1609 | #else 1610 | # define _cffi_f_ADI_GetRecordTime _cffi_d_ADI_GetRecordTime 1611 | #endif 1612 | 1613 | static ADIResultCode _cffi_d_ADI_GetSamples(struct ADI_FileHandle__ * x0, long x1, long x2, long x3, ADICDataFlags x4, long x5, float * x6, long * x7) 1614 | { 1615 | return ADI_GetSamples(x0, x1, x2, x3, x4, x5, x6, x7); 1616 | } 1617 | #ifndef PYPY_VERSION 1618 | static PyObject * 1619 | _cffi_f_ADI_GetSamples(PyObject *self, PyObject *args) 1620 | { 1621 | struct ADI_FileHandle__ * x0; 1622 | long x1; 1623 | long x2; 1624 | long x3; 1625 | ADICDataFlags x4; 1626 | long x5; 1627 | float * x6; 1628 | long * x7; 1629 | Py_ssize_t datasize; 1630 | struct _cffi_freeme_s *large_args_free = NULL; 1631 | ADIResultCode result; 1632 | PyObject *pyresult; 1633 | PyObject *arg0; 1634 | PyObject *arg1; 1635 | PyObject *arg2; 1636 | PyObject *arg3; 1637 | PyObject *arg4; 1638 | PyObject *arg5; 1639 | PyObject *arg6; 1640 | PyObject *arg7; 1641 | 1642 | if (!PyArg_UnpackTuple(args, "ADI_GetSamples", 8, 8, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7)) 1643 | return NULL; 1644 | 1645 | datasize = _cffi_prepare_pointer_call_argument( 1646 | _cffi_type(25), arg0, (char **)&x0); 1647 | if (datasize != 0) { 1648 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1649 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1650 | datasize, &large_args_free) < 0) 1651 | return NULL; 1652 | } 1653 | 1654 | x1 = _cffi_to_c_int(arg1, long); 1655 | if (x1 == (long)-1 && PyErr_Occurred()) 1656 | return NULL; 1657 | 1658 | x2 = _cffi_to_c_int(arg2, long); 1659 | if (x2 == (long)-1 && PyErr_Occurred()) 1660 | return NULL; 1661 | 1662 | x3 = _cffi_to_c_int(arg3, long); 1663 | if (x3 == (long)-1 && PyErr_Occurred()) 1664 | return NULL; 1665 | 1666 | if (_cffi_to_c((char *)&x4, _cffi_type(57), arg4) < 0) 1667 | return NULL; 1668 | 1669 | x5 = _cffi_to_c_int(arg5, long); 1670 | if (x5 == (long)-1 && PyErr_Occurred()) 1671 | return NULL; 1672 | 1673 | datasize = _cffi_prepare_pointer_call_argument( 1674 | _cffi_type(59), arg6, (char **)&x6); 1675 | if (datasize != 0) { 1676 | x6 = ((size_t)datasize) <= 640 ? (float *)alloca((size_t)datasize) : NULL; 1677 | if (_cffi_convert_array_argument(_cffi_type(59), arg6, (char **)&x6, 1678 | datasize, &large_args_free) < 0) 1679 | return NULL; 1680 | } 1681 | 1682 | datasize = _cffi_prepare_pointer_call_argument( 1683 | _cffi_type(4), arg7, (char **)&x7); 1684 | if (datasize != 0) { 1685 | x7 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1686 | if (_cffi_convert_array_argument(_cffi_type(4), arg7, (char **)&x7, 1687 | datasize, &large_args_free) < 0) 1688 | return NULL; 1689 | } 1690 | 1691 | Py_BEGIN_ALLOW_THREADS 1692 | _cffi_restore_errno(); 1693 | { result = ADI_GetSamples(x0, x1, x2, x3, x4, x5, x6, x7); } 1694 | _cffi_save_errno(); 1695 | Py_END_ALLOW_THREADS 1696 | 1697 | (void)self; /* unused */ 1698 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1699 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1700 | return pyresult; 1701 | } 1702 | #else 1703 | # define _cffi_f_ADI_GetSamples _cffi_d_ADI_GetSamples 1704 | #endif 1705 | 1706 | static ADIResultCode _cffi_d_ADI_GetUnitsName(struct ADI_FileHandle__ * x0, long x1, long x2, wchar_t * x3, long x4, long * x5) 1707 | { 1708 | return ADI_GetUnitsName(x0, x1, x2, x3, x4, x5); 1709 | } 1710 | #ifndef PYPY_VERSION 1711 | static PyObject * 1712 | _cffi_f_ADI_GetUnitsName(PyObject *self, PyObject *args) 1713 | { 1714 | struct ADI_FileHandle__ * x0; 1715 | long x1; 1716 | long x2; 1717 | wchar_t * x3; 1718 | long x4; 1719 | long * x5; 1720 | Py_ssize_t datasize; 1721 | struct _cffi_freeme_s *large_args_free = NULL; 1722 | ADIResultCode result; 1723 | PyObject *pyresult; 1724 | PyObject *arg0; 1725 | PyObject *arg1; 1726 | PyObject *arg2; 1727 | PyObject *arg3; 1728 | PyObject *arg4; 1729 | PyObject *arg5; 1730 | 1731 | if (!PyArg_UnpackTuple(args, "ADI_GetUnitsName", 6, 6, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5)) 1732 | return NULL; 1733 | 1734 | datasize = _cffi_prepare_pointer_call_argument( 1735 | _cffi_type(25), arg0, (char **)&x0); 1736 | if (datasize != 0) { 1737 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ *)alloca((size_t)datasize) : NULL; 1738 | if (_cffi_convert_array_argument(_cffi_type(25), arg0, (char **)&x0, 1739 | datasize, &large_args_free) < 0) 1740 | return NULL; 1741 | } 1742 | 1743 | x1 = _cffi_to_c_int(arg1, long); 1744 | if (x1 == (long)-1 && PyErr_Occurred()) 1745 | return NULL; 1746 | 1747 | x2 = _cffi_to_c_int(arg2, long); 1748 | if (x2 == (long)-1 && PyErr_Occurred()) 1749 | return NULL; 1750 | 1751 | datasize = _cffi_prepare_pointer_call_argument( 1752 | _cffi_type(2), arg3, (char **)&x3); 1753 | if (datasize != 0) { 1754 | x3 = ((size_t)datasize) <= 640 ? (wchar_t *)alloca((size_t)datasize) : NULL; 1755 | if (_cffi_convert_array_argument(_cffi_type(2), arg3, (char **)&x3, 1756 | datasize, &large_args_free) < 0) 1757 | return NULL; 1758 | } 1759 | 1760 | x4 = _cffi_to_c_int(arg4, long); 1761 | if (x4 == (long)-1 && PyErr_Occurred()) 1762 | return NULL; 1763 | 1764 | datasize = _cffi_prepare_pointer_call_argument( 1765 | _cffi_type(4), arg5, (char **)&x5); 1766 | if (datasize != 0) { 1767 | x5 = ((size_t)datasize) <= 640 ? (long *)alloca((size_t)datasize) : NULL; 1768 | if (_cffi_convert_array_argument(_cffi_type(4), arg5, (char **)&x5, 1769 | datasize, &large_args_free) < 0) 1770 | return NULL; 1771 | } 1772 | 1773 | Py_BEGIN_ALLOW_THREADS 1774 | _cffi_restore_errno(); 1775 | { result = ADI_GetUnitsName(x0, x1, x2, x3, x4, x5); } 1776 | _cffi_save_errno(); 1777 | Py_END_ALLOW_THREADS 1778 | 1779 | (void)self; /* unused */ 1780 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1781 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1782 | return pyresult; 1783 | } 1784 | #else 1785 | # define _cffi_f_ADI_GetUnitsName _cffi_d_ADI_GetUnitsName 1786 | #endif 1787 | 1788 | static ADIResultCode _cffi_d_ADI_NextComment(struct ADI_CommentsHandle__ * x0) 1789 | { 1790 | return ADI_NextComment(x0); 1791 | } 1792 | #ifndef PYPY_VERSION 1793 | static PyObject * 1794 | _cffi_f_ADI_NextComment(PyObject *self, PyObject *arg0) 1795 | { 1796 | struct ADI_CommentsHandle__ * x0; 1797 | Py_ssize_t datasize; 1798 | struct _cffi_freeme_s *large_args_free = NULL; 1799 | ADIResultCode result; 1800 | PyObject *pyresult; 1801 | 1802 | datasize = _cffi_prepare_pointer_call_argument( 1803 | _cffi_type(10), arg0, (char **)&x0); 1804 | if (datasize != 0) { 1805 | x0 = ((size_t)datasize) <= 640 ? (struct ADI_CommentsHandle__ *)alloca((size_t)datasize) : NULL; 1806 | if (_cffi_convert_array_argument(_cffi_type(10), arg0, (char **)&x0, 1807 | datasize, &large_args_free) < 0) 1808 | return NULL; 1809 | } 1810 | 1811 | Py_BEGIN_ALLOW_THREADS 1812 | _cffi_restore_errno(); 1813 | { result = ADI_NextComment(x0); } 1814 | _cffi_save_errno(); 1815 | Py_END_ALLOW_THREADS 1816 | 1817 | (void)self; /* unused */ 1818 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1819 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1820 | return pyresult; 1821 | } 1822 | #else 1823 | # define _cffi_f_ADI_NextComment _cffi_d_ADI_NextComment 1824 | #endif 1825 | 1826 | static ADIResultCode _cffi_d_ADI_OpenFile(wchar_t const * x0, struct ADI_FileHandle__ * * x1, ADIFileOpenMode x2) 1827 | { 1828 | return ADI_OpenFile(x0, x1, x2); 1829 | } 1830 | #ifndef PYPY_VERSION 1831 | static PyObject * 1832 | _cffi_f_ADI_OpenFile(PyObject *self, PyObject *args) 1833 | { 1834 | wchar_t const * x0; 1835 | struct ADI_FileHandle__ * * x1; 1836 | ADIFileOpenMode x2; 1837 | Py_ssize_t datasize; 1838 | struct _cffi_freeme_s *large_args_free = NULL; 1839 | ADIResultCode result; 1840 | PyObject *pyresult; 1841 | PyObject *arg0; 1842 | PyObject *arg1; 1843 | PyObject *arg2; 1844 | 1845 | if (!PyArg_UnpackTuple(args, "ADI_OpenFile", 3, 3, &arg0, &arg1, &arg2)) 1846 | return NULL; 1847 | 1848 | datasize = _cffi_prepare_pointer_call_argument( 1849 | _cffi_type(83), arg0, (char **)&x0); 1850 | if (datasize != 0) { 1851 | x0 = ((size_t)datasize) <= 640 ? (wchar_t const *)alloca((size_t)datasize) : NULL; 1852 | if (_cffi_convert_array_argument(_cffi_type(83), arg0, (char **)&x0, 1853 | datasize, &large_args_free) < 0) 1854 | return NULL; 1855 | } 1856 | 1857 | datasize = _cffi_prepare_pointer_call_argument( 1858 | _cffi_type(22), arg1, (char **)&x1); 1859 | if (datasize != 0) { 1860 | x1 = ((size_t)datasize) <= 640 ? (struct ADI_FileHandle__ * *)alloca((size_t)datasize) : NULL; 1861 | if (_cffi_convert_array_argument(_cffi_type(22), arg1, (char **)&x1, 1862 | datasize, &large_args_free) < 0) 1863 | return NULL; 1864 | } 1865 | 1866 | if (_cffi_to_c((char *)&x2, _cffi_type(85), arg2) < 0) 1867 | return NULL; 1868 | 1869 | Py_BEGIN_ALLOW_THREADS 1870 | _cffi_restore_errno(); 1871 | { result = ADI_OpenFile(x0, x1, x2); } 1872 | _cffi_save_errno(); 1873 | Py_END_ALLOW_THREADS 1874 | 1875 | (void)self; /* unused */ 1876 | pyresult = _cffi_from_c_deref((char *)&result, _cffi_type(1)); 1877 | if (large_args_free != NULL) _cffi_free_array_arguments(large_args_free); 1878 | return pyresult; 1879 | } 1880 | #else 1881 | # define _cffi_f_ADI_OpenFile _cffi_d_ADI_OpenFile 1882 | #endif 1883 | 1884 | _CFFI_UNUSED_FN 1885 | static void _cffi_checkfld_struct_ADI_CommentsHandle__(struct ADI_CommentsHandle__ *p) 1886 | { 1887 | /* only to generate compile-time warnings or errors */ 1888 | (void)p; 1889 | (void)((p->unused) | 0); /* check that 'struct ADI_CommentsHandle__.unused' is an integer */ 1890 | } 1891 | struct _cffi_align_struct_ADI_CommentsHandle__ { char x; struct ADI_CommentsHandle__ y; }; 1892 | 1893 | _CFFI_UNUSED_FN 1894 | static void _cffi_checkfld_struct_ADI_FileHandle__(struct ADI_FileHandle__ *p) 1895 | { 1896 | /* only to generate compile-time warnings or errors */ 1897 | (void)p; 1898 | (void)((p->unused) | 0); /* check that 'struct ADI_FileHandle__.unused' is an integer */ 1899 | } 1900 | struct _cffi_align_struct_ADI_FileHandle__ { char x; struct ADI_FileHandle__ y; }; 1901 | 1902 | static const struct _cffi_global_s _cffi_globals[] = { 1903 | { "ADI_CloseCommentsAccessor", (void *)_cffi_f_ADI_CloseCommentsAccessor, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_O, 6), (void *)_cffi_d_ADI_CloseCommentsAccessor }, 1904 | { "ADI_CloseFile", (void *)_cffi_f_ADI_CloseFile, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_O, 21), (void *)_cffi_d_ADI_CloseFile }, 1905 | { "ADI_CreateCommentsAccessor", (void *)_cffi_f_ADI_CreateCommentsAccessor, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 70), (void *)_cffi_d_ADI_CreateCommentsAccessor }, 1906 | { "ADI_GetChannelName", (void *)_cffi_f_ADI_GetChannelName, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 75), (void *)_cffi_d_ADI_GetChannelName }, 1907 | { "ADI_GetCommentInfo", (void *)_cffi_f_ADI_GetCommentInfo, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 12), (void *)_cffi_d_ADI_GetCommentInfo }, 1908 | { "ADI_GetErrorMessage", (void *)_cffi_f_ADI_GetErrorMessage, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 0), (void *)_cffi_d_ADI_GetErrorMessage }, 1909 | { "ADI_GetNumSamplesInRecord", (void *)_cffi_f_ADI_GetNumSamplesInRecord, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 46), (void *)_cffi_d_ADI_GetNumSamplesInRecord }, 1910 | { "ADI_GetNumTicksInRecord", (void *)_cffi_f_ADI_GetNumTicksInRecord, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 28), (void *)_cffi_d_ADI_GetNumTicksInRecord }, 1911 | { "ADI_GetNumberOfChannels", (void *)_cffi_f_ADI_GetNumberOfChannels, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 24), (void *)_cffi_d_ADI_GetNumberOfChannels }, 1912 | { "ADI_GetNumberOfRecords", (void *)_cffi_f_ADI_GetNumberOfRecords, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 24), (void *)_cffi_d_ADI_GetNumberOfRecords }, 1913 | { "ADI_GetRecordSamplePeriod", (void *)_cffi_f_ADI_GetRecordSamplePeriod, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 40), (void *)_cffi_d_ADI_GetRecordSamplePeriod }, 1914 | { "ADI_GetRecordTickPeriod", (void *)_cffi_f_ADI_GetRecordTickPeriod, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 40), (void *)_cffi_d_ADI_GetRecordTickPeriod }, 1915 | { "ADI_GetRecordTime", (void *)_cffi_f_ADI_GetRecordTime, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 33), (void *)_cffi_d_ADI_GetRecordTime }, 1916 | { "ADI_GetSamples", (void *)_cffi_f_ADI_GetSamples, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 52), (void *)_cffi_d_ADI_GetSamples }, 1917 | { "ADI_GetUnitsName", (void *)_cffi_f_ADI_GetUnitsName, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 62), (void *)_cffi_d_ADI_GetUnitsName }, 1918 | { "ADI_NextComment", (void *)_cffi_f_ADI_NextComment, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_O, 9), (void *)_cffi_d_ADI_NextComment }, 1919 | { "ADI_OpenFile", (void *)_cffi_f_ADI_OpenFile, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_V, 82), (void *)_cffi_d_ADI_OpenFile }, 1920 | { "kADICDataAtSampleRate", (void *)_cffi_const_kADICDataAtSampleRate, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1921 | { "kADICDataAtTickRate", (void *)_cffi_const_kADICDataAtTickRate, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1922 | { "kOpenFileForReadAndWrite", (void *)_cffi_const_kOpenFileForReadAndWrite, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1923 | { "kOpenFileForReadOnly", (void *)_cffi_const_kOpenFileForReadOnly, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1924 | { "kResultADICAPIMsgBase", (void *)_cffi_const_kResultADICAPIMsgBase, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1925 | { "kResultBufferTooSmall", (void *)_cffi_const_kResultBufferTooSmall, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1926 | { "kResultErrorFlagBit", (void *)_cffi_const_kResultErrorFlagBit, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1927 | { "kResultFail", (void *)_cffi_const_kResultFail, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1928 | { "kResultFileIOError", (void *)_cffi_const_kResultFileIOError, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1929 | { "kResultFileNotFound", (void *)_cffi_const_kResultFileNotFound, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1930 | { "kResultFileOpenFail", (void *)_cffi_const_kResultFileOpenFail, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1931 | { "kResultInvalidArg", (void *)_cffi_const_kResultInvalidArg, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1932 | { "kResultInvalidCommentNum", (void *)_cffi_const_kResultInvalidCommentNum, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1933 | { "kResultInvalidFileHandle", (void *)_cffi_const_kResultInvalidFileHandle, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1934 | { "kResultInvalidPosition", (void *)_cffi_const_kResultInvalidPosition, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1935 | { "kResultNoData", (void *)_cffi_const_kResultNoData, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1936 | { "kResultSuccess", (void *)_cffi_const_kResultSuccess, _CFFI_OP(_CFFI_OP_ENUM, -1), (void *)0 }, 1937 | }; 1938 | 1939 | static const struct _cffi_field_s _cffi_fields[] = { 1940 | { "unused", offsetof(struct ADI_CommentsHandle__, unused), 1941 | sizeof(((struct ADI_CommentsHandle__ *)0)->unused), 1942 | _CFFI_OP(_CFFI_OP_NOOP, 89) }, 1943 | { "unused", offsetof(struct ADI_FileHandle__, unused), 1944 | sizeof(((struct ADI_FileHandle__ *)0)->unused), 1945 | _CFFI_OP(_CFFI_OP_NOOP, 89) }, 1946 | }; 1947 | 1948 | static const struct _cffi_struct_union_s _cffi_struct_unions[] = { 1949 | { "ADI_CommentsHandle__", 90, _CFFI_F_CHECK_FIELDS, 1950 | sizeof(struct ADI_CommentsHandle__), offsetof(struct _cffi_align_struct_ADI_CommentsHandle__, y), 0, 1 }, 1951 | { "ADI_FileHandle__", 91, _CFFI_F_CHECK_FIELDS, 1952 | sizeof(struct ADI_FileHandle__), offsetof(struct _cffi_align_struct_ADI_FileHandle__, y), 1, 1 }, 1953 | }; 1954 | 1955 | static const struct _cffi_enum_s _cffi_enums[] = { 1956 | { "ADICDataFlags", 57, _cffi_prim_int(sizeof(ADICDataFlags), ((ADICDataFlags)-1) <= 0), 1957 | "kADICDataAtSampleRate,kADICDataAtTickRate" }, 1958 | { "ADIFileOpenMode", 85, _cffi_prim_int(sizeof(ADIFileOpenMode), ((ADIFileOpenMode)-1) <= 0), 1959 | "kOpenFileForReadOnly,kOpenFileForReadAndWrite" }, 1960 | { "ADIResultCode", 1, _cffi_prim_int(sizeof(ADIResultCode), ((ADIResultCode)-1) <= 0), 1961 | "kResultSuccess,kResultErrorFlagBit,kResultInvalidArg,kResultFail,kResultFileNotFound,kResultADICAPIMsgBase,kResultFileIOError,kResultFileOpenFail,kResultInvalidFileHandle,kResultInvalidPosition,kResultInvalidCommentNum,kResultNoData,kResultBufferTooSmall" }, 1962 | }; 1963 | 1964 | static const struct _cffi_typename_s _cffi_typenames[] = { 1965 | { "ADICDataFlags", 57 }, 1966 | { "ADIFileOpenMode", 85 }, 1967 | { "ADIResultCode", 1 }, 1968 | { "ADI_CommentsHandle", 10 }, 1969 | { "ADI_FileHandle", 25 }, 1970 | { "time_t", 3 }, 1971 | }; 1972 | 1973 | static const struct _cffi_type_context_s _cffi_type_context = { 1974 | _cffi_types, 1975 | _cffi_globals, 1976 | _cffi_fields, 1977 | _cffi_struct_unions, 1978 | _cffi_enums, 1979 | _cffi_typenames, 1980 | 34, /* num_globals */ 1981 | 2, /* num_struct_unions */ 1982 | 3, /* num_enums */ 1983 | 6, /* num_typenames */ 1984 | NULL, /* no includes */ 1985 | 93, /* num_types */ 1986 | 0, /* flags */ 1987 | }; 1988 | 1989 | #ifdef __GNUC__ 1990 | # pragma GCC visibility push(default) /* for -fvisibility= */ 1991 | #endif 1992 | 1993 | #ifdef PYPY_VERSION 1994 | PyMODINIT_FUNC 1995 | _cffi_pypyinit__adi_cffi(const void *p[]) 1996 | { 1997 | p[0] = (const void *)0x2601; 1998 | p[1] = &_cffi_type_context; 1999 | #if PY_MAJOR_VERSION >= 3 2000 | return NULL; 2001 | #endif 2002 | } 2003 | # ifdef _MSC_VER 2004 | PyMODINIT_FUNC 2005 | # if PY_MAJOR_VERSION >= 3 2006 | PyInit__adi_cffi(void) { return NULL; } 2007 | # else 2008 | init_adi_cffi(void) { } 2009 | # endif 2010 | # endif 2011 | #elif PY_MAJOR_VERSION >= 3 2012 | PyMODINIT_FUNC 2013 | PyInit__adi_cffi(void) 2014 | { 2015 | return _cffi_init("_adi_cffi", 0x2601, &_cffi_type_context); 2016 | } 2017 | #else 2018 | PyMODINIT_FUNC 2019 | init_adi_cffi(void) 2020 | { 2021 | _cffi_init("_adi_cffi", 0x2601, &_cffi_type_context); 2022 | } 2023 | #endif 2024 | 2025 | #ifdef __GNUC__ 2026 | # pragma GCC visibility pop 2027 | #endif 2028 | -------------------------------------------------------------------------------- /adi/_adi_cffi.cp310-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp310-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp311-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp311-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp312-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp312-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp313-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp313-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp36-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp36-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp37-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp37-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp38-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp38-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi.cp39-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi.cp39-win_amd64.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi2.cp38-win32.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi2.cp38-win32.pyd -------------------------------------------------------------------------------- /adi/_adi_cffi2.cp39-win32.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JimHokanson/adinstruments_sdk_python/40ae57103eac842fac319512dff589a122e186ac/adi/_adi_cffi2.cp39-win32.pyd -------------------------------------------------------------------------------- /adi/cffi_build.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 13 09:31:53 2019 4 | 5 | @author: RNEL 6 | """ 7 | 8 | from cffi import FFI 9 | ffibuilder = FFI() 10 | 11 | # cdef() expects a single string declaring the C types, functions and 12 | # globals needed to use the shared object. It must be in valid C syntax. 13 | ffibuilder.cdef(""" 14 | typedef enum ADIResultCode 15 | { 16 | //Win32 error codes (HRESULTs) 17 | kResultSuccess = 0, // operation succeeded 18 | kResultErrorFlagBit = 0x80000000, // high bit set if operation failed 19 | kResultInvalidArg = 0x80070057, // invalid argument. One (or more) of the arguments is invalid 20 | kResultFail = 0x80004005, // Unspecified error 21 | kResultFileNotFound = 0x80030002, // failure to find the specified file (check the path) 22 | 23 | 24 | //Start of error codes specific to this API 25 | kResultADICAPIMsgBase = 0xA0049000, 26 | 27 | kResultFileIOError = 0xA0049000, // file IO error - could not read/write file 28 | kResultFileOpenFail, // file failed to open 29 | kResultInvalidFileHandle, // file handle is invalid 30 | kResultInvalidPosition, // pos specified is outside the bounds of the record or file 31 | kResultInvalidCommentNum, // invalid commentNum. Comment could not be found 32 | kResultNoData, // the data requested was not present (e.g. no more comments in the record). 33 | kResultBufferTooSmall // the buffer passed to a function to receive data (e.g. comment text) was not big enough to receive all the data. 34 | 35 | // new result codes must be added at the end 36 | } ADIResultCode; 37 | 38 | typedef enum ADICDataFlags 39 | { 40 | kADICDataAtSampleRate = 0, // specifies that the function uses samples 41 | kADICDataAtTickRate = 0x80000000 // specifies that the function uses ticks 42 | } ADICDataFlags; 43 | 44 | 45 | typedef enum ADIFileOpenMode 46 | { 47 | kOpenFileForReadOnly = 0, // opens the file as read-only, so data cannot be written 48 | kOpenFileForReadAndWrite // opens the file as read/write 49 | } ADIFileOpenMode; 50 | 51 | struct ADI_FileHandle__ { int unused; }; typedef struct ADI_FileHandle__ *ADI_FileHandle; 52 | struct ADI_CommentsHandle__ { int unused; }; typedef struct ADI_CommentsHandle__ *ADI_CommentsHandle; 53 | 54 | ADIResultCode ADI_OpenFile(const wchar_t* path, ADI_FileHandle* fileH, ADIFileOpenMode mode); 55 | 56 | //Skipped CreateFile 57 | 58 | //NYI 59 | ADIResultCode ADI_GetErrorMessage(ADIResultCode code, wchar_t* messageOut, long maxChars, long *textLen); 60 | 61 | //Skipped ADI_TickToSamplePos 62 | //Skipped ADI_SamplePosToTick 63 | 64 | ADIResultCode ADI_GetNumberOfRecords(ADI_FileHandle fileH, long* nRecords); 65 | 66 | ADIResultCode ADI_GetNumberOfChannels(ADI_FileHandle fileH, long* nChannels); 67 | 68 | ADIResultCode ADI_GetNumTicksInRecord(ADI_FileHandle fileH, long record, long* nTicks); 69 | 70 | ADIResultCode ADI_GetRecordTickPeriod(ADI_FileHandle fileH, long channel, long record, double* secsPerTick); 71 | 72 | ADIResultCode ADI_GetNumSamplesInRecord(ADI_FileHandle fileH, long channel, long record, long* nSamples); 73 | 74 | ADIResultCode ADI_GetRecordSamplePeriod(ADI_FileHandle fileH, long channel, long record, double* secsPerSample); 75 | 76 | //Hack :/ 77 | //https://stackoverflow.com/questions/19352932/declare-struct-containing-time-t-field-in-python-cffi 78 | typedef long time_t; 79 | 80 | ADIResultCode ADI_GetRecordTime(ADI_FileHandle fileH, long record, time_t *triggerTime, double *fracSecs, long *triggerMinusStartTicks); 81 | 82 | ADIResultCode ADI_CreateCommentsAccessor(ADI_FileHandle fileH, long record, ADI_CommentsHandle* commentsH); 83 | 84 | ADIResultCode ADI_CloseCommentsAccessor(ADI_CommentsHandle *commentsH); 85 | 86 | ADIResultCode ADI_GetCommentInfo(ADI_CommentsHandle commentsH, long *tickPos, long *channel, long *commentNum, wchar_t* text, long maxChars, long *textLen); 87 | 88 | ADIResultCode ADI_NextComment(ADI_CommentsHandle commentsH); 89 | 90 | ADIResultCode ADI_GetSamples(ADI_FileHandle fileH, long channel, long record, long startPos, ADICDataFlags dataType, long nLength, float* data, long* returned); 91 | 92 | ADIResultCode ADI_GetUnitsName(ADI_FileHandle fileH, long channel, long record, wchar_t* units, long maxChars, long *textLen); 93 | 94 | ADIResultCode ADI_GetChannelName(ADI_FileHandle fileH, long channel, wchar_t* name, long maxChars, long *textLen); 95 | 96 | //Skipped a bunch in the header at this point ... 97 | 98 | ADIResultCode ADI_CloseFile(ADI_FileHandle* fileH); 99 | """) 100 | 101 | # set_source() gives the name of the python extension module to 102 | # produce, and some C source code as a string. This C code needs 103 | # to make the declarated functions, types and globals available, 104 | # so it is often just the "#include". 105 | ffibuilder.set_source("_adi_cffi", 106 | """ 107 | #include "ADIDatCAPI_mex.h" // the C header of the library 108 | """, 109 | libraries=['ADIDatIOWin64']) # library name, for the linker 110 | 111 | if __name__ == "__main__": 112 | ffibuilder.compile(verbose=True) -------------------------------------------------------------------------------- /adi/cffi_build_win32.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 13 09:31:53 2019 4 | 5 | @author: RNEL 6 | """ 7 | 8 | from cffi import FFI 9 | ffibuilder = FFI() 10 | 11 | # cdef() expects a single string declaring the C types, functions and 12 | # globals needed to use the shared object. It must be in valid C syntax. 13 | ffibuilder.cdef(""" 14 | typedef enum ADIResultCode 15 | { 16 | //Win32 error codes (HRESULTs) 17 | kResultSuccess = 0, // operation succeeded 18 | kResultErrorFlagBit = 0x80000000, // high bit set if operation failed 19 | kResultInvalidArg = 0x80070057, // invalid argument. One (or more) of the arguments is invalid 20 | kResultFail = 0x80004005, // Unspecified error 21 | kResultFileNotFound = 0x80030002, // failure to find the specified file (check the path) 22 | 23 | 24 | //Start of error codes specific to this API 25 | kResultADICAPIMsgBase = 0xA0049000, 26 | 27 | kResultFileIOError = 0xA0049000, // file IO error - could not read/write file 28 | kResultFileOpenFail, // file failed to open 29 | kResultInvalidFileHandle, // file handle is invalid 30 | kResultInvalidPosition, // pos specified is outside the bounds of the record or file 31 | kResultInvalidCommentNum, // invalid commentNum. Comment could not be found 32 | kResultNoData, // the data requested was not present (e.g. no more comments in the record). 33 | kResultBufferTooSmall // the buffer passed to a function to receive data (e.g. comment text) was not big enough to receive all the data. 34 | 35 | // new result codes must be added at the end 36 | } ADIResultCode; 37 | 38 | typedef enum ADICDataFlags 39 | { 40 | kADICDataAtSampleRate = 0, // specifies that the function uses samples 41 | kADICDataAtTickRate = 0x80000000 // specifies that the function uses ticks 42 | } ADICDataFlags; 43 | 44 | 45 | typedef enum ADIFileOpenMode 46 | { 47 | kOpenFileForReadOnly = 0, // opens the file as read-only, so data cannot be written 48 | kOpenFileForReadAndWrite // opens the file as read/write 49 | } ADIFileOpenMode; 50 | 51 | struct ADI_FileHandle__ { int unused; }; typedef struct ADI_FileHandle__ *ADI_FileHandle; 52 | struct ADI_CommentsHandle__ { int unused; }; typedef struct ADI_CommentsHandle__ *ADI_CommentsHandle; 53 | 54 | ADIResultCode ADI_OpenFile(const wchar_t* path, ADI_FileHandle* fileH, ADIFileOpenMode mode); 55 | 56 | //Skipped CreateFile 57 | 58 | //NYI 59 | ADIResultCode ADI_GetErrorMessage(ADIResultCode code, wchar_t* messageOut, long maxChars, long *textLen); 60 | 61 | //Skipped ADI_TickToSamplePos 62 | //Skipped ADI_SamplePosToTick 63 | 64 | ADIResultCode ADI_GetNumberOfRecords(ADI_FileHandle fileH, long* nRecords); 65 | 66 | ADIResultCode ADI_GetNumberOfChannels(ADI_FileHandle fileH, long* nChannels); 67 | 68 | ADIResultCode ADI_GetNumTicksInRecord(ADI_FileHandle fileH, long record, long* nTicks); 69 | 70 | ADIResultCode ADI_GetRecordTickPeriod(ADI_FileHandle fileH, long channel, long record, double* secsPerTick); 71 | 72 | ADIResultCode ADI_GetNumSamplesInRecord(ADI_FileHandle fileH, long channel, long record, long* nSamples); 73 | 74 | ADIResultCode ADI_GetRecordSamplePeriod(ADI_FileHandle fileH, long channel, long record, double* secsPerSample); 75 | 76 | //Hack :/ 77 | //https://stackoverflow.com/questions/19352932/declare-struct-containing-time-t-field-in-python-cffi 78 | typedef long time_t; 79 | 80 | ADIResultCode ADI_GetRecordTime(ADI_FileHandle fileH, long record, time_t *triggerTime, double *fracSecs, long *triggerMinusStartTicks); 81 | 82 | ADIResultCode ADI_CreateCommentsAccessor(ADI_FileHandle fileH, long record, ADI_CommentsHandle* commentsH); 83 | 84 | ADIResultCode ADI_CloseCommentsAccessor(ADI_CommentsHandle *commentsH); 85 | 86 | ADIResultCode ADI_GetCommentInfo(ADI_CommentsHandle commentsH, long *tickPos, long *channel, long *commentNum, wchar_t* text, long maxChars, long *textLen); 87 | 88 | ADIResultCode ADI_NextComment(ADI_CommentsHandle commentsH); 89 | 90 | ADIResultCode ADI_GetSamples(ADI_FileHandle fileH, long channel, long record, long startPos, ADICDataFlags dataType, long nLength, float* data, long* returned); 91 | 92 | ADIResultCode ADI_GetUnitsName(ADI_FileHandle fileH, long channel, long record, wchar_t* units, long maxChars, long *textLen); 93 | 94 | ADIResultCode ADI_GetChannelName(ADI_FileHandle fileH, long channel, wchar_t* name, long maxChars, long *textLen); 95 | 96 | //Skipped a bunch in the header at this point ... 97 | 98 | ADIResultCode ADI_CloseFile(ADI_FileHandle* fileH); 99 | """) 100 | 101 | # set_source() gives the name of the python extension module to 102 | # produce, and some C source code as a string. This C code needs 103 | # to make the declarated functions, types and globals available, 104 | # so it is often just the "#include". 105 | ffibuilder.set_source("_adi_cffi2", 106 | """ 107 | #include "ADIDatCAPI_mex.h" // the C header of the library 108 | """, 109 | libraries=['ADIDatIOWin']) # library name, for the linker 110 | 111 | if __name__ == "__main__": 112 | ffibuilder.compile(verbose=True) -------------------------------------------------------------------------------- /adi/read.py: -------------------------------------------------------------------------------- 1 | 2 | import inspect 3 | from datetime import datetime, timedelta 4 | 5 | #This is used only for returning the loaded data 6 | import numpy as np 7 | 8 | #Note apparently pylint doesn't like this because it is from a dll (.pyd file) 9 | #https://stackoverflow.com/questions/28437071/pylint-1-4-reports-e1101no-member-on-all-c-extensions 10 | import struct 11 | 12 | p_size = struct.calcsize("P") 13 | if p_size == 4: 14 | from adi._adi_cffi2 import ffi, lib 15 | else: 16 | from adi._adi_cffi import ffi, lib 17 | 18 | r""" 19 | #Test Code: 20 | import adi 21 | f = adi.read_file(r'C:\Users\RNEL\Desktop\test\test_file.adicht') 22 | channel_id = 2 23 | c = f.channels[channel_id-1] 24 | record_id = 1 25 | data = f.channels[1].get_data(record_id) 26 | import matplotlib.pyplot as plt 27 | plt.plot(data) 28 | plt.show() 29 | """ 30 | 31 | def read_file(file_path): 32 | """ 33 | This is the preferred entry point for working with this module. 34 | """ 35 | return File(file_path) 36 | 37 | def print_object(obj): 38 | """ 39 | Goal is to eventually mimic Matlab's default display behavior for objects 40 | Example output from Matlab 41 | morphology: [1x1 seg_worm.features.morphology] 42 | posture: [1x1 seg_worm.features.posture] 43 | locomotion: [1x1 seg_worm.features.locomotion] 44 | path: [1x1 seg_worm.features.path] 45 | info: [1x1 seg_worm.info] 46 | #TODO: For ndarrays we should implement size displays instead of length 47 | #TODO: The @property hack doesn't work for @property values from parent 48 | classes, I would need to look at __bases__ 49 | """ 50 | 51 | # TODO - have some way of indicating nested function and not doing fancy 52 | # print for nested objects ... 53 | 54 | MAX_WIDTH = 70 55 | 56 | dict_local = obj.__dict__ 57 | 58 | key_names = [k for k in dict_local] 59 | 60 | try: 61 | # TODO: Also include __bases__ 62 | names_of_prop_methods = [ 63 | name for name, value in vars( 64 | obj.__class__).items() if isinstance( 65 | value, property)] 66 | prop_code_ok = True 67 | except: 68 | prop_code_ok = False 69 | 70 | is_prop = [False] * len(key_names) 71 | if prop_code_ok: 72 | is_prop += [True] * len(names_of_prop_methods) 73 | key_names += names_of_prop_methods 74 | 75 | key_lengths = [len(x) for x in key_names] 76 | 77 | if len(key_lengths) == 0: 78 | return "" 79 | 80 | max_key_length = max(key_lengths) 81 | key_padding = [max_key_length - x for x in key_lengths] 82 | 83 | max_leadin_length = max_key_length + 2 84 | max_value_length = MAX_WIDTH - max_leadin_length 85 | 86 | lead_strings = [' ' * x + y + ': ' for x, y in zip(key_padding, key_names)] 87 | 88 | # TODO: Alphabatize the results ???? 89 | # Could pass in as a option 90 | # TODO: It might be better to test for built in types 91 | # Class::Bio.Entrez.Parser.DictionaryElement 92 | # => show actual dictionary, not what is above 93 | 94 | value_strings = [] 95 | for key, is_prop_local in zip(key_names, is_prop): 96 | if is_prop_local: 97 | temp_str = '@property method' 98 | else: 99 | run_extra_code = False 100 | value = dict_local[key] 101 | if hasattr(value, '__dict__'): 102 | try: # Not sure how to test for classes :/ 103 | class_name = value.__class__.__name__ 104 | module_name = inspect.getmodule(value).__name__ 105 | temp_str = 'Class::' + module_name + '.' + class_name 106 | except: 107 | run_extra_code = True 108 | else: 109 | run_extra_code = True 110 | 111 | if run_extra_code: 112 | # TODO: Change length to shape if available 113 | if isinstance(value, list) and len(value) > max_value_length: 114 | len_value = len(value) 115 | temp_str = 'Type::List, Len %d' % len_value 116 | else: 117 | # Perhaps we want str instead? 118 | # Changed from repr to str because things Python was not 119 | # happy with lists of numpy arrays 120 | temp_str = str(value) 121 | if len(temp_str) > max_value_length: 122 | #type_str = str(type(value)) 123 | #type_str = type_str[7:-2] 124 | try: 125 | len_value = len(value) 126 | except: 127 | len_value = 1 128 | temp_str = str.format( 129 | 'Type::{}, Len: {}', type(value).__name__, len_value) 130 | 131 | value_strings.append(temp_str) 132 | 133 | final_str = '' 134 | for cur_lead_str, cur_value in zip(lead_strings, value_strings): 135 | final_str += (cur_lead_str + cur_value + '\n') 136 | 137 | return final_str 138 | 139 | class Comment(): 140 | 141 | """ 142 | Currently created in get_all_comments 143 | 144 | TODO: In record add dt info so that time is valid as well (needs dt) 145 | 146 | """ 147 | def __init__(self,text,tick_pos,channel_id,comment_id): 148 | self.text = text 149 | self.tick_position = tick_pos 150 | self.channel_ = channel_id 151 | self.id = comment_id 152 | 153 | 154 | def _add_info(self,tick_dt): 155 | self.tick_dt = tick_dt 156 | self.time = self.tick_position*self.tick_dt 157 | 158 | 159 | def __repr__(self): 160 | return print_object(self) 161 | 162 | 163 | class Channel(): 164 | 165 | def __init__(self,h,channel_id,records): 166 | self.h = h 167 | self.id = channel_id #1 based 168 | self.n_records = len(records) 169 | self.tick_dt = [x.tick_dt for x in records] 170 | self.records = records 171 | 172 | self.name = SDK.get_channel_name(self.h,self.id) 173 | 174 | self.units = [SDK.get_units_name(self.h,x+1,self.id) for x in range(self.n_records)] 175 | self.n_samples = [SDK.get_n_samples_in_record(self.h,x+1,self.id) for x in range(self.n_records)] 176 | self.dt = [SDK.get_sample_period(self.h,x+1,self.id) for x in range(self.n_records)] 177 | self.fs = [1/x for x in self.dt] 178 | 179 | """ 180 | https://github.com/JimHokanson/adinstruments_sdk_matlab/blob/master/%2Badi/%40channel/channel.m 181 | obj.tick_dt = [record_handles.tick_dt]; 182 | obj.data_starts = [record_handles.data_start]; 183 | obj.record_starts = [record_handles.record_start]; 184 | obj.record_handles = record_handles; 185 | """ 186 | #self.tick_dt = [x.tick_dt for x in records] 187 | #self.tick_dt = [x.tick_dt for x in records] 188 | #self.tick_dt = [x.tick_dt for x in records] 189 | 190 | 191 | def get_data(self,record_id,start_sample=None,stop_sample=None): 192 | 193 | if start_sample is None: 194 | start_sample = 1 195 | elif start_sample < 1: 196 | raise Exception('The value of start_sample has to be greater than 0') 197 | 198 | if stop_sample is None: 199 | stop_sample = self.n_samples[record_id-1] 200 | elif stop_sample > self.n_samples[record_id-1]: 201 | raise Exception('Out of range data requested') 202 | 203 | return SDK.get_channel_data(self.h,record_id,self.id,start_sample,stop_sample) 204 | 205 | def __repr__(self): 206 | return print_object(self) 207 | 208 | 209 | class RecordTime(): 210 | 211 | """ 212 | Apparently it is possible to trigger data collection before or after a trigger signal. 213 | 214 | Datetimes for both the trigger and data start are properties of this class. 215 | """ 216 | def __init__(self,tick_dt,trig_time,frac_secs,trig_minus_start_ticks): 217 | 218 | self.trig_datetime = datetime.utcfromtimestamp(trig_time) + timedelta(seconds = frac_secs) 219 | self.trig_start_delta = trig_minus_start_ticks 220 | self.trig_datestr = self.trig_datetime.strftime("%Y-%m-%d %H:%M:%S.%f").rstrip('0') 221 | 222 | delta = timedelta(seconds = abs(trig_minus_start_ticks*tick_dt)) 223 | 224 | if trig_minus_start_ticks > 0: 225 | self.rec_datetime = self.trig_datetime + delta 226 | else: 227 | self.rec_datetime = self.trig_datetime - delta; 228 | 229 | self.rec_datestr = self.rec_datetime.strftime("%Y-%m-%d %H:%M:%S.%f").rstrip('0') 230 | 231 | #+ve - trigger before block 232 | #-ve - trigger after block 233 | 234 | def __repr__(self): 235 | return print_object(self) 236 | 237 | class Record(): 238 | 239 | """ 240 | Attributes 241 | ---------- 242 | n_ticks : 243 | # of samples in the record for the channel sampled at the highest rate 244 | tick_dt : 245 | Time between "ticks" 246 | comments : Comment 247 | 248 | """ 249 | def __init__(self,h,record_id): 250 | 251 | """ 252 | h : 253 | Handle to the underlying file pointer 254 | sdk : SDK 255 | record_id : int? 256 | 1 based record 257 | """ 258 | self.h = h 259 | self.id = record_id 260 | 261 | 262 | self.n_ticks = SDK.get_n_ticks_in_record(self.h,record_id) 263 | 264 | #Not actually channel specific, channel is ignored (according to ADI) 265 | #Hard coded in "first channel" => 1 266 | self.tick_dt = SDK.get_tick_period(self.h,record_id,1) 267 | 268 | self.comments = SDK.get_all_comments(self.h,record_id) 269 | 270 | for c in self.comments: 271 | c._add_info(self.tick_dt) 272 | 273 | 274 | self.record_time = SDK.get_record_time_info(self.h,record_id,self.tick_dt) 275 | 276 | def __repr__(self): 277 | return print_object(self) 278 | 279 | 280 | 281 | class File(): 282 | 283 | """ 284 | Attributes 285 | ---------- 286 | file_loaded 287 | h 288 | 289 | 290 | """ 291 | def __init__(self,file_path): 292 | self.file_loaded = False 293 | self.h = SDK.open_read_file(file_path) 294 | self.file_loaded = True 295 | 296 | self.n_records = SDK.get_n_records(self.h) 297 | 298 | self.n_channels = SDK.get_n_channels(self.h) 299 | 300 | self.records = [Record(self.h,x+1) for x in range(self.n_records)] 301 | 302 | self.channels = [Channel(self.h,x+1,self.records) for x in range(self.n_channels)] 303 | 304 | 305 | def __del__(self): 306 | #print("object deleted") 307 | if self.file_loaded: 308 | SDK.close_file(self.h) 309 | 310 | def __repr__(self): 311 | return print_object(self) 312 | 313 | 314 | class SDK(): 315 | 316 | @staticmethod 317 | def open_read_file(file_path): 318 | h = ffi.new("ADI_FileHandle *") 319 | result = lib.ADI_OpenFile(file_path,h,lib.kOpenFileForReadOnly) 320 | 321 | if result == 0: 322 | return h 323 | else: 324 | #TODO: Add more 325 | raise Exception('Error opening file for reading') 326 | 327 | """ 328 | ============================ Record ============================ 329 | """ 330 | 331 | @staticmethod 332 | def get_record_time_info(h,record_id,tick_dt): 333 | trig_time = ffi.new("time_t *") 334 | frac_secs = ffi.new("double *") 335 | trigger_minus_rec_start = ffi.new("long *") 336 | result = lib.ADI_GetRecordTime(h[0],record_id-1,trig_time,frac_secs,trigger_minus_rec_start) 337 | if result == 0: 338 | return RecordTime(tick_dt,trig_time[0],frac_secs[0],trigger_minus_rec_start[0]) 339 | else: 340 | #TODO: Improve message 341 | raise Exception('Error getting # of ticks in record') 342 | 343 | 344 | @staticmethod 345 | def get_n_ticks_in_record(h,record_id): 346 | n_ticks = ffi.new("long *") 347 | result = lib.ADI_GetNumTicksInRecord(h[0],record_id-1,n_ticks) 348 | if result == 0: 349 | return n_ticks[0] 350 | else: 351 | #TODO: Improve message 352 | raise Exception('Error getting # of ticks in record') 353 | 354 | """ 355 | ============================ Channel ============================ 356 | """ 357 | #TODO: Would be better to include channel in names ... 358 | @staticmethod 359 | def get_tick_period(h,record_id,channel_id): 360 | tick_period = ffi.new("double *") 361 | result = lib.ADI_GetRecordTickPeriod(h[0],channel_id-1,record_id-1,tick_period) 362 | if result == 0: 363 | return tick_period[0] 364 | else: 365 | raise Exception('Error getting tick period') 366 | 367 | @staticmethod 368 | def get_n_samples_in_record(h,record_id,channel_id): 369 | n_samples = ffi.new("long *") 370 | result = lib.ADI_GetNumSamplesInRecord(h[0],channel_id-1,record_id-1,n_samples) 371 | 372 | if result == 0 or result == 1: 373 | return n_samples[0] 374 | else: 375 | raise Exception('Error getting # of samples in record') 376 | 377 | 378 | @staticmethod 379 | def get_sample_period(h,record_id,channel_id): 380 | sample_period = ffi.new("double *") 381 | result = lib.ADI_GetRecordSamplePeriod(h[0],channel_id-1,record_id-1,sample_period) 382 | if result == 0 or result == 1: 383 | return sample_period[0] 384 | else: 385 | raise Exception('Error getting sample period') 386 | 387 | 388 | 389 | @staticmethod 390 | def get_units_name(h,record_id,channel_id): 391 | #TODO: Make length a variable 392 | 393 | #Different interfae ... 394 | # N = 10 395 | #ptr = ffi.new( "float[]", N ) 396 | 397 | text = ffi.new("wchar_t[1000]") 398 | max_chars = 999 #needs null termination??? 399 | text_length = ffi.new("long *") 400 | result = lib.ADI_GetUnitsName(h[0],channel_id-1,record_id-1,text,max_chars,text_length) 401 | 402 | if not(result == 0 or result == 1): 403 | print(result) 404 | raise Exception('Error retrieving units') 405 | 406 | #I think the length includes null terminaton so we substract 1 407 | final_text = ffi.unpack(text,text_length[0]-1) 408 | return final_text 409 | 410 | @staticmethod 411 | def get_channel_name(h,channel_id): 412 | 413 | 414 | #TODO: Make length a variable 415 | text = ffi.new("wchar_t[1000]") 416 | max_chars = 999 #needs null termination??? 417 | text_length = ffi.new("long *") 418 | result = lib.ADI_GetChannelName(h[0],channel_id-1,text,max_chars,text_length) 419 | 420 | if not(result == 0 or result == 1): 421 | print(result) 422 | raise Exception('Error retrieving channel name') 423 | 424 | #I think the length includes null terminaton so we substract 1 425 | final_text = ffi.unpack(text,text_length[0]-1) 426 | return final_text 427 | 428 | 429 | 430 | @staticmethod 431 | def get_channel_data(h,record_id,channel_id,start_sample,stop_sample): 432 | 433 | n_elements = stop_sample-start_sample+1 434 | 435 | if n_elements <= 0: 436 | raise ValueError("# of samples requested is less than 1") 437 | 438 | np_arr = np.zeros(n_elements, dtype=np.float32) 439 | 440 | #Note, we might just be able to case to numpy after running 441 | #=> numpy.frombuffer => 0 copy? 442 | 443 | #https://ammous88.wordpress.com/2014/12/30/numpy-array-with-cffi-c-function/ 444 | cffi_arr = ffi.cast('float*', np_arr.ctypes.data) 445 | 446 | returned = ffi.new("long *") 447 | result = lib.ADI_GetSamples(h[0],channel_id-1,record_id-1,start_sample-1,lib.kADICDataAtSampleRate,n_elements,cffi_arr,returned) 448 | 449 | if result == 0: 450 | return np_arr 451 | else: 452 | raise Exception('Unable to retrieve requested data') 453 | 454 | 455 | """ 456 | ============================ Comments ============================ 457 | """ 458 | @staticmethod 459 | def get_comment_accessor(h,record_id): 460 | """ 461 | 0 indicates no comments 462 | """ 463 | h2 = ffi.new("ADI_CommentsHandle *") 464 | result = lib.ADI_CreateCommentsAccessor(h[0],record_id-1,h2) 465 | 466 | #No comments - not sure why we don't have a flag for this ... 467 | if result == -1610313723: 468 | return 0 469 | elif result == 0: 470 | return h2 471 | else: 472 | raise Exception('Error opening comments accessor') 473 | 474 | 475 | @staticmethod 476 | def advance_comment_ptr(h2): 477 | """ 478 | returns True if comment is available 479 | """ 480 | result = lib.ADI_NextComment(h2[0]) 481 | 482 | if result == 0: 483 | return True 484 | elif result == lib.kResultNoData: 485 | return False 486 | else: 487 | raise Exception('Unhandled case for advancing comment pointer') 488 | 489 | @staticmethod 490 | def get_all_comments(h,record_id): 491 | 492 | h2 = SDK.get_comment_accessor(h,record_id) 493 | if h2 == 0: 494 | return [] 495 | else: 496 | output = [] 497 | c = SDK.get_comment(h2) 498 | output.append(c) 499 | while SDK.advance_comment_ptr(h2): 500 | c = SDK.get_comment(h2) 501 | output.append(c) 502 | 503 | 504 | SDK.close_comment_accessor(h2) 505 | return output 506 | 507 | 508 | @staticmethod 509 | def get_comment(h2): 510 | tick_pos = ffi.new("long *") 511 | channel = ffi.new("long *") 512 | comment_id = ffi.new("long *") 513 | #TODO: Make length a variable 514 | text = ffi.new("wchar_t[1000]") 515 | max_chars = 999 #needs null termination???? 516 | text_length = ffi.new("long *") 517 | result = lib.ADI_GetCommentInfo(h2[0],tick_pos,channel,comment_id,text,max_chars,text_length) 518 | 519 | if result != 0: 520 | raise Exception('Error retrieving comment') 521 | 522 | #I think the length includes null terminaton so we substract 1 523 | final_text = ffi.unpack(text,text_length[0]-1) 524 | return Comment(final_text,tick_pos[0],channel[0],comment_id[0]) 525 | 526 | #ADI_GetCommentInfo 527 | #ADIResultCode ADI_GetCommentInfo(ADI_CommentsHandle commentsH, long *tickPos, long *channel, long *commentNum, wchar_t* text, long maxChars, long *textLen); 528 | 529 | @staticmethod 530 | def close_comment_accessor(h2): 531 | result = lib.ADI_CloseCommentsAccessor(h2) 532 | if result == 0: 533 | pass 534 | else: 535 | raise Exception('Error closing comments handle') 536 | 537 | @staticmethod 538 | def get_n_records(h): 539 | n_records = ffi.new("long *") 540 | result = lib.ADI_GetNumberOfRecords(h[0],n_records) 541 | if result == 0: 542 | return n_records[0] 543 | else: 544 | raise Exception('Error getting # of records') 545 | 546 | 547 | @staticmethod 548 | def get_n_channels(h): 549 | n_channels = ffi.new("long *") 550 | result = lib.ADI_GetNumberOfChannels(h[0],n_channels) 551 | if result == 0: 552 | return n_channels[0] 553 | else: 554 | raise Exception('Error getting # of channels') 555 | 556 | @staticmethod 557 | def close_file(h): 558 | result = lib.ADI_CloseFile(h) 559 | if result == 0: 560 | pass 561 | else: 562 | raise Exception('Error closing file handle') 563 | -------------------------------------------------------------------------------- /docs/notes_for_pypi_build.txt: -------------------------------------------------------------------------------- 1 | #Notes for sending to pypi 2 | 3 | G: 4 | cd G:\repos\python\adinstruments_sdk_python 5 | #These are temporary path modification commands 6 | set PATH=%PATH%;C:\Users\RNEL\AppData\Local\Programs\Python\Python39\Scripts 7 | set PATH=%PATH%;C:\Users\RNEL\AppData\Local\Programs\Python\Python39 8 | pip install wheel 9 | python setup.py sdist bdist_wheel 10 | 11 | twine upload dist/* 12 | will be prompted for user/pass 13 | 14 | remove all build files 15 | -------------------------------------------------------------------------------- /manifest.in: -------------------------------------------------------------------------------- 1 | include = adi/*.* -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import setuptools 4 | 5 | with open("README.md", "r", encoding="utf-8") as fh: 6 | long_description = fh.read() 7 | 8 | setuptools.setup( 9 | name="adi-reader", 10 | version="0.0.13", 11 | author="Jim Hokanson", 12 | author_email="jim.hokanson@gmail.com", 13 | description="Reading LabChart recorded data", 14 | long_description=long_description, 15 | long_description_content_type="text/markdown", 16 | url="https://github.com/JimHokanson/adinstruments_sdk_python/", 17 | packages=setuptools.find_packages(), 18 | install_requires=['numpy', 'cffi'], 19 | classifiers=[ 20 | "Programming Language :: Python :: 3", 21 | "License :: OSI Approved :: MIT License", 22 | "Operating System :: Microsoft :: Windows", 23 | ], 24 | python_requires='>= 3.6, <= 3.13', 25 | include_package_data=True, 26 | ) --------------------------------------------------------------------------------