Skip to content

Commit 23325c6

Browse files
committed
Additional work on implicit type conversions
1 parent c5b86b0 commit 23325c6

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

modConverse.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ Module modConverse
238238
Case "link"
239239
If inputData(1) = "insteon" AndAlso inputData(2) = "address" Then
240240
Dim response As String = ""
241-
Dim intLinkType As Integer = 3
241+
Dim intLinkType As Byte = 3
242242
' 0x00 IM is Responder, 0x01 IM is Controller, 0x03 IM is Either
243-
If inputData.Length = 5 Then intLinkType = CInt(inputData(4))
243+
If inputData.Length = 5 Then intLinkType = CByte(inputData(4))
244244
modInsteon.InsteonLinkI2CSDevice(inputData(3), response, intLinkType)
245245
strCommandResponse = "Linking"
246246
End If

modInsteon.vb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@
133133
End Sub
134134

135135
Sub InsteonAlarmControl(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal Command1 As String, Optional ByVal intSeconds As Integer = 0)
136-
Dim comm1 As Short
137-
Dim comm2 As Short
136+
Dim comm1 As Byte
137+
Dim comm2 As Byte
138138

139139
Select Case Command1
140140
Case "Off", "off"
@@ -168,9 +168,9 @@
168168
InsteonSendStdCommand(strAddress, 13, 0)
169169
End Sub
170170

171-
Sub InsteonLightControl(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal Command1 As String, Optional ByVal intBrightness As Integer = 255)
172-
Dim comm1 As Short
173-
Dim comm2 As Short
171+
Sub InsteonLightControl(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal Command1 As String, Optional ByVal intBrightness As Byte = 255)
172+
Dim comm1 As Byte
173+
Dim comm2 As Byte
174174
Dim needExtended As Boolean = False
175175

176176
Select Case Command1
@@ -215,7 +215,7 @@
215215
End If
216216
End Sub
217217

218-
Sub InsteonLinkI2CSDevice(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal intLinkType As Integer)
218+
Sub InsteonLinkI2CSDevice(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal intLinkType As Byte)
219219
SyncLock serialLock
220220
Dim data(4) As Byte
221221

@@ -243,7 +243,7 @@
243243
End Select
244244
End Sub
245245

246-
Sub InsteonSendExtCommand(ByVal strAddress As String, ByVal comm1 As Short, ByVal comm2 As Short)
246+
Sub InsteonSendExtCommand(ByVal strAddress As String, ByVal comm1 As Byte, ByVal comm2 As Byte)
247247
SyncLock serialLock
248248
If My.Settings.Insteon_Enable = True Then
249249
If SerialPLM.IsOpen = True Then
@@ -275,7 +275,7 @@
275275
End SyncLock
276276
End Sub
277277

278-
Sub InsteonSendStdCommand(ByVal strAddress As String, ByVal comm1 As Short, ByVal comm2 As Short)
278+
Sub InsteonSendStdCommand(ByVal strAddress As String, ByVal comm1 As Byte, ByVal comm2 As Byte)
279279
SyncLock serialLock
280280
If My.Settings.Insteon_Enable = True Then
281281
If SerialPLM.IsOpen = True Then
@@ -306,9 +306,9 @@
306306
End SyncLock
307307
End Sub
308308

309-
Sub InsteonThermostatControl(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal Command1 As String, Optional ByVal intTemperature As Integer = 72)
310-
Dim comm1 As Short
311-
Dim comm2 As Short
309+
Sub InsteonThermostatControl(ByVal strAddress As String, ByRef ResponseMsg As String, ByVal Command1 As String, Optional ByVal intTemperature As Byte = 72)
310+
Dim comm1 As Byte
311+
Dim comm2 As Byte
312312

313313
If strAddress = "" And My.Settings.Insteon_ThermostatAddr = "" Then
314314
My.Application.Log.WriteEntry("No thermostat set, asking for it")
@@ -327,7 +327,7 @@
327327
comm2 = 5
328328
Case "CoolSet", "coolset"
329329
comm1 = 108
330-
comm2 = intTemperature * 2
330+
comm2 = CByte(intTemperature * 2)
331331
Case "Down", "down"
332332
comm1 = 105
333333
comm2 = 2
@@ -342,7 +342,7 @@
342342
comm2 = 4
343343
Case "HeatSet", "heatset"
344344
comm1 = 109
345-
comm2 = intTemperature * 2
345+
comm2 = CByte(intTemperature * 2)
346346
Case "Off", "off"
347347
comm1 = 107
348348
comm2 = 9
@@ -405,7 +405,7 @@
405405
Dim PLMThread As New Threading.Thread(AddressOf PLM)
406406

407407
Do Until SerialPLM.BytesToRead = 0
408-
x(x_LastWrite + 1) = SerialPLM.ReadByte
408+
x(x_LastWrite + 1) = CByte(SerialPLM.ReadByte)
409409
x(x_LastWrite + 10) = 0
410410
If x_LastWrite < 30 Then x(x_LastWrite + 1001) = x(x_LastWrite + 1)
411411
' the ends overlap so no message breaks over the limit of the array
@@ -1274,8 +1274,8 @@
12741274
Function X10SendCommand(ByVal strAddress As String, ByVal strCommand As String) As String
12751275
Dim strOutcome As String = ""
12761276
Dim bytCommand As Byte
1277-
Dim HouseCode As Byte = Asc(strAddress.Substring(0, 1)) - 65
1278-
Dim DeviceCode As Byte = CInt(strAddress.Substring(1, strAddress.Length - 1))
1277+
Dim HouseCode As Byte = CByte(Asc(strAddress.Substring(0, 1)) - 65)
1278+
Dim DeviceCode As Byte = CByte(strAddress.Substring(1, strAddress.Length - 1))
12791279

12801280
Select Case strCommand
12811281
Case "bright"
@@ -2040,10 +2040,10 @@
20402040
' TODO: Don't assume this info is temperature! It might not be! (But currently my code only requests it.)
20412041
modDatabase.Execute("INSERT INTO ENVIRONMENT (Date, Source, Location, Temperature) VALUES('" + Now.ToUniversalTime.ToString("u") & "', 'Insteon " & FromAddress & "', 'Interior', " & CStr(Int(comm2 / 2)) & ")")
20422042
If FromAddress = My.Settings.Insteon_ThermostatAddr Then
2043-
My.Settings.Global_LastKnownInsideTemp = Int(comm2 / 2)
2043+
My.Settings.Global_LastKnownInsideTemp = CInt(Int(comm2 / 2))
20442044
My.Settings.Global_TimeThermostatLastUpdated = Now()
20452045
ElseIf FromAddress = My.Settings.Insteon_ThermostatSlaveAddr Then
2046-
My.Settings.Global_LastKnownInsideTemp2nd = Int(comm2 / 2)
2046+
My.Settings.Global_LastKnownInsideTemp2nd = CInt(Int(comm2 / 2))
20472047
End If
20482048
' TODO: Probably should grab these temperature warnings from the second thermostat too someday.
20492049
If My.Settings.Global_LastKnownInsideTemp >= My.Settings.Global_InsideTempHeatWarning Then
@@ -2058,10 +2058,10 @@
20582058
Case 110
20592059
modDatabase.Execute("INSERT INTO ENVIRONMENT (Date, Source, Location, Temperature) VALUES('" & Now.ToUniversalTime.ToString("u") & "', 'Insteon " & FromAddress & "', 'Interior', " & CStr(Int(comm2 / 2)) & ")")
20602060
If FromAddress = My.Settings.Insteon_ThermostatAddr Then
2061-
My.Settings.Global_LastKnownInsideTemp = Int(comm2 / 2)
2061+
My.Settings.Global_LastKnownInsideTemp = CInt(Int(comm2 / 2))
20622062
My.Settings.Global_TimeThermostatLastUpdated = Now()
20632063
ElseIf FromAddress = My.Settings.Insteon_ThermostatSlaveAddr Then
2064-
My.Settings.Global_LastKnownInsideTemp2nd = Int(comm2 / 2)
2064+
My.Settings.Global_LastKnownInsideTemp2nd = CInt(Int(comm2 / 2))
20652065
End If
20662066
Return "Temperature: " & CStr(Int(comm2 / 2)) & " F"
20672067
Case 111

0 commit comments

Comments
 (0)