I'm trying to construct a VBA script that opens INCA and extracts specific calibration values.
To start, I found a Youtube video by ETAS (https://www.youtube.com/watch?v=OQAvE0UT5xk), and I copied the code from there:
Private Function inca_com_api() As Variant
Dim Inca As Object
Dim DB As Object
Dim DBname As String
Dim devices() As Variant
Dim calValue As Variant
Set Inca = CreateObject("inca.inca")
Set DB = Inca.GetCurrentDataBase
DBname = DB.GetName
inca_com_api = DBname
Inca.DisconnectFromTool
End Function
The code opens INCA and runs as intended, returning the database name, but what I want is not the database name, but specific calibration values.
I was under the impression that I could just use the API functions listed in the User's Guide for INCA-MIP (https://www.etas.com/en/downloadcenter/18008.php), which is the INCA COM-API interface package for Matlab.
I don't have INCA-MIP, I just thought I could call those functions through VBA, by using the same function name or similar function names.
But when I try code like:
devices() = DB.IncaGetDevices
or
devices() = DB.GetDevices
or
devices() = Inca.IncaGetDevices
or
devices() = Inca.GetDevices
or the same variations of GetCalibrationValue, IncaGetCalibrationValue, I get:
Run-time error '438': Object doesn't support this property or method
I was planning to use IncaGetDevices to show me a device name, which I could then use as an input argument for IncaGetCalibrationValue, for each of my specific calibration names that I want returned.
Again, I don't have INCA-MIP, but I am wondering how I can return these calibration values using the VBA and the COM-API for INCA?
Also, I tried looking through the following posts for answers:
In ETAS INCA, is there a way to quickly retrieve an item from an arbitrary path in an ASAP2Project?
In ETAS INCA, what classes correspond to each type of database item?
but I don't really know what they're talking about.
Any help would be appreciated.
The syntax used in INCA-MIP is different to the COM API syntax.
The documentation you're looking for is located in the "cebra" folder of your INCA installation. Example: "C:\ETAS\INCA7.5\cebra\INCA Tool-API Documentation.chm"
Here is a small example how to get a scalar calibration value from your currently opened experiment:
Dim IncaApi
Dim oOnlineExperiment
Dim oExperimentView
Dim DEVICE_ID
Dim DEVICELIST_ID
Dim CALIBRATION_ScalarObj
Dim Scalar
Dim ScalarVal
' Calibration labels
Scalar = "DEMO_CONSTANT_1"
Set IncaApi = CreateObject ("Inca.Inca")
' Use currently opened experiment
Set oOnlineExperiment = IncaApi.GetOpenedExperiment()
'Set oExperimentView = IncaApi.GetOpenedExperimentView()
' Get a reference to the device used in this experiment
DEVICELIST_ID = oOnlineExperiment.GetAllDevices()
Set DEVICE_ID = DEVICELIST_ID(0)
Set CALIBRATION_ScalarObj = oOnlineExperiment.GetCalibrationValueInDevice (Scalar, DEVICE_ID)
'oExperimentView.OpenViewForExperimentDataItem(CALIBRATION_ScalarObj)
ScalarVal = CALIBRATION_ScalarObj.GetDoublePhysValue() ' "ScalarVal" contains the current value
WScript.Echo ScalarVal
IncaApi.DisconnectFromTool()
Set IncaApi = Nothing
You can include the ExperimentView to show the calibration item in the experiment view