ARK Datalogging API

An instrument using a Sound Design circuit, which supports datalogging, will generate a CSV file with the log details. These values can be read independently of whether the instrument has been read or not.

Decoding CSV Datalog File

The .csv file is a comma delimited file with the following row and column (field) definitions:

5,9,0,-6,58,0 . . . 20,9,0,-6,58,0 21,9,0,-6,55,2 365,246,19,454 6 </code>

Field Details

For any rows with the exception of the first and last rows, these are the fields: 1. Timestamp

2. Battery Level

iLog version 2.0 provides more granularity in the battery level

v1.0 settings

v2.0 settings

3. Memory

4. VC Level

5. Ambient Level

6. iSceneDetect (Environmental Classification) Value

Generating a CSV Datalog File

Private Declare Function SHGetSpecialFolderLocation _
    Lib "shell32" (ByVal hWnd As Long, _
    ByVal nFolder As Long, ppidl As Long) As Long
 
Private Declare Function SHGetPathFromIDList _
    Lib "shell32" Alias "SHGetPathFromIDListA" _
    (ByVal Pidl As Long, ByVal pszPath As String) As Long
 
Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
 
Const CSIDL_APPDATA = &H1A
Const MAX_PATH = 300
Const NOERROR = 0
 
 
 
Private Function SpecFolder(ByVal lngFolder As Long) As String
    Dim lngPidlFound As Long
    Dim lngFolderFound As Long
    Dim lngPidl As Long
    Dim strPath As String
 
    strPath = Space(MAX_PATH)
    lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
    If lngPidlFound = NOERROR Then
        lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
        If lngFolderFound Then
            SpecFolder = Left$(strPath, _
                InStr(1, strPath, vbNullChar) - 1)
        End If
    End If
    CoTaskMemFree lngPidl
End Function
 
Private Sub ReadDataLog()
    Dim i As Integer
    Dim prg2 As ark.IProgrammer2
    Dim datalog As ark.IDataLog
    Dim datalogentry As ark.IDataLogEntry
    Dim ventprod5 As ark.IVentureProduct5
    Dim freefd As Integer
    Dim memcount() As Long
    Dim lRet As Long
    Dim bRet As Boolean
    Dim FileName As String
    Dim corruptionerror As Boolean
 
    If Not g_Cache(g_CurrentEar).LastOp = OP_INIT Then _
        Err.Raise vbObjectError, , "Device not initialized."
 
    Set prg2 = g_Prog
    SetMousePointerBusy True
 
    On Error Resume Next
    Set ventprod5 = g_Prod
    On Error GoTo HandleError
 
    If Not ventprod5 Is Nothing Then
        If ventprod5.HybridVal <> 33 Then
            MsgBox "Datalogging is not supported in this product", vbOKOnly, "Error"
            Exit Sub
        End If
    Else
        Exit Sub
    End If
 
    Set datalog = ventprod5.ReadLogSafe(prg2, g_CurrentEar, 4, memcount(), corruptionerror)
    SetMousePointerBusy False
 
    If corruptionerror = True Then
        MsgBox "Warning: Datalog has been corrupted.  Clean data will still be displayed, but time measurements " + _
            "could be inaccurate.", vbOKOnly, "Warning"
    End If
 
    FileName = SpecFolder(CSIDL_APPDATA) + "\Sound Design Technologies\IDS"
 
 
    'if directory does not exist, create it
    If Dir$(FileName$, vbDirectory) = "" Then
        Shell "cmd /c mkdir " + """" + FileName + """", vbHide
        Sleep 1000 'this sleep is necessary for Vista to allow it to recover from creating the new directory
                    'before it has to go and write a file there.
    End If
    FileName = FileName + "\iLog.csv"
 
    ' Open the output file
    freefd = FreeFile
    Open FileName For Output As freefd
 
    Print #freefd, "--Version 1.0--"
 
    'Write the data to a file
    For i = 0 To datalog.count - 1
 
        Print #freefd, CStr(datalog.Item(i).TimeStamp) + ",";
        Print #freefd, CStr(datalog.Item(i).LogBattLevel) + ",";
        Print #freefd, CStr(datalog.Item(i).LogMemory) + ",";
        Print #freefd, CStr(datalog.Item(i).LogVC) + ",";
        Print #freefd, CStr(datalog.Item(i).LogLEQ)
 
    Next i
 
    For i = 0 To 3
        Print #freefd, CStr(memcount(i));
        If i <> 3 Then
            Print #freefd, ",";
        End If
    Next i
    Print #freefd,
 
    Close freefd
 
    'shell out to DataLogging Display Application
 
    FileName = """" + FileName + """"
 
    bRet = ShellAndWait("iLog.exe" + " " + FileName, 1, lRet, _
    "", App.Path)
 
    If Not bRet Then
        MsgBox "Could not find iLog Application", vbOKOnly
    End If
 
 
    Exit Sub
HandleError:
    MsgBox Err.Description, vbOKOnly, "Error"
    SetMousePointerBusy False
End Sub
 
Private Sub ClearDataLog()
    Dim prg2 As ark.IProgrammer2
    Dim ventprod5 As ark.IVentureProduct5
 
    If Not g_Cache(g_CurrentEar).LastOp = OP_INIT Then _
        Err.Raise vbObjectError, , "Device not initialized."
 
    Set prg2 = g_Prog
 
    On Error Resume Next
    Set ventprod5 = g_Prod
    On Error GoTo HandleError
 
    If Not ventprod5 Is Nothing Then
        If ventprod5.HybridVal <> 33 Then
            MsgBox "Datalogging is not supported in this product", vbOKOnly, "Error"
            Exit Sub
        End If
    Else
        Exit Sub
    End If
 
    ventprod5.ResetLog prg2, g_CurrentEar
 
    Exit Sub
HandleError:
    MsgBox Err.Description, vbOKOnly, "Error"
 
End Sub