Frédéric-O DUCHEMIN Posted June 18, 2015 Report Share Posted June 18, 2015 Hi Paul, Sometimes and some payware flood NAV com This an example 19:23 UTC Transponder set to 0465 19:23 UTC Transponder set to 0465 19:24 UTC Transponder set to 0465 19:24 UTC Transponder set to 0465 19:24 UTC Transponder set to 0465 19:24 UTC Transponder set to 0465 19:25 UTC Transponder set to 0465 19:25 UTC Transponder set to 0465 19:25 UTC Transponder set to 0465 19:25 UTC Transponder set to 0465 19:26 UTC Transponder set to 0465 19:26 UTC Transponder set to 0465 19:26 UTC Transponder set to 0465 19:27 UTC Transponder set to 0465 19:27 UTC Transponder set to 0465 Link: http://www.skydream-airlines.com/index.php/pireps/view/1649 the code: Public transponder As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H354) Public Function gettransponder() Return (Conversion.Hex(transponder.Value)).ToString() End Function Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value = txtTransponder.Text Then Else Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponder, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) transponder = txtTransponder.Text End If tmrtrans.Stop() End Sub Private Sub txtTransponder_TextChanged(sender As Object, e As EventArgs) Handles txtTransponder.TextChanged If txtTransponder.Text.Length = 1 Then txtTransponder.Text = "000" & txtTransponder.Text End If If txtTransponder.Text.Length = 2 Then txtTransponder.Text = "00" & txtTransponder.Text End If If txtTransponder.Text.Length = 3 Then txtTransponder.Text = "0" & txtTransponder.Text End If tmrtrans.Start() End Sub The question: How to avoid to catch the value when is the same ? Regards, Fred Link to comment Share on other sites More sharing options...
Paul Henty Posted June 18, 2015 Report Share Posted June 18, 2015 Hi Fred, This line in tmrtrans_tick() is wrong: If transponder.Value = txtTransponder.Text Then It's trying to catch the same value so the log line does not appear. But, it's testing the integer value against the converted hex string. They will never be the same. The easiest way to fix this with the code you have is: 1. Create a form level private variable to hold the last value written: (Make it the same type as the offset (i.e. Integer)) Private lastTransponder as Integer 2. Change the tmrtrans_tick() to test against this value. When you write a new value, update the 'lastTransponder' variable: (I also rewrote the 'If = then else' as 'if <> then') Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value <> lastTransponder Then Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponder, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Value End If tmrtrans.Stop() End Sub Try that. Paul Link to comment Share on other sites More sharing options...
Frédéric-O DUCHEMIN Posted June 18, 2015 Author Report Share Posted June 18, 2015 Thanks Paul, Problem maybe the timer is stopped but never started Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value <> lastTransponder Then Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponder, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Value End If tmrtrans.Stop() End Sub I will make a try. I suppose all NAV and COM it's wrong ?! Private Sub txtNAV1_TextChanged(sender As Object, e As EventArgs) Handles txtNAV1.TextChanged tmrNAV1.Start() End Sub Private Sub tmrNAV1_Tick(sender As Object, e As EventArgs) Handles tmrNAV1.Tick If nav1.Value = txtNAV1.Text Then Else Dim nav1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "NAV1 set to " & txtNAV1.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, nav1, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "NAV1 set to " & txtNAV1.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) nav1 = txtNAV1.Text End If tmrNAV1.Stop() End Sub Private Sub txtCOM2_TextChanged(sender As Object, e As EventArgs) Handles txtCOM2.TextChanged tmrCOM2.Start() End Sub Private Sub tmrCOM2_Tick(sender As Object, e As EventArgs) Handles tmrCOM2.Tick If com2.Value = txtCOM2.Text Then Else Dim com2 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "COM2 set to " & txtCOM2.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, com2, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "COM2 set to " & txtCOM2.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) com2 = txtCOM2.Text End If tmrCOM2.Stop() End Sub Private Sub txtCOM1_TextChanged(sender As Object, e As EventArgs) Handles txtCOM1.TextChanged tmrCOM1.Start() End Sub Private Sub tmrCOM1_Tick(sender As Object, e As EventArgs) Handles tmrCOM1.Tick If com1.Value = txtCOM1.Text Then Else Dim com1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "COM1 set to " & txtCOM1.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, com1, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "COM1 set to " & txtCOM1.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) com1 = txtCOM1.Text End If tmrCOM1.Stop() End Sub Private Sub Cbqnh_TextChanged(sender As Object, e As EventArgs) Handles Cbqnh.TextChanged tmrQNH.Start() End Sub Private Sub tmrQNH_Tick(sender As Object, e As EventArgs) Handles tmrQNH.Tick ' If qnh.Value.ToString = Cbqnh.Text Then If Cbqnh.Text = "1013" Then Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "QNH Set to: STD" & vbCrLf My.Computer.FileSystem.WriteAllText(logname, vt, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "QNH Set to: STD" & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) Else Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "QNH Set to: " & Cbqnh.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, vt, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "QNH Set to: " & Cbqnh.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) 'qnh = Cbqnh.Text End If ' End If tmrQNH.Stop() End Sub Link to comment Share on other sites More sharing options...
Paul Henty Posted June 18, 2015 Report Share Posted June 18, 2015 Problem maybe the timer is stopped but never started The timers don't make any sense to me. They seem to be started, run one tick and then stop again. I don't know if you want to sort that out. It could lead to more problems. I suppose all NAV and COM it's wrong ?! Yes they all have the same problem. They all compare the value with the text. It's the same solution: store the last value and compare against that. Paul Link to comment Share on other sites More sharing options...
Frédéric-O DUCHEMIN Posted June 19, 2015 Author Report Share Posted June 19, 2015 Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value <> lastTransponder Then Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponder, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Value End If tmrtrans.Stop() End Sub I have an error in VB 2012 Ultimate with this line with transponder.Value (as string) lastTransponder = transponder.Value I have made the changes bellow: Private lastTransponder as Integer Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value <> lastTransponder Then Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponder, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Length.ToString End If tmrtrans.Stop() End Sub Private Sub txtTransponder_TextChanged(sender As Object, e As EventArgs) Handles txtTransponder.TextChanged tmrtrans.Start() End Sub It's work now but it's the good way to code ?! You told me to remove timers. I'm agree with you so how I can do that ?Thanks, Regards, Fred Link to comment Share on other sites More sharing options...
Paul Henty Posted June 19, 2015 Report Share Posted June 19, 2015 transponder.Length.ToString will not work. I have an error in VB 2012 Ultimate with this line with transponder.Value (as string) Ah yes. I did not see that there is another variable being declared call transponder: Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf This is bad because it's the same name as the offset called transponder. If you change the name of this new variable then it will work. I changed it to transponderMsg: Private Sub tmrtrans_Tick(sender As Object, e As EventArgs) Handles tmrtrans.Tick If transponder.Value <> lastTransponder Then Dim transponderMsg As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponderMsg, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Value End If tmrtrans.Stop() End Sub You told me to remove timers. I'm agree with you so how I can do that ? This should do the same thing without timers. I renamed the timer tick event and removed the timers start/stop calls. Private Sub logTransponder() If transponder.Value <> lastTransponder Then Dim transponderMSg As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf My.Computer.FileSystem.WriteAllText(logname, transponderMSg, True) Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & "*" My.Computer.FileSystem.WriteAllText(reportname, xml, True) lastTransponder = transponder.Value End If End Sub Private Sub txtTransponder_TextChanged(sender As Object, e As EventArgs) Handles txtTransponder.TextChanged If txtTransponder.Text.Length = 1 Then txtTransponder.Text = "000" & txtTransponder.Text End If If txtTransponder.Text.Length = 2 Then txtTransponder.Text = "00" & txtTransponder.Text End If If txtTransponder.Text.Length = 3 Then txtTransponder.Text = "0" & txtTransponder.Text End If logTransponder() End Sub Link to comment Share on other sites More sharing options...
Frédéric-O DUCHEMIN Posted June 19, 2015 Author Report Share Posted June 19, 2015 transponder.Length.ToString will not work. So it's working (I'm flying now) [10:53] PMDG 747-8F PMDG House Livery B748 [10:53] Flight SDC7849 is ready to depart LGAV with a final destination of LFML [10:53] ZFW: 591801 lbs [10:53] TOW: 591801 lbs [10:53] METAR for departing airport: 2015/06/19 10:20 LGAV 191020Z 34007KT 9999 FEW018 BKN025 23/12 Q1010 NOSIG [10:53] Boarding [10:53] Parking Brake Applied [10:58] Transponder set to 2234 [10:58] Engine 1 ON [10:58] Engine 4 ON [10:59] Engine 2 ON [10:59] Engine 3 ON [11:00] Flaps at Position 1 [11:00] Flaps at Position 5 [11:00] Flaps at Position 10 [11:00] Beacon lights ON [11:01] Taxi lights ON [11:01] QNH Set to: 1010 [11:02] Parking Brake Released [11:02] Taxiing to Runway [11:09] Taxi lights OFF [11:09] Taxi lights ON [11:09] Landing lights ON [11:09] Strobe lights ON [11:09] Taking Off with 293638 Cargo on board [11:09] Taking Off from Runway 03R [11:10] You Take off @ 186 kt [11:10] Pitch angle 8 degrees and 146042 lbs FOB [11:10] Wind Heading 340 | Wind Speed 7 kt | Temperature 25 °C [11:10] Landing Gear Up | 192 kt and 560 ft [11:11] Flaps at Position 5 @ 197 kt [11:11] Climbing to TOC [11:11] Flaps at Position 2 @ 211 kt [11:14] Flaps at Position 1 @ 240 kt [11:15] QNH Set to: 1011 [11:15] QNH Set to: 1012 [11:15] QNH Set to: STD [11:15] Taxi lights OFF [11:15] Landing lights OFF @ 10200 ft [11:16] Flaps Retracted @ 256 kt [11:28] TOC reached. Cruise started 32000 ft but I have removed this part of code (before your answer). In the code actually I don't have the code bellow Private Sub txtTransponder_TextChanged(sender As Object, e As EventArgs) Handles txtTransponder.TextChanged If txtTransponder.Text.Length = 1 Then txtTransponder.Text = "000" & txtTransponder.Text End If If txtTransponder.Text.Length = 2 Then txtTransponder.Text = "00" & txtTransponder.Text End If If txtTransponder.Text.Length = 3 Then txtTransponder.Text = "0" & txtTransponder.Text End If logTransponder() End Sub Ah yes. I did not see that there is another variable being declared call transponder: Dim transponder As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Transponder set to " & txtTransponder.Text & vbCrLf This is bad because it's the same name as the offset called transponder. Ok I will change after the flight. To the processflaps() function I have also get the aircraft model but in my example I have 2 conditions one for AIRBUS an other for BOEING But Now I'm flying with PMDG 747-8F is good is BOEING but the flaps detentes are not the same like 737-800... How todo a well loop by subcategories I have seen in the forum someone declare "obj". processflaps.txt Regards, Fred Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now