Jump to content
The simFlight Network Forums

Daan van der Spek

new Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Daar

Daan van der Spek's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks a lot! That has fixed it!! (now I finally understand when to call the offsets thanks :P)
  2. Hello everyone, It may be stupid, but I can not get my appilication to work. I will first explain it. What I do is I open a connection to FSUIPC, set the timer to 20 sec and run it. Every 20 seconds I append the text in my Rich Text Area (called Log) and so I have Position Report. Now when I land, I try to log my touchdown rate, but I just get the number 0! My code: Imports FSUIPC Public Class Form1 Function SRound(ByVal Real As Double) As Integer Dim tmp As Integer tmp = Val(Real) If Real - tmp >= 0.5 Then SRound = tmp + 1 Else SRound = tmp End If End Function Function Report() If Conn.Text = "Connected" Then Dim lon As FsLongitude = New FsLongitude(playerLongitude.Value) Dim lat As FsLatitude = New FsLatitude(playerLatitude.Value) Dim airpeedKnots As Double = (airSpeed.Value / 128D) Dim altFeet As Double altFeet = playerAltitude.Value / (65536.0 * 65536.0) * 3.28084 altFeet = SRound(altFeet) Log.AppendText(lat.ToString() & ", " & lon.ToString() & " @ " & altFeet & " feet, with " & airpeedKnots.ToString("f1") & "knots." & vbNewLine) End If End Function Function CheckGround() FSUIPCConnection.Process() Dim touch As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H30C) Dim airspeedKnots As Double = (airSpeed.Value / 128D) Dim speedKnots As String = airspeedKnots & " knots." Dim touchrate As Double = (touch.Value / 256.0) * 3.28084 * 60.0 If touchrate = 0 Then Else Log.AppendText("Landed " & touchrate & vbNewLine) End If If onGround.Value = 1 Then If onGroundall = 1 Then Else If Airborneall = 1 Then Log.AppendText("Landed " & vbNewLine) Else Log.AppendText("On ground" & vbNewLine) End If onGroundall = 1 Airborneall = 0 End If Else If Airborneall = 1 Then Else Log.AppendText("In air!" & vbNewLine) Airborneall = 1 onGroundall = 0 End If End If End Function Private Const AppTitle As String = "FSUIPCClientExample_VB" ' Register the Offsets we're interesing in for this application Dim airSpeed As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2BC) ' Basic integer read example Dim avionics As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2E80) ' Basic integer read and write example Dim fsLocalDateTime As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H238, 10) ' Example of reading an arbitary set of bytes. Dim aircraftType As Offset(Of String) = New FSUIPC.Offset(Of String)("AircraftInfo", &H3160, 24) ' Example of string and use of a group Dim lights As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&HD0C, 2) ' Example of BitArray used to manage a bit field type offset. Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' Example for disconnecting/reconnecting Dim pause As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H262, True) ' Example of a write only offset. Dim com2bcd As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H3118) ' Example of reading a frequency coded in Biary Coded Decimal Dim playerLatitude As Offset(Of Long) = New Offset(Of Long)(&H560) ' Offset for Lat/Lon features Dim playerLongitude As Offset(Of Long) = New Offset(Of Long)(&H568) ' Offset for Lat/Lon features Dim onGround As Offset(Of Short) = New Offset(Of Short)(&H366) ' Offset for Lat/Lon features Dim magVar As Offset(Of Short) = New Offset(Of Short)(&H2A0) ' Offset for Lat/Lon features Dim playerHeadingTrue As Offset(Of UInteger) = New Offset(Of UInteger)(&H580) ' Offset for moving the plane Dim playerAltitude As Offset(Of Long) = New Offset(Of Long)(&H570) ' Offset for moving the plane Dim slewMode As Offset(Of Short) = New Offset(Of Short)(&H5DC, True) ' Offset for moving the plane Dim sendControl As Offset(Of Integer) = New Offset(Of Integer)(&H3110, True) ' Offset for moving the plane Dim onGroundall As Integer = 0 Dim Airborneall As Integer = 0 Const REFRESH_SCENERY As Integer = 65562 ' Control number to refresh the scenery Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Connect.Click If Conn.Text = "Connected" Then FSUIPCConnection.Close() Connect.Text = "Connect" Me.Timer1.Enabled = False Else FSUIPCConnection.Open() Conn.Text = "Connected" Connect.Text = "Disconnect" Timer2.Enabled = True CheckGround() Me.Timer1.Interval = 20000 Me.Timer1.Enabled = True Report() End If End Sub Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed Timer1.Enabled = False Timer2.Enabled = False FSUIPCConnection.Close() End Sub Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Report() End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick CheckGround() End Sub End Class Please help me out!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.