neuroNicle API - Sample Code
Sample Code 2 – Simple brainwave charting with neuroNicle API.
Abstract.
This article’s VC++2013 project(Code Sample 2) shows the simple real time brainwave charting with using “neuroNicle API”. The purpose of this code sample is “how we can acquire the brainwave raw data from neuroNicle API and how we can handle real time processing”. To avoid the code complexity, this project’s charting component is very navie and simple. You can use more beautiful charting components or your own charting codes. This article shows the detail informations about coding flow with screen capture step by step. Although you are newbie in VC++2013 you can easily understand how to make VC++2013 general project and how to use “neuroNicle API”. developing IDE : “Visual Studio Community 2013 with Update 4”
Tip : Visual Studio Community 2013 verson is a free and full-featured IDE. This is better than Visual Studio Express Version. You can download here -> http://www.visualstudio.com/downloads/download-visual-studio-vs
Step 1. Create Project
This section shows the detail steps for creating VC++ project as SDI Type with most simple project’s options. The final ececuted program shot is as following.
This section includes very basic routinal informations, if you are familiar with the Visual C++ project’s creation, please skip this section and go to next step2.
Step2. Add modeless dialog to project
In this section, dialog is added to the project. The purpose of the dialog is to communicate with “neuroNicle API”. The buttons are placed in this dialog are to be used for calling the API functions. The final shot of the dialog is as following figure.
Now the class “CDlgMainControl” is added to our project and you can see the default dialog shape is created in resource view.
Dialog Settings
Delete the OK and Cancel buttons, and set the properties as follows. – Topmost : true – System Menu : false (To avoid closing the dialog) – Caption : MainControl – neuroNicle API Place the four button controls and then set the properties as follows. These buttons are basically needed to call the “neuroNicle API” functions.
button1 : Caption -> OpenApi, ID -> IDD_BTN_OPENAPI
button2 : Caption -> OpenDevice, ID -> IDD_BTN_OPENDEVICE
button3 : Caption -> CloseDevicei, ID -> IDD_BTN_CLOSEDEVICE
button4 : Caption -> CloseApi, ID -> IDD_BTN_CLOSEAPI
Now, the dialog shape is the following.
Add hanlder for all buttons
Let’s add handler for each button click event. Press “ctrl+shift+x” to show the claass wizard window . In class wiazrd add handler to CDlgMainControl class for each button as follows. The blue box show all added handler.
Setting Dialog as Modeless
Now we set the CDlgMainControl as a Modeless as follows.
1. add code to file “neuroNicleAPI_SampleCode2View.h” as follows.
2. add code to file
“neuroNicleAPI_SampleCode2View.cpp” as follows. The codes in constructor create the dialog at the same time as creation of view instance.
check the program execution. MainControl dialog is shown and topmost window.
The view client area will be used as a plotting area and the MainControl dialog box will be used as a main user control and status display.
Step3. Add “neuroNicle API” files to project folders.
Now we are ready to add code for using “neuroNicle API”. The “neuroNicle API” is a type of Dynamic Linked Library(DLL). The using method is the same as that of general dll – incldue the header file, implicit link the lib file and place the dll file into folder which exist execution file.
1. Getting the neuroNicle API files.
Download the “neuroNicleAPI.zip” files from this link -> click here to download , and then unzip. You can see the files as follows.
2. Copy files to suitabe folder.
You should copy the following three filess into the folder which has a sample project’s execution file i.e. neuroNicleAPI_CodeSample2.exe.
- neuroNicleAPI.dll
- neuroNicleAPI_SelfUpdate.exe
- Kjs,Applife.Udate.Controller.dl
You should copy the following two files to sample project’s source folder.
- neuroNicleAPI.lib
- neuroNicleAPI_DEF.h
The following figures show the copied files into suitable folder.
Step4. Code writing to use “neuroNicle API”
1. Include API’s header file and Link the lib file.
Include neuroNicleAPI_DEF.h and link the neuroNicleAPI.lib. below shows codes added in DlgMainControl.h.
2.Call API functions
Most important neuroNicle API functions are the following.
- OpenApi_neuroNicleAPI
- OpenDevice_neuroNicleAPI
- CloseDeivce_neuroNicleAPI
- CloseApi_neuroNicleAPI
Call the function OpenApi at first and then cal the OpenDevice to communicate with specific neuroNicle device with a parameter LXDeviceID which is unique identification integer number something like 256 in the case of “neuroNicle E1” product. If your application going to close, call the CloseDevice and then CloseApi. In our project sample, the above 4 functions are called from the button click handler in the MainControl dialog class as follows.
Now run (ctrl + F5) the application and then click the buttons.
Set 1 of the first parameter of OpenApi function means that show the API windows for debugging purpose. if you call the API functions in your program, the internal status can be seen the window’s list box.
Set 1 of the second parameter of OpenApi function means that run the process “Check for self -uodates for neuroNicle API” . neuroNicle API can be automatically updated with a new version or patch via network. If you using the neuroNicle API , there is no need to check new API version and patch manually.
The “Check for updates” window is the following.
Step5. Code writing to plot the brainwave data.
add codes to “neuroNicleAPI_SampleCode2View.h” as follows.
Add codes into ondraw method ( “neuroNicleAPI_SampleCode2View.cpp file”) as follows.
Comments are closed