Introduction | Core Component | Communications | Additional Topics | Reference Guide
Additional Topics
Selecting a Product Component
Once a product component library is selected, the software can then choose an individual product component from the library. In the Params example, the user is permitted to choose a product component via the Products drop down list. The code that is executed when a new product component is chosen is as follows:
Private Sub cmbProducts_Click()
Dim mem As ARK.IMemory
On Error GoTo HandleError
' Get the memory object for the current product so that it can
' be applied to the newly selected product if it has the same
' parameter map.
If Not m_Prod Is Nothing Then
Set mem = m_Prod.GetControllerMemoryEx(From, fResistor, Nothing)
End If
With cmbProducts
Set m_Prod = m_Lib.Products(.ItemData(.ListIndex))
End With
If m_LastParameterMap = m_Prod.ParameterMap And Not mem Is Nothing Then
If Not m_Control Is Nothing Then
m_Prod.SetControllerMemoryEx m_Control
End If
m_Prod.SetControllerMemoryEx mem
Else
If m_LastOp = OP_INIT Then
MsgBox "You have selected a product component with " + _
"incompatible parameters. The device will have to " + _
"be re-initialized before you can access it again."
UpdateState OP_WHICHCHIP
Set m_Control = Nothing
End If
End If
Set m_ParamList = m_Prod.IntParameters
m_LastParameterMap = m_Prod.ParameterMap
UpdateParameterList
lblParameter.Caption = ""
txtValue.Text = ""
lblRange.Caption = ""
Set m_Param = Nothing
Exit Sub
HandleError:
MsgBox Err.Description, vbOKOnly Or vbExclamation, "Error"
End Sub
In the above code, when a new product component is selected and has the same parameter map as the previous product component, the configuration data is transferred to the new component. This is implemented in the above code in three steps:
- GetControllerMemoryEx is used to obtain the configuration data for the previously selected product component
- The new product component is selected from the Products collection
- The configuration data is passed to the new product component with SetControllerMemoryEx.
Before the third step, the control data obtained in the last call to
cmdInit_Click is also passed to the new product component.
Note that in the line
Set m_Prod = m_Lib.Products(.ItemData(.ListIndex))
there is no
.CreateObject. Incorporating such a method was unnecessary, because the product is contained within the product component library DLL, and the DLL has already been instantiated.
If the new product component has a different parameter map than the previous product component, the hearing instrument must be re-initialized. This is because the new product component might be incompatible with the connected hearing instrument or might require different control data to be read from the instrument.
Using Multiple Memories
The previous section and the Params example have dealt with a single memory system. When implementing multiple memories, the following should be kept in mind.
All of the memories must use the same product component. If the application must remember the parameter values for all of the memories, an array of
Memory objects should be maintained that keeps track of the state of all of the memories. When the user switches to a different memory,
GetControllerMemoryEx can be used to save the state of the product component into a
Memory object which is then stored in the array. Then, the
Memory object corresponding to the newly selected memory can be reapplied to the product component using
SetControllerMemoryEx.
A new controller component method in
IProgrammer2, called
SwitchToMemory, causes the hearing instrument to load a specified memory from EEPROM into registers, thus making it active. When communicating with PARAGON hybrids, an exception is raised if the memory is invalid that the application is attempting to switch to. An exception is also raised if the PARAGON hybrid is configured to be in static mode (more on this below). When communicating with programmable analog hybrids, the hybrid goes to the "short" or "open" state, depending on how the device is configured.
In PARAGON hybrids,
SwitchToMemory only works when the hybrid is configured to be in momentary mode, which is the default. Switching to static mode is possible by setting the MSS parameter to 1 in the control
Memory object. In the IDS, this parameter can be changed under Programmer->Settings... Burning to other memories in static mode is also not possible when
GetControllerMemoryEx has been called with the fROMandRegisters argument, because the Burn operation first needs to be able to switch to the desired memory. It is recommended that fitting software temporarily switch to momentary mode when programming, so that the Burn operation can be performed in the normal way. If this is not desirable,
GetControllerMemoryEx could be called with the fROM argument to cause the Burn operation to burn to the other memory strictly in EEPROM. A Write operation could then be performed to change the active settings and allow the patient to hear the changes.
For examples on how to implement multiple memories, refer to the source code for the Interactive Data Sheet.
Graphing
The
IProduct2 interface exposes the
Graphs collection and a number of properties to assist with plotting curves. The properties
MaxOutput,
MaxGain,
IsAcoustic, and
HasWDRC provide information that may be useful in scaling graphs.
MaxOutput returns an estimate of the maximum output of the product.
MaxGain returns an estimate of the maximum gain of the product in dB. In these two methods, acoustic products return a number in dBSPL and electrical products return a number in dBV.
IsAcoustic and
HasWDRC return boolean values.
The
Graphs collection contains one or more models that can be used to plot curves describing the behaviour of the product at the current parameter settings. Element 0 in the collection is always the model that describes the entire system from the microphone port to the end of the receiver tubing, in acoustic models, and from the input of the hybrid to the output, in electrical models. Other elements in the
Graphs collection may contain models demonstrating the crossover frequencies in the filter bank, polar patterns, or other views of the system.
The standard interface to a
Graph object is called
IGraph. The most important parts of
IGraph are the
Prepare and
CalcPoint methods.
Prepare must be called before
CalcPoint if the internal or external parameters have changed since the last call to
Prepare or if
Prepare has not been called yet. It is typically called once every time a graph is redrawn in the application.
Prepare performs any calculations that depend on the parameter values but not the input level or frequency.
CalcPoint takes two or three parameters. The first is the input level in dBSPL for acoustic products or dBV for electrical products. The second is the frequency, in Hertz. The third parameter, which is optional, is the channel number. An example of a multi-channel model is the crossover frequency model in the GA3203 library, which outputs the high and low channels of the band-split filter. System models are always single channel, because they have a single input and output.
The Params example allows the user to copy the frequency response for the currently selected product at a selected input level. The code that implements this feature is given below.
Private Sub cmdCopyFreqResp_Click()
Dim i As Integer
Dim inputlevel As Double
Dim s As String
Dim graph As ARK.IGraph
On Error GoTo BadValue
inputlevel = CDbl(txtInputLevel.Text)
On Error GoTo HandleError
' Get the graph object for the entire system (item 0) from the Graphs collection.
Set graph = m_Prod.Graphs(0)
graph.Prepare
s = ""
For i = 1 To 80
s = s + CStr(i * 100) + vbTab + _
Format(graph.CalcPoint(inputlevel, i * 100), "0.0###") + vbCrLf
Next i
Clipboard.Clear
Clipboard.SetText s, vbCFText
Exit Sub
BadValue:
MsgBox "The input level must be a number.", vbOKOnly, "Bad Value"
Exit Sub
HandleError:
MsgBox Err.Description, vbOKOnly Or vbExclamation, "Error"
End Sub
PARAGON Special Features
ManIDs, LibraryIDs, and ProductIDs
The control memory in PARAGON-based hearing instruments contains several fields to help fitting software determine which product component from which library was used to program the hearing instrument. These parameters can be examined in the
Parameters collection of the control
Memory object after
Init is called. In this case,
Init should be called rather than
InitEx, because
InitEx requires
GetFull to have been called before, which assumes that a product component has already been selected. The
ManID and
LibraryID properties of the
ICatalogEntry2 interface can then be used to locate the particular library in the Libraries catalog, and the ProductID can be used as an index into the
Products collection to find the particular product component. Once a product component is selected, the hearing instrument should be initialized again in the normal way using
InitEx and
GetFull.
The Scratch Area
The remaining PARAGON special features are exposed through a special interface that extends
IProduct2 called
IProductWithUtilities.
Before using any of the other scratch-related methods,
InitScratch must be called with the desired number of bytes of scratch space as an argument. The GB3210-S01 PAL currently supports up to 256 bytes of scratch space.
The other methods convert a
Memory object to a byte array and vice versa. These methods are used in a similar way to
GetControllerMemoryEx and
SetControllerMemoryEx. When reading from the scratch area, the following three steps need to occur:
The conversion methods with the word
Safe appended to them should be used with Visual Basic, Matlab, and other languages that implement arrays in COM as SAFEARRAYs. The methods that do not have
Safe appended should be used with C++.
When burning to the scratch area, these steps need to occur:
When calling
ReadEx or
Burn when accessing scratch data, the memory number parameter is not relevant and should be -1.
If the information in the scratch area needs to be accessed before a product component is selected, it can be read after calling
Init rather than
InitEx, as described in the previous section.
Below is a self-contained example that burns 256 bytes to the scratch area then reads it back.
Private Sub cmdScratchEx_Click()
Dim i As Integer
Dim myark As New ARK.Core2
Dim prg As ARK.IProgrammer2
Dim lib As ARK.ILibrary
Dim prod As ARK.IProductWithUtilities
Dim mem As ARK.IMemory2
Dim control As ARK.IMemory
Dim scratch(0 To 255) As Byte
Dim out() As Byte
' Select a library and product
Set lib = myark.Libraries("GB3210").CreateObject
Set prod = lib.Products(0)
' Initialize the controller component and device
Set prg = myark.Programmers("GenHiPro").CreateObject
prg.Open hWnd
Debug.Print prg.WhichChip(fLeft)
Debug.Print prg.Init(fLeft, control)
' Fill the scratch array with arbitrary values
For i = 0 To 255
scratch(i) = i
Next i
' Initialize the scratch area to be 256 bytes long
prod.InitScratch 256
' Burn in the scratch array
Set mem = prod.ScratchArrayToMemorySafe(scratch)
prg.Burn fLeft, -1, mem
' Read back the scratch array
Set mem = prod.GetFull(fScratch)
prg.ReadEx fLeft, -1, mem
prod.MemoryToScratchArraySafe mem, 256, out
' Compare what was burned with what was read back
For i = 0 To 255
Debug.Assert scratch(i) = out(i)
Next i
Set prod = Nothing
Set lib = Nothing
Set prg = Nothing
Set myark = Nothing
End Sub
Tone Generation
The amplitude and frequency of the tone generator are set through the parameter map. The only additional function that is needed turns the generator on and off. The
EnableToneGenerator method in
IProductWithUtilities allows the application to do this. If the
enable argument is
True, the tone generator is turned on, and if the argument is
False, the tone generator is turned off.
In PARAGON,
Write and
Burn operations automatically turn off the tone generator. Also, the tone generator cannot be enabled when HRX is enabled.
ACME2 Parameters
Several of the new ACME 2 features are exposed through the control memory. These parameters can be examined in the control
Memory object after
Init is called.
The name and functionality of these parameters are as follows:
- MemChangeTone - 1 if a memory change tone should be played, 0 if not. MemChangeMultiBeep- 1 if multiple beeps should be played on a memory change, 0 if not. (MemChangeTone parameter must be 1 for this feature to take effect.) P3Switch - 1 if static mode MS switch is to be configured as a tri-state mode to select memory A, B and C, 0 if not. (MSS must be 1 in order to use this feature.)
- MemDOnly - 1 if the MS2 switch is to be used to select Memory D, 0 if not. (MSS must be 1 in order to use this feature.)
NEXT:
Reference Guide