Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

cbhwlib.h 158 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148
  1. /* =STS=> cbhwlib.h[1687].aa78 submit SMID:82 */
  2. ///////////////////////////////////////////////////////////////////////////////////////////////////
  3. //
  4. // (c) Copyright 2002-2008 Cyberkinetics, Inc.
  5. // (c) Copyright 2008-2011 Blackrock Microsystems
  6. //
  7. // $Workfile: cbhwlib.h $
  8. // $Archive: /Cerebus/Human/LinuxApps/player/cbhwlib.h $
  9. // $Revision: 50 $
  10. // $Date: 5/17/05 10:07a $
  11. // $Author: Dsebald $
  12. //
  13. // $NoKeywords: $
  14. //
  15. ///////////////////////////////////////////////////////////////////////////////////////////////////
  16. //
  17. // PURPOSE:
  18. //
  19. // This code libary defines an standardized control and data acess interface for microelectrode
  20. // neurophysiology equipment. The interface allows several applications to simultaneously access
  21. // the control and data stream for the equipment through a central control application. This
  22. // central application governs the flow of information to the user interface applications and
  23. // performs hardware specific data processing for the instruments. This is diagrammed as follows:
  24. //
  25. // Instruments <---> Central Control App <--+--> Cerebus Library <---> User Application
  26. // +--> Cerebus Library <---> User Application
  27. // +--> Cerebus Library <---> User Application
  28. //
  29. // The Central Control Application can also exchange window/application configuration data so that
  30. // the Central Application can save and restore instrument and application window settings.
  31. //
  32. // All hardware configuration, hardware acknowledgement, and data information are passed on the
  33. // system in packet form. Cerebus user applications interact with the hardware in the system by
  34. // sending and receiving configuration and data packets through the Central Control Application.
  35. // In order to aid efficiency, the Central Control App caches information regarding hardware
  36. // configuration so that multiple applications do not need to request hardware configuration
  37. // packets from the system. The Neuromatic Library provides high-level functions for retreiving
  38. // data from this cache and high-level functions for transmitting configuration packets to the
  39. // hardware. Neuromatic applications must provide a callback function for receiving data and
  40. // configuration acknowledgement packets.
  41. //
  42. // The data stream from the hardware is composed of "neural data" to be saved in experiment files
  43. // and "preview data" that provides information such as compressed real-time channel data for
  44. // scrolling displays and Line Noise Cancellation waveforms to update the user.
  45. //
  46. ///////////////////////////////////////////////////////////////////////////////////////////////////
  47. // Standard include guards
  48. #ifndef CBHWLIB_H_INCLUDED
  49. #define CBHWLIB_H_INCLUDED
  50. // Only standard headers might be included here
  51. #if defined(WIN32)
  52. #ifndef _CRT_SECURE_NO_DEPRECATE
  53. #define _CRT_SECURE_NO_DEPRECATE
  54. #endif
  55. // It has to be in this order for right version of sockets
  56. #ifdef NO_AFX
  57. #include <winsock2.h>
  58. #include <windows.h>
  59. #endif // NO_AFX
  60. #endif // defined(WIN32)
  61. #ifdef __cplusplus
  62. #include <string.h>
  63. #endif
  64. #include <stdint.h>
  65. #pragma pack(push, 1)
  66. #define cbVERSION_MAJOR 3
  67. #define cbVERSION_MINOR 10
  68. // Version history:
  69. // 3.10 - 23 Oct 2014 hls - Added reboot capability for extension loader
  70. // 26 Jul 2014 js - Added analog output to extension
  71. // 18 Mar 2014 sa - Add triggered digital output
  72. // 3 Mar 2013 eaz - Adjust MTU
  73. // 3.9 - 23 Jan 2012 eaz - Expanded Analogout Waveform packet
  74. // 29 Apr 2012 eaz - Added cross-platform glue
  75. // 06 Nov 2012 eaz - Added multiple library instance handling
  76. // 3.8 - 10 Oct 2011 hls - added map info packet
  77. // 15 Apr 2011 tkr - added poll packet
  78. // 13 Apr 2011 tkr - added initialize auto impedance packet
  79. // 04 Apr 2011 tkr - added impedance data packet
  80. // 30 Mar 2011 tkr - added patient info for file recording
  81. // 27 Aug 2010 rpa - Added NTrode ellipse support for NTrode sorting
  82. // 3.7 - 04 May 2010 eaz - Added comment, video synchronization and NeuroMotive configuration packets
  83. // 25 May 2010 eaz - Added tracking, logging and patient trigger configuration packets
  84. // 03 Jul 2010 eaz - Added NeuroMotive status and file config reporting
  85. // 03 Jul 2010 eaz - Added nPlay stepping
  86. // 04 Jul 2010 eaz - Added cbOpen under custom stand-alone application
  87. // 3.6 - 10 Nov 2008 jrs - Added extra space for 3D boundaries & Packet for
  88. // recalculating PCA Basis Vectors and Values
  89. // 10 Apr 2009 eaz - Added PCA basis calculation info
  90. // 12 May 2009 eaz - Added LNC parameters and type (nominal frequency, lock channel and method)
  91. // 20 May 2009 eaz - Added LNC waveform display scaling
  92. // 20 May 2009 hls - Added software reference electrode per channel
  93. // 21 May 2009 eaz - Added Auto/Manual threshold packet
  94. // 14 Jun 2009 eaz - Added Waveform Collection Matrix info
  95. // 23 Jun 2009 eaz - Added Video Synch packet
  96. // 25 Jun 2009 eaz - Added stand-alone application capability to library
  97. // 20 Oct 2009 eaz - Expanded the file config packet to control and monitor recording
  98. // 02 Nov 2009 eaz - Expanded nPlay packet to control and monitor nPlay
  99. // 3.5 - 1 Aug 2007 hls - Added env min/max for threshold preview
  100. // 3.4 - 12 Jun 2007 mko - Change Spike Sort Override Circles to Ellipses
  101. // 31 May 2007 hls - Added cbPKTTYPE_REFELECFILTSET
  102. // 19 Jun 2007 hls - Added cbPKT_SS_RESET_MODEL
  103. // 3.3 - 27 Mar 2007 mko - Include angle of rotation with Noise Boundary variables
  104. // 3.2 - 7 Dec 2006 mko - Make spike width variable - to max length of 128 samples
  105. // 20 Dec 2006 hls - move wave to end of spike packet
  106. // 3.1 - 25 Sep 2006 hls - Added unit mapping functionality
  107. // 17 Sep 2006 djs - Changed from noise line to noise ellipse and renamed
  108. // variables with NOISE_LINE to NOISE_BOUNDARY for
  109. // better generalization context
  110. // 15 Aug 2006 djs - Changed exponential measure to histogram correlation
  111. // measure and added histogram peak count algorithm
  112. // 21 Jul 2006 djs/hls - Added exponential measure autoalg
  113. // djs/hls - Changed exponential measure to histogram correlation
  114. // measure and added histogram peak count algorithm
  115. // mko - Added protocol checking to procinfo system
  116. // 3.0 - 15 May 2006 hls - Merged the Manual & Auto Sort protocols
  117. // 2.5 - 18 Nov 2005 hls - Added cbPKT_SS_STATUS
  118. // 2.4 - 10 Nov 2005 kfk - Added cbPKT_SET_DOUT
  119. // 2.3 - 02 Nov 2005 kfk - Added cbPKT_SS_RESET
  120. // 2.2 - 27 Oct 2005 kfk - Updated cbPKT_SS_STATISTICS to include params to affect
  121. // spike sorting rates
  122. //
  123. // 2.1 - 22 Jun 2005 kfk - added all packets associated with spike sorting options
  124. // cbPKTDLEN_SS_DETECT
  125. // cbPKT_SS_ARTIF_REJECT
  126. // cbPKT_SS_NOISE_LINE
  127. // cbPKT_SS_STATISTICS
  128. //
  129. // 2.0 - 11 Apr 2005 kfk - Redifined the Spike packet to include classificaiton data
  130. //
  131. // 1.8 - 27 Mar 2006 ab - Added cbPKT_SS_STATUS
  132. // 1.7 - 7 Feb 2006 hls - Added anagain to cbSCALING structure
  133. // to support different external gain
  134. // 1.6 - 25 Feb 2005 kfk - Added cbPKTTYPE_ADAPTFILTSET and
  135. // cbGetAdaptFilter() and cbSGetAdaptFilter()
  136. // 1.5 - 30 Dec 2003 kfk - Added cbPKTTYPE_REPCONFIGALL and cbPKTTYPE_PREVREP
  137. // redefined cbPKTTYPE_REQCONFIGALL
  138. // 1.4 - 15 Dec 2003 kfk - Added "last_valid_index" to the send buffer
  139. // Added cbDOUT_TRACK
  140. //
  141. ///////////////////////////////////////////////////////////////////////////////////////////////////
  142. //
  143. // Fixed storage size definitions for delcared variables
  144. // (includes conditional testing so that there is no clash with win32 headers)
  145. //
  146. ///////////////////////////////////////////////////////////////////////////////////////////////////
  147. #ifndef WIN32
  148. typedef const char * LPCSTR;
  149. typedef void * HANDLE;
  150. typedef uint32_t COLORREF;
  151. typedef int32_t LONG;
  152. typedef LONG * LPLONG;
  153. typedef LONG * PLONG;
  154. typedef uint8_t BYTE;
  155. typedef uint32_t DWORD;
  156. typedef unsigned int UINT;
  157. #define RGB(r,g,b) ((uint8_t)r + ((uint8_t)g << 8) + ((uint8_t)b << 16))
  158. #define MAKELONG(a, b) ((a & 0xffff) | ((b & 0xffff) << 16))
  159. #ifndef FALSE
  160. #define FALSE 0
  161. #define TRUE 1
  162. #endif
  163. #ifndef BOOL
  164. #define BOOL int
  165. #endif
  166. #define MAX_PATH 1024
  167. #endif
  168. ///////////////////////////////////////////////////////////////////////////////////////////////////
  169. //
  170. // Default Cerebus networking connection parameters
  171. //
  172. // All connections should be defined here
  173. //
  174. ///////////////////////////////////////////////////////////////////////////////////////////////////
  175. #define cbNET_UDP_ADDR_INST "192.168.137.1" // Cerebus default address
  176. #define cbNET_UDP_ADDR_CNT "192.168.137.128" // NSP default control address
  177. #define cbNET_UDP_ADDR_BCAST "192.168.137.255" // NSP default broadcast address
  178. #define cbNET_UDP_PORT_BCAST 51002 // Neuroflow Data Port
  179. #define cbNET_UDP_PORT_CNT 51001 // Neuroflow Control Port
  180. // maximum udp datagram size used to transport cerebus packets, taken from MTU size
  181. #define cbCER_UDP_SIZE_MAX 1452 // Note that multiple packets may reside in one udp datagram as aggregate
  182. ///////////////////////////////////////////////////////////////////////////////////////////////////
  183. //
  184. // Maximum entity ranges for static declarations using this version of the library
  185. //
  186. ///////////////////////////////////////////////////////////////////////////////////////////////////
  187. #define cbNSP1 1
  188. ///////////////////////////////////////////////////////////
  189. #define cbRAWGROUP 6 // group number for raw data feed
  190. ///////////////////////////////////////////////////////////
  191. // Front End Channels (128) -> (256)
  192. // Analog Input (16) -> (32)
  193. // Analog Output (4) -> (8)
  194. // Audio Output (2) -> (4)
  195. // Digital Output (4) -> (8)
  196. // Digital Input (1) -> (2)
  197. // Serial Input (1) -> (2)
  198. //---------------------------------------
  199. // Total (actually 156) (160) -> (320)
  200. //
  201. #define cbMAXOPEN 4 // Maximum number of open cbhwlib's (nsp's)
  202. #define cbMAXPROCS 1 // Number of NSP's
  203. #define cbMAXGROUPS 8 // number of sample rate groups
  204. #define cbMAXFILTS 32
  205. #define cbMAXVIDEOSOURCE 1 // maximum number of video sources
  206. #define cbMAXTRACKOBJ 20 // maximum number of trackable objects
  207. #define cbMAXHOOPS 4
  208. #define cbMAX_AOUT_TRIGGER 5 // maximum number of per-channel (analog output, or digital output) triggers
  209. // N-Trode definitions
  210. #define cbMAXSITES 4 //*** maximum number of electrodes that can be included in an n-trode group -- eventually want to support octrodes
  211. #define cbMAXSITEPLOTS ((cbMAXSITES - 1) * cbMAXSITES / 2) // combination of 2 out of n is n!/((n-2)!2!) -- the only issue is the display
  212. // Channel Definitions
  213. #define cbNUM_FE_CHANS 128 // #Front end channels
  214. #define cbNUM_ANAIN_CHANS 16 // #Analog Input channels
  215. #define cbNUM_ANALOG_CHANS (cbNUM_FE_CHANS + cbNUM_ANAIN_CHANS) // Total Analog Inputs
  216. #define cbNUM_ANAOUT_CHANS 4 // #Analog Output channels
  217. #define cbNUM_AUDOUT_CHANS 2 // #Audio Output channels
  218. #define cbNUM_ANALOGOUT_CHANS (cbNUM_ANAOUT_CHANS + cbNUM_AUDOUT_CHANS) // Total Analog Output
  219. #define cbNUM_DIGIN_CHANS 1 // #Digital Input channels
  220. #define cbNUM_SERIAL_CHANS 1 // #Serial Input channels
  221. #define cbNUM_DIGOUT_CHANS 4 // #Digital Output channels
  222. // Total of all channels = 156
  223. #define cbMAXCHANS (cbNUM_ANALOG_CHANS + cbNUM_ANALOGOUT_CHANS + cbNUM_DIGIN_CHANS + cbNUM_SERIAL_CHANS + cbNUM_DIGOUT_CHANS)
  224. #define cbFIRST_FE_CHAN 0 // 0 First Front end channel
  225. #define cbFIRST_ANAIN_CHAN cbNUM_FE_CHANS // 256 First Analog Input channel
  226. #define cbFIRST_ANAOUT_CHAN (cbFIRST_ANAIN_CHAN + cbNUM_ANAIN_CHANS) // 288 First Analog Output channel
  227. #define cbFIRST_AUDOUT_CHAN (cbFIRST_ANAOUT_CHAN + cbNUM_ANAOUT_CHANS) // 296 First Audio Output channel
  228. #define cbFIRST_DIGIN_CHAN (cbFIRST_AUDOUT_CHAN + cbNUM_AUDOUT_CHANS) // 300 First Digital Input channel
  229. #define cbFIRST_SERIAL_CHAN (cbFIRST_DIGIN_CHAN + cbNUM_DIGIN_CHANS) // 302 First Serial Input channel
  230. #define cbFIRST_DIGOUT_CHAN (cbFIRST_SERIAL_CHAN + cbNUM_SERIAL_CHANS) // 304 First Digital Output channel
  231. // Bank definitions - NOTE: If any of the channel types have more than cbCHAN_PER_BANK channels, the banks must be increased accordingly
  232. #define cbCHAN_PER_BANK 32 // number of 32 channel banks == 1024
  233. #define cbNUM_FE_BANKS (cbNUM_FE_CHANS / cbCHAN_PER_BANK) // number of Front end banks
  234. #define cbNUM_ANAIN_BANKS 1 // number of Analog Input banks
  235. #define cbNUM_ANAOUT_BANKS 1 // number of Analog Output banks
  236. #define cbNUM_AUDOUT_BANKS 1 // number of Audio Output banks
  237. #define cbNUM_DIGIN_BANKS 1 // number of Digital Input banks
  238. #define cbNUM_SERIAL_BANKS 1 // number of Serial Input banks
  239. #define cbNUM_DIGOUT_BANKS 1 // number of Digital Output banks
  240. // Custom digital filters
  241. #define cbFIRST_DIGITAL_FILTER 13 // (0-based) filter number, must be less than cbMAXFILTS
  242. #define cbNUM_DIGITAL_FILTERS 4
  243. // This is the number of aout chans with gain. Conveniently, the
  244. // 4 Analog Outputs and the 2 Audio Outputs are right next to each other
  245. // in the channel numbering sequence.
  246. #define AOUT_NUM_GAIN_CHANS (cbNUM_ANAOUT_CHANS + cbNUM_AUDOUT_CHANS)
  247. // Total number of banks
  248. #define cbMAXBANKS (cbNUM_FE_BANKS + cbNUM_ANAIN_BANKS + cbNUM_ANAOUT_BANKS + cbNUM_AUDOUT_BANKS + cbNUM_DIGIN_BANKS + cbNUM_SERIAL_BANKS + cbNUM_DIGOUT_BANKS)
  249. #define cbMAXUNITS 5 // hard coded to 5 in some places
  250. #define cbMAXNTRODES (cbNUM_ANALOG_CHANS / 2) // minimum is stereotrode so max n-trodes is max chans / 2
  251. // These defines moved from cbHwlibHi to have a central place
  252. #define MAX_CHANS_FRONT_END cbNUM_FE_CHANS
  253. #define MIN_CHANS_ANALOG_IN (MAX_CHANS_FRONT_END + 1)
  254. #define MAX_CHANS_ANALOG_IN (MAX_CHANS_FRONT_END + cbNUM_ANAIN_CHANS)
  255. #define MIN_CHANS_ANALOG_OUT (MAX_CHANS_ANALOG_IN + 1)
  256. #define MAX_CHANS_ANALOG_OUT (MAX_CHANS_ANALOG_IN + cbNUM_ANAOUT_CHANS)
  257. #define MIN_CHANS_AUDIO (MAX_CHANS_ANALOG_OUT + 1)
  258. #define MAX_CHANS_AUDIO (MAX_CHANS_ANALOG_OUT + cbNUM_AUDOUT_CHANS)
  259. #define MIN_CHANS_DIGITAL_IN (MAX_CHANS_AUDIO + 1)
  260. #define MAX_CHANS_DIGITAL_IN (MAX_CHANS_AUDIO + cbNUM_DIGIN_CHANS)
  261. #define MIN_CHANS_SERIAL (MAX_CHANS_DIGITAL_IN + 1)
  262. #define MAX_CHANS_SERIAL (MAX_CHANS_DIGITAL_IN + cbNUM_SERIAL_CHANS)
  263. #define MIN_CHANS_DIGITAL_OUT (MAX_CHANS_SERIAL + 1)
  264. #define MAX_CHANS_DIGITAL_OUT (MAX_CHANS_SERIAL + cbNUM_DIGOUT_CHANS)
  265. #define SCALE_LNC_COUNT 17
  266. #define SCALE_CONTINUOUS_COUNT 17
  267. #define SCALE_SPIKE_COUNT 23
  268. // Special unit classification values
  269. enum UnitClassification
  270. {
  271. UC_UNIT_UNCLASSIFIED = 0, // This unit is not classified
  272. UC_UNIT_ANY = 254, // Any unit including noise
  273. UC_UNIT_NOISE = 255, // This unit is really noise
  274. };
  275. ///////////////////////////////////////////////////////////////////////////////////////////////////
  276. // Some of the string length constants
  277. #define cbLEN_STR_UNIT 8
  278. #define cbLEN_STR_LABEL 16
  279. #define cbLEN_STR_FILT_LABEL 16
  280. #define cbLEN_STR_IDENT 64
  281. ///////////////////////////////////////////////////////////////////////////////////////////////////
  282. ///////////////////////////////////////////////////////////////////////////////////////////////////
  283. //
  284. // Library Result defintions
  285. //
  286. ///////////////////////////////////////////////////////////////////////////////////////////////////
  287. typedef unsigned int cbRESULT;
  288. #define cbRESULT_OK 0 // Function executed normally
  289. #define cbRESULT_NOLIBRARY 1 // The library was not properly initialized
  290. #define cbRESULT_NOCENTRALAPP 2 // Unable to access the central application
  291. #define cbRESULT_LIBINITERROR 3 // Error attempting to initialize library error
  292. #define cbRESULT_MEMORYUNAVAIL 4 // Not enough memory available to complete the operation
  293. #define cbRESULT_INVALIDADDRESS 5 // Invalid Processor or Bank address
  294. #define cbRESULT_INVALIDCHANNEL 6 // Invalid channel ID passed to function
  295. #define cbRESULT_INVALIDFUNCTION 7 // Channel exists, but requested function is not available
  296. #define cbRESULT_NOINTERNALCHAN 8 // No internal channels available to connect hardware stream
  297. #define cbRESULT_HARDWAREOFFLINE 9 // Hardware is offline or unavailable
  298. #define cbRESULT_DATASTREAMING 10 // Hardware is streaming data and cannot be configured
  299. #define cbRESULT_NONEWDATA 11 // There is no new data to be read in
  300. #define cbRESULT_DATALOST 12 // The Central App incoming data buffer has wrapped
  301. #define cbRESULT_INVALIDNTRODE 13 // Invalid NTrode number passed to function
  302. #define cbRESULT_BUFRECALLOCERR 14 // Receive buffer could not be allocated
  303. #define cbRESULT_BUFGXMTALLOCERR 15 // Global transmit buffer could not be allocated
  304. #define cbRESULT_BUFLXMTALLOCERR 16 // Local transmit buffer could not be allocated
  305. #define cbRESULT_BUFCFGALLOCERR 17 // Configuration buffer could not be allocated
  306. #define cbRESULT_BUFPCSTATALLOCERR 18 // PC status buffer could not be allocated
  307. #define cbRESULT_BUFSPKALLOCERR 19 // Spike cache buffer could not be allocated
  308. #define cbRESULT_EVSIGERR 20 // Couldn't create shared event signal
  309. #define cbRESULT_SOCKERR 21 // Generic socket creation error
  310. #define cbRESULT_SOCKOPTERR 22 // Socket option error (possibly permission issue)
  311. #define cbRESULT_SOCKMEMERR 23 // Socket memory assignment error
  312. #define cbRESULT_INSTINVALID 24 // Invalid range or instrument address
  313. #define cbRESULT_SOCKBIND 25 // Cannot bind to any address (possibly no Instrument network)
  314. #define cbRESULT_SYSLOCK 26 // Cannot (un)lock the system resources (possiblly resource busy)
  315. #define cbRESULT_INSTOUTDATED 27 // The instrument runs an outdated protocol version
  316. #define cbRESULT_LIBOUTDATED 28 // The library is outdated
  317. ///////////////////////////////////////////////////////////////////////////////////////////////////
  318. //
  319. // Library Initialization Functions
  320. //
  321. // The standard procedure for intializing and using this library is to:
  322. // 1) Intialize the library with cbOpen().
  323. // 2) Obtain system and channel configuration info with cbGet* commands.
  324. // 3) Configure the system channels with appropriate cbSet* commands.
  325. // 4) Receive data through the callback function
  326. // 5) Repeat steps 2/3/4 as needed until the application closes.
  327. // 6) call cbClose() to de-allocate and free the library
  328. //
  329. ///////////////////////////////////////////////////////////////////////////////////////////////////
  330. uint32_t cbVersion(void);
  331. // Returns the major/minor revision of the current library in the upper/lower uint16_t fields.
  332. ///////////////////////////////////////////////////////////////////////////////////////////////////
  333. //
  334. // Systemwide Inquiry and Configuration Functions
  335. //
  336. ///////////////////////////////////////////////////////////////////////////////////////////////////
  337. #ifdef __cplusplus
  338. // Open multiple instances of library as stand-alone or under Central application
  339. cbRESULT cbOpen(BOOL bStandAlone = FALSE, uint32_t nInstance = 0);
  340. // Initializes the Neuromatic library (and establishes a link to the Central Control Application if bStandAlone is FALSE).
  341. // This function must be called before any other functions are called from this library.
  342. // Returns OK, NOCENTRALAPP, LIBINITERROR, MEMORYUNVAIL, HARDWAREOFFLINE, INSTOUTDATED or LIBOUTDATED
  343. cbRESULT cbClose(BOOL bStandAlone = FALSE, uint32_t nInstance = 0);
  344. // Close the library (must match how library is openned)
  345. cbRESULT cbCheckApp(const char * lpName);
  346. // Check if an application is running using its mutex
  347. cbRESULT cbAquireSystemLock(const char * lpName, HANDLE & hLock);
  348. cbRESULT cbReleaseSystemLock(const char * lpName, HANDLE & hLock);
  349. // Aquire or release application system lock
  350. #define cbINSTINFO_READY 0x0001 // Instrument is connected
  351. #define cbINSTINFO_LOCAL 0x0002 // Instrument runs on the localhost
  352. #define cbINSTINFO_NPLAY 0x0004 // Instrument is nPlay
  353. #define cbINSTINFO_CEREPLEX 0x0008 // Instrument is Cereplex
  354. #define cbINSTINFO_EMULATOR 0x0010 // Instrument is Emulator
  355. #define cbINSTINFO_NSP1 0x0020 // Instrument is NSP1
  356. cbRESULT cbGetInstInfo(uint32_t *instInfo, uint32_t nInstance = 0);
  357. // Purpose: get instrument information.
  358. cbRESULT cbGetLatency(uint32_t *nLatency, uint32_t nInstance = 0);
  359. // Purpose: get instrument latency.
  360. // Returns instrument information
  361. // Returns cbRESULT_OK if successful, cbRESULT_NOLIBRARY if library was never initialized.
  362. cbRESULT cbGetSystemClockFreq(uint32_t *freq, uint32_t nInstance = 0);
  363. // Retrieves the system timestamp/sample clock frequency (in Hz) from the Central App cache.
  364. //
  365. // Returns: cbRESULT_OK if data successfully retrieved.
  366. // cbRESULT_NOLIBRARY if the library was not properly initialized
  367. cbRESULT cbGetSystemClockTime(uint32_t *time, uint32_t nInstance = 0);
  368. // Retrieves the last 32-bit timestamp from the Central App cache.
  369. //
  370. // Returns: cbRESULT_OK if data successfully retrieved.
  371. // cbRESULT_NOLIBRARY if the library was not properly initialized
  372. #endif
  373. // .nev packet data structure (1024 bytes total)
  374. typedef struct {
  375. uint32_t time; // system clock timestamp
  376. uint16_t chid; // channel identifier
  377. uint8_t type; // packet type
  378. uint8_t dlen; // length of data field in 32-bit chunks
  379. uint32_t data[254]; // data buffer (up to 1016 bytes)
  380. } nevPKT_GENERIC;
  381. #define nevPKT_HEADER_SIZE 8 // define the size of the packet header in bytes
  382. #define cbPKT_MAX_SIZE 1024 // the maximum size of the packet in bytes for 128 channels
  383. #define cbPKT_HEADER_SIZE sizeof(cbPKT_HEADER) // define the size of the packet header in bytes
  384. #define cbPKT_HEADER_32SIZE (cbPKT_HEADER_SIZE / 4) // define the size of the packet header in uint32_t's
  385. // Cerebus packet header data structure (must be a multiple of uint32_t)
  386. typedef struct {
  387. uint32_t time; // system clock timestamp
  388. uint16_t chid; // channel identifier
  389. uint8_t type; // packet type
  390. uint8_t dlen; // length of data field in 32-bit chunks
  391. } cbPKT_HEADER;
  392. // Generic Cerebus packet data structure (1024 bytes total)
  393. typedef struct {
  394. uint32_t time; // system clock timestamp
  395. uint16_t chid; // channel identifier
  396. uint8_t type; // packet type
  397. uint8_t dlen; // length of data field in 32-bit chunks
  398. uint32_t data[(cbPKT_MAX_SIZE - cbPKT_HEADER_SIZE) / 4]; // data buffer (up to 1016 bytes)
  399. } cbPKT_GENERIC;
  400. #ifdef __cplusplus
  401. // Shuts down the programming library and frees any resources linked in cbOpen()
  402. // Returns cbRESULT_OK if successful, cbRESULT_NOLIBRARY if library was never initialized.
  403. // Updates the read pointers in the memory area so that
  404. // all of the un-read packets are ignored. In other words, it
  405. // initializes all of the pointers so that the begging of read time is NOW.
  406. cbRESULT cbMakePacketReadingBeginNow(uint32_t nInstance = 0);
  407. ///////////////////////////////////////////////////////////////////////////////////////////////////
  408. //
  409. // Data checking and processing functions
  410. //
  411. // To get data from the shared memory buffers used in the Central App, the user can:
  412. // 1) periodically poll for new data using a multimedia or windows timer
  413. // 2) create a thread that uses a Win32 Event synchronization object to que the data polling
  414. //
  415. ///////////////////////////////////////////////////////////////////////////////////////////////////
  416. enum cbLevelOfConcern
  417. {
  418. LOC_LOW, // Time for sippen lemonaide
  419. LOC_MEDIUM, // Step up to the plate
  420. LOC_HIGH, // Put yer glass down
  421. LOC_CRITICAL, // Get yer but in gear
  422. LOC_COUNT // How many level of concerns are there
  423. };
  424. cbRESULT cbCheckforData(cbLevelOfConcern & nLevelOfConcern, uint32_t *pktstogo = NULL, uint32_t nInstance = 0);
  425. // The pktstogo and timetogo are optional fields (NULL if not used) that returns the number of new
  426. // packets and timestamps that need to be read to catch up to the buffer.
  427. //
  428. // Returns: cbRESULT_OK if there is new data in the buffer
  429. // cbRESULT_NONEWDATA if there is no new data available
  430. // cbRESULT_DATALOST if the Central App incoming data buffer has wrapped the read buffer
  431. cbRESULT cbWaitforData(uint32_t nInstance = 0);
  432. // Executes a WaitForSingleObject command to wait for the Central App event signal
  433. //
  434. // Returns: cbRESULT_OK if there is new data in the buffer
  435. // cbRESULT_NONEWDATA if the function timed out after 250ms
  436. // cbRESULT_DATALOST if the Central App incoming data buffer has wrapped the read buffer
  437. ///////////////////////////////////////////////////////////////////////////////////////////////////
  438. //
  439. // NEV file definitions
  440. //
  441. ///////////////////////////////////////////////////////////////////////////////////////////////////
  442. cbPKT_GENERIC *cbGetNextPacketPtr(uint32_t nInstance = 0);
  443. // Returns pointer to next packet in the shared memory space. If no packet available, returns NULL
  444. // Cerebus Library function to send packets via the Central Application Queue
  445. cbRESULT cbSendPacket(void * pPacket, uint32_t nInstance = 0);
  446. cbRESULT cbSendLoopbackPacket(void * pPacket, uint32_t nInstance = 0);
  447. #endif
  448. ///////////////////////////////////////////////////////////////////////////////////////////////////
  449. //
  450. // Configuration/Report Packet Definitions (chid = 0x8000)
  451. //
  452. ///////////////////////////////////////////////////////////////////////////////////////////////////
  453. #define cbPKTCHAN_CONFIGURATION 0x8000 // Channel # to mean configuration
  454. ///////////////////////////////////////////////////////////////////////////////////////////////////
  455. //
  456. // Detailed Processor and Bank Inquiry Functions
  457. //
  458. // Instrumentation equipment is organized into three levels within this library:
  459. // 1) Signal Processors - Signal processing and data distribution layer
  460. // 2) Signal Banks - Groups of channels with similar properties and physical locations
  461. // 3) Signal Channels - Individual physical channels with one or more functions
  462. //
  463. // Computer --+-- Signal Processor ----- Signal Bank --+-- Channel
  464. // | | +-- Channel
  465. // | | +-- Channel
  466. // | |
  467. // | +-- Signal Bank --+-- Channel
  468. // | +-- Channel
  469. // | +-- Channel
  470. // |
  471. // +-- Signal Processor ----- Signal Bank --+-- Channel
  472. // | +-- Channel
  473. // | +-- Channel
  474. // |
  475. // +-- Signal Bank --+-- Channel
  476. // +-- Channel
  477. // +-- Channel
  478. //
  479. // In this implementation, Signal Channels are numbered from 1-32767 across the entire system and
  480. // are associated to Signal Banks and Signal Processors by the hardware.
  481. //
  482. // Signal Processors are numbered 1-8 and Signal Banks are numbered from 1-16 within a specific
  483. // Signal Processor. Processor and Bank numbers are NOT required to be continuous and
  484. // are a function of the hardware configuration. For example, an instrumentation set-up could
  485. // include Processors at addresses 1, 2, and 7. Configuration packets given to the computer to
  486. // describe the hardware also report the channel enumeration.
  487. //
  488. ///////////////////////////////////////////////////////////////////////////////////////////////////
  489. #define cbSORTMETHOD_MANUAL 0
  490. #define cbSORTMETHOD_AUTO 1
  491. // Signal Processor Configuration Structure
  492. typedef struct {
  493. uint32_t idcode; // manufacturer part and rom ID code of the Signal Processor
  494. char ident[cbLEN_STR_IDENT]; // ID string with the equipment name of the Signal Processor
  495. uint32_t chanbase; // lowest channel identifier claimed by this processor
  496. uint32_t chancount; // number of channel identifiers claimed by this processor
  497. uint32_t bankcount; // number of signal banks supported by the processor
  498. uint32_t groupcount; // number of sample groups supported by the processor
  499. uint32_t filtcount; // number of digital filters supported by the processor
  500. uint32_t sortcount; // number of channels supported for spike sorting (reserved for future)
  501. uint32_t unitcount; // number of supported units for spike sorting (reserved for future)
  502. uint32_t hoopcount; // number of supported hoops for spike sorting (reserved for future)
  503. uint32_t sortmethod; // sort method (0=manual, 1=automatic spike sorting)
  504. uint32_t version; // current version of libraries
  505. } cbPROCINFO;
  506. // Signal Bank Configuration Structure
  507. typedef struct {
  508. uint32_t idcode; // manufacturer part and rom ID code of the module addressed to this bank
  509. char ident[cbLEN_STR_IDENT]; // ID string with the equipment name of the Signal Bank hardware module
  510. char label[cbLEN_STR_LABEL]; // Label on the instrument for the signal bank, eg "Analog In"
  511. uint32_t chanbase; // lowest channel identifier claimed by this bank
  512. uint32_t chancount; // number of channel identifiers claimed by this bank
  513. } cbBANKINFO;
  514. typedef struct {
  515. char name[cbLEN_STR_LABEL];
  516. float fps; // nominal record fps
  517. } cbVIDEOSOURCE;
  518. #ifdef __cplusplus
  519. cbRESULT cbGetVideoSource(char *name, float *fps, uint32_t id, uint32_t nInstance = 0);
  520. cbRESULT cbSetVideoSource(const char *name, float fps, uint32_t id, uint32_t nInstance = 0);
  521. // Get/Set the video source parameters.
  522. //
  523. // Returns: cbRESULT_OK if data successfully retrieved.
  524. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  525. #endif
  526. #define cbTRACKOBJ_TYPE_UNDEFINED 0
  527. #define cbTRACKOBJ_TYPE_2DMARKERS 1
  528. #define cbTRACKOBJ_TYPE_2DBLOB 2
  529. #define cbTRACKOBJ_TYPE_3DMARKERS 3
  530. #define cbTRACKOBJ_TYPE_2DBOUNDARY 4
  531. #define cbTRACKOBJ_TYPE_1DSIZE 5
  532. typedef struct {
  533. char name[cbLEN_STR_LABEL];
  534. uint16_t type; // trackable type (cbTRACKOBJ_TYPE_*)
  535. uint16_t pointCount; // maximum number of points
  536. } cbTRACKOBJ;
  537. #ifdef __cplusplus
  538. cbRESULT cbGetTrackObj(char *name, uint16_t *type, uint16_t *pointCount, uint32_t id, uint32_t nInstance = 0);
  539. cbRESULT cbSetTrackObj(const char *name, uint16_t type, uint16_t pointCount, uint32_t id, uint32_t nInstance = 0);
  540. // Get/Set the trackable object parameters.
  541. //
  542. // Returns: cbRESULT_OK if data successfully retrieved.
  543. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  544. #endif
  545. #define cbFILTTYPE_PHYSICAL 0x0001
  546. #define cbFILTTYPE_DIGITAL 0x0002
  547. #define cbFILTTYPE_ADAPTIVE 0x0004
  548. #define cbFILTTYPE_NONLINEAR 0x0008
  549. #define cbFILTTYPE_BUTTERWORTH 0x0100
  550. #define cbFILTTYPE_CHEBYCHEV 0x0200
  551. #define cbFILTTYPE_BESSEL 0x0400
  552. #define cbFILTTYPE_ELLIPTICAL 0x0800
  553. typedef struct {
  554. char label[cbLEN_STR_FILT_LABEL];
  555. uint32_t hpfreq; // high-pass corner frequency in milliHertz
  556. uint32_t hporder; // high-pass filter order
  557. uint32_t hptype; // high-pass filter type
  558. uint32_t lpfreq; // low-pass frequency in milliHertz
  559. uint32_t lporder; // low-pass filter order
  560. uint32_t lptype; // low-pass filter type
  561. } cbFILTDESC;
  562. typedef struct {
  563. uint32_t bEnabled; // BOOL implemented as uint32_t - for structure alignment at paragraph boundary
  564. int16_t nAmplPos;
  565. int16_t nAmplNeg;
  566. } cbAMPLITUDEREJECT;
  567. typedef struct {
  568. int16_t nOverride;
  569. int16_t afOrigin[3];
  570. int16_t afShape[3][3];
  571. int16_t aPhi;
  572. uint32_t bValid; // is this unit in use at this time?
  573. // BOOL implemented as uint32_t - for structure alignment at paragraph boundary
  574. } cbMANUALUNITMAPPING;
  575. #define cbCHAN_EXISTS 0x00000001 // Channel id is allocated
  576. #define cbCHAN_CONNECTED 0x00000002 // Channel is connected and mapped and ready to use
  577. #define cbCHAN_ISOLATED 0x00000004 // Channel is electrically isolated
  578. #define cbCHAN_AINP 0x00000100 // Channel has analog input capabilities
  579. #define cbCHAN_AOUT 0x00000200 // Channel has analog output capabilities
  580. #define cbCHAN_DINP 0x00000400 // Channel has digital input capabilities
  581. #define cbCHAN_DOUT 0x00000800 // Channel has digital output capabilities
  582. #ifdef __cplusplus
  583. cbRESULT cbGetChanCaps(uint32_t chan, uint32_t *chancaps, uint32_t nInstance = 0);
  584. // Retreives the channel capabilities from the Central App Cache.
  585. //
  586. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  587. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  588. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  589. #endif
  590. ///////////////////////////////////////////////////////////////////////////////////////////////////
  591. //
  592. // Digital Input Inquiry and Configuration Functions
  593. //
  594. ///////////////////////////////////////////////////////////////////////////////////////////////////
  595. #define cbDINP_SERIALMASK 0x000000FF // Bit mask used to detect RS232 Serial Baud Rates
  596. #define cbDINP_BAUD2400 0x00000001 // RS232 Serial Port operates at 2400 (n-8-1)
  597. #define cbDINP_BAUD9600 0x00000002 // RS232 Serial Port operates at 9600 (n-8-1)
  598. #define cbDINP_BAUD19200 0x00000004 // RS232 Serial Port operates at 19200 (n-8-1)
  599. #define cbDINP_BAUD38400 0x00000008 // RS232 Serial Port operates at 38400 (n-8-1)
  600. #define cbDINP_BAUD57600 0x00000010 // RS232 Serial Port operates at 57600 (n-8-1)
  601. #define cbDINP_BAUD115200 0x00000020 // RS232 Serial Port operates at 115200 (n-8-1)
  602. #define cbDINP_1BIT 0x00000100 // Port has a single input bit (eg single BNC input)
  603. #define cbDINP_8BIT 0x00000200 // Port has 8 input bits
  604. #define cbDINP_16BIT 0x00000400 // Port has 16 input bits
  605. #define cbDINP_32BIT 0x00000800 // Port has 32 input bits
  606. #define cbDINP_ANYBIT 0x00001000 // Capture the port value when any bit changes.
  607. #define cbDINP_WRDSTRB 0x00002000 // Capture the port when a word-write line is strobed
  608. #define cbDINP_PKTCHAR 0x00004000 // Capture packets using an End of Packet Character
  609. #define cbDINP_PKTSTRB 0x00008000 // Capture packets using an End of Packet Logic Input
  610. #define cbDINP_MONITOR 0x00010000 // Port controls other ports or system events
  611. #define cbDINP_REDGE 0x00020000 // Capture the port value when any bit changes lo-2-hi (rising edge)
  612. #define cbDINP_FEDGE 0x00040000 // Capture the port value when any bit changes hi-2-lo (falling edge)
  613. #define cbDINP_STRBANY 0x00080000 // Capture packets using 8-bit strobe/8-bit any Input
  614. #define cbDINP_STRBRIS 0x00100000 // Capture packets using 8-bit strobe/8-bit rising edge Input
  615. #define cbDINP_STRBFAL 0x00200000 // Capture packets using 8-bit strobe/8-bit falling edge Input
  616. #define cbDINP_MASK (cbDINP_ANYBIT | cbDINP_WRDSTRB | cbDINP_PKTCHAR | cbDINP_PKTSTRB | cbDINP_MONITOR | cbDINP_REDGE | cbDINP_FEDGE | cbDINP_STRBANY | cbDINP_STRBRIS | cbDINP_STRBFAL)
  617. #ifdef __cplusplus
  618. cbRESULT cbGetDinpCaps(uint32_t chan, uint32_t *dinpcaps, uint32_t nInstance = 0);
  619. // Retreives the channel's digital input capabilities from the Central App Cache.
  620. // Port Capabilities are reported as compbined cbDINPOPT_* flags. Zero = no DINP capabilities.
  621. //
  622. // Returns: cbRESULT_OK if data successfully retreived.
  623. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  624. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  625. cbRESULT cbGetDinpOptions(uint32_t chan, uint32_t *options, uint32_t *eopchar, uint32_t nInstance = 0);
  626. cbRESULT cbSetDinpOptions(uint32_t chan, uint32_t options, uint32_t eopchar, uint32_t nInstance = 0);
  627. // Get/Set the Digital Input Port options for the specified channel.
  628. //
  629. // Port options are expressed as a combined set of cbDINP_* option flags, for example:
  630. // a) cbDINP_SERIAL + cbDINP_BAUDxx = capture single 8-bit RS232 serial values.
  631. // b) cbDINP_SERIAL + cbDINP_BAUDxx + cbDINP_PKTCHAR = capture serial packets that are terminated
  632. // with an end of packet character (only the lower 8 bits are used).
  633. // c) cbDINP_1BIT + cbDINP_ANYBIT = capture the changes of a single digital input line.
  634. // d) cbDINP_xxBIT + cbDINP_ANYBIT = capture the xx-bit input word when any bit changes.
  635. // e) cbDINP_xxBIT + cbDINP_WRDSTRB = capture the xx-bit input based on a word-strobe line.
  636. // f) cbDINP_xxBIT + cbDINP_WRDSTRB + cbDINP_PKTCHAR = capture packets composed of xx-bit words
  637. // in which the packet is terminated with the specified end-of-packet character.
  638. // g) cbDINP_xxBIT + cbDINP_WRDSTRB + cbDINP_PKTLINE = capture packets composed of xx-bit words
  639. // in which the last character of a packet is accompanyied with an end-of-pkt logic signal.
  640. // h) cbDINP_xxBIT + cbDINP_REDGE = capture the xx-bit input word when any bit goes from low to hi.
  641. // i) cbDINP_xxBIT + dbDINP_FEDGE = capture the xx-bit input word when any bit goes from hi to low.
  642. //
  643. // NOTE: If the end-of-packet character value (eopchar) is not used in the options, it is ignored.
  644. //
  645. // Add cbDINP_PREVIEW to the option set to get preview updates (cbPKT_PREVDINP) at each word,
  646. // not only when complete packets are sent.
  647. //
  648. // The Get function returns values from the Central Control App cache. The Set function validates
  649. // that the specified options are available and then queues a cbPKT_SETDINPOPT packet. The system
  650. // acknowledges this change with a cbPKT_ACKDINPOPT packet.
  651. //
  652. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  653. // cbRESULT_INVALIDFUNCTION a requested option is not available on that channel.
  654. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  655. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  656. #endif
  657. ///////////////////////////////////////////////////////////////////////////////////////////////////
  658. //
  659. // Digital Output Inquiry and Configuration Functions
  660. //
  661. ///////////////////////////////////////////////////////////////////////////////////////////////////
  662. #define cbDOUT_SERIALMASK 0x000000FF // Port operates as an RS232 Serial Connection
  663. #define cbDOUT_BAUD2400 0x00000001 // Serial Port operates at 2400 (n-8-1)
  664. #define cbDOUT_BAUD9600 0x00000002 // Serial Port operates at 9600 (n-8-1)
  665. #define cbDOUT_BAUD19200 0x00000004 // Serial Port operates at 19200 (n-8-1)
  666. #define cbDOUT_BAUD38400 0x00000008 // Serial Port operates at 38400 (n-8-1)
  667. #define cbDOUT_BAUD57600 0x00000010 // Serial Port operates at 57600 (n-8-1)
  668. #define cbDOUT_BAUD115200 0x00000020 // Serial Port operates at 115200 (n-8-1)
  669. #define cbDOUT_1BIT 0x00000100 // Port has a single output bit (eg single BNC output)
  670. #define cbDOUT_8BIT 0x00000200 // Port has 8 output bits
  671. #define cbDOUT_16BIT 0x00000400 // Port has 16 output bits
  672. #define cbDOUT_32BIT 0x00000800 // Port has 32 output bits
  673. #define cbDOUT_VALUE 0x00010000 // Port can be manually configured
  674. #define cbDOUT_TRACK 0x00020000 // Port should track the most recently selected channel
  675. #define cbDOUT_FREQUENCY 0x00040000 // Port can output a frequency
  676. #define cbDOUT_TRIGGERED 0x00080000 // Port can be triggered
  677. #define cbDOUT_MONITOR_UNIT0 0x01000000 // Can monitor unit 0 = UNCLASSIFIED
  678. #define cbDOUT_MONITOR_UNIT1 0x02000000 // Can monitor unit 1
  679. #define cbDOUT_MONITOR_UNIT2 0x04000000 // Can monitor unit 2
  680. #define cbDOUT_MONITOR_UNIT3 0x08000000 // Can monitor unit 3
  681. #define cbDOUT_MONITOR_UNIT4 0x10000000 // Can monitor unit 4
  682. #define cbDOUT_MONITOR_UNIT5 0x20000000 // Can monitor unit 5
  683. #define cbDOUT_MONITOR_UNIT_ALL 0x3F000000 // Can monitor ALL units
  684. #define cbDOUT_MONITOR_SHIFT_TO_FIRST_UNIT 24 // This tells us how many bit places to get to unit 1
  685. // Trigger types for Digital Output channels
  686. #define cbDOUT_TRIGGER_NONE 0 // instant software trigger
  687. #define cbDOUT_TRIGGER_DINPRISING 1 // digital input rising edge trigger
  688. #define cbDOUT_TRIGGER_DINPFALLING 2 // digital input falling edge trigger
  689. #define cbDOUT_TRIGGER_SPIKEUNIT 3 // spike unit
  690. #define cbDOUT_TRIGGER_NM 4 // comment RGBA color (A being big byte)
  691. #define cbDOUT_TRIGGER_SOFTRESET 5 // soft-reset trigger
  692. #define cbDOUT_TRIGGER_EXTENSION 6 // extension trigger
  693. #ifdef __cplusplus
  694. cbRESULT cbGetDoutCaps(uint32_t chan, uint32_t *doutcaps, uint32_t nInstance = 0);
  695. // Retreives the channel's digital output capabilities from the Central Control App Cache.
  696. // Port Capabilities are reported as compbined cbDOUTOPT_* flags. Zero = no DINP capabilities.
  697. //
  698. // Returns: cbRESULT_OK if data successfully retreived.
  699. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  700. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  701. cbRESULT cbGetDoutOptions(uint32_t chan, uint32_t *options, uint32_t *monchan, uint32_t *doutval,
  702. uint8_t *triggertype = NULL, uint16_t *trigchan = NULL, uint16_t *trigval = NULL, uint32_t nInstance = 0);
  703. cbRESULT cbSetDoutOptions(uint32_t chan, uint32_t options, uint32_t monchan, uint32_t doutval,
  704. uint8_t triggertype = cbDOUT_TRIGGER_NONE, uint16_t trigchan = 0, uint16_t trigval = 0, uint32_t nInstance = 0);
  705. // Get/Set the Digital Output Port options for the specified channel.
  706. //
  707. // The only changable DOUT options in this version of the interface libraries are baud rates for
  708. // serial output ports. These are set with the cbDOUTOPT_BAUDxx options.
  709. //
  710. // The Get function returns values from the Central Control App cache. The Set function validates
  711. // that the specified options are available and then queues a cbPKT_SETDOUTOPT packet. The system
  712. // acknowledges this change with a cbPKT_REPDOUTOPT packet.
  713. //
  714. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  715. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  716. // cbRESULT_NOINTERNALCHAN if there is no internal channel for mapping the in->out chan
  717. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  718. #endif
  719. ///////////////////////////////////////////////////////////////////////////////////////////////////
  720. //
  721. // Analog Input Inquiry and Configuration Functions
  722. //
  723. // The analog input processing in this library assumes the following signal flow structure:
  724. //
  725. // Input with --+-- Adaptive LNC filter -- Adaptive Filter --+-- Sampling Stream Filter -- Sample Group
  726. // physical | |
  727. // filter +-- Raw Preview |
  728. // +-- Adaptive Filter -- Spike Stream Filter --+-- Spike Processing
  729. // | |
  730. // | +-- Spike Preview
  731. // +-- LNC Preview
  732. //
  733. // Adaptive Filter (above) is one or the other depending on settings, never both!
  734. //
  735. // This system forks the signal into 2 separate streams: a continuous stream and a spike stream.
  736. // All simpler systems are derived from this structure and unincluded elements are bypassed or
  737. // ommitted, for example the structure of the NSAS neural channels would be:
  738. //
  739. // Input with --------+-- Spike Processing ( NOTE: the physical filter is tuned )
  740. // physical | ( for spikes and spike processing )
  741. // filter +-- Spike Preview
  742. //
  743. ///////////////////////////////////////////////////////////////////////////////////////////////////
  744. // In this system, analog values are represented by 16-bit signed integers. The cbSCALING
  745. // structure gives the mapping between the signal's analog space and the converted digital values.
  746. //
  747. // (anamax) ---
  748. // |
  749. // |
  750. // | \ --- (digmax)
  751. // analog === Analog to ===\ |
  752. // range === Digital ===/ digital
  753. // | / range
  754. // | |
  755. // | --- (digmin)
  756. // (anamin) ---
  757. //
  758. // The analog range extent values are reported in 32-bit integers, along with a unit description.
  759. // Units should be given with traditional metric scales such as P, M, K, m, u(for micro), n, p,
  760. // etc and they are limited to 8 ASCII characters for description.
  761. //
  762. // The anamin and anamax represent the min and max values of the analog signal. The digmin and
  763. // digmax values are their cooresponding converted digital values. If the signal is inverted in
  764. // the scaling conversion, the digmin value will be greater than the digmax value.
  765. //
  766. // For example if a +/-5V signal is mapped into a +/-1024 digital value, the preferred unit
  767. // would be "mV", anamin/max = +/- 5000, and digmin/max= +/-1024.
  768. typedef struct {
  769. int16_t digmin; // digital value that cooresponds with the anamin value
  770. int16_t digmax; // digital value that cooresponds with the anamax value
  771. int32_t anamin; // the minimum analog value present in the signal
  772. int32_t anamax; // the maximum analog value present in the signal
  773. int32_t anagain; // the gain applied to the default analog values to get the analog values
  774. char anaunit[cbLEN_STR_UNIT]; // the unit for the analog signal (eg, "uV" or "MPa")
  775. } cbSCALING;
  776. #define cbAINP_RAWPREVIEW 0x00000001 // Generate scrolling preview data for the raw channel
  777. #define cbAINP_LNC 0x00000002 // Line Noise Cancellation
  778. #define cbAINP_LNCPREVIEW 0x00000004 // Retrieve the LNC correction waveform
  779. #define cbAINP_SMPSTREAM 0x00000010 // stream the analog input stream directly to disk
  780. #define cbAINP_SMPFILTER 0x00000020 // Digitally filter the analog input stream
  781. #define cbAINP_RAWSTREAM 0x00000040 // Raw data stream available
  782. #define cbAINP_SPKSTREAM 0x00000100 // Spike Stream is available
  783. #define cbAINP_SPKFILTER 0x00000200 // Selectable Filters
  784. #define cbAINP_SPKPREVIEW 0x00000400 // Generate scrolling preview of the spike channel
  785. #define cbAINP_SPKPROC 0x00000800 // Channel is able to do online spike processing
  786. #define cbAINP_OFFSET_CORRECT_CAP 0x00001000 // Offset correction mode (0-disabled 1-enabled)
  787. #ifdef __cplusplus
  788. cbRESULT cbGetAinpCaps(uint32_t chan, uint32_t *ainpcaps, cbSCALING *physcalin, cbFILTDESC *phyfiltin, uint32_t nInstance = 0);
  789. // Retreives the channel's analog input capabilities from the Central Control App Cache.
  790. // Capabilities are reported as combined cbAINP_* flags. Zero = no AINP capabilities.
  791. //
  792. // Returns: cbRESULT_OK if data successfully retreived.
  793. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  794. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  795. #endif
  796. #define cbAINP_LNC_OFF 0x00000000 // Line Noise Cancellation disabled
  797. #define cbAINP_LNC_RUN_HARD 0x00000001 // Hardware-based LNC running and adapting according to the adaptation const
  798. #define cbAINP_LNC_RUN_SOFT 0x00000002 // Software-based LNC running and adapting according to the adaptation const
  799. #define cbAINP_LNC_HOLD 0x00000004 // LNC running, but not adapting
  800. #define cbAINP_LNC_MASK 0x00000007 // Mask for LNC Flags
  801. #define cbAINP_REFELEC_LFPSPK 0x00000010 // Apply reference electrode to LFP & Spike
  802. #define cbAINP_REFELEC_SPK 0x00000020 // Apply reference electrode to Spikes only
  803. #define cbAINP_REFELEC_MASK 0x00000030 // Mask for Reference Electrode flags
  804. #define cbAINP_RAWSTREAM_ENABLED 0x00000040 // Raw data stream enabled
  805. #define cbAINP_OFFSET_CORRECT 0x00000100 // Offset correction mode (0-disabled 1-enabled)
  806. #ifdef __cplusplus
  807. cbRESULT cbGetAinpOpts(uint32_t chan, uint32_t *ainpopts, uint32_t *LNCrate, uint32_t *refElecChan, uint32_t nInstance = 0);
  808. cbRESULT cbSetAinpOpts(uint32_t chan, const uint32_t ainpopts, uint32_t LNCrate, const uint32_t refElecChan, uint32_t nInstance = 0);
  809. // Get and Set the user-assigned amplitude reject values.
  810. //
  811. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  812. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  813. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  814. //
  815. // The LNC configuration is composed of an adaptation rate and a mode variable. The rate sets the
  816. // first order decay of the filter according to:
  817. //
  818. // newLNCvalue = (LNCrate/65536)*(oldLNCvalue) + ((65536-LNCrate)/65536)*LNCsample
  819. //
  820. // The relationships between the adaptation time constant in sec, line frequency in Hz and the
  821. // the LNCrate variable are given below:
  822. //
  823. // time_constant = 1 / ln[ (LNCrate/65536)^(-line_freq) ]
  824. //
  825. // LNCrate = 65536 * e^[-1/(time_constant*line_freq)]
  826. //
  827. // The LNCmode sets whether the channel LNC block is disabled, running, or on hold.
  828. //
  829. // To set multiple channels on hold or run, pass channel=0. In this case, the LNCrate is ignored
  830. // and the run or hold value passed to the LNCmode variable is applied to all LNC enabled channels.
  831. cbRESULT cbGetAinpScaling(uint32_t chan, cbSCALING *scaling, uint32_t nInstance = 0);
  832. cbRESULT cbSetAinpScaling(uint32_t chan, cbSCALING *scaling, uint32_t nInstance = 0);
  833. // Get/Set the user-specified scaling for the channel. The digmin and digmax values of the user
  834. // specified scaling must be within the digmin and digmax values for the physical channel mapping.
  835. //
  836. // Returns: cbRESULT_OK if data successfully retreived.
  837. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  838. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  839. cbRESULT cbGetAinpDisplay(uint32_t chan, int32_t *smpdispmin, int32_t *smpdispmax, int32_t *spkdispmax, int32_t *lncdispmax, uint32_t nInstance = 0);
  840. cbRESULT cbSetAinpDisplay(uint32_t chan, int32_t smpdispmin, int32_t smpdispmax, int32_t spkdispmax, int32_t lncdispmax, uint32_t nInstance = 0);
  841. // Get and Set the display ranges used by User applications. smpdispmin/max set the digital value
  842. // range that should be displayed for the sampled analog stream. Spike streams are assumed to be
  843. // symmetric about zero so that spikes should be plotted from -spkdispmax to +spkdispmax. Passing
  844. // zero as a scale instructs the Central app to send the cached value. Fields with NULL pointers
  845. // are ignored by the library.
  846. //
  847. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  848. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  849. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  850. #endif
  851. // <<NOTE: these constants are based on the preview request packet identifier>>
  852. #define cbAINPPREV_LNC 0x81
  853. #define cbAINPPREV_STREAM 0x82
  854. #define cbAINPPREV_ALL 0x83
  855. #ifdef __cplusplus
  856. cbRESULT cbSetAinpPreview(uint32_t chan, uint32_t prevopts, uint32_t nInstance = 0);
  857. // Requests preview packets for a specific channel.
  858. // Setting the AINPPREV_LNC option gets a single LNC update waveform.
  859. // Setting the AINPPREV_STREAMS enables compressed preview information.
  860. //
  861. // A channel ID of zero requests the specified preview packets from all active ainp channels.
  862. //
  863. // Returns: cbRESULT_OK if data successfully retreived.
  864. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  865. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  866. //////////////////////////////////////////////////////////////
  867. // AINP Continuous Stream Functions
  868. cbRESULT cbGetAinpSampling(uint32_t chan, uint32_t *filter, uint32_t *group, uint32_t nInstance = 0);
  869. cbRESULT cbSetAinpSampling(uint32_t chan, uint32_t filter, uint32_t group, uint32_t nInstance = 0);
  870. // Get/Set the periodic sample group for the channel. Continuous sampling is performed in
  871. // groups with each Neural Signal Processor. There are up to 4 groups for each processor.
  872. // A group number of zero signifies that the channel is not part of a continuous sample group.
  873. // filter = 1 to cbNFILTS, 0 is reserved for the null filter case
  874. //
  875. // Returns: cbRESULT_OK if data successfully retreived.
  876. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  877. // cbRESULT_INVALIDFUNCTION if the group number is not valid.
  878. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  879. #endif
  880. //////////////////////////////////////////////////////////////
  881. // AINP Spike Stream Functions
  882. #define cbAINPSPK_EXTRACT 0x00000001 // Time-stamp and packet to first superthreshold peak
  883. #define cbAINPSPK_REJART 0x00000002 // Reject around clipped signals on multiple channels
  884. #define cbAINPSPK_REJCLIP 0x00000004 // Reject clipped signals on the channel
  885. #define cbAINPSPK_ALIGNPK 0x00000008 //
  886. #define cbAINPSPK_REJAMPL 0x00000010 // Reject based on amplitude
  887. #define cbAINPSPK_THRLEVEL 0x00000100 // Analog level threshold detection
  888. #define cbAINPSPK_THRENERGY 0x00000200 // Energy threshold detection
  889. #define cbAINPSPK_THRAUTO 0x00000400 // Auto threshold detection
  890. #define cbAINPSPK_SPREADSORT 0x00001000 // Enable Auto spread Sorting
  891. #define cbAINPSPK_CORRSORT 0x00002000 // Enable Auto Histogram Correlation Sorting
  892. #define cbAINPSPK_PEAKMAJSORT 0x00004000 // Enable Auto Histogram Peak Major Sorting
  893. #define cbAINPSPK_PEAKFISHSORT 0x00008000 // Enable Auto Histogram Peak Fisher Sorting
  894. #define cbAINPSPK_HOOPSORT 0x00010000 // Enable Manual Hoop Sorting
  895. #define cbAINPSPK_PCAMANSORT 0x00020000 // Enable Manual PCA Sorting
  896. #define cbAINPSPK_PCAKMEANSORT 0x00040000 // Enable K-means PCA Sorting
  897. #define cbAINPSPK_PCAEMSORT 0x00080000 // Enable EM-clustering PCA Sorting
  898. #define cbAINPSPK_PCADBSORT 0x00100000 // Enable DBSCAN PCA Sorting
  899. #define cbAINPSPK_AUTOSORT (cbAINPSPK_SPREADSORT | cbAINPSPK_CORRSORT | cbAINPSPK_PEAKMAJSORT | cbAINPSPK_PEAKFISHSORT) // old auto sorting methods
  900. #define cbAINPSPK_NOSORT 0x00000000 // No sorting
  901. #define cbAINPSPK_PCAAUTOSORT (cbAINPSPK_PCAKMEANSORT | cbAINPSPK_PCAEMSORT | cbAINPSPK_PCADBSORT) // All PCA sorting auto algorithms
  902. #define cbAINPSPK_PCASORT (cbAINPSPK_PCAMANSORT | cbAINPSPK_PCAAUTOSORT) // All PCA sorting algorithms
  903. #define cbAINPSPK_ALLSORT (cbAINPSPK_AUTOSORT | cbAINPSPK_HOOPSORT | cbAINPSPK_PCASORT) // All sorting algorithms
  904. #ifdef __cplusplus
  905. cbRESULT cbGetAinpSpikeCaps(uint32_t chan, uint32_t *flags, uint32_t nInstance = 0);
  906. cbRESULT cbGetAinpSpikeOptions(uint32_t chan, uint32_t *flags, uint32_t *filter, uint32_t nInstance = 0);
  907. cbRESULT cbSetAinpSpikeOptions(uint32_t chan, uint32_t flags, uint32_t filter, uint32_t nInstance = 0);
  908. // Get/Set spike capabilities and options. The EXTRACT flag must be set for a channel to perform
  909. // spike extraction and processing. The HOOPS and TEMPLATE flags are exclusive, only one can be
  910. // used at a time.
  911. // the THRSHOVR flag will turn auto thresholding off for that channel
  912. // filter = 1 to cbNFILTS, 0 is reserved for the null filter case
  913. //
  914. // Returns: cbRESULT_OK if data successfully retreived.
  915. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  916. // cbRESULT_INVALIDFUNCTION if invalid flag combinations are passed.
  917. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  918. //
  919. cbRESULT cbGetAinpSpikeThreshold(uint32_t chan, int32_t *level, uint32_t nInstance = 0);
  920. cbRESULT cbSetAinpSpikeThreshold(uint32_t chan, int32_t level, uint32_t nInstance = 0);
  921. // Get/Set the spike detection threshold and threshold detection mode.
  922. //
  923. // Returns: cbRESULT_OK if data successfully retreived.
  924. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  925. // cbRESULT_INVALIDFUNCTION if invalid flag combinations are passed.
  926. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  927. #endif
  928. typedef struct {
  929. uint16_t valid; // 0=undefined, 1 for valid
  930. int16_t time; // time offset into spike window
  931. int16_t min; // minimum value for the hoop window
  932. int16_t max; // maximum value for the hoop window
  933. } cbHOOP;
  934. #ifdef __cplusplus
  935. cbRESULT cbGetAinpSpikeHoops(uint32_t chan, cbHOOP *hoops, uint32_t nInstance = 0);
  936. cbRESULT cbSetAinpSpikeHoops(uint32_t chan, cbHOOP *hoops, uint32_t nInstance = 0);
  937. // Get/Set the spike hoop set. The hoops parameter points to an array of hoops declared as
  938. // cbHOOP hoops[cbMAXUNITS][cbMAXHOOPS].
  939. //
  940. // Empty hoop definitions have zeros for the cbHOOP structure members. Hoop definitions can be
  941. // cleared by passing a NULL cbHOOP pointer to the Set function or by calling the Set function
  942. // with an all-zero cbHOOP structure.
  943. //
  944. // Returns: cbRESULT_OK if data successfully retreived.
  945. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  946. // cbRESULT_INVALIDFUNCTION if an invalid unit or hoop number is passed.
  947. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  948. #endif
  949. ///////////////////////////////////////////////////////////////////////////////////////////////////
  950. //
  951. // Analog Output Inquiry and Configuration Functions
  952. //
  953. ///////////////////////////////////////////////////////////////////////////////////////////////////
  954. #define cbAOUT_AUDIO 0x00000001 // Channel is physically optimized for audio output
  955. #define cbAOUT_SCALE 0x00000002 // Output a static value
  956. #define cbAOUT_TRACK 0x00000004 // Output a static value
  957. #define cbAOUT_STATIC 0x00000008 // Output a static value
  958. #define cbAOUT_MONITORRAW 0x00000010 // Monitor an analog signal line - RAW data
  959. #define cbAOUT_MONITORLNC 0x00000020 // Monitor an analog signal line - Line Noise Cancelation
  960. #define cbAOUT_MONITORSMP 0x00000040 // Monitor an analog signal line - Continuous
  961. #define cbAOUT_MONITORSPK 0x00000080 // Monitor an analog signal line - spike
  962. #define cbAOUT_STIMULATE 0x00000100 // Stimulation waveform functions are available.
  963. #define cbAOUT_WAVEFORM 0x00000200 // Custom Waveform
  964. #define cbAOUT_EXTENSION 0x00000400 // Output Waveform from Extension
  965. #define cbAOUT_EXTENSIONDOFS 356 // Special value for having analog out use values from a plugin.
  966. // Basically we're placing the analog output values back into their own spots in the IO buffer.
  967. #ifdef __cplusplus
  968. cbRESULT cbGetAoutCaps(uint32_t chan, uint32_t *aoutcaps, cbSCALING *physcalout, cbFILTDESC *phyfiltout, uint32_t nInstance = 0);
  969. // Get/Set the spike template capabilities and options. The nunits and nhoops values detail the
  970. // number of units that the channel supports.
  971. //
  972. // Empty template definitions have zeros for the cbSPIKETEMPLATE structure members. Spike
  973. // Template definitions can be cleared by passing a NULL cbSPIKETEMPLATE pointer to the Set
  974. // function or by calling the Set function with an all-zero cbSPIKETEMPLATE structure.
  975. //
  976. // Returns: cbRESULT_OK if data successfully retreived.
  977. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  978. // cbRESULT_INVALIDFUNCTION if an invalid unit number is passed.
  979. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  980. cbRESULT cbGetAoutScaling(uint32_t chan, cbSCALING *scaling, uint32_t nInstance = 0);
  981. cbRESULT cbSetAoutScaling(uint32_t chan, cbSCALING *scaling, uint32_t nInstance = 0);
  982. // Get/Set the user-specified scaling for the channel. The digmin and digmax values of the user
  983. // specified scaling must be within the digmin and digmax values for the physical channel mapping.
  984. //
  985. // Returns: cbRESULT_OK if data successfully retreived.
  986. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  987. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  988. cbRESULT cbGetAoutOptions(uint32_t chan, uint32_t *options, uint32_t *monchan, uint32_t *value, uint32_t nInstance = 0);
  989. cbRESULT cbSetAoutOptions(uint32_t chan, uint32_t options, uint32_t monchan, uint32_t value, uint32_t nInstance = 0);
  990. // Get/Set the Monitored channel for a Analog Output Port. Setting zero for the monitored channel
  991. // stops the monitoring and frees any instrument monitor resources. The factor ranges
  992. //
  993. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  994. // cbRESULT_NOINTERNALCHAN if there is no internal channel for mapping the in->out chan
  995. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  996. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  997. // Request that the sorting model be updated
  998. cbRESULT cbGetSortingModel(uint32_t nInstance = 0);
  999. cbRESULT cbGetFeatureSpaceDomain(uint32_t nInstance = 0);
  1000. // Getting and setting the noise boundary
  1001. cbRESULT cbSSGetNoiseBoundary(uint32_t chanIdx, float afCentroid[3], float afMajor[3], float afMinor_1[3], float afMinor_2[3], uint32_t nInstance = 0);
  1002. cbRESULT cbSSSetNoiseBoundary(uint32_t chanIdx, float afCentroid[3], float afMajor[3], float afMinor_1[3], float afMinor_2[3], uint32_t nInstance = 0);
  1003. cbRESULT cbSSGetNoiseBoundaryByTheta(uint32_t chanIdx, float afCentroid[3], float afAxisLen[3], float afTheta[3], uint32_t nInstance = 0);
  1004. cbRESULT cbSSSetNoiseBoundaryByTheta(uint32_t chanIdx, const float afCentroid[3], const float afAxisLen[3], const float afTheta[3], uint32_t nInstance = 0);
  1005. // Getting and settings statistics
  1006. cbRESULT cbSSGetStatistics(uint32_t * pnUpdateSpikes, uint32_t * pnAutoalg, uint32_t * nMode,
  1007. float * pfMinClusterPairSpreadFactor,
  1008. float * pfMaxSubclusterSpreadFactor,
  1009. float * pfMinClusterHistCorrMajMeasure,
  1010. float * pfMaxClusterPairHistCorrMajMeasure,
  1011. float * pfClusterHistValleyPercentage,
  1012. float * pfClusterHistClosePeakPercentage,
  1013. float * pfClusterHistMinPeakPercentage,
  1014. uint32_t * pnWaveBasisSize,
  1015. uint32_t * pnWaveSampleSize,
  1016. uint32_t nInstance = 0);
  1017. cbRESULT cbSSSetStatistics(uint32_t nUpdateSpikes, uint32_t nAutoalg, uint32_t nMode,
  1018. float fMinClusterPairSpreadFactor,
  1019. float fMaxSubclusterSpreadFactor,
  1020. float fMinClusterHistCorrMajMeasure,
  1021. float fMaxClusterPairHistCorrMajMeasure,
  1022. float fClusterHistValleyPercentage,
  1023. float fClusterHistClosePeakPercentage,
  1024. float fClusterHistMinPeakPercentage,
  1025. uint32_t nWaveBasisSize,
  1026. uint32_t nWaveSampleSize,
  1027. uint32_t nInstance = 0);
  1028. // Spike sorting artifact rejecting
  1029. cbRESULT cbSSGetArtifactReject(uint32_t * pnMaxChans, uint32_t * pnRefractorySamples, uint32_t nInstance = 0);
  1030. cbRESULT cbSSSetArtifactReject(uint32_t nMaxChans, uint32_t nRefractorySamples, uint32_t nInstance = 0);
  1031. // Spike detection parameters
  1032. cbRESULT cbSSGetDetect(float * pfThreshold, float * pfScaling, uint32_t nInstance = 0);
  1033. cbRESULT cbSSSetDetect(float fThreshold, float fScaling, uint32_t nInstance = 0);
  1034. #endif
  1035. // To control and keep track of how long an element of spike sorting has been adapting.
  1036. //
  1037. enum ADAPT_TYPE { ADAPT_NEVER, ADAPT_ALWAYS, ADAPT_TIMED };
  1038. typedef struct {
  1039. uint32_t nMode; // 0-do not adapt at all, 1-always adapt, 2-adapt if timer not timed out
  1040. float fTimeOutMinutes; // how many minutes until time out
  1041. float fElapsedMinutes; // the amount of time that has elapsed
  1042. #ifdef __cplusplus
  1043. void set(ADAPT_TYPE nMode, float fTimeOutMinutes)
  1044. {
  1045. this->nMode = static_cast<uint32_t>(nMode);
  1046. this->fTimeOutMinutes = fTimeOutMinutes;
  1047. }
  1048. #endif
  1049. } cbAdaptControl;
  1050. #ifdef __cplusplus
  1051. // Getting and setting spike sorting status parameters
  1052. cbRESULT cbSSGetStatus(cbAdaptControl * pcntlUnitStats, cbAdaptControl * pcntlNumUnits, uint32_t nInstance = 0);
  1053. cbRESULT cbSSSetStatus(cbAdaptControl cntlUnitStats, cbAdaptControl cntlNumUnits, uint32_t nInstance = 0);
  1054. #endif
  1055. ///////////////////////////////////////////////////////////////////////////////////////////////////
  1056. //
  1057. // Data Packet Structures (chid<0x8000)
  1058. //
  1059. ///////////////////////////////////////////////////////////////////////////////////////////////////
  1060. ////////////////////////////////////////////////////////////////////
  1061. // Declarations of firmware update packet structures and constants
  1062. // Never change anything about this packet
  1063. ////////////////////////////////////////////////////////////////////
  1064. #define cbRUNLEVEL_UPDATE 78
  1065. #define cbPKTTYPE_UPDATESET 0xF1
  1066. #define cbPKTTYPE_UPDATEREP 0x71
  1067. #define cbPKTDLEN_UPDATE (sizeof(cbPKT_UPDATE)/4)-2
  1068. typedef struct {
  1069. uint32_t time;
  1070. uint16_t chan;
  1071. uint8_t type;
  1072. uint8_t dlen;
  1073. char filename[64];
  1074. uint32_t blockseq;
  1075. uint32_t blockend;
  1076. uint32_t blocksiz;
  1077. uint8_t block[512];
  1078. } cbPKT_UPDATE;
  1079. // Sample Group data packet
  1080. typedef struct {
  1081. uint32_t time; // system clock timestamp
  1082. uint16_t chid; // 0x0000
  1083. uint8_t type; // sample group ID (1-127)
  1084. uint8_t dlen; // packet length equal
  1085. int16_t data[cbNUM_ANALOG_CHANS]; // variable length address list
  1086. } cbPKT_GROUP;
  1087. // DINP digital value data
  1088. typedef struct {
  1089. uint32_t time; // system clock timestamp
  1090. uint16_t chid; // channel identifier
  1091. uint8_t unit; // reserved
  1092. uint8_t dlen; // length of waveform in 32-bit chunks
  1093. uint32_t data[254]; // data buffer (up to 1016 bytes)
  1094. } cbPKT_DINP;
  1095. // AINP spike waveform data
  1096. // cbMAX_PNTS must be an even number
  1097. #define cbMAX_PNTS 128 // make large enough to track longest possible - spike width in samples
  1098. #define cbPKTDLEN_SPK ((sizeof(cbPKT_SPK)/4) - cbPKT_HEADER_32SIZE)
  1099. #define cbPKTDLEN_SPKSHORT (cbPKTDLEN_SPK - ((sizeof(int16_t)*cbMAX_PNTS)/4))
  1100. typedef struct {
  1101. uint32_t time; // system clock timestamp
  1102. uint16_t chid; // channel identifier
  1103. uint8_t unit; // unit identification (0=unclassified, 1-5=classified, 255=artifact, 254=background)
  1104. uint8_t dlen; // length of what follows ... always cbPKTDLEN_SPK
  1105. float fPattern[3]; // values of the pattern space (Normal uses only 2, PCA uses third)
  1106. int16_t nPeak;
  1107. int16_t nValley;
  1108. // wave must be the last item in the structure because it can be variable length to a max of cbMAX_PNTS
  1109. int16_t wave[cbMAX_PNTS]; // Room for all possible points collected
  1110. } cbPKT_SPK;
  1111. // System Heartbeat Packet (sent every 10ms)
  1112. #define cbPKTTYPE_SYSHEARTBEAT 0x00
  1113. #define cbPKTDLEN_SYSHEARTBEAT ((sizeof(cbPKT_SYSHEARTBEAT)/4) - cbPKT_HEADER_32SIZE)
  1114. typedef struct {
  1115. uint32_t time; // system clock timestamp
  1116. uint16_t chid; // 0x8000
  1117. uint8_t type; // 0
  1118. uint8_t dlen; // cbPKTDLEN_SYSHEARTBEAT
  1119. } cbPKT_SYSHEARTBEAT;
  1120. // Audio commands "val"
  1121. #define cbAUDIO_CMD_NONE 0 // PC->NPLAY query audio status
  1122. // nPlay file version (first byte NSx version, second byte NEV version)
  1123. #define cbNPLAY_FILE_NS21 1 // NSX 2.1 file
  1124. #define cbNPLAY_FILE_NS22 2 // NSX 2.2 file
  1125. #define cbNPLAY_FILE_NEV21 (1 << 8) // Nev 2.1 file
  1126. #define cbNPLAY_FILE_NEV22 (2 << 8) // Nev 2.2 file
  1127. #define cbNPLAY_FILE_NEV23 (3 << 8) // Nev 2.3 file
  1128. // nPlay commands and status changes (cbPKT_NPLAY.mode)
  1129. #define cbNPLAY_FNAME_LEN 992 // length of the file name (with terminating null)
  1130. #define cbNPLAY_MODE_NONE 0 // no command (parameters)
  1131. #define cbNPLAY_MODE_PAUSE 1 // PC->NPLAY pause if "val" is non-zero, un-pause otherwise
  1132. #define cbNPLAY_MODE_SEEK 2 // PC->NPLAY seek to time "val"
  1133. #define cbNPLAY_MODE_CONFIG 3 // PC<->NPLAY request full config
  1134. #define cbNPLAY_MODE_OPEN 4 // PC->NPLAY open new file in "val" for playback
  1135. #define cbNPLAY_MODE_PATH 5 // PC->NPLAY use the directory path in fname
  1136. #define cbNPLAY_MODE_CONFIGMAIN 6 // PC<->NPLAY request main config packet
  1137. #define cbNPLAY_MODE_STEP 7 // PC<->NPLAY run "val" procTime steps and pause, then send cbNPLAY_FLAG_STEPPED
  1138. #define cbNPLAY_MODE_SINGLE 8 // PC->NPLAY single mode if "val" is non-zero, wrap otherwise
  1139. #define cbNPLAY_MODE_RESET 9 // PC->NPLAY reset nPlay
  1140. #define cbNPLAY_MODE_NEVRESORT 10 // PC->NPLAY resort NEV if "val" is non-zero, do not if otherwise
  1141. #define cbNPLAY_MODE_AUDIO_CMD 11 // PC->NPLAY perform audio command in "val" (cbAUDIO_CMD_*), with option "opt"
  1142. #define cbNPLAY_FLAG_NONE 0x00 // no flag
  1143. #define cbNPLAY_FLAG_CONF 0x01 // NPLAY->PC config packet ("val" is "fname" file index)
  1144. #define cbNPLAY_FLAG_MAIN (0x02 | cbNPLAY_FLAG_CONF) // NPLAY->PC main config packet ("val" is file version)
  1145. #define cbNPLAY_FLAG_DONE 0x02 // NPLAY->PC step command done
  1146. // nPlay configuration packet(sent on restart together with config packet)
  1147. #define cbPKTTYPE_NPLAYREP 0x5C /* NPLAY->PC response */
  1148. #define cbPKTTYPE_NPLAYSET 0xDC /* PC->NPLAY request */
  1149. #define cbPKTDLEN_NPLAY ((sizeof(cbPKT_NPLAY)/4) - cbPKT_HEADER_32SIZE)
  1150. typedef struct {
  1151. uint32_t time; // system clock timestamp
  1152. uint16_t chid; // 0x8000
  1153. uint8_t type; // cbPKTTYPE_NPLAY*
  1154. uint8_t dlen; // cbPKTDLEN_NPLAY
  1155. union {
  1156. uint32_t ftime; // the total time of the file.
  1157. uint32_t opt; // optional value
  1158. };
  1159. uint32_t stime; // start time
  1160. uint32_t etime; // stime < end time < ftime
  1161. uint32_t val; // Used for current time to traverse, file index, file version, ...
  1162. uint16_t mode; // cbNPLAY_MODE_* command to nPlay
  1163. uint16_t flags; // cbNPLAY_FLAG_* status of nPlay
  1164. float speed; // positive means fast forward, negative means rewind, 0 means go as fast as you can.
  1165. char fname[cbNPLAY_FNAME_LEN]; // This is a String with the file name.
  1166. } cbPKT_NPLAY;
  1167. #ifdef __cplusplus
  1168. cbRESULT cbGetNplay(char *fname, float *speed, uint32_t *flags, uint32_t *ftime, uint32_t *stime, uint32_t *etime, uint32_t * filever, uint32_t nInstance = 0);
  1169. cbRESULT cbSetNplay(const char *fname, float speed, uint32_t mode, uint32_t val, uint32_t stime, uint32_t etime, uint32_t nInstance = 0);
  1170. // Get/Set the nPlay parameters.
  1171. //
  1172. // Returns: cbRESULT_OK if data successfully retrieved.
  1173. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1174. #endif
  1175. #define cbTRIGGER_MODE_UNDEFINED 0
  1176. #define cbTRIGGER_MODE_BUTTONPRESS 1 // Patient button press event
  1177. #define cbTRIGGER_MODE_EVENTRESET 2 // event reset
  1178. // Custom trigger event packet
  1179. #define cbPKTTYPE_TRIGGERREP 0x5E /* NPLAY->PC response */
  1180. #define cbPKTTYPE_TRIGGERSET 0xDE /* PC->NPLAY request */
  1181. #define cbPKTDLEN_TRIGGER ((sizeof(cbPKT_TRIGGER)/4) - cbPKT_HEADER_32SIZE)
  1182. typedef struct {
  1183. uint32_t time; // system clock timestamp
  1184. uint16_t chid; // 0x8000
  1185. uint8_t type; // cbPKTTYPE_TRIGGER*
  1186. uint8_t dlen; // cbPKTDLEN_TRIGGER
  1187. uint32_t mode; // cbTRIGGER_MODE_*
  1188. } cbPKT_TRIGGER;
  1189. // Video tracking event packet
  1190. #define cbMAX_TRACKCOORDS (128) // Maximum nimber of coordinates (must be an even number)
  1191. #define cbPKTTYPE_VIDEOTRACKREP 0x5F /* NPLAY->PC response */
  1192. #define cbPKTTYPE_VIDEOTRACKSET 0xDF /* PC->NPLAY request */
  1193. #define cbPKTDLEN_VIDEOTRACK ((sizeof(cbPKT_VIDEOTRACK)/4) - cbPKT_HEADER_32SIZE)
  1194. #define cbPKTDLEN_VIDEOTRACKSHORT (cbPKTDLEN_VIDEOTRACK - ((sizeof(uint16_t)*cbMAX_TRACKCOORDS)/4))
  1195. typedef struct {
  1196. uint32_t time; // system clock timestamp
  1197. uint16_t chid; // 0x8000
  1198. uint8_t type; // cbPKTTYPE_VIDEOTRACK*
  1199. uint8_t dlen; // cbPKTDLEN_VIDEOTRACK
  1200. uint16_t parentID; // parent ID
  1201. uint16_t nodeID; // node ID (cross-referenced in the TrackObj header)
  1202. uint16_t nodeCount; // Children count
  1203. uint16_t pointCount; // number of points at this node
  1204. // this must be the last item in the structure because it can be variable length to a max of cbMAX_TRACKCOORDS
  1205. union {
  1206. uint16_t coords[cbMAX_TRACKCOORDS];
  1207. uint32_t sizes[cbMAX_TRACKCOORDS / 2];
  1208. };
  1209. } cbPKT_VIDEOTRACK;
  1210. #define cbLOG_MODE_NONE 0 // Normal log
  1211. #define cbLOG_MODE_CRITICAL 1 // Critical log
  1212. #define cbLOG_MODE_RPC 2 // PC->NSP: Remote Procedure Call (RPC)
  1213. #define cbLOG_MODE_PLUGINFO 3 // NSP->PC: Plugin information
  1214. #define cbLOG_MODE_RPC_RES 4 // NSP->PC: Remote Procedure Call Results
  1215. #define cbLOG_MODE_PLUGINERR 5 // NSP->PC: Plugin error information
  1216. #define cbLOG_MODE_RPC_END 6 // NSP->PC: Last RPC packet
  1217. #define cbLOG_MODE_RPC_KILL 7 // PC->NSP: terminate last RPC
  1218. #define cbLOG_MODE_RPC_INPUT 8 // PC->NSP: RPC command input
  1219. #define cbLOG_MODE_UPLOAD_RES 9 // NSP->PC: Upload result
  1220. #define cbLOG_MODE_ENDPLUGIN 10 // PC->NSP: Signal the plugin to end
  1221. #define cbLOG_MODE_NSP_REBOOT 11 // PC->NSP: Reboot the NSP
  1222. // Reconfiguration log event
  1223. #define cbMAX_LOG 128 // Maximum log description
  1224. #define cbPKTTYPE_LOGREP 0x63 /* NPLAY->PC response */
  1225. #define cbPKTTYPE_LOGSET 0xE3 /* PC->NPLAY request */
  1226. #define cbPKTDLEN_LOG ((sizeof(cbPKT_LOG)/4) - cbPKT_HEADER_32SIZE)
  1227. #define cbPKTDLEN_LOGSHORT (cbPKTDLEN_LOG - ((sizeof(char)*cbMAX_LOG)/4)) // All but description
  1228. typedef struct {
  1229. uint32_t time; // system clock timestamp
  1230. uint16_t chid; // 0x8000
  1231. uint8_t type; // cbPKTTYPE_LOG*
  1232. uint8_t dlen; // cbPKTDLEN_LOG
  1233. uint16_t mode; // log mode (cbLOG_MODE_*)
  1234. char name[cbLEN_STR_LABEL]; // Logger source name (Computer name, Plugin name, ...)
  1235. char desc[cbMAX_LOG]; // description of the change (will fill the rest of the packet)
  1236. } cbPKT_LOG;
  1237. // Protocol Monitoring packet (sent periodically about every second)
  1238. #define cbPKTTYPE_SYSPROTOCOLMONITOR 0x01
  1239. #define cbPKTDLEN_SYSPROTOCOLMONITOR ((sizeof(cbPKT_SYSPROTOCOLMONITOR)/4) - cbPKT_HEADER_32SIZE)
  1240. typedef struct {
  1241. uint32_t time; // system clock timestamp
  1242. uint16_t chid; // 0x8000
  1243. uint8_t type; // 1
  1244. uint8_t dlen; // cbPKTDLEN_SYSPROTOCOLMONITOR
  1245. uint32_t sentpkts; // Packets sent since last cbPKT_SYSPROTOCOLMONITOR (or 0 if timestamp=0);
  1246. // the cbPKT_SYSPROTOCOLMONITOR packets are counted as well so this must
  1247. // be equal to at least 1
  1248. } cbPKT_SYSPROTOCOLMONITOR;
  1249. #define cbPKTTYPE_REQCONFIGALL 0x88 // request for ALL configuration information
  1250. #define cbPKTTYPE_REPCONFIGALL 0x08 // response that NSP got your request
  1251. // System Condition Report Packet
  1252. #define cbPKTTYPE_SYSREP 0x10
  1253. #define cbPKTTYPE_SYSREPSPKLEN 0x11
  1254. #define cbPKTTYPE_SYSREPRUNLEV 0x12
  1255. #define cbPKTTYPE_SYSSET 0x90
  1256. #define cbPKTTYPE_SYSSETSPKLEN 0x91
  1257. #define cbPKTTYPE_SYSSETRUNLEV 0x92
  1258. #define cbPKTDLEN_SYSINFO ((sizeof(cbPKT_SYSINFO)/4) - cbPKT_HEADER_32SIZE)
  1259. typedef struct {
  1260. uint32_t time; // system clock timestamp
  1261. uint16_t chid; // 0x8000
  1262. uint8_t type; // PKTTYPE_SYS*
  1263. uint8_t dlen; // cbPKT_SYSINFODLEN
  1264. uint32_t sysfreq; // System clock frequency in Hz
  1265. uint32_t spikelen; // The length of the spike events
  1266. uint32_t spikepre; // Spike pre-trigger samples
  1267. uint32_t resetque; // The channel for the reset to que on
  1268. uint32_t runlevel; // System runlevel
  1269. uint32_t runflags;
  1270. } cbPKT_SYSINFO;
  1271. #ifdef __cplusplus
  1272. cbRESULT cbGetSpikeLength(uint32_t *length, uint32_t *pretrig, uint32_t * pSysfreq, uint32_t nInstance = 0);
  1273. cbRESULT cbSetSpikeLength(uint32_t length, uint32_t pretrig, uint32_t nInstance = 0);
  1274. // Get/Set the system-wide spike length. Lengths should be specified in multiples of 2 and
  1275. // within the range of 16 to 128 samples long.
  1276. //
  1277. // Returns: cbRESULT_OK if data successfully retrieved.
  1278. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1279. // cbRESULT_INVALIDFUNCTION if invalid flag combinations are passed.
  1280. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1281. #endif
  1282. #define cbRUNLEVEL_STARTUP 10
  1283. #define cbRUNLEVEL_HARDRESET 20
  1284. #define cbRUNLEVEL_STANDBY 30
  1285. #define cbRUNLEVEL_RESET 40
  1286. #define cbRUNLEVEL_RUNNING 50
  1287. #define cbRUNLEVEL_STRESSED 60
  1288. #define cbRUNLEVEL_ERROR 70
  1289. #define cbRUNLEVEL_SHUTDOWN 80
  1290. #define cbRUNFLAGS_NONE 0
  1291. #define cbRUNFLAGS_LOCK 1 // Lock recording after reset
  1292. #ifdef __cplusplus
  1293. cbRESULT cbGetSystemRunLevel(uint32_t *runlevel, uint32_t *runflags, uint32_t *resetque, uint32_t nInstance = 0);
  1294. cbRESULT cbSetSystemRunLevel(uint32_t runlevel, uint32_t runflags, uint32_t resetque, uint32_t nInstance = 0);
  1295. // Get Set the System Condition
  1296. // Returns: cbRESULT_OK if data successfully retrieved.
  1297. // cbRESULT_NOLIBRARY if the library was not properly initialized
  1298. #endif
  1299. // Video/external synchronization packet.
  1300. // This packet comes from NeuroMotive through network or RS232
  1301. // then is transmitted to the Central after spike or LFP packets to stamp them.
  1302. #define cbPKTTYPE_VIDEOSYNCHREP 0x29 /* NSP->PC response */
  1303. #define cbPKTTYPE_VIDEOSYNCHSET 0xA9 /* PC->NSP request */
  1304. #define cbPKTDLEN_VIDEOSYNCH ((sizeof(cbPKT_VIDEOSYNCH)/4) - cbPKT_HEADER_32SIZE)
  1305. typedef struct {
  1306. uint32_t time; // System clock timestamp
  1307. uint16_t chid; // 0x8000
  1308. uint8_t type; // cbPKTTYPE_VIDEOSYNCH*
  1309. uint8_t dlen; // cbPKTDLEN_VIDEOSYNCH
  1310. uint16_t split; // file split number of the video file
  1311. uint32_t frame; // frame number in last video
  1312. uint32_t etime; // capture elapsed time (in milliseconds)
  1313. uint16_t id; // video source id
  1314. } cbPKT_VIDEOSYNCH;
  1315. // Comment flags
  1316. #define cbCOMMENT_FLAG_RGBA 0x00 // data is color in rgba format
  1317. #define cbCOMMENT_FLAG_TIMESTAMP 0x01 // data is the timestamp of when the comment was started
  1318. // Comment annotation packet.
  1319. #define cbMAX_COMMENT 128 // cbMAX_COMMENT must be a multiple of four
  1320. #define cbPKTTYPE_COMMENTREP 0x31 /* NSP->PC response */
  1321. #define cbPKTTYPE_COMMENTSET 0xB1 /* PC->NSP request */
  1322. #define cbPKTDLEN_COMMENT ((sizeof(cbPKT_COMMENT)/4) - cbPKT_HEADER_32SIZE)
  1323. #define cbPKTDLEN_COMMENTSHORT (cbPKTDLEN_COMMENT - ((sizeof(uint8_t)*cbMAX_COMMENT)/4))
  1324. typedef struct {
  1325. uint32_t time; // System clock timestamp
  1326. uint16_t chid; // 0x8000
  1327. uint8_t type; // cbPKTTYPE_COMMENT*
  1328. uint8_t dlen; // cbPKTDLEN_COMMENT
  1329. struct {
  1330. uint8_t charset; // Character set (0 - ANSI, 1 - UTF16, 255 - NeuroMotive ANSI)
  1331. uint8_t flags; // Can be any of cbCOMMENT_FLAG_*
  1332. uint8_t reserved[2]; // Reserved (must be 0)
  1333. } info;
  1334. uint32_t data; // depends on flags (see flags above)
  1335. char comment[cbMAX_COMMENT]; // Comment
  1336. } cbPKT_COMMENT;
  1337. #ifdef __cplusplus
  1338. cbRESULT cbSetComment(uint8_t charset, uint8_t flags, uint32_t data, const char * comment, uint32_t nInstance = 0);
  1339. // Set one comment event.
  1340. //
  1341. // Returns: cbRESULT_OK if data successfully retrieved.
  1342. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1343. #endif
  1344. // NeuroMotive status
  1345. #define cbNM_STATUS_IDLE 0 // NeuroMotive is idle
  1346. #define cbNM_STATUS_EXIT 1 // NeuroMotive is exiting
  1347. #define cbNM_STATUS_REC 2 // NeuroMotive is recording
  1348. #define cbNM_STATUS_PLAY 3 // NeuroMotive is playing video file
  1349. #define cbNM_STATUS_CAP 4 // NeuroMotive is capturing from camera
  1350. #define cbNM_STATUS_STOP 5 // NeuroMotive is stopping
  1351. #define cbNM_STATUS_PAUSED 6 // NeuroMotive is paused
  1352. #define cbNM_STATUS_COUNT 7 // This is the count of status options
  1353. // NeuroMotive commands and status changes (cbPKT_NM.mode)
  1354. #define cbNM_MODE_NONE 0
  1355. #define cbNM_MODE_CONFIG 1 // Ask NeuroMotive for configuration
  1356. #define cbNM_MODE_SETVIDEOSOURCE 2 // Configure video source
  1357. #define cbNM_MODE_SETTRACKABLE 3 // Configure trackable
  1358. #define cbNM_MODE_STATUS 4 // NeuroMotive status reporting (cbNM_STATUS_*)
  1359. #define cbNM_MODE_TSCOUNT 5 // Timestamp count (value is the period with 0 to disable this mode)
  1360. #define cbNM_MODE_SYNCHCLOCK 6 // Start (or stop) synchronization clock (fps*1000 specified by value, zero fps to stop capture)
  1361. #define cbNM_MODE_ASYNCHCLOCK 7 // Asynchronous clock
  1362. #define cbNM_FLAG_NONE 0
  1363. #define cbPKTTYPE_NMREP 0x32 /* NSP->PC response */
  1364. #define cbPKTTYPE_NMSET 0xB2 /* PC->NSP request */
  1365. #define cbPKTDLEN_NM ((sizeof(cbPKT_NM)/4) - cbPKT_HEADER_32SIZE)
  1366. typedef struct {
  1367. uint32_t time; // System clock timestamp
  1368. uint16_t chid; // 0x8000
  1369. uint8_t type; // cbPKTTYPE_NM*
  1370. uint8_t dlen; // cbPKTDLEN_NM
  1371. uint32_t mode; // cbNM_MODE_* command to NeuroMotive or Central
  1372. uint32_t flags; // cbNM_FLAG_* status of NeuroMotive
  1373. uint32_t value; // value assigned to this mode
  1374. union {
  1375. uint32_t opt[cbLEN_STR_LABEL / 4]; // Additional options for this mode
  1376. char name[cbLEN_STR_LABEL]; // name associated with this mode
  1377. };
  1378. } cbPKT_NM;
  1379. // Report Processor Information (duplicates the cbPROCINFO structure)
  1380. #define cbPKTTYPE_PROCREP 0x21
  1381. #define cbPKTDLEN_PROCINFO ((sizeof(cbPKT_PROCINFO)/4) - cbPKT_HEADER_32SIZE)
  1382. typedef struct {
  1383. uint32_t time; // system clock timestamp
  1384. uint16_t chid; // 0x8000
  1385. uint8_t type; // cbPKTTYPE_PROC*
  1386. uint8_t dlen; // cbPKT_PROCINFODLEN
  1387. uint32_t proc; // index of the bank
  1388. uint32_t idcode; // manufacturer part and rom ID code of the Signal Processor
  1389. char ident[cbLEN_STR_IDENT]; // ID string with the equipment name of the Signal Processor
  1390. uint32_t chanbase; // lowest channel number of channel id range claimed by this processor
  1391. uint32_t chancount; // number of channel identifiers claimed by this processor
  1392. uint32_t bankcount; // number of signal banks supported by the processor
  1393. uint32_t groupcount; // number of sample groups supported by the processor
  1394. uint32_t filtcount; // number of digital filters supported by the processor
  1395. uint32_t sortcount; // number of channels supported for spike sorting (reserved for future)
  1396. uint32_t unitcount; // number of supported units for spike sorting (reserved for future)
  1397. uint32_t hoopcount; // number of supported units for spike sorting (reserved for future)
  1398. uint32_t sortmethod; // sort method (0=manual, 1=automatic spike sorting)
  1399. uint32_t version; // current version of libraries
  1400. } cbPKT_PROCINFO;
  1401. #ifdef __cplusplus
  1402. cbRESULT cbGetProcInfo(uint32_t proc, cbPROCINFO *procinfo, uint32_t nInstance = 0);
  1403. // Retreives information for a the Signal Processor module located at procid
  1404. // The function requires an allocated but uninitialized cbPROCINFO structure.
  1405. //
  1406. // Returns: cbRESULT_OK if data successfully retreived.
  1407. // cbRESULT_INVALIDADDRESS if no hardware at the specified Proc and Bank address
  1408. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1409. cbRESULT cbGetChanCount(uint32_t *count, uint32_t nInstance = 0);
  1410. // Retreives the total number of channels in the system
  1411. //
  1412. // Returns: cbRESULT_OK if data successfully retreived.
  1413. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1414. #endif
  1415. // Report Bank Information (duplicates the cbBANKINFO structure)
  1416. #define cbPKTTYPE_BANKREP 0x22
  1417. #define cbPKTDLEN_BANKINFO ((sizeof(cbPKT_BANKINFO)/4) - cbPKT_HEADER_32SIZE)
  1418. typedef struct {
  1419. uint32_t time; // system clock timestamp
  1420. uint16_t chid; // 0x8000
  1421. uint8_t type; // cbPKTTYPE_BANK*
  1422. uint8_t dlen; // cbPKT_BANKINFODLEN
  1423. uint32_t proc; // the address of the processor on which the bank resides
  1424. uint32_t bank; // the address of the bank reported by the packet
  1425. uint32_t idcode; // manufacturer part and rom ID code of the module addressed to this bank
  1426. char ident[cbLEN_STR_IDENT]; // ID string with the equipment name of the Signal Bank hardware module
  1427. char label[cbLEN_STR_LABEL]; // Label on the instrument for the signal bank, eg "Analog In"
  1428. uint32_t chanbase; // lowest channel number of channel id range claimed by this bank
  1429. uint32_t chancount; // number of channel identifiers claimed by this bank
  1430. } cbPKT_BANKINFO;
  1431. #ifdef __cplusplus
  1432. cbRESULT cbGetBankInfo(uint32_t proc, uint32_t bank, cbBANKINFO *bankinfo, uint32_t nInstance = 0);
  1433. // Retreives information for the Signal bank located at bankaddr on Proc procaddr.
  1434. // The function requires an allocated but uninitialized cbBANKINFO structure.
  1435. //
  1436. // Returns: cbRESULT_OK if data successfully retreived.
  1437. // cbRESULT_INVALIDADDRESS if no hardware at the specified Proc and Bank address
  1438. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1439. #endif
  1440. // Filter (FILT) Information Packets
  1441. #define cbPKTTYPE_FILTREP 0x23
  1442. #define cbPKTTYPE_FILTSET 0xA3
  1443. #define cbPKTDLEN_FILTINFO ((sizeof(cbPKT_FILTINFO)/4) - cbPKT_HEADER_32SIZE)
  1444. typedef struct {
  1445. uint32_t time; // system clock timestamp
  1446. uint16_t chid; // 0x8000
  1447. uint8_t type; // cbPKTTYPE_GROUP*
  1448. uint8_t dlen; // packet length equal to length of list + 6 quadlets
  1449. uint32_t proc; //
  1450. uint32_t filt; //
  1451. char label[cbLEN_STR_FILT_LABEL]; //
  1452. uint32_t hpfreq; // high-pass corner frequency in milliHertz
  1453. uint32_t hporder; // high-pass filter order
  1454. uint32_t hptype; // high-pass filter type
  1455. uint32_t lpfreq; // low-pass frequency in milliHertz
  1456. uint32_t lporder; // low-pass filter order
  1457. uint32_t lptype; // low-pass filter type
  1458. // These are for sending the NSP filter info, otherwise the NSP has this stuff in NSPDefaults.c
  1459. double gain; // filter gain
  1460. double sos1a1; // filter coefficient
  1461. double sos1a2; // filter coefficient
  1462. double sos1b1; // filter coefficient
  1463. double sos1b2; // filter coefficient
  1464. double sos2a1; // filter coefficient
  1465. double sos2a2; // filter coefficient
  1466. double sos2b1; // filter coefficient
  1467. double sos2b2; // filter coefficient
  1468. } cbPKT_FILTINFO;
  1469. #ifdef __cplusplus
  1470. cbRESULT cbGetFilterDesc(uint32_t proc, uint32_t filt, cbFILTDESC *filtdesc, uint32_t nInstance = 0);
  1471. // Retreives the user filter definitions from a specific processor
  1472. // filter = 1 to cbNFILTS, 0 is reserved for the null filter case
  1473. // Returns: cbRESULT_OK if data successfully retreived.
  1474. // cbRESULT_INVALIDADDRESS if no hardware at the specified Proc and Bank address
  1475. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1476. #endif
  1477. // Factory Default settings request packet
  1478. #define cbPKTTYPE_CHANRESETREP 0x24 /* NSP->PC response...ignore all values */
  1479. #define cbPKTTYPE_CHANRESET 0xA4 /* PC->NSP request */
  1480. #define cbPKTDLEN_CHANRESET ((sizeof(cbPKT_CHANRESET) / 4) - cbPKT_HEADER_32SIZE)
  1481. typedef struct {
  1482. uint32_t time; // system clock timestamp
  1483. uint16_t chid; // 0x8000
  1484. uint8_t type; // cbPKTTYPE_AINP*
  1485. uint8_t dlen; // cbPKT_DLENCHANINFO
  1486. uint32_t chan; // actual channel id of the channel being configured
  1487. // For all of the values that follow
  1488. // 0 = NOT change value; nonzero = reset to factory defaults
  1489. uint8_t label; // Channel label
  1490. uint8_t userflags; // User flags for the channel state
  1491. uint8_t position; // reserved for future position information
  1492. uint8_t scalin; // user-defined scaling information
  1493. uint8_t scalout; // user-defined scaling information
  1494. uint8_t doutopts; // digital output options (composed of cbDOUT_* flags)
  1495. uint8_t dinpopts; // digital input options (composed of cbDINP_* flags)
  1496. uint8_t aoutopts; // analog output options
  1497. uint8_t eopchar; // the end of packet character
  1498. uint8_t monsource; // address of channel to monitor
  1499. uint8_t outvalue; // output value
  1500. uint8_t ainpopts; // analog input options (composed of cbAINP_* flags)
  1501. uint8_t lncrate; // line noise cancellation filter adaptation rate
  1502. uint8_t smpfilter; // continuous-time pathway filter id
  1503. uint8_t smpgroup; // continuous-time pathway sample group
  1504. uint8_t smpdispmin; // continuous-time pathway display factor
  1505. uint8_t smpdispmax; // continuous-time pathway display factor
  1506. uint8_t spkfilter; // spike pathway filter id
  1507. uint8_t spkdispmax; // spike pathway display factor
  1508. uint8_t lncdispmax; // Line Noise pathway display factor
  1509. uint8_t spkopts; // spike processing options
  1510. uint8_t spkthrlevel; // spike threshold level
  1511. uint8_t spkthrlimit; //
  1512. uint8_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  1513. uint8_t spkhoops; // spike hoop sorting set
  1514. } cbPKT_CHANRESET;
  1515. ///////////////////////////////////////////////////////////////////////////////////////////////////
  1516. // Adaptive filtering
  1517. #define cbPKTTYPE_ADAPTFILTREP 0x25 /* NSP->PC response...*/
  1518. #define cbPKTTYPE_ADAPTFILTSET 0xA5 /* PC->NSP request */
  1519. #define cbPKTDLEN_ADAPTFILTINFO ((sizeof(cbPKT_ADAPTFILTINFO) / 4) - cbPKT_HEADER_32SIZE)
  1520. // These are the adaptive filter settings
  1521. #define ADAPT_FILT_DISABLED 0
  1522. #define ADAPT_FILT_ALL 1
  1523. #define ADAPT_FILT_SPIKES 2
  1524. typedef struct {
  1525. uint32_t time; // system clock timestamp
  1526. uint16_t chid; // 0x8000
  1527. uint8_t type; // cbPKTTYPE_ADAPTFILTSET or cbPKTTYPE_ADAPTFILTREP
  1528. uint8_t dlen; // cbPKTDLEN_ADAPTFILTINFO
  1529. uint32_t chan; // Ignored
  1530. uint32_t nMode; // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1531. float dLearningRate; // speed at which adaptation happens. Very small. e.g. 5e-12
  1532. uint32_t nRefChan1; // The first reference channel (1 based).
  1533. uint32_t nRefChan2; // The second reference channel (1 based).
  1534. } cbPKT_ADAPTFILTINFO; // The packet....look below vvvvvvvv
  1535. #ifdef __cplusplus
  1536. // Tell me about the current adaptive filter settings
  1537. cbRESULT cbGetAdaptFilter(uint32_t proc, // which NSP processor?
  1538. uint32_t * pnMode, // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1539. float * pdLearningRate, // speed at which adaptation happens. Very small. e.g. 5e-12
  1540. uint32_t * pnRefChan1, // The first reference channel (1 based).
  1541. uint32_t * pnRefChan2, // The second reference channel (1 based).
  1542. uint32_t nInstance = 0);
  1543. // Update the adaptive filter settings
  1544. cbRESULT cbSetAdaptFilter(uint32_t proc, // which NSP processor?
  1545. uint32_t * pnMode, // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1546. float * pdLearningRate, // speed at which adaptation happens. Very small. e.g. 5e-12
  1547. uint32_t * pnRefChan1, // The first reference channel (1 based).
  1548. uint32_t * pnRefChan2, // The second reference channel (1 based).
  1549. uint32_t nInstance = 0);
  1550. // Useful for creating cbPKT_ADAPTFILTINFO packets
  1551. struct PktAdaptFiltInfo : public cbPKT_ADAPTFILTINFO
  1552. {
  1553. PktAdaptFiltInfo(uint32_t nMode, float dLearningRate, uint32_t nRefChan1, uint32_t nRefChan2)
  1554. {
  1555. this->chid = 0x8000;
  1556. this->type = cbPKTTYPE_ADAPTFILTSET;
  1557. this->dlen = cbPKTDLEN_ADAPTFILTINFO;
  1558. this->nMode = nMode;
  1559. this->dLearningRate = dLearningRate;
  1560. this->nRefChan1 = nRefChan1;
  1561. this->nRefChan2 = nRefChan2;
  1562. };
  1563. };
  1564. #endif
  1565. ///////////////////////////////////////////////////////////////////////////////////////////////////
  1566. // Reference Electrode filtering
  1567. #define cbPKTTYPE_REFELECFILTREP 0x26 /* NSP->PC response...*/
  1568. #define cbPKTTYPE_REFELECFILTSET 0xA6 /* PC->NSP request */
  1569. #define cbPKTDLEN_REFELECFILTINFO ((sizeof(cbPKT_REFELECFILTINFO) / 4) - cbPKT_HEADER_32SIZE)
  1570. // These are the reference electrode filter settings
  1571. #define REFELEC_FILT_DISABLED 0
  1572. #define REFELEC_FILT_ALL 1
  1573. #define REFELEC_FILT_SPIKES 2
  1574. typedef struct {
  1575. uint32_t time; // system clock timestamp
  1576. uint16_t chid; // 0x8000
  1577. uint8_t type; // cbPKTTYPE_REFELECFILTSET or cbPKTTYPE_REFELECFILTREP
  1578. uint8_t dlen; // cbPKTDLEN_REFELECFILTINFO
  1579. uint32_t chan; // Ignored
  1580. uint32_t nMode; // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1581. uint32_t nRefChan; // The reference channel (1 based).
  1582. #ifdef __cplusplus
  1583. void set(uint32_t nMode, uint32_t nRefChan)
  1584. {
  1585. chid = cbPKTCHAN_CONFIGURATION;
  1586. type = cbPKTTYPE_REFELECFILTSET;
  1587. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  1588. this->nMode = nMode;
  1589. this->nRefChan = nRefChan;
  1590. }
  1591. #endif
  1592. } cbPKT_REFELECFILTINFO; // The packet
  1593. #ifdef __cplusplus
  1594. // Tell me about the current reference electrode filter settings
  1595. cbRESULT cbGetRefElecFilter(uint32_t proc, // which NSP processor?
  1596. uint32_t * pnMode, // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1597. uint32_t * pnRefChan, // The reference channel (1 based).
  1598. uint32_t nInstance = 0);
  1599. // Update the reference electrode filter settings
  1600. cbRESULT cbSetRefElecFilter(uint32_t proc, // which NSP processor?
  1601. uint32_t * pnMode, // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  1602. uint32_t * pnRefChan, // The reference channel (1 based).
  1603. uint32_t nInstance = 0);
  1604. #endif
  1605. // NTrode Information Packets
  1606. #define cbNTRODEINFO_FS_PEAK 0 // Ntrode peak feature space
  1607. #define cbNTRODEINFO_FS_VALLEY 1 // Ntrode valley feature space
  1608. #define cbPKTTYPE_REPNTRODEINFO 0x27 /* NSP->PC response...*/
  1609. #define cbPKTTYPE_SETNTRODEINFO 0xA7 /* PC->NSP request */
  1610. #define cbPKTDLEN_NTRODEINFO ((sizeof(cbPKT_NTRODEINFO) / 4) - cbPKT_HEADER_32SIZE)
  1611. typedef struct {
  1612. uint32_t time; // system clock timestamp
  1613. uint16_t chid; // 0x8000
  1614. uint8_t type; // cbPKTTYPE_REPNTRODEINFO or cbPKTTYPE_SETNTRODEINFO
  1615. uint8_t dlen; // cbPKTDLEN_NTRODEGRPINFO
  1616. uint32_t ntrode; // ntrode with which we are working (1-based)
  1617. char label[cbLEN_STR_LABEL]; // Label of the Ntrode (null terminated if < 16 characters)
  1618. cbMANUALUNITMAPPING ellipses[cbMAXSITEPLOTS][cbMAXUNITS]; // unit mapping
  1619. uint16_t nSite; // number channels in this NTrode ( 0 <= nSite <= cbMAXSITES)
  1620. uint16_t fs; // NTrode feature space cbNTRODEINFO_FS_*
  1621. uint16_t nChan[cbMAXSITES]; // group of channels in this NTrode
  1622. #ifdef __cplusplus
  1623. void set(uint32_t ntrode, char label[cbLEN_STR_LABEL])
  1624. {
  1625. chid = cbPKTCHAN_CONFIGURATION;
  1626. type = cbPKTTYPE_SETNTRODEINFO;
  1627. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  1628. this->ntrode = ntrode;
  1629. memcpy(this->label, label, sizeof(this->label));
  1630. memset(this->ellipses, 0, sizeof(ellipses));
  1631. }
  1632. #endif
  1633. } cbPKT_NTRODEINFO; // ntrode information packet
  1634. #ifdef __cplusplus
  1635. cbRESULT cbGetNTrodeInfo( const uint32_t ntrode, char *label, cbMANUALUNITMAPPING ellipses[][cbMAXUNITS], uint16_t * nSite, uint16_t * chans, uint16_t * fs, uint32_t nInstance = 0);
  1636. cbRESULT cbSetNTrodeInfo( const uint32_t ntrode, const char *label, cbMANUALUNITMAPPING ellipses[][cbMAXUNITS], uint16_t fs, uint32_t nInstance = 0);
  1637. #endif
  1638. // Sample Group (GROUP) Information Packets
  1639. #define cbPKTTYPE_GROUPREP 0x30 // (lower 7bits=ppppggg)
  1640. #define cbPKTTYPE_GROUPSET 0xB0
  1641. #define cbPKTDLEN_GROUPINFO ((sizeof(cbPKT_GROUPINFO)/4) - cbPKT_HEADER_32SIZE)
  1642. #define cbPKTDLEN_GROUPINFOSHORT (8) // basic length without list
  1643. typedef struct {
  1644. uint32_t time; // system clock timestamp
  1645. uint16_t chid; // 0x8000
  1646. uint8_t type; // cbPKTTYPE_GROUP*
  1647. uint8_t dlen; // packet length equal to length of list + 6 quadlets
  1648. uint32_t proc; //
  1649. uint32_t group; //
  1650. char label[cbLEN_STR_LABEL]; // sampling group label
  1651. uint32_t period; // sampling period for the group
  1652. uint32_t length; //
  1653. uint32_t list[cbNUM_ANALOG_CHANS]; // variable length list. The max size is
  1654. // the total number of analog channels
  1655. } cbPKT_GROUPINFO;
  1656. #ifdef __cplusplus
  1657. cbRESULT cbGetSampleGroupInfo(uint32_t proc, uint32_t group, char *label, uint32_t *period, uint32_t *length, uint32_t nInstance = 0);
  1658. cbRESULT cbGetSampleGroupList(uint32_t proc, uint32_t group, uint32_t *length, uint32_t *list, uint32_t nInstance = 0);
  1659. cbRESULT cbSetSampleGroupOptions(uint32_t proc, uint32_t group, uint32_t period, char *label, uint32_t nInstance = 0);
  1660. // Retreives the Sample Group information in a processor and their definitions
  1661. // Labels are 16-characters maximum.
  1662. //
  1663. // Returns: cbRESULT_OK if data successfully retreived.
  1664. // cbRESULT_INVALIDADDRESS if no hardware at the specified Proc and Bank address
  1665. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1666. #endif
  1667. // Analog Input (AINP) Information Packets
  1668. #define cbPKTTYPE_CHANREP 0x40
  1669. #define cbPKTTYPE_CHANREPLABEL 0x41
  1670. #define cbPKTTYPE_CHANREPSCALE 0x42
  1671. #define cbPKTTYPE_CHANREPDOUT 0x43
  1672. #define cbPKTTYPE_CHANREPDINP 0x44
  1673. #define cbPKTTYPE_CHANREPAOUT 0x45
  1674. #define cbPKTTYPE_CHANREPDISP 0x46
  1675. #define cbPKTTYPE_CHANREPAINP 0x47
  1676. #define cbPKTTYPE_CHANREPSMP 0x48
  1677. #define cbPKTTYPE_CHANREPSPK 0x49
  1678. #define cbPKTTYPE_CHANREPSPKTHR 0x4A
  1679. #define cbPKTTYPE_CHANREPSPKHPS 0x4B
  1680. #define cbPKTTYPE_CHANREPUNITOVERRIDES 0x4C
  1681. #define cbPKTTYPE_CHANREPNTRODEGROUP 0x4D
  1682. #define cbPKTTYPE_CHANREPREJECTAMPLITUDE 0x4E
  1683. #define cbPKTTYPE_CHANREPAUTOTHRESHOLD 0x4F
  1684. #define cbPKTTYPE_CHANSET 0xC0
  1685. #define cbPKTTYPE_CHANSETLABEL 0xC1
  1686. #define cbPKTTYPE_CHANSETSCALE 0xC2
  1687. #define cbPKTTYPE_CHANSETDOUT 0xC3
  1688. #define cbPKTTYPE_CHANSETDINP 0xC4
  1689. #define cbPKTTYPE_CHANSETAOUT 0xC5
  1690. #define cbPKTTYPE_CHANSETDISP 0xC6
  1691. #define cbPKTTYPE_CHANSETAINP 0xC7
  1692. #define cbPKTTYPE_CHANSETSMP 0xC8
  1693. #define cbPKTTYPE_CHANSETSPK 0xC9
  1694. #define cbPKTTYPE_CHANSETSPKTHR 0xCA
  1695. #define cbPKTTYPE_CHANSETSPKHPS 0xCB
  1696. #define cbPKTTYPE_CHANSETUNITOVERRIDES 0xCC
  1697. #define cbPKTTYPE_CHANSETNTRODEGROUP 0xCD
  1698. #define cbPKTTYPE_CHANSETREJECTAMPLITUDE 0xCE
  1699. #define cbPKTTYPE_CHANSETAUTOTHRESHOLD 0xCF
  1700. #define cbPKTDLEN_CHANINFO ((sizeof(cbPKT_CHANINFO)/4) - cbPKT_HEADER_32SIZE)
  1701. #define cbPKTDLEN_CHANINFOSHORT (cbPKTDLEN_CHANINFO - ((sizeof(cbHOOP)*cbMAXUNITS*cbMAXHOOPS)/4))
  1702. typedef struct {
  1703. uint32_t time; // system clock timestamp
  1704. uint16_t chid; // 0x8000
  1705. uint8_t type; // cbPKTTYPE_AINP*
  1706. uint8_t dlen; // cbPKT_DLENCHANINFO
  1707. uint32_t chan; // actual channel id of the channel being configured
  1708. uint32_t proc; // the address of the processor on which the channel resides
  1709. uint32_t bank; // the address of the bank on which the channel resides
  1710. uint32_t term; // the terminal number of the channel within it's bank
  1711. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  1712. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  1713. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  1714. uint32_t aoutcaps; // analog output capablities (composed of cbAOUT_* flags)
  1715. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  1716. uint32_t spkcaps; // spike processing capabilities
  1717. cbSCALING physcalin; // physical channel scaling information
  1718. cbFILTDESC phyfiltin; // physical channel filter definition
  1719. cbSCALING physcalout; // physical channel scaling information
  1720. cbFILTDESC phyfiltout; // physical channel filter definition
  1721. char label[cbLEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  1722. uint32_t userflags; // User flags for the channel state
  1723. int32_t position[4]; // reserved for future position information
  1724. cbSCALING scalin; // user-defined scaling information for AINP
  1725. cbSCALING scalout; // user-defined scaling information for AOUT
  1726. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  1727. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  1728. uint32_t aoutopts; // analog output options
  1729. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  1730. union {
  1731. struct {
  1732. uint32_t monsource; // address of channel to monitor
  1733. int32_t outvalue; // output value
  1734. };
  1735. struct {
  1736. uint16_t lowsamples; // address of channel to monitor
  1737. uint16_t highsamples; // address of channel to monitor
  1738. int32_t offset; // output value
  1739. };
  1740. };
  1741. uint8_t trigtype; // trigger type (see cbDOUT_TRIGGER_*)
  1742. uint16_t trigchan; // trigger channel
  1743. uint16_t trigval; // trigger value
  1744. uint32_t ainpopts; // analog input options (composed of cbAINP* flags)
  1745. uint32_t lncrate; // line noise cancellation filter adaptation rate
  1746. uint32_t smpfilter; // continuous-time pathway filter id
  1747. uint32_t smpgroup; // continuous-time pathway sample group
  1748. int32_t smpdispmin; // continuous-time pathway display factor
  1749. int32_t smpdispmax; // continuous-time pathway display factor
  1750. uint32_t spkfilter; // spike pathway filter id
  1751. int32_t spkdispmax; // spike pathway display factor
  1752. int32_t lncdispmax; // Line Noise pathway display factor
  1753. uint32_t spkopts; // spike processing options
  1754. int32_t spkthrlevel; // spike threshold level
  1755. int32_t spkthrlimit; //
  1756. uint32_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  1757. int16_t amplrejpos; // Amplitude rejection positive value
  1758. int16_t amplrejneg; // Amplitude rejection negative value
  1759. uint32_t refelecchan; // Software reference electrode channel
  1760. cbMANUALUNITMAPPING unitmapping[cbMAXUNITS]; // manual unit mapping
  1761. cbHOOP spkhoops[cbMAXUNITS][cbMAXHOOPS]; // spike hoop sorting set
  1762. } cbPKT_CHANINFO;
  1763. #ifdef __cplusplus
  1764. cbRESULT cbGetChanInfo(uint32_t chan, cbPKT_CHANINFO *pChanInfo, uint32_t nInstance = 0);
  1765. // Get the full channel config.
  1766. //
  1767. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1768. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1769. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1770. cbRESULT cbGetChanAmplitudeReject(uint32_t chan, cbAMPLITUDEREJECT *AmplitudeReject, uint32_t nInstance = 0);
  1771. cbRESULT cbSetChanAmplitudeReject(uint32_t chan, const cbAMPLITUDEREJECT AmplitudeReject, uint32_t nInstance = 0);
  1772. // Get and Set the user-assigned amplitude reject values.
  1773. //
  1774. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1775. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1776. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1777. cbRESULT cbGetChanAutoThreshold(uint32_t chan, uint32_t *bEnabled, uint32_t nInstance = 0);
  1778. cbRESULT cbSetChanAutoThreshold(uint32_t chan, const uint32_t bEnabled, uint32_t nInstance = 0);
  1779. // Get and Set the user-assigned auto threshold option
  1780. //
  1781. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1782. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1783. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1784. cbRESULT cbGetChanUnitMapping( uint32_t chan, cbMANUALUNITMAPPING *unitmapping, uint32_t nInstance = 0);
  1785. cbRESULT cbSetChanUnitMapping( uint32_t chan, cbMANUALUNITMAPPING *unitmapping, uint32_t nInstance = 0);
  1786. // Get and Set the user-assigned unit override for the channel.
  1787. //
  1788. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1789. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1790. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1791. cbRESULT cbGetChanLoc(uint32_t chan, uint32_t *proc, uint32_t *bank, char *banklabel, uint32_t *term, uint32_t nInstance = 0);
  1792. // Gives the physical processor number, bank label, and terminal number of the specified channel
  1793. // by reading the configuration data in the Central App Cache. Bank Labels are the name of the
  1794. // bank that is written on the instrument and they are null-terminated, up to 16 char long.
  1795. //
  1796. // Returns: cbRESULT_OK if all is ok
  1797. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1798. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1799. // flags for user flags...no effect on the cerebus
  1800. //#define cbUSER_DISABLED 0x00000001 // Channel should be electrically disabled
  1801. //#define cbUSER_EXPERIMENT 0x00000100 // Channel used for experiment environment information
  1802. //#define cbUSER_NEURAL 0x00000200 // Channel connected to neural electrode or signal
  1803. cbRESULT cbGetChanLabel(uint32_t chan, char *label, uint32_t *userflags, int32_t *position, uint32_t nInstance = 0);
  1804. cbRESULT cbSetChanLabel(uint32_t chan, const char *label, uint32_t userflags, int32_t *position, uint32_t nInstance = 0);
  1805. // Get and Set the user-assigned label for the channel. Channel Names may be up to 16 chars long
  1806. // and should be null terminated if shorter.
  1807. //
  1808. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1809. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1810. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1811. cbRESULT cbGetChanNTrodeGroup(uint32_t chan, uint32_t *NTrodeGroup, uint32_t nInstance = 0);
  1812. cbRESULT cbSetChanNTrodeGroup(uint32_t chan, const uint32_t NTrodeGroup, uint32_t nInstance = 0);
  1813. // Get and Set the user-assigned label for the N-Trode. N-Trode Names may be up to 16 chars long
  1814. // and should be null terminated if shorter.
  1815. //
  1816. // Returns: cbRESULT_OK if data successfully retreived or packet successfully queued to be sent.
  1817. // cbRESULT_INVALIDCHANNEL if the specified channel is not mapped or does not exist.
  1818. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1819. #endif
  1820. /////////////////////////////////////////////////////////////////////////////////
  1821. // These are part of the "reflected" mechanism. They go out as type 0xE? and come
  1822. // Back in as type 0x6?
  1823. #define cbPKTTYPE_MASKED_REFLECTED 0xE0
  1824. #define cbPKTTYPE_COMPARE_MASK_REFLECTED 0xF0
  1825. #define cbPKTTYPE_REFLECTED_CONVERSION_MASK 0x7F
  1826. // Packet which says that these channels are now selected
  1827. typedef struct _cbPKT_UNIT_SELECTION
  1828. {
  1829. uint32_t time; // system clock timestamp
  1830. uint16_t chid; // 0x8000
  1831. uint8_t type; //
  1832. uint8_t dlen; // How many dwords follow......end of standard header
  1833. int32_t lastchan; // Which channel was clicked last.
  1834. uint16_t abyUnitSelections[cbMAXCHANS]; // one for each channel, channels are 0 based here
  1835. #ifdef __cplusplus
  1836. // Inputs:
  1837. // ulastchan = 0 based channel that was most recently selected
  1838. _cbPKT_UNIT_SELECTION(int16_t iLastchan = 1) :
  1839. chid(0x8000),
  1840. type(TYPE_OUTGOING),
  1841. lastchan(iLastchan)
  1842. {
  1843. // Can't use 'this' in a member-initialization
  1844. dlen = sizeof(*this) / 4 - cbPKT_HEADER_32SIZE;
  1845. memset(abyUnitSelections, 0, sizeof(abyUnitSelections));
  1846. }
  1847. // These are the packet type constants
  1848. enum { TYPE_OUTGOING = 0xE2 }; // Goes out like this
  1849. enum { TYPE_INCOMING = 0x62 }; // Comes back in like this after "reflection"
  1850. // These are the masks for use with abyUnitSelections
  1851. enum
  1852. {
  1853. UNIT_UNCLASS_MASK = 0x01, // mask to use to say unclassified units are selected
  1854. UNIT_1_MASK = 0x02, // mask to use to say unit 1 is selected
  1855. UNIT_2_MASK = 0x04, // mask to use to say unit 2 is selected
  1856. UNIT_3_MASK = 0x08, // mask to use to say unit 3 is selected
  1857. UNIT_4_MASK = 0x10, // mask to use to say unit 4 is selected
  1858. UNIT_5_MASK = 0x20, // mask to use to say unit 5 is selected
  1859. CONTINUOUS_MASK = 0x40, // mask to use to say the continuous signal is selected
  1860. UNIT_ALL_MASK = UNIT_UNCLASS_MASK |
  1861. UNIT_1_MASK | // This means the channel is completely selected
  1862. UNIT_2_MASK |
  1863. UNIT_3_MASK |
  1864. UNIT_4_MASK |
  1865. UNIT_5_MASK |
  1866. CONTINUOUS_MASK,
  1867. };
  1868. static int UnitToUnitmask(int nUnit) { return 1 << nUnit; }
  1869. #endif
  1870. } cbPKT_UNIT_SELECTION;
  1871. #ifdef __cplusplus
  1872. cbRESULT cbGetChannelSelection(cbPKT_UNIT_SELECTION * pPktUnitSel, uint32_t nInstance = 0);
  1873. // Retreives the channel unit selection status
  1874. // Returns: cbRESULT_OK if data successfully retreived.
  1875. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1876. #endif
  1877. // file config options
  1878. #define cbFILECFG_OPT_NONE 0x00000000 // Launch File dialog, set file info, start or stop recording
  1879. #define cbFILECFG_OPT_KEEPALIVE 0x00000001 // Keep-alive message
  1880. #define cbFILECFG_OPT_REC 0x00000002 // Recording is in progress
  1881. #define cbFILECFG_OPT_STOP 0x00000003 // Recording stopped
  1882. #define cbFILECFG_OPT_NMREC 0x00000004 // NeuroMotive recording status
  1883. #define cbFILECFG_OPT_CLOSE 0x00000005 // Close file application
  1884. #define cbFILECFG_OPT_SYNCH 0x00000006 // Recording datetime
  1885. #define cbFILECFG_OPT_OPEN 0x00000007 // Launch File dialog, do not set or do anything
  1886. // file save configuration packet
  1887. #define cbPKTTYPE_REPFILECFG 0x61
  1888. #define cbPKTTYPE_SETFILECFG 0xE1
  1889. #define cbPKTDLEN_FILECFG ((sizeof(cbPKT_FILECFG)/4) - cbPKT_HEADER_32SIZE)
  1890. #define cbPKTDLEN_FILECFGSHORT (cbPKTDLEN_FILECFG - ((sizeof(char)*3*256)/4)) // used for keep-alive messages
  1891. typedef struct {
  1892. uint32_t time; // system clock timestamp
  1893. uint16_t chid; // 0x8000
  1894. uint8_t type;
  1895. uint8_t dlen;
  1896. uint32_t options; // cbFILECFG_OPT_*
  1897. uint32_t duration;
  1898. uint32_t recording; // If cbFILECFG_OPT_NONE this option starts/stops recording remotely
  1899. uint32_t extctrl; // If cbFILECFG_OPT_REC this is split number (0 for non-TOC)
  1900. // If cbFILECFG_OPT_STOP this is error code (0 means no error)
  1901. char username[256];
  1902. union {
  1903. char filename[256];
  1904. char datetime[256];
  1905. };
  1906. char comment[256];
  1907. } cbPKT_FILECFG;
  1908. #ifdef __cplusplus
  1909. cbRESULT cbGetFileInfo(cbPKT_FILECFG * filecfg, uint32_t nInstance = 0);
  1910. // Retreives the file recordign status
  1911. // Returns: cbRESULT_OK if data successfully retreived.
  1912. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  1913. #endif
  1914. // Patient information for recording file
  1915. #define cbMAX_PATIENTSTRING 128 //
  1916. #define cbPKTTYPE_REPPATIENTINFO 0x64
  1917. #define cbPKTTYPE_SETPATIENTINFO 0xE4
  1918. #define cbPKTDLEN_PATIENTINFO ((sizeof(cbPKT_PATIENTINFO)/4) - cbPKT_HEADER_32SIZE)
  1919. typedef struct {
  1920. uint32_t time; // system clock timestamp
  1921. uint16_t chid; // 0x8000
  1922. uint8_t type; // cbPKTTYPE_SETPATIENTINFO
  1923. uint8_t dlen;
  1924. char ID[cbMAX_PATIENTSTRING];
  1925. char firstname[cbMAX_PATIENTSTRING];
  1926. char lastname[cbMAX_PATIENTSTRING];
  1927. uint32_t DOBMonth;
  1928. uint32_t DOBDay;
  1929. uint32_t DOBYear;
  1930. } cbPKT_PATIENTINFO;
  1931. // Calculated Impedance data packet
  1932. #define cbPKTTYPE_REPIMPEDANCE 0x65
  1933. #define cbPKTTYPE_SETIMPEDANCE 0xE5
  1934. #define cbPKTDLEN_IMPEDANCE ((sizeof(cbPKT_IMPEDANCE)/4) - cbPKT_HEADER_32SIZE)
  1935. typedef struct {
  1936. uint32_t time; // system clock timestamp
  1937. uint16_t chid; // 0x8000
  1938. uint8_t type; // E5
  1939. uint8_t dlen; // packet length equal
  1940. float data[cbNUM_FE_CHANS]; // variable length address list
  1941. } cbPKT_IMPEDANCE;
  1942. // Poll packet command
  1943. #define cbPOLL_MODE_NONE 0 // no command (parameters)
  1944. #define cbPOLL_MODE_APPSTATUS 1 // Poll or response to poll about the status of an application
  1945. // Poll packet status flags
  1946. #define cbPOLL_FLAG_NONE 0 // no flag (parameters)
  1947. #define cbPOLL_FLAG_RESPONSE 1 // Response to the query
  1948. // Extra information
  1949. #define cbPOLL_EXT_NONE 0 // No extra information
  1950. #define cbPOLL_EXT_EXISTS 1 // App exists
  1951. #define cbPOLL_EXT_RUNNING 2 // App is running
  1952. // poll applications to determine different states
  1953. // Central will return if an application exists (and is running)
  1954. #define cbPKTTYPE_REPPOLL 0x67
  1955. #define cbPKTTYPE_SETPOLL 0xE7
  1956. #define cbPKTDLEN_POLL ((sizeof(cbPKT_POLL)/4) - cbPKT_HEADER_32SIZE)
  1957. typedef struct {
  1958. uint32_t time; // system clock timestamp
  1959. uint16_t chid; // 0x8000
  1960. uint8_t type; // E7
  1961. uint8_t dlen; // packet length equal
  1962. uint32_t mode; // any of cbPOLL_MODE_* commands
  1963. uint32_t flags; // any of the cbPOLL_FLAG_* status
  1964. uint32_t extra; // Extra parameters depending on flags and mode
  1965. char appname[32]; // name of program to apply command specified by mode
  1966. char username[256]; // return your computername
  1967. uint32_t res[32]; // reserved for the future
  1968. } cbPKT_POLL;
  1969. // initiate impedance check
  1970. #define cbPKTTYPE_REPINITIMPEDANCE 0x66
  1971. #define cbPKTTYPE_SETINITIMPEDANCE 0xE6
  1972. #define cbPKTDLEN_INITIMPEDANCE ((sizeof(cbPKT_INITIMPEDANCE)/4) - cbPKT_HEADER_32SIZE)
  1973. typedef struct {
  1974. uint32_t time; // system clock timestamp
  1975. uint16_t chid; // 0x8000
  1976. uint8_t type; // E6
  1977. uint8_t dlen; // packet length equal
  1978. uint32_t initiate; // on set call -> 1 to start autoimpedance
  1979. // on response -> 1 initiated
  1980. } cbPKT_INITIMPEDANCE;
  1981. // file save configuration packet
  1982. #define cbPKTTYPE_REPMAPFILE 0x68
  1983. #define cbPKTTYPE_SETMAPFILE 0xE8
  1984. #define cbPKTDLEN_MAPFILE ((sizeof(cbPKT_MAPFILE)/4) - cbPKT_HEADER_32SIZE)
  1985. typedef struct {
  1986. uint32_t time; // system clock timestamp
  1987. uint16_t chid; // 0x8000
  1988. uint8_t type;
  1989. uint8_t dlen;
  1990. char filename[512];
  1991. #ifdef __cplusplus
  1992. void set(const char *szMapFilename)
  1993. {
  1994. chid = cbPKTCHAN_CONFIGURATION;
  1995. type = cbPKTTYPE_SETMAPFILE;
  1996. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  1997. memset(filename, 0, sizeof(filename));
  1998. strncpy(filename, szMapFilename, sizeof(filename));
  1999. }
  2000. #endif
  2001. } cbPKT_MAPFILE;
  2002. //-----------------------------------------------------
  2003. ///// Packets to tell me about the spike sorting model
  2004. // This packet says, "Give me all of the model". In response, you will get a series of cbPKTTYPE_MODELREP
  2005. //
  2006. #define cbPKTTYPE_SS_MODELALLREP 0x50 /* NSP->PC response */
  2007. #define cbPKTTYPE_SS_MODELALLSET 0xD0 /* PC->NSP request */
  2008. #define cbPKTDLEN_SS_MODELALLSET ((sizeof(cbPKT_SS_MODELALLSET) / 4) - cbPKT_HEADER_32SIZE)
  2009. typedef struct {
  2010. uint32_t time; // system clock timestamp
  2011. uint16_t chid; // 0x8000
  2012. uint8_t type; // cbPKTTYPE_MODELALLSET or cbPKTTYPE_MODELALLREP depending on the direction
  2013. uint8_t dlen; // 0
  2014. } cbPKT_SS_MODELALLSET;
  2015. //
  2016. #define cbPKTTYPE_SS_MODELREP 0x51 /* NSP->PC response */
  2017. #define cbPKTTYPE_SS_MODELSET 0xD1 /* PC->NSP request */
  2018. #define cbPKTDLEN_SS_MODELSET ((sizeof(cbPKT_SS_MODELSET) / 4) - cbPKT_HEADER_32SIZE)
  2019. #define MAX_REPEL_POINTS 3
  2020. typedef struct {
  2021. uint32_t time; // system clock timestamp
  2022. uint16_t chid; // 0x8000
  2023. uint8_t type; // cbPKTTYPE_SS_MODELREP or cbPKTTYPE_SS_MODELSET depending on the direction
  2024. uint8_t dlen; // cbPKTDLEN_SS_MODELSET
  2025. uint32_t chan; // actual channel id of the channel being configured (0 based)
  2026. uint32_t unit_number; // unit label (0 based, 0 is noise cluster)
  2027. uint32_t valid; // 1 = valid unit, 0 = not a unit, in other words just deleted when NSP -> PC
  2028. uint32_t inverted; // 0 = not inverted, 1 = inverted
  2029. // Block statistics (change from block to block)
  2030. int32_t num_samples; // non-zero value means that the block stats are valid
  2031. float mu_x[2];
  2032. float Sigma_x[2][2];
  2033. float determinant_Sigma_x;
  2034. ///// Only needed if we are using a Bayesian classification model
  2035. float Sigma_x_inv[2][2];
  2036. float log_determinant_Sigma_x;
  2037. /////
  2038. float subcluster_spread_factor_numerator;
  2039. float subcluster_spread_factor_denominator;
  2040. float mu_e;
  2041. float sigma_e_squared;
  2042. } cbPKT_SS_MODELSET;
  2043. // This packet contains the options for the automatic spike sorting.
  2044. //
  2045. #define cbPKTTYPE_SS_DETECTREP 0x52 /* NSP->PC response */
  2046. #define cbPKTTYPE_SS_DETECTSET 0xD2 /* PC->NSP request */
  2047. #define cbPKTDLEN_SS_DETECT ((sizeof(cbPKT_SS_DETECT) / 4) - cbPKT_HEADER_32SIZE)
  2048. typedef struct {
  2049. uint32_t time; // system clock timestamp
  2050. uint16_t chid; // 0x8000
  2051. uint8_t type; // cbPKTTYPE_SS_DETECTREP or cbPKTTYPE_SS_DETECTSET depending on the direction
  2052. uint8_t dlen; // cbPKTDLEN_SS_DETECT
  2053. float fThreshold; // current detection threshold
  2054. float fMultiplier; // multiplier
  2055. #ifdef __cplusplus
  2056. void set(float fThreshold, float fMultiplier)
  2057. {
  2058. chid = cbPKTCHAN_CONFIGURATION;
  2059. type = cbPKTTYPE_SS_DETECTSET;
  2060. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2061. this->fThreshold = fThreshold;
  2062. this->fMultiplier = fMultiplier;
  2063. }
  2064. #endif
  2065. } cbPKT_SS_DETECT;
  2066. // Options for artifact rejecting
  2067. //
  2068. #define cbPKTTYPE_SS_ARTIF_REJECTREP 0x53 /* NSP->PC response */
  2069. #define cbPKTTYPE_SS_ARTIF_REJECTSET 0xD3 /* PC->NSP request */
  2070. #define cbPKTDLEN_SS_ARTIF_REJECT ((sizeof(cbPKT_SS_ARTIF_REJECT) / 4) - cbPKT_HEADER_32SIZE)
  2071. typedef struct {
  2072. uint32_t time; // system clock timestamp
  2073. uint16_t chid; // 0x8000
  2074. uint8_t type; // cbPKTTYPE_SS_ARTIF_REJECTREP or cbPKTTYPE_SS_ARTIF_REJECTSET depending on the direction
  2075. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  2076. uint32_t nMaxSimulChans; // how many channels can fire exactly at the same time???
  2077. uint32_t nRefractoryCount; // for how many samples (30 kHz) is a neuron refractory, so can't re-trigger
  2078. #ifdef __cplusplus
  2079. void set(uint32_t nMaxSimulChans, uint32_t nRefractoryCount)
  2080. {
  2081. chid = cbPKTCHAN_CONFIGURATION;
  2082. type = cbPKTTYPE_SS_ARTIF_REJECTSET;
  2083. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2084. this->nMaxSimulChans = nMaxSimulChans;
  2085. this->nRefractoryCount = nRefractoryCount;
  2086. }
  2087. #endif
  2088. } cbPKT_SS_ARTIF_REJECT;
  2089. // Options for noise boundary
  2090. //
  2091. #define cbPKTTYPE_SS_NOISE_BOUNDARYREP 0x54 /* NSP->PC response */
  2092. #define cbPKTTYPE_SS_NOISE_BOUNDARYSET 0xD4 /* PC->NSP request */
  2093. #define cbPKTDLEN_SS_NOISE_BOUNDARY ((sizeof(cbPKT_SS_NOISE_BOUNDARY) / 4) - cbPKT_HEADER_32SIZE)
  2094. typedef struct {
  2095. uint32_t time; // system clock timestamp
  2096. uint16_t chid; // 0x8000
  2097. uint8_t type; // cbPKTTYPE_SS_NOISE_BOUNDARYREP or cbPKTTYPE_SS_NOISE_BOUNDARYSET depending on the direction
  2098. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  2099. uint32_t chan; // which channel we belong to
  2100. float afc[3]; // the center of the ellipsoid
  2101. float afS[3][3]; // an array of the axes for the ellipsoid
  2102. #ifdef __cplusplus
  2103. void set(uint32_t chan, float afc1, float afc2, float afS11, float afS12, float afS21, float afS22, float /*theta = 0*/)
  2104. {// theta is ignored, but kept for backward compatibility
  2105. set(chan, afc1, afc2, 0, afS11, afS12, 0, afS21, afS22, 0, 0, 0, 50);
  2106. }
  2107. void set(uint32_t chan, float cen1,float cen2, float cen3, float maj1, float maj2, float maj3,
  2108. float min11, float min12, float min13, float min21, float min22, float min23)
  2109. {
  2110. chid = cbPKTCHAN_CONFIGURATION;
  2111. type = cbPKTTYPE_SS_NOISE_BOUNDARYSET;
  2112. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2113. this->chan = chan;
  2114. this->afc[0] = cen1;
  2115. this->afc[1] = cen2;
  2116. this->afc[2] = cen3;
  2117. this->afS[0][0] = maj1;
  2118. this->afS[0][1] = maj2;
  2119. this->afS[0][2] = maj3;
  2120. this->afS[1][0] = min11;
  2121. this->afS[1][1] = min12;
  2122. this->afS[1][2] = min13;
  2123. this->afS[2][0] = min21;
  2124. this->afS[2][1] = min22;
  2125. this->afS[2][2] = min23;
  2126. }
  2127. // The information obtained by these functions is implicit within the structure data,
  2128. // but they are provided for convenience
  2129. void GetAxisLengths(float afAxisLen[3])const;
  2130. void GetRotationAngles(float afTheta[3])const;
  2131. #endif
  2132. } cbPKT_SS_NOISE_BOUNDARY;
  2133. // All sorting algorithms for which we can change settings
  2134. // (in cbPKT_SS_STATISTICS.nAutoalg)
  2135. #define cbAUTOALG_NONE 0 // No sorting
  2136. #define cbAUTOALG_SPREAD 1 // Auto spread
  2137. #define cbAUTOALG_HIST_CORR_MAJ 2 // Auto Hist Correlation
  2138. #define cbAUTOALG_HIST_PEAK_COUNT_MAJ 3 // Auto Hist Peak Maj
  2139. #define cbAUTOALG_HIST_PEAK_COUNT_FISH 4 // Auto Hist Peak Fish
  2140. #define cbAUTOALG_PCA 5 // Manual PCA
  2141. #define cbAUTOALG_HOOPS 6 // Manual Hoops
  2142. #define cbAUTOALG_PCA_KMEANS 7 // K-means PCA
  2143. #define cbAUTOALG_PCA_EM 8 // EM-clustering PCA
  2144. #define cbAUTOALG_PCA_DBSCAN 9 // DBSCAN PCA
  2145. // The commands to change sorting parameters and state
  2146. // (in cbPKT_SS_STATISTICS.nMode)
  2147. #define cbAUTOALG_MODE_SETTING 0 // Change the settings and leave sorting the same (PC->NSP request)
  2148. #define cbAUTOALG_MODE_APPLY 1 // Change settings and apply this sorting to all channels (PC->NSP request)
  2149. // This packet contains the settings for the spike sorting algorithms
  2150. //
  2151. #define cbPKTTYPE_SS_STATISTICSREP 0x55 /* NSP->PC response */
  2152. #define cbPKTTYPE_SS_STATISTICSSET 0xD5 /* PC->NSP request */
  2153. #define cbPKTDLEN_SS_STATISTICS ((sizeof(cbPKT_SS_STATISTICS) / 4) - cbPKT_HEADER_32SIZE)
  2154. typedef struct {
  2155. uint32_t time; // system clock timestamp
  2156. uint16_t chid; // 0x8000
  2157. uint8_t type; // cbPKTTYPE_SS_STATISTICSREP or cbPKTTYPE_SS_STATISTICSSET depending on the direction
  2158. uint8_t dlen; // cbPKTDLEN_SS_STATISTICS
  2159. uint32_t nUpdateSpikes; // update rate in spike counts
  2160. uint32_t nAutoalg; // sorting algorithm (0=none 1=spread, 2=hist_corr_maj, 3=hist_peak_count_maj, 4=hist_peak_count_maj_fisher, 5=pca, 6=hoops)
  2161. uint32_t nMode; // cbAUTOALG_MODE_SETTING,
  2162. float fMinClusterPairSpreadFactor; // larger number = more apt to combine 2 clusters into 1
  2163. float fMaxSubclusterSpreadFactor; // larger number = less apt to split because of 2 clusers
  2164. float fMinClusterHistCorrMajMeasure; // larger number = more apt to split 1 cluster into 2
  2165. float fMaxClusterPairHistCorrMajMeasure; // larger number = less apt to combine 2 clusters into 1
  2166. float fClusterHistValleyPercentage; // larger number = less apt to split nearby clusters
  2167. float fClusterHistClosePeakPercentage; // larger number = less apt to split nearby clusters
  2168. float fClusterHistMinPeakPercentage; // larger number = less apt to split separated clusters
  2169. uint32_t nWaveBasisSize; // number of wave to collect to calculate the basis,
  2170. // must be greater than spike length
  2171. uint32_t nWaveSampleSize; // number of samples sorted with the same basis before re-calculating the basis
  2172. // 0=manual re-calculation
  2173. // nWaveBasisSize * nWaveSampleSize is the number of waves/spikes to run against
  2174. // the same PCA basis before next
  2175. #ifdef __cplusplus
  2176. void set(uint32_t nUpdateSpikes, uint32_t nAutoalg, uint32_t nMode, float fMinClusterPairSpreadFactor, float fMaxSubclusterSpreadFactor,
  2177. float fMinClusterHistCorrMajMeasure, float fMaxClusterPairHistCorrMajMeasure,
  2178. float fClusterHistValleyPercentage, float fClusterHistClosePeakPercentage, float fClusterHistMinPeakPercentage,
  2179. uint32_t nWaveBasisSize, uint32_t nWaveSampleSize)
  2180. {
  2181. chid = cbPKTCHAN_CONFIGURATION;
  2182. type = cbPKTTYPE_SS_STATISTICSSET;
  2183. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2184. this->nUpdateSpikes = nUpdateSpikes;
  2185. this->nAutoalg = nAutoalg;
  2186. this->nMode = nMode;
  2187. this->fMinClusterPairSpreadFactor = fMinClusterPairSpreadFactor;
  2188. this->fMaxSubclusterSpreadFactor = fMaxSubclusterSpreadFactor;
  2189. this->fMinClusterHistCorrMajMeasure = fMinClusterHistCorrMajMeasure;
  2190. this->fMaxClusterPairHistCorrMajMeasure = fMaxClusterPairHistCorrMajMeasure;
  2191. this->fClusterHistValleyPercentage = fClusterHistValleyPercentage;
  2192. this->fClusterHistClosePeakPercentage = fClusterHistClosePeakPercentage;
  2193. this->fClusterHistMinPeakPercentage = fClusterHistMinPeakPercentage;
  2194. this->nWaveBasisSize = nWaveBasisSize;
  2195. this->nWaveSampleSize = nWaveSampleSize;
  2196. }
  2197. #endif
  2198. } cbPKT_SS_STATISTICS;
  2199. // Send this packet to the NSP to tell it to reset all spike sorting to default values
  2200. #define cbPKTTYPE_SS_RESETREP 0x56 /* NSP->PC response */
  2201. #define cbPKTTYPE_SS_RESETSET 0xD6 /* PC->NSP request */
  2202. #define cbPKTDLEN_SS_RESET ((sizeof(cbPKT_SS_RESET) / 4) - cbPKT_HEADER_32SIZE)
  2203. typedef struct
  2204. {
  2205. uint32_t time; // system clock timestamp
  2206. uint16_t chid; // 0x8000
  2207. uint8_t type; // cbPKTTYPE_SS_RESETREP or cbPKTTYPE_SS_RESETSET depending on the direction
  2208. uint8_t dlen; // cbPKTDLEN_SS_RESET
  2209. #ifdef __cplusplus
  2210. void set()
  2211. {
  2212. chid = cbPKTCHAN_CONFIGURATION;
  2213. type = cbPKTTYPE_SS_RESETSET;
  2214. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2215. }
  2216. #endif
  2217. } cbPKT_SS_RESET;
  2218. // This packet contains the status of the automatic spike sorting.
  2219. //
  2220. #define cbPKTTYPE_SS_STATUSREP 0x57 /* NSP->PC response */
  2221. #define cbPKTTYPE_SS_STATUSSET 0xD7 /* PC->NSP request */
  2222. #define cbPKTDLEN_SS_STATUS ((sizeof(cbPKT_SS_STATUS) / 4) - cbPKT_HEADER_32SIZE)
  2223. typedef struct {
  2224. uint32_t time; // system clock timestamp
  2225. uint16_t chid; // 0x8000
  2226. uint8_t type; // cbPKTTYPE_SS_STATUSREP or cbPKTTYPE_SS_STATUSSET depending on the direction
  2227. uint8_t dlen; // cbPKTDLEN_SS_STATUS
  2228. cbAdaptControl cntlUnitStats;
  2229. cbAdaptControl cntlNumUnits;
  2230. #ifdef __cplusplus
  2231. void set(cbAdaptControl cntlUnitStats, cbAdaptControl cntlNumUnits)
  2232. {
  2233. chid = cbPKTCHAN_CONFIGURATION; //0x8000
  2234. type = cbPKTTYPE_SS_STATUSSET;
  2235. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2236. this->cntlUnitStats = cntlUnitStats;
  2237. this->cntlNumUnits = cntlNumUnits;
  2238. }
  2239. #endif
  2240. } cbPKT_SS_STATUS;
  2241. // Send this packet to the NSP to tell it to reset all spike sorting models
  2242. #define cbPKTTYPE_SS_RESET_MODEL_REP 0x58 /* NSP->PC response */
  2243. #define cbPKTTYPE_SS_RESET_MODEL_SET 0xD8 /* PC->NSP request */
  2244. #define cbPKTDLEN_SS_RESET_MODEL ((sizeof(cbPKT_SS_RESET_MODEL) / 4) - cbPKT_HEADER_32SIZE)
  2245. typedef struct
  2246. {
  2247. uint32_t time; // system clock timestamp
  2248. uint16_t chid; // 0x8000
  2249. uint8_t type; // cbPKTTYPE_SS_RESET_MODEL_REP or cbPKTTYPE_SS_RESET_MODEL_SET depending on the direction
  2250. uint8_t dlen; // cbPKTDLEN_SS_RESET_MODEL
  2251. #ifdef __cplusplus
  2252. void set()
  2253. {
  2254. chid = cbPKTCHAN_CONFIGURATION;
  2255. type = cbPKTTYPE_SS_RESET_MODEL_SET;
  2256. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2257. }
  2258. #endif
  2259. } cbPKT_SS_RESET_MODEL;
  2260. // Feature space commands and status changes (cbPKT_SS_RECALC.mode)
  2261. #define cbPCA_RECALC_START 0 // PC ->NSP start recalculation
  2262. #define cbPCA_RECALC_STOPPED 1 // NSP->PC finished recalculation
  2263. #define cbPCA_COLLECTION_STARTED 2 // NSP->PC waveform collection started
  2264. #define cbBASIS_CHANGE 3 // Change the basis of feature space
  2265. #define cbUNDO_BASIS_CHANGE 4
  2266. #define cbREDO_BASIS_CHANGE 5
  2267. #define cbINVALIDATE_BASIS 6
  2268. // Send this packet to the NSP to tell it to re calculate all PCA Basis Vectors and Values
  2269. #define cbPKTTYPE_SS_RECALCREP 0x59 /* NSP->PC response */
  2270. #define cbPKTTYPE_SS_RECALCSET 0xD9 /* PC->NSP request */
  2271. #define cbPKTDLEN_SS_RECALC ((sizeof(cbPKT_SS_RECALC) / 4) - cbPKT_HEADER_32SIZE)
  2272. typedef struct
  2273. {
  2274. uint32_t time; // system clock timestamp
  2275. uint16_t chid; // 0x8000
  2276. uint8_t type; // cbPKTTYPE_SS_RECALCREP or cbPKTTYPE_SS_RECALCSET depending on the direction
  2277. uint8_t dlen; // cbPKTDLEN_SS_RECALC
  2278. uint32_t chan; // 1 based channel we want to recalc (0 = All channels)
  2279. uint32_t mode; // cbPCA_RECALC_START -> Start PCa basis, cbPCA_RECALC_STOPPED-> PCA basis stopped, cbPCA_COLLECTION_STARTED -> PCA waveform collection started
  2280. #ifdef __cplusplus
  2281. void set(uint32_t chan, uint32_t mode)
  2282. {
  2283. chid = cbPKTCHAN_CONFIGURATION;
  2284. type = cbPKTTYPE_SS_RECALCSET;
  2285. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2286. this->chan = chan;
  2287. this->mode = mode;
  2288. }
  2289. #endif
  2290. } cbPKT_SS_RECALC;
  2291. // This packet holds the calculated basis of the feature space from NSP to Central
  2292. // Or it has the previous basis retrieved and transmitted by central to NSP
  2293. #define cbPKTTYPE_FS_BASISREP 0x5B /* NSP->PC response */
  2294. #define cbPKTTYPE_FS_BASISSET 0xDB /* PC->NSP request */
  2295. #define cbPKTDLEN_FS_BASIS ((sizeof(cbPKT_FS_BASIS) / 4) - cbPKT_HEADER_32SIZE)
  2296. #define cbPKTDLEN_FS_BASISSHORT (cbPKTDLEN_FS_BASIS - ((sizeof(float)* cbMAX_PNTS * 3)/4))
  2297. typedef struct
  2298. {
  2299. uint32_t time; // system clock timestamp
  2300. uint16_t chid; // 0x8000
  2301. uint8_t type; // cbPKTTYPE_FS_BASISREP or cbPKTTYPE_FS_BASISSET depending on the direction
  2302. uint8_t dlen; // cbPKTDLEN_FS_BASIS
  2303. uint32_t chan; // 1-based channel number
  2304. uint32_t mode; // cbBASIS_CHANGE, cbUNDO_BASIS_CHANGE, cbREDO_BASIS_CHANGE, cbINVALIDATE_BASIS ...
  2305. uint32_t fs; // Feature space: cbAUTOALG_PCA
  2306. // basis must be the last item in the structure because it can be variable length to a max of cbMAX_PNTS
  2307. float basis[cbMAX_PNTS][3]; // Room for all possible points collected
  2308. #ifdef __cplusplus
  2309. void set(uint32_t chan, uint32_t mode, uint32_t fs, float * basis[], int spikeLen)
  2310. {
  2311. int i = 0, j = 0;
  2312. chid = cbPKTCHAN_CONFIGURATION;
  2313. type = cbPKTTYPE_FS_BASISSET;
  2314. uint16_t dlenShort = uint16_t(((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE) - ((sizeof(float)* cbMAX_PNTS * 3)/4));
  2315. dlen = uint8_t(dlenShort + sizeof(float) * spikeLen / 4 * 3);
  2316. this->chan = chan;
  2317. this->mode = mode;
  2318. this->fs = fs;
  2319. for (i = 0; i < spikeLen; ++i){
  2320. for (j = 0; j < 3; ++j) {
  2321. this->basis[i][j] = basis[i][j];
  2322. }
  2323. }
  2324. }
  2325. #endif
  2326. } cbPKT_FS_BASIS;
  2327. // This packet holds the Line Noise Cancellation parameters
  2328. #define cbPKTTYPE_LNCREP 0x28 /* NSP->PC response */
  2329. #define cbPKTTYPE_LNCSET 0xA8 /* PC->NSP request */
  2330. #define cbPKTDLEN_LNC ((sizeof(cbPKT_LNC) / 4) - cbPKT_HEADER_32SIZE)
  2331. typedef struct
  2332. {
  2333. uint32_t time; // system clock timestamp
  2334. uint16_t chid; // 0x8000
  2335. uint8_t type; // cbPKTTYPE_LNCSET or cbPKTTYPE_LNCREP depending on the direction
  2336. uint8_t dlen; // cbPKTDLEN_LNC
  2337. uint32_t lncFreq; // Nominal line noise frequency to be canceled (in Hz)
  2338. uint32_t lncRefChan; // Reference channel for lnc synch (1-based)
  2339. uint32_t lncGlobalMode; // reserved
  2340. #ifdef __cplusplus
  2341. void set(uint32_t lncFreq, uint32_t lncRefChan, uint32_t lncGlobalMode)
  2342. {
  2343. chid = cbPKTCHAN_CONFIGURATION;
  2344. type = cbPKTTYPE_LNCSET;
  2345. dlen = ((sizeof(*this) / 4) - cbPKT_HEADER_32SIZE);
  2346. this->lncFreq = lncFreq;
  2347. this->lncRefChan = lncRefChan;
  2348. this->lncGlobalMode = lncGlobalMode;
  2349. }
  2350. #endif
  2351. } cbPKT_LNC;
  2352. #ifdef __cplusplus
  2353. cbRESULT cbGetLncParameters(uint32_t *nLncFreq, uint32_t *nLncRefChan, uint32_t *nLncGMode, uint32_t nInstance = 0);
  2354. cbRESULT cbSetLncParameters(uint32_t nLncFreq, uint32_t nLncRefChan, uint32_t nLncGMode, uint32_t nInstance = 0);
  2355. // Get/Set the system-wide LNC parameters.
  2356. //
  2357. // Returns: cbRESULT_OK if data successfully retrieved.
  2358. // cbRESULT_NOLIBRARY if the library was not properly initialized.
  2359. #endif
  2360. // Send this packet to force the digital output to this value
  2361. #define cbPKTTYPE_SET_DOUTREP 0x5D /* NSP->PC response */
  2362. #define cbPKTTYPE_SET_DOUTSET 0xDD /* PC->NSP request */
  2363. #define cbPKTDLEN_SET_DOUT ((sizeof(cbPKT_SET_DOUT) / 4) - cbPKT_HEADER_32SIZE)
  2364. typedef struct {
  2365. uint32_t time; // system clock timestamp
  2366. uint16_t chid; // 0x8000
  2367. uint8_t type; // cbPKTTYPE_SET_DOUTREP or cbPKTTYPE_SET_DOUTSET depending on direction
  2368. uint8_t dlen; // length of waveform in 32-bit chunks
  2369. uint16_t chan; // which digital output channel (1 based, will equal chan from GetDoutCaps)
  2370. uint16_t value; // Which value to set? zero = 0; non-zero = 1 (output is 1 bit)
  2371. #ifdef __cplusplus
  2372. // Inputs:
  2373. // nChan - 1 based channel to set
  2374. // bSet - TRUE means to assert the port (1); FALSE, unassert (0)
  2375. void set(uint32_t nChan, bool bSet)
  2376. {
  2377. chid = cbPKTCHAN_CONFIGURATION;
  2378. type = cbPKTTYPE_SET_DOUTSET;
  2379. dlen = sizeof(*this) / 4 - cbPKT_HEADER_32SIZE;
  2380. chan = nChan;
  2381. value = bSet ? 1 : 0;
  2382. }
  2383. #endif
  2384. } cbPKT_SET_DOUT;
  2385. #define cbMAX_WAVEFORM_PHASES ((cbPKT_MAX_SIZE - cbPKT_HEADER_SIZE - 24) / 4) // Maximum number of phases in a waveform
  2386. typedef struct _cbWaveformData
  2387. {
  2388. int16_t offset; // DC offset
  2389. union {
  2390. struct {
  2391. uint16_t sineFrequency; // sine wave Hz
  2392. int16_t sineAmplitude; // sine amplitude
  2393. };
  2394. struct {
  2395. uint16_t seq; // Wave sequence number (for file playback)
  2396. uint16_t seqTotal; // total number of sequences
  2397. uint16_t phases; // Number of valid phases in this wave (maximum is cbMAX_WAVEFORM_PHASES)
  2398. uint16_t duration[cbMAX_WAVEFORM_PHASES];
  2399. int16_t amplitude[cbMAX_WAVEFORM_PHASES];
  2400. };
  2401. };
  2402. } cbWaveformData;
  2403. #ifdef __cplusplus
  2404. cbRESULT cbGetAoutWaveform(uint32_t channel, uint8_t trigNum, uint16_t * mode, uint32_t * repeats, uint16_t * trig,
  2405. uint16_t * trigChan, uint16_t * trigValue, cbWaveformData * wave, uint32_t nInstance = 0);
  2406. // Returns anallog output waveform information
  2407. // Returns cbRESULT_OK if successful, cbRESULT_NOLIBRARY if library was never initialized.
  2408. #endif
  2409. // signal generator waveform type
  2410. #define cbWAVEFORM_MODE_NONE 0 // waveform is disabled
  2411. #define cbWAVEFORM_MODE_PARAMETERS 1 // waveform is a repeated sequence
  2412. #define cbWAVEFORM_MODE_SINE 2 // waveform is a sinusoids
  2413. // signal generator waveform trigger type
  2414. #define cbWAVEFORM_TRIGGER_NONE 0 // instant software trigger
  2415. #define cbWAVEFORM_TRIGGER_DINPREG 1 // digital input rising edge trigger
  2416. #define cbWAVEFORM_TRIGGER_DINPFEG 2 // digital input falling edge trigger
  2417. #define cbWAVEFORM_TRIGGER_SPIKEUNIT 3 // spike unit
  2418. #define cbWAVEFORM_TRIGGER_COMMENTCOLOR 4 // comment RGBA color (A being big byte)
  2419. #define cbWAVEFORM_TRIGGER_SOFTRESET 5 // soft-reset trigger
  2420. #define cbWAVEFORM_TRIGGER_EXTENSION 6 // extension trigger
  2421. // AOUT signal generator waveform data
  2422. #define cbPKTTYPE_WAVEFORMREP 0x33 /* NSP->PC response */
  2423. #define cbPKTTYPE_WAVEFORMSET 0xB3 /* PC->NSP request */
  2424. #define cbPKTDLEN_WAVEFORM ((sizeof(cbPKT_AOUT_WAVEFORM)/4) - cbPKT_HEADER_32SIZE)
  2425. typedef struct {
  2426. uint32_t time; // system clock timestamp
  2427. uint16_t chid; // cbPKTCHAN_CONFIGURATION
  2428. uint8_t type; // cbPKTTYPE_WAVEFORMREP or cbPKTTYPE_WAVEFORMSET depending on direction
  2429. uint8_t dlen; // packet size
  2430. uint16_t chan; // which analog output/audio output channel (1-based, will equal chan from GetDoutCaps)
  2431. // Each file may contain multiple sequences.
  2432. // Each sequence consists of phases
  2433. // Each phase is defined by amplitude and duration
  2434. // Waveform parameter information
  2435. uint16_t mode; // Can be any of cbWAVEFORM_MODE_*
  2436. uint32_t repeats; // Number of repeats (0 means forever)
  2437. uint16_t trig; // Can be any of cbWAVEFORM_TRIGGER_*
  2438. uint16_t trigChan; // Depends on trig:
  2439. // for cbWAVEFORM_TRIGGER_DINP* 1-based trigChan (1-16) is digin1, (17-32) is digin2, ...
  2440. // for cbWAVEFORM_TRIGGER_SPIKEUNIT 1-based trigChan (1-156) is channel number
  2441. // for cbWAVEFORM_TRIGGER_COMMENTCOLOR trigChan is A->B in A->B->G->R
  2442. uint16_t trigValue; // Trigger value (spike unit, G-R comment color, ...)
  2443. uint8_t trigNum; // trigger number (0-based) (can be up to cbMAX_AOUT_TRIGGER-1)
  2444. uint8_t active; // status of trigger
  2445. cbWaveformData wave; // Actual waveform data
  2446. #ifdef __cplusplus
  2447. void reset(uint16_t nChan, uint8_t nTrigNum)
  2448. {
  2449. memset(this, 0, sizeof(*this));
  2450. chid = cbPKTCHAN_CONFIGURATION;
  2451. type = cbPKTTYPE_WAVEFORMSET;
  2452. dlen = sizeof(*this) / 4 - cbPKT_HEADER_32SIZE;
  2453. chan = nChan;
  2454. mode = cbWAVEFORM_MODE_NONE;
  2455. trigNum = nTrigNum;
  2456. }
  2457. // Inputs:
  2458. // nChan - 1-based channel
  2459. void set(uint16_t nChan, int16_t offset, uint16_t nSineFrequency, int16_t nSineAmplitude, uint16_t nTrigChan = 0, uint16_t nTrig = cbWAVEFORM_TRIGGER_NONE,
  2460. uint32_t nRepeats = 0, uint16_t nTrigValue = 0, uint8_t nTrigNum = 0)
  2461. {
  2462. chid = cbPKTCHAN_CONFIGURATION;
  2463. type = cbPKTTYPE_WAVEFORMSET;
  2464. dlen = sizeof(*this) / 4 - cbPKT_HEADER_32SIZE;
  2465. chan = nChan;
  2466. wave.offset = offset;
  2467. wave.sineFrequency = nSineFrequency;
  2468. wave.sineAmplitude = nSineAmplitude;
  2469. mode = cbWAVEFORM_MODE_SINE;
  2470. repeats = nRepeats;
  2471. trig = nTrig;
  2472. trigChan = nTrigChan;
  2473. trigValue = nTrigValue;
  2474. trigNum = nTrigNum;
  2475. active = 0;
  2476. }
  2477. // Inputs:
  2478. // nChan - 1-based channel
  2479. // Note: For performance minimal validity check is made;
  2480. // at least one duration must be non-zero (avoid zero-duration for performance)
  2481. // phases must be non-zero
  2482. void set(uint16_t nChan, uint16_t nPhases, uint16_t nDuration[], int16_t nAmplitude[], uint16_t nTrigChan = 0, uint32_t nTrig = cbWAVEFORM_TRIGGER_NONE,
  2483. uint32_t nRepeats = 0, uint32_t nSeqTotal = 1, uint16_t nSeq = 0, int16_t offset = 0, uint16_t nTrigValue = 0, uint8_t nTrigNum = 0)
  2484. {
  2485. chid = cbPKTCHAN_CONFIGURATION;
  2486. type = cbPKTTYPE_WAVEFORMSET;
  2487. dlen = sizeof(*this) / 4 - cbPKT_HEADER_32SIZE;
  2488. chan = nChan;
  2489. if (nPhases > cbMAX_WAVEFORM_PHASES)
  2490. nPhases = cbMAX_WAVEFORM_PHASES;
  2491. memcpy(wave.duration, nDuration, sizeof(uint16_t) * nPhases);
  2492. memcpy(wave.amplitude, nAmplitude, sizeof(int16_t) * nPhases);
  2493. wave.seq = nSeq;
  2494. wave.seqTotal = nSeqTotal;
  2495. wave.phases = nPhases;
  2496. wave.offset = offset;
  2497. mode = cbWAVEFORM_MODE_PARAMETERS;
  2498. repeats = nRepeats;
  2499. trig = nTrig;
  2500. trigChan = nTrigChan;
  2501. trigValue = nTrigValue;
  2502. trigNum = nTrigNum;
  2503. active = 0;
  2504. }
  2505. #endif
  2506. } cbPKT_AOUT_WAVEFORM;
  2507. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2508. //
  2509. // Preview Data Packet Definitions (chid = 0x8000 + channel)
  2510. //
  2511. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2512. // preview information requests
  2513. #define cbPKTTYPE_PREVSETLNC 0x81
  2514. #define cbPKTTYPE_PREVSETSTREAM 0x82
  2515. #define cbPKTTYPE_PREVSET 0x83
  2516. #define cbPKTTYPE_PREVREP 0x03 // Acknowledged response from the packet above
  2517. // line noise cancellation (LNC) waveform preview packet
  2518. #define cbPKTTYPE_PREVREPLNC 0x01
  2519. #define cbPKTDLEN_PREVREPLNC ((sizeof(cbPKT_LNCPREV)/4) - cbPKT_HEADER_32SIZE)
  2520. typedef struct {
  2521. uint32_t time; // system clock timestamp
  2522. uint16_t chid; // 0x8000 + channel identifier
  2523. uint8_t type; // cbPKT_LNCPREVLEN
  2524. uint8_t dlen; // length of the waveform/2
  2525. uint32_t freq; // Estimated line noise frequency * 1000 (zero means not valid)
  2526. int16_t wave[300]; // lnc cancellation waveform (downsampled by 2)
  2527. } cbPKT_LNCPREV;
  2528. // These values are taken by nSampleRows if PCA
  2529. #define cbPCA_START_COLLECTION 0 // start collecting samples
  2530. #define cbPCA_START_BASIS 1 // start basis calculation
  2531. #define cbPCA_MANUAL_LAST_SAMPLE 2 // the manual-only PCA, samples at zero, calculates PCA basis at 1 and stops at 2
  2532. // the first time a basis is calculated it can be used, even for the waveforms collected for the next basis
  2533. #define cbSTREAMPREV_NONE 0x00000000
  2534. #define cbSTREAMPREV_PCABASIS_NONEMPTY 0x00000001
  2535. // Streams preview packet
  2536. #define cbPKTTYPE_PREVREPSTREAM 0x02
  2537. #define cbPKTDLEN_PREVREPSTREAM ((sizeof(cbPKT_STREAMPREV)/4) - cbPKT_HEADER_32SIZE)
  2538. typedef struct {
  2539. uint32_t time; // system clock timestamp
  2540. uint16_t chid; // 0x8000 + channel identifier
  2541. uint8_t type; // cbPKTTYPE_PREVREPSTREAM
  2542. uint8_t dlen; // cbPKTDLEN_PREVREPSTREAM
  2543. int16_t rawmin; // minimum raw channel value over last preview period
  2544. int16_t rawmax; // maximum raw channel value over last preview period
  2545. int16_t smpmin; // minimum sample channel value over last preview period
  2546. int16_t smpmax; // maximum sample channel value over last preview period
  2547. int16_t spkmin; // minimum spike channel value over last preview period
  2548. int16_t spkmax; // maximum spike channel value over last preview period
  2549. uint32_t spkmos; // mean of squares
  2550. uint32_t eventflag; // flag to detail the units that happend in the last sample period
  2551. int16_t envmin; // minimum envelope channel value over the last preview period
  2552. int16_t envmax; // maximum envelope channel value over the last preview period
  2553. int32_t spkthrlevel; // preview of spike threshold level
  2554. uint32_t nWaveNum; // this tracks the number of waveforms collected in the WCM for each channel
  2555. uint32_t nSampleRows; // tracks number of sample vectors of waves
  2556. uint32_t nFlags; // cbSTREAMPREV_*
  2557. } cbPKT_STREAMPREV;
  2558. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2559. //
  2560. // Shared Memory Definitions used by Central App and Cerebus library functions
  2561. //
  2562. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2563. // TODO: separate out these definitions so that there are no conditional compiles
  2564. #ifdef __cplusplus
  2565. typedef struct {
  2566. COLORREF winrsvd[48];
  2567. COLORREF dispback;
  2568. COLORREF dispgridmaj;
  2569. COLORREF dispgridmin;
  2570. COLORREF disptext;
  2571. COLORREF dispwave;
  2572. COLORREF dispwavewarn;
  2573. COLORREF dispwaveclip;
  2574. COLORREF dispthresh;
  2575. COLORREF dispmultunit;
  2576. COLORREF dispunit[16]; // 0 = unclassified
  2577. COLORREF dispnoise;
  2578. COLORREF dispchansel[3];
  2579. COLORREF disptemp[5];
  2580. COLORREF disprsvd[14];
  2581. } cbCOLORTABLE;
  2582. cbRESULT cbGetColorTable(cbCOLORTABLE **colortable, uint32_t nInstance = 0);
  2583. typedef struct {
  2584. float fRMSAutoThresholdDistance; // multiplier to use for autothresholding when using
  2585. // RMS to guess noise
  2586. uint32_t reserved[31];
  2587. } cbOPTIONTABLE;
  2588. // Get/Set the multiplier to use for autothresholdine when using RMS to guess noise
  2589. // This will adjust fAutoThresholdDistance above, but use the API instead
  2590. float cbGetRMSAutoThresholdDistance(uint32_t nInstance = 0);
  2591. void cbSetRMSAutoThresholdDistance(float fRMSAutoThresholdDistance, uint32_t nInstance = 0);
  2592. //////////////////////////////////////////////////////////////////////////////////////////////////
  2593. #define cbPKT_SPKCACHEPKTCNT 400
  2594. #define cbPKT_SPKCACHELINECNT cbNUM_ANALOG_CHANS
  2595. typedef struct {
  2596. uint32_t chid; // ID of the Channel
  2597. uint32_t pktcnt; // # of packets which can be saved
  2598. uint32_t pktsize; // Size of an individual packet
  2599. uint32_t head; // Where (0 based index) in the circular buffer to place the NEXT packet.
  2600. uint32_t valid; // How many packets have come in since the last configuration
  2601. cbPKT_SPK spkpkt[cbPKT_SPKCACHEPKTCNT]; // Circular buffer of the cached spikes
  2602. } cbSPKCACHE;
  2603. typedef struct {
  2604. uint32_t flags;
  2605. uint32_t chidmax;
  2606. uint32_t linesize;
  2607. uint32_t spkcount;
  2608. cbSPKCACHE cache[cbPKT_SPKCACHELINECNT];
  2609. } cbSPKBUFF;
  2610. cbRESULT cbGetSpkCache(uint32_t chid, cbSPKCACHE **cache, uint32_t nInstance = 0);
  2611. #ifdef WIN32
  2612. enum WM_USER_GLOBAL
  2613. {
  2614. WM_USER_WAITEVENT = WM_USER, // mmtimer says it is OK to continue
  2615. WM_USER_CRITICAL_DATA_CATCHUP, // We have reached a critical data point and we have skipped
  2616. };
  2617. #endif
  2618. #define cbRECBUFFLEN 4194304
  2619. typedef struct {
  2620. uint32_t received;
  2621. uint32_t lasttime;
  2622. uint32_t headwrap;
  2623. uint32_t headindex;
  2624. uint32_t buffer[cbRECBUFFLEN];
  2625. } cbRECBUFF;
  2626. #ifdef _MSC_VER
  2627. // The following structure is used to hold Cerebus packets queued for transmission to the NSP.
  2628. // The length of the structure is set during initialization of the buffer in the Central App.
  2629. // The pragmas allow a zero-length data field entry in the structure for referencing the data.
  2630. #pragma warning(push)
  2631. #pragma warning(disable:4200)
  2632. #endif
  2633. typedef struct {
  2634. uint32_t transmitted; // How many packets have we sent out?
  2635. uint32_t headindex; // 1st empty position
  2636. // (moves on filling)
  2637. uint32_t tailindex; // 1 past last emptied position (empty when head = tail)
  2638. // Moves on emptying
  2639. uint32_t last_valid_index;// index number of greatest valid starting index for a head (or tail)
  2640. uint32_t bufferlen; // number of indexes in buffer (units of uint32_t) <------+
  2641. uint32_t buffer[0]; // big buffer of data...there are actually "bufferlen"--+ indices
  2642. } cbXMTBUFF;
  2643. #ifdef _MSC_VER
  2644. #pragma warning(pop)
  2645. #endif
  2646. #define WM_USER_SET_THOLD_SIGMA (WM_USER + 100)
  2647. #define WM_USER_SET_THOLD_TIME (WM_USER + 101)
  2648. typedef struct {
  2649. // ***** THESE MUST BE 1ST IN THE STRUCTURE WITH MODELSET LAST OF THESE ***
  2650. // ***** SEE WriteCCFNoPrompt() ***
  2651. cbPKT_FS_BASIS asBasis[cbMAXCHANS]; // All of the PCA basis values
  2652. cbPKT_SS_MODELSET asSortModel[cbMAXCHANS][cbMAXUNITS + 2]; // All of the model (rules) for spike sorting
  2653. //////// These are spike sorting options
  2654. cbPKT_SS_DETECT pktDetect; // parameters dealing with actual detection
  2655. cbPKT_SS_ARTIF_REJECT pktArtifReject; // artifact rejection
  2656. cbPKT_SS_NOISE_BOUNDARY pktNoiseBoundary[cbNUM_ANALOG_CHANS]; // where o'where are the noise boundaries
  2657. cbPKT_SS_STATISTICS pktStatistics; // information about statistics
  2658. cbPKT_SS_STATUS pktStatus; // Spike sorting status
  2659. } cbSPIKE_SORTING;
  2660. #define PCSTAT_TYPE_CERVELLO 0x00000001 // Cervello type system
  2661. #define PCSTAT_DISABLE_RAW 0x00000002 // Disable recording of raw data
  2662. class cbPcStatus
  2663. {
  2664. public:
  2665. cbPKT_UNIT_SELECTION isSelection;
  2666. private:
  2667. int32_t m_iBlockRecording;
  2668. uint32_t m_nPCStatusFlags;
  2669. public:
  2670. cbPcStatus() :
  2671. isSelection(1),
  2672. m_iBlockRecording(0),
  2673. m_nPCStatusFlags(0)
  2674. {
  2675. }
  2676. bool IsRecordingBlocked() { return m_iBlockRecording != 0; }
  2677. void SetBlockRecording(bool bBlockRecording) { m_iBlockRecording += bBlockRecording ? 1 : -1; }
  2678. uint32_t cbGetPCStatusFlags() { return m_nPCStatusFlags; }
  2679. void cbSetPCStatusFlags(uint32_t nPCStatusFlags) { m_nPCStatusFlags = nPCStatusFlags; }
  2680. };
  2681. typedef struct {
  2682. uint32_t version;
  2683. uint32_t sysflags;
  2684. cbOPTIONTABLE optiontable; // Should be 32 32-bit values
  2685. cbCOLORTABLE colortable; // Should be 96 32-bit values
  2686. cbPKT_SYSINFO sysinfo;
  2687. cbPKT_PROCINFO procinfo[cbMAXPROCS];
  2688. cbPKT_BANKINFO bankinfo[cbMAXPROCS][cbMAXBANKS];
  2689. cbPKT_GROUPINFO groupinfo[cbMAXPROCS][cbMAXGROUPS]; // sample group ID (1-4=proc1, 5-8=proc2, etc)
  2690. cbPKT_FILTINFO filtinfo[cbMAXPROCS][cbMAXFILTS];
  2691. cbPKT_ADAPTFILTINFO adaptinfo; // Settings about adapting
  2692. cbPKT_REFELECFILTINFO refelecinfo; // Settings about reference electrode filtering
  2693. cbPKT_CHANINFO chaninfo[cbMAXCHANS];
  2694. cbSPIKE_SORTING isSortingOptions; // parameters dealing with spike sorting
  2695. cbPKT_NTRODEINFO isNTrodeInfo[cbMAXNTRODES]; // allow for the max number of ntrodes (if all are stereo-trodes)
  2696. cbPKT_AOUT_WAVEFORM isWaveform[AOUT_NUM_GAIN_CHANS][cbMAX_AOUT_TRIGGER]; // Waveform parameters
  2697. cbPKT_LNC isLnc; //LNC parameters
  2698. cbPKT_NPLAY isNPlay; // nPlay Info
  2699. cbVIDEOSOURCE isVideoSource[cbMAXVIDEOSOURCE]; // Video source
  2700. cbTRACKOBJ isTrackObj[cbMAXTRACKOBJ]; // Trackable objects
  2701. cbPKT_FILECFG fileinfo; // File recording status
  2702. // This must be at the bottom of this structure because it is variable size 32-bit or 64-bit
  2703. // depending on the compile settings e.g. 64-bit cbmex communicating with 32-bit Central
  2704. HANDLE hwndCentral; // Handle to the Window in Central
  2705. } cbCFGBUFF;
  2706. // Latest CCF structure
  2707. typedef struct {
  2708. cbPKT_CHANINFO isChan[cbMAXCHANS];
  2709. cbPKT_ADAPTFILTINFO isAdaptInfo;
  2710. cbPKT_SS_DETECT isSS_Detect;
  2711. cbPKT_SS_ARTIF_REJECT isSS_ArtifactReject;
  2712. cbPKT_SS_NOISE_BOUNDARY isSS_NoiseBoundary[cbNUM_ANALOG_CHANS];
  2713. cbPKT_SS_STATISTICS isSS_Statistics;
  2714. cbPKT_SS_STATUS isSS_Status;
  2715. cbPKT_SYSINFO isSysInfo;
  2716. cbPKT_NTRODEINFO isNTrodeInfo[cbMAXNTRODES];
  2717. cbPKT_AOUT_WAVEFORM isWaveform[AOUT_NUM_GAIN_CHANS][cbMAX_AOUT_TRIGGER];
  2718. cbPKT_FILTINFO filtinfo[cbNUM_DIGITAL_FILTERS];
  2719. cbPKT_LNC isLnc;
  2720. } cbCCF;
  2721. // CCF processing state
  2722. typedef enum _cbStateCCF
  2723. {
  2724. CCFSTATE_READ = 0, // Reading in progress
  2725. CCFSTATE_WRITE, // Writing in progress
  2726. CCFSTATE_SEND , // Sendign in progress
  2727. CCFSTATE_CONVERT, // Conversion in progress
  2728. CCFSTATE_THREADREAD, // Total threaded read progress
  2729. CCFSTATE_THREADWRITE, // Total threaded write progress
  2730. CCFSTATE_UNKNOWN, // (Always the last) unknown state
  2731. } cbStateCCF;
  2732. // External Global Variables
  2733. extern HANDLE cb_xmt_global_buffer_hnd[cbMAXOPEN]; // Transmit queues to send out of this PC
  2734. extern cbXMTBUFF* cb_xmt_global_buffer_ptr[cbMAXOPEN];
  2735. extern HANDLE cb_xmt_local_buffer_hnd[cbMAXOPEN]; // Transmit queues only for local (this PC) use
  2736. extern cbXMTBUFF* cb_xmt_local_buffer_ptr[cbMAXOPEN];
  2737. extern HANDLE cb_rec_buffer_hnd[cbMAXOPEN];
  2738. extern cbRECBUFF* cb_rec_buffer_ptr[cbMAXOPEN];
  2739. extern HANDLE cb_cfg_buffer_hnd[cbMAXOPEN];
  2740. extern cbCFGBUFF* cb_cfg_buffer_ptr[cbMAXOPEN];
  2741. extern HANDLE cb_pc_status_buffer_hnd[cbMAXOPEN];
  2742. extern cbPcStatus* cb_pc_status_buffer_ptr[cbMAXOPEN]; // parameters dealing with local pc status
  2743. extern HANDLE cb_spk_buffer_hnd[cbMAXOPEN];
  2744. extern cbSPKBUFF* cb_spk_buffer_ptr[cbMAXOPEN];
  2745. extern HANDLE cb_sig_event_hnd[cbMAXOPEN];
  2746. extern uint32_t cb_library_initialized[cbMAXOPEN];
  2747. extern uint32_t cb_library_index[cbMAXOPEN];
  2748. #endif
  2749. #pragma pack(pop)
  2750. #endif // end of include guard