-
Posts
14 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Downloads
Posts posted by friedrich
-
-
'declare it only once on top - class/form level
Dim APHeadingValue As Offset(Of UInteger) = New FSUIPC.Offset(Of UInteger)(&H7CC)
-------------------------------------------------------------
'could be done in a shorter and or different way
Dim APHaeding As Integer
APHeading = 350 (assign heading)
'whatever you calculate before, p.e. Hdg + a Wind-Drift-Value
If APHeading > 360 Then
APHeading = APHeading - 360
ElseIf APHeading < 0 Then
APHeading = 360 + APHeading
End If
'AP Heading Value in ° 16384 = 90°
APHeading = APHeading * 182
If APHeading > 65536.0 Then APHeading = 65536.0
APHeadingValue.Value = APHeading 'set Hdg to AP
-
No you wouldn't set the interval nor enable the timer within the 'tick' routine as it would never start
Set the interval in the form load section or at design time if the interval does not need to be changed and start the timer when the app is started
Yes you are right. I forgot to mention it separately.
Anyhow the import thing is the Timer1_Tick section for our friend 'djp122'.
regards,
Friedrich
-
1) download the latest download by Paul Henty
2) Read the complete VB.net example. FSUIPCClientExample_VB (Form1.vb)
3) Refer to the "Timer1_Tick" Section. You need the Timer Tick. Within this Timer Tick you declare for example:
The Timer tick is reading data every 200 ms for example.
Me.Timer1.Interval = 200
Me.Timer1.Enabled = True
ecc.....
' COM2 frequency
' Shows decoding a DCD frequency to a string
' a. Convert to a string in Hexadecimal format
Dim com2String As String = com2bcd.Value.ToString("X")
' b. Add the assumed '1' and insert the decimal point
com2String = "1" & com2String.Substring(0, 2) & "." & com2String.Substring(2, 2)
Me.txtCOM2.Text = com2String
This is the way you get a continous update for all data you declare.
You do not need any Button for it.
You can read and Set all data.
regards,
Friedrich
.
-
I'm using this code for some KEY_EVENTS:
Class Form1
Dim fsx_simconnect As SimConnect
Const WM_USER_SIMCONNECT As Integer = &H402
....
Public Enum hSimconnect
group1
End Enum
Private Enum INPUT_ID 'should be used for sending Keyboard Input ?
INPUT0
End Enum
....
Private Enum EVENT_ID
EVENT_APon
EVENT_APoff
EVENT_FLAPSup
EVENT_FLAPSdn
EVENT_ALTOnOff
End Enum
....
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
Structure Struct1
. '0
.
.
Public aponoffx As Single '7
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Titlex As String
End Structure
....
Private Enum DEFINITIONS
Struct1
End Enum
Private Enum DATA_REQUESTS
REQUEST_1
End Enum
Enum UPEVENT 'should be used for sending Keyboard Input ?
WHATEVER
End Enum
Enum DOWNEVENT 'should be used for sending Keyboard Input ?
WHATEVER
End Enum
.....
Private Sub btnconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handle btnconnect.Click
'EXAMPLE
fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APOnOff, "AP_MASTER")
fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APon, "AUTOPILOT_ON")
fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APoff, "AUTOPILOT_OFF")
.
.
fsx_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "AUTOPILOT MASTER", "Bool", SIMCONNECT_DATATYPE.FLOAT32, 0, 7)
.
.
.
fsx_simconnect.RegisterDataDefineStruct(Of Struct1)(DEFINITIONS.Struct1)
AddHandler fsx_simconnect.OnRecvSimobjectData, New SimConnect.RecvSimobjectDataEventHandler(AddressOf simconnect_OnRecvSimobjectData)
fsx_simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.VISUAL_FRAME, 0, 0, 0, 0)
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If aponoff = 0 Then fsx_simconnect.TransmitClientEvent(DEFINITIONS.Struct1, EVENT_ID.EVENT_APon, 0, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
If aponoff = 1 Then fsx_simconnect.TransmitClientEvent(DEFINITIONS.Struct1, EVENT_ID.EVENT_APoff, 0, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' Here should be the Transmit Key Event to the AUTOPILOT MASTER as a Example
End Sub
---------------------------------------
Everything is working OK.
Several trials with different Forums explanations for sending Keystrokes via Simconnect unfortunately without success.
I would need a precise Example how to implement the KEYSTROKE "Z" for the "AP MASTER" for example.
I think it is also possible to send a combination of Keystrokes like "shift+h".
Many thanks in advance.
regards,
-
If you are using my DLL then the easiest way is to declare the offset as a 'BitArray' type.
The sample application included with the DLL has an example of using a BitArray offset for the lights.
Basically, you need to declare the offset as follows:
Dim enginesOnFire As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&H3366, 1)
[/CODE]Note the size is 1 because the offset is 1 byte.
Then after processing you can check if each bit is set by using an array index. This is 0 based so to test is bit 0 is set you use:
[CODE]
If enginesOnFire.Value(0) = True then
' Engine 1 on Fire!
end if
[/CODE]Engine 2 would be enginesOnFire.Value(1)
Engine 3 would be enginesOnFire.Value(2)
Engine 4 would be enginesOnFire.Value(3)
You can also set and reset these bits by setting the value to True or False repectively e.g.
[CODE]
enginesOnFire.Value(2) = True
[/CODE]although the documentation says this probably doesn't start a fire in the simulation, just sets the warning light.
Paul
Many thanks for you explanation. It's OK.
regards
-
Hi,
there is a difference between VB 6 + VB 8.
Manipulating was different using arrays.
My question is:
How Read + Write a single Flag value with Visual Basic 2008 ?
Example: FSuipc - Offset 3366 - Var.Type U8 - Bit 0 .. 7
Thank you.
-
But only the whiskey compass offset is a Double type. Please read the User Guide supplied with my DLL that explains what VB.NET types to use with each size offset. The offset sizes are marked in the "FSUIPC For Programmers.PDF" and "FSUIPC Offset Status.PDF" that comes with the FSUIPC SDK.
The same documents also explain how to convert the values from FSUIPC into 'human readable' values, as shown in my post above.
Understanding these two concepts is essential. You can't use the FSUIPC interface without this knowledge.
Paul
Many thanks to you and Pete. In fact i noticed the Double + Integer values.
Regards,
Friedrich
-
You can't. That compass floats, and only reads accurately when flying straight and level. That's one reason why other aids were invented.
Regards
Pete
Many thanks for your quick answer.
That's one reason why other aids were invented.It would be nice if someone could supply the VB code for getting the right Compass Heading when Banking left or right. (like the wisky compass when flying straight)
We have the following Offsets:
Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' compass Heading
Dim truehdg As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H580) ' True Heading
Dim magvar As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2A0) ' Magnetic Variation
Dim gyrodrift As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&HC3E) ' Gyrodrift
Many thanks in advance,
Friedrich
-
I have one question relating to the Wisky Compass Offset 02CC.<BR><BR>- Using VB 2008 - Timer set to a value of: 200 (even tried with different values)<BR><BR>Reading the Compass Value while:<BR><BR>1. flying with no Bank inclination - straight - compass value is correct.<BR><BR>2. changing the Bank inclination to the left - Compass Value is INCREASING<BR><BR>3. changing the Bank inclination to the right - Compass Value is DECREASING<BR><BR>It takes quite a lot of time to stabilize.<BR><BR>How can this be corrected in order to get a smooth reading like the GPS ?<BR><BR>Many many thanks in advance for your kind help.<BR><BR><BR>NB:<BR>i searched for a previous Forum Post and found 1 specific: <SPAN class=main_topic_title>Geting heading from FSUIPC with VB<BR><BR></SPAN>Is it possibile to get the VB code for a Hdg value like the GPS-Heading ?<BR><BR><BR><BR>Friedrich
-
Friedrich,
The example code you posted originally is using the old VB.NET SDK. It looks like you are using my .NET Client DLL, so that's why it looks strange to you and doesn't work.
Paul
Thank you. Now it is working.
Friedrich
-
Ah, I thought you were pointing to the compiler errors you listed, i.e.
Pete
In fact my reference to offset 238 is just mentioned in order to show that other offset-readings with 'that' method (Dim .....) is working while the TCAS procedure does not.
Now i will try it with the new DLL suggested by Paul Henty.
thanks
Friedrich
-
Thanks for your answer Mr. Pete
My VB program is working with all other Offsets. I get all single data as stated above like:
Dim fsLocalDateTime As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H238, 10)
FSUIPC is open.
Private Sub OpenFSUIPC()
Try
' Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
FSUIPCConnection.Open()
Me.Timer1.Enabled = True
Catch ex As Exception
MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
JUST the TCAS reading data Procedure is giving errors.
There must be DECLARATIONS missing which are not a part of the VB basic language.
Sure, the 'Connection' Error is easy to master with a boolean value.
Maybe someone knows the way it should work.
Anyway, many thanks
Friedrich
-
Imports FSUIPC
----------------------
Structure TCAS_DATA
Dim id As Integer
Dim lat As Single
Dim lon As Single
Dim alt As Single
Dim hdg As Short
Dim gs As Short
Dim vs As Short
Dim idATC() As Byte
Dim com1 As Short
End Structure
Sub Test_TCAS_DATA()
Dim dwResult As Integer
Dim Token As Integer
Dim result As Integer
Dim fsByte(4095) As Byte
Dim TCA(0) As TCAS_DATA
Dim T As System.Type
T = TCA(0).GetType
Try
If Connected Then
If FSUIPC_Read(&HF000, 4096, Token, dwResult) Then
If FSUIPC_Process(dwResult) Then
If FSUIPC_Get(Token, 4096, fsByte) Then
.
.
.
End Sub
Using:
- Visual Basic 2008
- FSUIPC unregistered
- FSUIPC last update 4.7
ERROR LIST IS READING
- Name Connected is not declared
- FSUIPC_Read is not declared
- FSUIPC_Get is not declared
I would like to use the code found at the Link (year 2003):
http://forum.simflig...dpost__p__34735
Normally i'm reading Offsets like:
Dim fsLocalDateTime As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H238, 10)
Someone can tell me what is wrong here and how can I make it working ?
Many thanks for your kind help and assistance.
Friedrich
.
Assign Mouse Commands to Joystick?
in FSUIPC Support Pete Dowson Modules
Posted
Under " User Contribution " you can find a particular program that is doing things like that.
Mouseclicks is a general application software and not only for a Flight Simulator. MouseClicks is acting on Joystick and Keyboard.
Hope it can be of help.