wesrater Posted December 21, 2008 Report Posted December 21, 2008 Could someone give me a source code example on a fuel manager utilizing fsuipc in visual basic (vb6, 2005, 2008, it really doesn't matter). Thanks! Wes
Paul Henty Posted December 23, 2008 Report Posted December 23, 2008 You could start with downloading my .NET DLL that lets you talk to FSUIPC from any .NET language. http://forums.simflight.com/viewtopic.php?f=54&t=53255 It has full documentation and an example project in VB.NET that shows how to use the DLL to read and write to/from offsets in FSUIPC. It doesn't have any examples that deal with fuel, but you can find out which offsets relate to fuel in the "FSUIPC Guide For Programmers" in Pete's FSUIPC SDK. Paul
wesrater Posted December 23, 2008 Author Report Posted December 23, 2008 Thank you very much. I've downloaded it and am trying to figure it out now :p
wesrater Posted December 24, 2008 Author Report Posted December 24, 2008 Here is what I have now and it doesn't work... Could someone help me out a bit and change something around, so it works (And yes, the timer is enabled, the interval is 1)(nothing is underlined blue, so the code is correct, but it doesn't change the fuel (and the fuel tank is set to 1, which is all tanks))? Imports FSUIPC Public Class Form1 Private Const AppTitle As String = "FSUIPCClientExample_VB" Dim Fuel As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HAF4) Dim Tank As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HAF8) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Tank.Value = 1 End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click Try FSUIPCConnection.Open() MsgBox("Connected :)") Catch ex As Exception MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Fuel.Value = TrackBar1.Value / 256 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick TextBox1.Text = TrackBar1.Value / 256 End Sub End Class
Paul Henty Posted December 24, 2008 Report Posted December 24, 2008 Hi, Firstly the offsets you are looking at are documented as being 2 bytes long, not 4 so you should be declaring the offsets as Short not Integer. The main problem though is that your code never makes a FSUIPCConnection.Process() call. This is the bit that actually gets data from FS and writes it. You must call process() to update the values of all of your offsets you have declared. If you have changed the value of any offset, Process() will also send that value to FS. On your button click, you need to add a Process call after you set Fuel.Value. If you want your text box to show you the current fuel then it should be something more like this.... Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick FSUIPCConnection.Process() TextBox1.Text = Fuel.Value / 256 End Sub Have you read the UserGuide.htm in the docs folder? It explains all of the above. Please read it if you haven't. If you need any more help though, just ask. Paul
Paul Henty Posted December 24, 2008 Report Posted December 24, 2008 I've had a closer look at the offsets for fuel. If you want to know how much fuel is in the plane (and possibly change the amount) you need to be looking at offsets starting at 0B74 and another block starting at 1244. (These are 4 bytes and so you need Integers in this case). Paul
wesrater Posted December 25, 2008 Author Report Posted December 25, 2008 This is getting a tad bit too confusing for me. Maybe you could just write me a small code that would change the fuel of a selected tank please? Thanks! :) -Wes
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