PDA

View Full Version : Interfacing with fsuipc / vb part 1



Captain_Slarty
01-09-2002, 07:21 AM
LAST EDITED ON Jan-09-02 AT 07:39AM (EDT)[p]Ok, a simple project to start with.

object:

What we will do is make fs2002 display a message when the airpseed increases above a set limit.

the message will be "My Program Worked - Hello World"

you gotta have a 'hello world' :-lol

we will read the airspeed variable from fs2002/fsuipc and then call a routine to display it in the message window of 2002.

the principle is the same for interfacing to the outside world, ie, cockpit displays, once you have obtained the variable, you can then send it to the comm port, or, to usb, or whatever.

what you need.

fs2002, of course :-roll
fsuipc latest instaled in the modules directory.
the fsuipc sdk (Sample program fsuipc hello - tested and working)
a print out of the fsuipc for programmers (Word Doc)
vb (Visual basic)

first part will be this evening and will include setting up a program in vb that has a couple of sub routines to call. fusipc read and fsuipc write. - a sub to read the airpseed, and then a call to the write offset for the adventure text.

that should do for a start.

Captn S.

Acknowledgements.

Peter Dowson for FSUIPC
Chris Brett for the vb sdk for fsuipc.
Microsoft for fs2002 and VB


load fsuipc hello

clear (delete) the form code and then add these subs / code. (also a dd a timer (timer1) to the form.


' airspeed read and display warning Captain Slarty 2001
Dim dwResult As Long
Dim dwOffset As Long
Dim dwSize As Long
Dim ptr As Long
Dim asi As Long








Private Sub butOK_Click()
Unload frmMain
End Sub



Private Sub Form_Load()




End Sub

Private Sub Form_Unload(Cancel As Integer)
' close connection to UIPC
FSUIPC_Close
End Sub

Private Sub Timer1_Timer()

' make the calls here
'test of airspeed
airspeed

End Sub
Private Sub Read_fsuipc()
'dwoffset is in uipc table hex
'dwsize is size of item in ipc table
' pdest=varptr(item)
'dwresult=long

If FSUIPC_Read(dwOffset, dwSize, ptr, dwResult) Then
' "Read" proceeded without any problems
If FSUIPC_Process(dwResult) Then
' "Process" proceeded without any problems
' do something with the result here


Else
' Unable to "Process"
MsgBox "problem with process"
End If
Else
' Unable to "Read"
MsgBox "unable to read"
End If
End Sub

Private Sub write_fsuipc()
' set the items here prior to call

If FSUIPC_Write(dwOffset, dwSize, ptr, dwResult) Then

If FSUIPC_Process(dwResult) Then


Else
' Unable to "Process"
MsgBox "problem with process"
End If
Else
' Unable to "write"

End If


End Sub
Private Sub airspeed()
end sub



save your project as airspeedtest

more later tonight. :-)







http://www.captainslarty.com/images/sl0015fps.gif

Captain_Slarty
01-09-2002, 01:02 PM
Now we will read the airspeed (IAS) for fs2002.

the offset is from the programmers documentation ... look at ofset &H2BC... IAS *128

we will read this value, then divide it by 128 and, firstly, display it on the fsuipc hello form.

Later, we will print the data obtained in the adventure text display of fs2002.

ok, change the lablel3 caption to read airspeed.

now, add the following to the 'airspeed' subroutine

-------------------------------------------------------------

dwOffset = &H2BC ' offset from fsuipc documentation for airspeed IAS
dwSize = 4 'size of data block


ptr = VarPtr(ASI) ' provide a pointer to the data, not the actual data !

Read_fsuipc ' call our read routine


lblClock.Caption = Format(ASI / 128, "####.##") ' print it on the form in a readable format.

----------------------------------------------------

now, start fs2002, make it a small window.... reduce your vb woekspace so you can see both vb and fs on screen, run the program... you should see the airspeed displayed on the form.

as said, next bit will concentrate on getting the value to be printed WITIHN fs2002 along with some triggers.

please feel free to ask questions... :-)

easy init .....



http://www.captainslarty.com/images/sl0015fps.gif

qazia
04-09-2002, 11:27 AM
Hello,

I was wondering if you could help me out with
interfacing with FSUIPC. I would like to get
weather information. Not only at my current
location but for anywhere. For example,
if I am at Meigs field I would like to know
the current weather in Boston.

What I really want to make is a weather radar
map. So I would really need weather info for
about a 100 mile radius.

I have looked in the FSUIPC documentation but
I fail to understand how to get weather info
for a specific location :-hmmm .

Thanks