This is an old revision of the document!


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:

  • The datalogging version is stored in the first line of the file (row 1). This row has 1 field only. Eg.: –Version 1.0–
  • For (rows > 1) and (rows < TotalRows-1), the fields are as follows (there are 5 fields):
    1. Timestamp
    2. Battery Level
    3. Memory
    4. VC Level
    5. Ambient Level
  • For the list row (TotalRows-1), the lifetime statistics (time spent in each memory in 15 minute increments) is stored. This row has 4 fields only. It has the following format:
    1. Total spent in Memory 1
    2. Total spent in Memory 2
    3. Total spent in Memory 3
    4. Total spent in Memory 4
  • Example:
    --Version 1.0--					
    0,2,0,0,55
    0,3,0,0,76
    0,3,0,-42.1,55
    0,2,1,0,82
    0,2,1,0,67
    0,3,1,0,82
    0,2,1,0,73
    0,2,1,0,67
    0,2,1,0,61
    0,2,2,0,61
    2,2,2,0,55
    . . .
    0,3,0,0,58
    0,3,0,0,61
    1283,5,1,0

Field Details

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

  • The timestamp is a value from 0 to 63. Each increment of the timestamp represents 15 minutes of elapsed time.
  • At power on, the logging routine will always log a new value with a timestamp of 0 to represent a new session.
  • If the device remains powered on for more than 16 hours, the device will log a timestamp of 63 (even if nothing changed in the part), and the timestamps will start again at 1 (i.e. a timestamp of 0 will be skipped because this value indicates a new session).

2. Battery Level

  • The battery level is a value from 0 to 3.
  • 3 = 1.3V or higher
  • 2 = 1.2V to 1.29V
  • 1 = 1.1V to 1.19V
  • 0 = Less than 1.1V

3. Memory

  • 0 = memory 1
  • 1 = memory 2
  • 2 = memory 3
  • 3 = memory 4

4. VC Level

  • 0 to -47.1 dB

5. Ambient Level

  • 55 to 100 dBSPL

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