Skip to content

Commit

Permalink
Preliminary support for VoiceAttack SDK version 4... not extensively …
Browse files Browse the repository at this point in the history
…tested yet
  • Loading branch information
Antaniserse committed Nov 18, 2016
1 parent adf3354 commit db5553c
Show file tree
Hide file tree
Showing 27 changed files with 1,337 additions and 1,548 deletions.
430 changes: 119 additions & 311 deletions TestApp/Form1.designer.vb

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions TestApp/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="BindingSourceMathCond.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>9, 12</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down
621 changes: 279 additions & 342 deletions TestApp/Form1.vb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions TestApp/TestApp.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="VAProxyReplica.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Form1.resx">
Expand Down
138 changes: 138 additions & 0 deletions TestApp/VAProxyReplica.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
Public Class VAProxyReplica
Public Context As String

Public SessionState As New Dictionary(Of String, Object)

Private smallIntValues As Dictionary(Of String, Nullable(Of Int16)) = New Dictionary(Of String, Nullable(Of Int16))
Private textValues As Dictionary(Of String, String) = New Dictionary(Of String, String)
Private intValues As Dictionary(Of String, Nullable(Of Integer)) = New Dictionary(Of String, Nullable(Of Integer))
Private decimalValues As Dictionary(Of String, Nullable(Of Decimal)) = New Dictionary(Of String, Nullable(Of Decimal))
Private booleanValues As Dictionary(Of String, Nullable(Of Boolean)) = New Dictionary(Of String, Nullable(Of Boolean))
Private dateTimeValues As Dictionary(Of String, Nullable(Of DateTime)) = New Dictionary(Of String, Nullable(Of DateTime))
Private extendedValues As Dictionary(Of String, Object) = New Dictionary(Of String, Object)

#Region "Values Get/set"

Public Function GetText(ByVal variableName As String) As String
If textValues.ContainsKey(variableName) Then
Return textValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetText(ByVal variableName As String, ByVal value As String)
If textValues.ContainsKey(variableName) Then textValues.Remove(variableName)
If value IsNot Nothing Then textValues.Add(variableName, value)
End Sub

Public Function GetSmallInt(ByVal variableName As String) As Nullable(Of Int16)
If smallIntValues.ContainsKey(variableName) Then
Return smallIntValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetSmallInt(ByVal variableName As String, ByVal value As Nullable(Of Int16))
If smallIntValues.ContainsKey(variableName) Then smallIntValues.Remove(variableName)
If value.HasValue Then smallIntValues.Add(variableName, value)
End Sub

Public Function GetInt(ByVal variableName As String) As Nullable(Of Int32)
If intValues.ContainsKey(variableName) Then
Return intValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetInt(ByVal variableName As String, ByVal value As Nullable(Of Int32))
If intValues.ContainsKey(variableName) Then intValues.Remove(variableName)
If value.HasValue Then intValues.Add(variableName, value)
End Sub

Public Function GetDecimal(ByVal variableName As String) As Nullable(Of Decimal)
If decimalValues.ContainsKey(variableName) Then
Return decimalValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetDecimal(ByVal variableName As String, ByVal value As Nullable(Of Decimal))
If decimalValues.ContainsKey(variableName) Then decimalValues.Remove(variableName)
If value.HasValue Then decimalValues.Add(variableName, value)
End Sub

Public Function GetBoolean(ByVal variableName As String) As Nullable(Of Boolean)
If booleanValues.ContainsKey(variableName) Then
Return booleanValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetBoolean(ByVal variableName As String, ByVal value As Nullable(Of Boolean))
If booleanValues.ContainsKey(variableName) Then booleanValues.Remove(variableName)
If value.HasValue Then booleanValues.Add(variableName, value)
End Sub

Public Function GetDateTime(ByVal variableName As String) As Nullable(Of DateTime)
If dateTimeValues.ContainsKey(variableName) Then
Return dateTimeValues(variableName)
Else
Return Nothing
End If
End Function

Public Sub SetDateTime(ByVal variableName As String, ByVal value As Nullable(Of DateTime))
If dateTimeValues.ContainsKey(variableName) Then dateTimeValues.Remove(variableName)
dateTimeValues.Add(variableName, value)
End Sub
#End Region

#Region "Misc"
Public Function ProxyVersion() As System.Version
Return New System.Version(4, 0, 0, 0)
End Function

Public Function VAVersion() As System.Version
Return New System.Version(1, 5, 7, 3)
End Function

Public Function GetProfileName() As String
Return "TestApp profile"
End Function

Public Function CommandExists(ByVal name As String) As Boolean
Return True
End Function

Public Sub ExecuteCommand(ByVal name As String)
Return
End Sub

Public Sub WriteToLog(ByVal value As String, color As String)
Debug.WriteLine(String.Format("[VA LOG {0}({1})]", value, color))
End Sub

Public Function ParseTokens(ByVal name As String) As String
Return String.Empty
End Function
#End Region

#Region "** Not included in VA interface"
Public Sub ClearAllInput()
'SessionState is left untouched
smallIntValues.Clear()
textValues.Clear()
intValues.Clear()
decimalValues.Clear()
booleanValues.Clear()
dateTimeValues.Clear()
extendedValues.Clear()
End Sub
#End Region

End Class
2 changes: 2 additions & 0 deletions VAExtensions/App.vb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Public Const KEY_DB_COLUMNS As String = "VxDBColumns"
Public Const KEY_DB_WHERE As String = "VxDBWhere"

Public Const KEY_TIMER As String = "VxTimer" 'VxTimer0, VxTimer1, etc.
Public Const KEY_TIMER_RESULT As String = "VxTimerResult" 'VxTimerResult0, VxTimerResult1, etc.

Public Const KEY_RANGEMIN As String = "VxRangeMin" '"VAMathRangeMin"
Public Const KEY_RANGEMAX As String = "VxRangeMax" '"VAMathRangeMax"
Expand Down
64 changes: 20 additions & 44 deletions VAExtensions/ContextHandlers/ContextFactory.vb
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,17 @@
<EnumInfo("Delete a record into a SQLite database", "delete_db")>
DeleteDB


<EnumInfo("Perform an addition of all the given values", "math_add")>
MathAdd
<EnumInfo("Perform an subtraction of all the given values", "math_subtract")>
MathSubtract
<EnumInfo("Perform a multiplication of all the given values", "math_multiply")>
MathMultiply
<EnumInfo("Perform a division of all the given values", "math_divide")>
MathDivide
<EnumInfo("Perform a modulo operation (remainder of division) all the given values", "math_mod")>
MathMod
<EnumInfo("Return the higher in a list of values", "math_max")>
MathMax
<EnumInfo("Return the lower in a list of values", "math_min")>
MathMin

<EnumInfo("Perform a bitwise AND operation between two supplied values", "bit_and")>
BitAnd
<EnumInfo("Perform a bitwise OR operation between two supplied values", "bit_or")>
BitOr
<EnumInfo("Perform a bitwise XOR operation between two supplied values", "bit_xor")>
BitXOr

<EnumInfo("Start a timer of X seconds and manage the countdown to zero", "countdown")>
Countdown
<EnumInfo("Start a timer of X seconds", "timer_start")>
TimerStart
<EnumInfo("Check timer running time", "timer_check")>
TimerCheck

<EnumInfo("Create a random list of non-repeating numbers", "rnd_init")>
RandomInit
Expand All @@ -81,59 +67,49 @@
SupportedContexts.AddRange(EnumInfoAttribute.ToSimpleList(Of Contexts))
End Sub

Public Shared Function Create(ByVal contextName As String, ByRef state As Dictionary(Of String, Object) _
, ByRef smallIntValues As Dictionary(Of String, Nullable(Of Short)) _
, ByRef textValues As Dictionary(Of String, String) _
, ByRef intValues As Dictionary(Of String, Nullable(Of Integer)) _
, ByRef decimalValues As Dictionary(Of String, Nullable(Of Decimal)) _
, ByRef booleanValues As Dictionary(Of String, Nullable(Of Boolean)) _
, ByRef extendedValues As Dictionary(Of String, Object)) As ContextHandlerBase
Public Shared Function Create(vaProxy As Object) As ContextHandlerBase

Dim result As ContextHandlerBase = Nothing

For Each c As Contexts In SupportedContexts
If String.Compare(EnumInfoAttribute.GetTag(c), contextName, True) = 0 Then
If String.Compare(EnumInfoAttribute.GetTag(c), vaProxy.Context, True) = 0 Then
Select Case c
Case Contexts.Config
result = New ContextHandlerInfoDialog(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerInfoDialog(c, vaProxy)

Case Contexts.ReadFile
result = New ContextHandlerReadFile(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadFile(c, vaProxy)

Case Contexts.ReadXml
result = New ContextHandlerReadXML(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadXML(c, vaProxy)

Case Contexts.ReadJSON
result = New ContextHandlerReadJSON(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadJSON(c, vaProxy)

Case Contexts.ReadRSS
result = New ContextHandlerReadRSS(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadRSS(c, vaProxy)

Case Contexts.LoadCSV, Contexts.ReadCSV, Contexts.SearchCSV
result = New ContextHandlerReadCSV(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadCSV(c, vaProxy)

Case Contexts.ShowFile, Contexts.ShowText
result = New ContextHandlerShowFile(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerShowFile(c, vaProxy)

Case Contexts.SpellText
result = New ContextHandlerSpellText(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerSpellText(c, vaProxy)

Case Contexts.ReadStdOut
result = New ContextHandlerReadStdOut(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadStdOut(c, vaProxy)

Case Contexts.ReadINI
result = New ContextHandlerReadINI(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerReadINI(c, vaProxy)
Case Contexts.WriteINI
result = New ContextHandlerWriteINI(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)

Case Contexts.MathAdd, Contexts.MathSubtract, Contexts.MathMultiply, Contexts.MathDivide _
, Contexts.MathMod, Contexts.MathMin, Contexts.MathMax, Contexts.BitAnd, Contexts.BitOr, Contexts.BitXOr
result = New ContextHandlerMath(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerWriteINI(c, vaProxy)

Case Contexts.RandomInit, Contexts.RandomNext
result = New ContextHandlerRandom(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
Case Contexts.Countdown
result = New ContextHandlerCountdown(c, state, smallIntValues, textValues, intValues, decimalValues, booleanValues, extendedValues)
result = New ContextHandlerRandom(c, vaProxy)
Case Contexts.TimerStart, Contexts.TimerCheck
result = New ContextHandlerCountdown(c, vaProxy)

End Select
Exit For
Expand Down
40 changes: 10 additions & 30 deletions VAExtensions/ContextHandlers/ContextHandlerBase.vb
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
Public MustInherit Class ContextHandlerBase
Public Const ERR_CONTEXT As Int16 = 1
Public Const ERR_IO As Int16 = 2
Public Const ERR_ARGUMENTS As Int16 = 3
Public Const ERR_CONTEXT As Int16 = 1
Public Const ERR_IO As Int16 = 2
Public Const ERR_ARGUMENTS As Int16 = 3

Protected m_Context As ContextFactory.Contexts
Protected m_State As Dictionary(Of String, Object)
Protected m_smallIntValues As Dictionary(Of String, Nullable(Of Short))
Protected m_TextValues As Dictionary(Of String, String)
Protected m_intValues As Dictionary(Of String, Nullable(Of Integer))
Protected m_decimalValues As Dictionary(Of String, Nullable(Of Decimal))
Protected m_booleanValues As Dictionary(Of String, Nullable(Of Boolean))
Protected m_ExtendedValues As Dictionary(Of String, Object)
Protected Context As ContextFactory.Contexts
Protected VAProxy As Object

Public Sub New(ByVal context As ContextFactory.Contexts, ByRef state As Dictionary(Of String, Object) _
, ByRef smallIntValues As Dictionary(Of String, Nullable(Of Short)) _
, ByRef textValues As Dictionary(Of String, String) _
, ByRef intValues As Dictionary(Of String, Nullable(Of Integer)) _
, ByRef decimalValues As Dictionary(Of String, Nullable(Of Decimal)) _
, ByRef booleanValues As Dictionary(Of String, Nullable(Of Boolean)) _
, ByRef extendedValues As Dictionary(Of String, Object))
Public Sub New(ByVal context As ContextFactory.Contexts, vaProxy As Object)
Me.Context = context
Me.VAProxy = vaProxy
End Sub


m_Context = context
m_State = state
m_smallIntValues = smallIntValues
m_TextValues = textValues
m_intValues = intValues
m_decimalValues = decimalValues
m_booleanValues = booleanValues
m_ExtendedValues = extendedValues
End Sub

Public MustOverride Function Execute() As Boolean
Public MustOverride Function Execute() As Boolean
End Class
Loading

0 comments on commit db5553c

Please sign in to comment.