Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Paul.

your answer did the trick,however here's the problem I now face. I am reading the digi pot, or encoder from the arduino maga 2560. I can send it to VB.NET 2010 and display it in a textbox. For your answer to work it needs to have the decimal point.(121.55) the data I can send from the encoder read is (12155) no (.) I don't know how to change the (12155) to include a (.) if I send from arduino (121.55) I am fine, but the read from arduino does not include a (.) I not asking you to tell me how to change the arduino code if you don't have one you would not know, rather how to convert the VB NET 2010 serial read data to include the (.) IE 12155 to 121.55 and then send it as your answer states.Yes I know this question is confusing. So....

How can I convert a number such as 12155 to 121.55 in VB NET 2010.?? Thanks so much, Ron.

Posted

Hi Paul.

your answer did the trick,however here's the problem I now face. I am reading the digi pot, or encoder from the arduino maga 2560. I can send it to VB.NET 2010 and display it in a textbox. For your answer to work it needs to have the decimal point.(121.55) the data I can send from the encoder read is (12155) no (.)

Hi Ron,

My snippit of code assumes there is a . in the frequency string because that's how it normally is. However, if your string doesn't have a . in it then you can just change it to fit what you have.

FSUIPC requires 121.55 to be in the format 2155. In my example the second line of code transforms 121.55 into 2155 buy concatenating the second, third, fith and sixth together:

Dim com2FS As String = newCom2Frequency.Substring(1, 2) & newCom2Frequency.Substring(4, 2)

So if you are starting with 12155 all you need to do is take the second digit onwards:

Dim com2FS As String = newCom2Frequency.Substring(1)

So the whole example would be:

				Dim newCom2Frequency As String = "11945" ' 119.45 as read from arduino
				' get the freqeuncy into FS format (no leading 1 = 1945)
				Dim com2FS As String = newCom2Frequency.Substring(1)
				' set the value to the com2 offset after converting to a short as a hex string
				com2Offset.Value = Short.Parse(com2FS, Globalization.NumberStyles.AllowHexSpecifier)

How can I convert a number such as 12155 to 121.55 in VB NET 2010.?? Thanks so much, Ron.

If you use the code above you don't need to. But incase you need it for display purposes just use the Substring() method:

Dim stringFromArduino as String = "12155"
Dim stringWithDecimal as String = stringFromArduino.Substring(0,3) & "." & stringFromArduino.Substring(3)

Paul

Posted

Thank you Paul. That's what I needed. If your wondering, I have build NEW radio comm panels for my simm. I am replacing my 12yr old EPIC hardware which has pretty much given up. The analogs stoped working some time ago so I built the Arduino UNO for throttles,flaps,elev.trim and spoilers, all working better than EPIC ever did. Now the radios work again. Next will be the MCP. I do use the Interface IT board for the overhead and CDU,but I wanted to keep the price tag down so going with Arduino. So far so good,thanks to you and Mr Dawson's hard work. I am very pleased., Thanks. Ron. :razz:

Posted
You use the Offset BEB ?? The Gear positions are read in 0BEC 4 Gear position (nose): 0=full up, 16383=full down 0BF0 4 Gear position (right): 0=full up, 16383=full down 0BF4 4 Gear position (left): 0=full up, 16383=full down The value for Gear down is 16383.

According to the documentation the offset address is 0xBE8 (Bravo Echo Eight) and not 0x0BEB (Bravo Echo Bravo). Also could you confirm whether writing to the 0x0BEC, 0x0BF0 and 0x0BF4 (each offset is 4 bytes long) actually works, or are they read-only?

  • 2 weeks later...
Posted
Hello :) I have a question.. How can i write a textstrip into FS.

You need to use offsets 3380 and 32FA. Details of these can be found in the FSUIPC documentation.

Here is some example code:

Declaration of the required offsets:


Public messageText As Offset(Of String) = New Offset(Of String)("textstrip", &H3380, 128, True)
Public messageControl As Offset(Of Short) = New Offset(Of Short)("textstrip", &H32FA, True)
[/CODE]

Note that 3380 requires the offset length (128) as it's a string type. Also they are both declared as WriteOnly because there is no point reading what's in these offsets.

I have also put them in thier own offset group called "textstrip". This is so we can send messages without processing all the other offsets.

The code to write the message:

[CODE]
messageText.Value = "XXX has connected with your FSX"
messageControl.Value = 5
FSUIPCConnection.Process("textstrip")
[/CODE]

Note that here we only process the "textstrip" group.

This will make the message appear on the screen for 5 seconds. See the FSUIPC documentation for the different options avilable for the control offset (32FA).

Paul

  • 3 weeks later...
Posted (edited)

Hello all,

My name is melvin, and i'm learning to programm for about 4 weeks now in C#.net.

I'm using fsuipc and fsuipc client dll 2.0 and VS2010.

I'm am able to build a PFD wich is working perfect:)

i'm also able to read the offset for the autopilot heading value/selector.

Now have have encountert a problem, I want to read the heading and display it in a string in GDI+.

here is what i have tried,

Offset<int> headingview = new Offset<int>(0x05D0);

Offset<short> varmag = new Offset<short>(0x2A0);

double degree =(double)headingview.Value *360d/(65536d*65536d);

double degreetrue =(double) degree-(varmag.Value *360d/65536d);

 

 

 

A.DrawString(degreetrue.ToString("000"),

new Font("Verdana", 13, FontStyle.Bold),

new SolidBrush(Color.LawnGreen),

new Point(200, 310));

it works, only it displays the heading from 000 to 340, the the last 20 degrees are showen from -1 to -20 :s

I have tried every option, uint/int/double but i just cant get it to work like it should :S

Maybe someone can tell me what i'm doing wrong?

Sorry for my english, but it isnt my native language ;)

greetings,

Melvin.

Edited by klm1509
Posted

greetings,

Melvin.

Melvin,

The following snippets are cut/pasted from parts of my aircraft class in Vb.Net for you to look at so it should be simple to convert to c#

The norm360 function is possibly the part you should be interested in.

Why are you reading offset 05D0 View Direction when you mention autopilot heading which is offset 7CC?



Private fsAPHeadingValue As Offset(Of UShort) = New FSUIPC.Offset(Of UShort)("autopilot", &H7CC)
Public APHeadingValue As Short

'autopilot'

Public Sub getAutopilot()

FSUIPCConnection.Process("autopilot")

Me.APEnabled = Me.fsAPEnabled.Value

Me.APAltitudeValue = fsAPAltitudeValue.Value * 3.28084 / 65536

Me.APHeadingValue = fsAPHeadingValue.Value * 360 / 65536

Me.APVSValue = fsAPVSValue.Value * 3.28084 / 65536

End Sub


[/CODE]

[CODE]

Private fsCurrentHeading As Offset(Of UInt32) = New FSUIPC.Offset(Of UInt32)("heading", &H580)
Public CurrentHeading As UInt32

'magnetic variation'
Private fsMagneticVariation As Offset(Of Short) = New FSUIPC.Offset(Of Short)("magneticvariation", &H2A0) 'this is the heading of the aircraft'
Private MagneticVariation As Short

'gyrodrift'
Private fsGyroDrift As Offset(Of Short) = New FSUIPC.Offset(Of Short)("gyrodrift", &HC3E)
Private GyroDrift As Short

Public Sub getCurrentHeading()
'return aircraft heading'
FSUIPCConnection.Process("heading")
FSUIPCConnection.Process("magneticvariation")
FSUIPCConnection.Process("gyrodrift")
Me.CurrentHeading = fsCurrentHeading.Value * 360D / (65536D * 65536D)
MagneticVariation = fsMagneticVariation.Value * 360D / 65536D
GyroDrift = fsGyroDrift.Value * 360D / 65536D
Me.CurrentHeading = norm360((CurrentHeading + GyroDrift) - MagneticVariation)
End Sub

Function Norm360(ByVal h As Short) As Long
'this function returns correct heading within 360 degrees'
If h > 360 Then
Norm360 = h - 360
ElseIf h = 0 Then
Norm360 = 0 'originally 360'
ElseIf h < 0 Then
Norm360 = h + 360
Else
Norm360 = h
End If
Return Norm360
End Function

[/CODE]

Posted (edited)

gjpollitt,

first of all, thank u for the reply. maybe i had to be more specific.....

I tried to and succeeded to get the value from 07CC to show wich heading i have set in the autopilot.

What i now want to to is reading and showing , is my current heading the plane is flying. this is why I tryed 0ffset 05d0.

Thanks again for an example i ll try it, and let u now if it solves my problem.

greetings,

Melvin

Edited by klm1509
Posted

What i now want to to is reading and showing , is my current heading the plane is flying. this is why I tryed 0ffset 05d0.

But as is documented, 05D0 is the current viewpoint direction, not the aircraft heading. your view direction could be anything. Also as documented, that offset doesn't work in FSX.

The aircraft heading is provided in offset 0580, for all versions of FS, along with the rest of the aircraft position and orientation data (LLAPBH == Lat, Long, Alt, Pitch, Bank, Heading).

Regards

Pete

Posted

Pete,

after trying (in my oppinnion) everything to get this to work, i somehow thought that 0580 wasnt the one i needed.

thanks for the extra info.

greetings,

melvin

Posted

after trying (in my oppinnion) everything to get this to work, i somehow thought that 0580 wasnt the one i needed.

Well, it IS the heading, but it is TRUE. For the MAG heading as more generally used (except above lat 60) you'll need to subtract the Mag Var (02A0).

Regards

Pete

Posted (edited)

Hello everyone,

I have tryed to covert the example that gjpollitt gave me,

I have tried it and .......

IT WORKS, thanks everyone for helping :)

Greetings,

Melvin.

Edited by klm1509
  • 3 weeks later...
Posted

Hi Paul,

How can I get the lat and lon of aitraffic as numbers without the letters and symbols?

The only option seems to be the location for AITrafficServices which gives the complete lat and lon with symbols. Is there any option to get the lat and lon without the symbols you add? And even better as location.lat and location.lon

Regards,

Achilles

Posted

Hi Paul,

How can I get the lat and lon of aitraffic as numbers without the letters and symbols?

The only option seems to be the location for AITrafficServices which gives the complete lat and lon with symbols. Is there any option to get the lat and lon without the symbols you add? And even better as location.lat and location.lon

Regards,

Achilles

Hi Achilles,

All the locations used in my DLL are an instance of the FsLatLonPoint class. This has properties for the Longitude and the Latitude which are instances of FsLongitude and FsLatitude. These classes have various properties for obtaining the lon/lat in various ways.

It's all explained on the Intellisense and in the user guide. If you're not seeing the intellisense then make sure you have the FSUIPCClient.XML file in the folder as the FSUIPCClient.DLL.

To answer your specific question about the lon/lat of AI traffic you can use the following to get the lon and lat as a numeric value of degrees:


Dim aiPlaneLat As Double = myAIPlane.Location.Latitude.DecimalDegrees
Dim aiPlaneLon As Double = myAIPlane.Location.Longitude.DecimalDegrees
[/CODE]

Paul

Posted

Hi Achilles,

All the locations used in my DLL are an instance of the FsLatLonPoint class. This has properties for the Longitude and the Latitude which are instances of FsLongitude and FsLatitude. These classes have various properties for obtaining the lon/lat in various ways.

It's all explained on the Intellisense and in the user guide. If you're not seeing the intellisense then make sure you have the FSUIPCClient.XML file in the folder as the FSUIPCClient.DLL.

To answer your specific question about the lon/lat of AI traffic you can use the following to get the lon and lat as a numeric value of degrees:


Dim aiPlaneLat As Double = myAIPlane.Location.Latitude.DecimalDegrees
Dim aiPlaneLon As Double = myAIPlane.Location.Longitude.DecimalDegrees
[/CODE]

Paul

Hi,

Thats my fault. The xml was missing.

Thanks Paul

Posted

Is there any way to find out which ai plane has priority (in row) when a runway is assinged for it?

I don't know of any, sorry. Certainly my DLL isn't supplying such information and I don't remember reading anything about that in the FSUIPC documentation.

Maybe Pete or someone else might be able to help you if you post in the main support forum.

Paul

Posted

I don't know of any, sorry. Certainly my DLL isn't supplying such information and I don't remember reading anything about that in the FSUIPC documentation.

Maybe Pete or someone else might be able to help you if you post in the main support forum.

Paul

I will make some tests to see if the ID has to do anything and there is any relative to the prioriry.

Posted

Hi Paul,

I am trying to read an offset dymamically

Dim Newoffset="&H" & textbox1.text

Dim readoffset As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(Newoffset)

fsuipcconnection.process()

label1.text=readoffset.value

But always returns zero?

What I miss? Have you ever done this?

Regards,

Achilles

Posted

I am trying to read an offset dymamically

But always returns zero?

Hi,

There's nothing wrong with the code that I can see. I've tried it here using "02BC" (Airspeed) in the textbox and it worked fine.

It would depend on what you're typing into the textbox and what kind of data is stored at that offset. You can obviously only use offsets of 4 bytes that are integers with the code you posted.

This is not related to your problem, but you need to be careful when creating offsets when the program is running. When you 'Dim' a new offset it's registered with the FSUIPCConnection class which holds a reference to that Offset instance it. If that offset then goes out of scope in your program it will still be registered with the FSUIPCConnection class. Therefore it is still taking up memory and will still be read every time you do Process().

As your program is at the moment, if you use this dynamic feature 50 times you will have all 50 offsets still in memory and all 50 being read each Process().

To clean up offsets you don't want any more you must either:

1. Disconnect them by calling MyOffset.Disconnect()

or

2. Delete the group they are in (If you put them in a group). e.g. FSUIPCConnection.DeleteGroup("MyTemporaryOffsets")

Here is your code again (works here for a few offsets I tried - e.g. 02BC (Airspeed)) but with the disconnect in:


Dim Newoffset = "&H" & TextBox1.Text
Dim readoffset As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(Newoffset)
FSUIPCConnection.Process()
MsgBox(readoffset.Value)
readoffset.Disconnect()

[/CODE]

If you still have problems let me know what offsets don't work.

Paul

Posted

Hi,

There's nothing wrong with the code that I can see. I've tried it here using "02BC" (Airspeed) in the textbox and it worked fine.

It would depend on what you're typing into the textbox and what kind of data is stored at that offset. You can obviously only use offsets of 4 bytes that are integers with the code you posted.

This is not related to your problem, but you need to be careful when creating offsets when the program is running. When you 'Dim' a new offset it's registered with the FSUIPCConnection class which holds a reference to that Offset instance it. If that offset then goes out of scope in your program it will still be registered with the FSUIPCConnection class. Therefore it is still taking up memory and will still be read every time you do Process().

As your program is at the moment, if you use this dynamic feature 50 times you will have all 50 offsets still in memory and all 50 being read each Process().

To clean up offsets you don't want any more you must either:

1. Disconnect them by calling MyOffset.Disconnect()

or

2. Delete the group they are in (If you put them in a group). e.g. FSUIPCConnection.DeleteGroup("MyTemporaryOffsets")

Here is your code again (works here for a few offsets I tried - e.g. 02BC (Airspeed)) but with the disconnect in:


Dim Newoffset = "&H" & TextBox1.Text
Dim readoffset As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(Newoffset)
FSUIPCConnection.Process()
MsgBox(readoffset.Value)
readoffset.Disconnect()

[/CODE]

If you still have problems let me know what offsets don't work.

Paul

After pc restart it worked. Do not know what happend. It must be related to VS2010 bug. At VS2008 it worked fine

Thanks Paul for your time

Regards,

Achilles

Posted

Hi Paul,

Using the below code

FSUIPCConnection.AITrafficServices.RefreshAITrafficInformation()

FSUIPCConnection.AITrafficServices.OverrideGroundTrafficINISettings(ATCIdentifier.AirlineAndFlightNumber,True, 0, 0)

FSUIPCConnection.AITrafficServices.OverrideAirborneTrafficINISettings(ATCIdentifier.AirlineAndFlightNumber, RangeInNM:=0)

all the airborn traffic ATCIdentifier returns the AirlineAndFlightNumber

all the ground traffic ATCIdentifier returns only the Airline

Can you check it please?

Regards,

Achilles

Posted

all the airborn traffic ATCIdentifier returns the AirlineAndFlightNumber

all the ground traffic ATCIdentifier returns only the Airline

Hi Achilles,

That's probably because the ground planes are 'sleeping'. They only have flight numbers assigned when they are in an active state like 'Taxiing out' or 'ready for takeoff'. I've tried it here with FSUIPC4 and the active ground planes do have flight numbers. The sleeping ones (most of them) do not.

Incidentally, it's probably better to set the INI options before refreshing the AI data:


FSUIPCConnection.AITrafficServices.OverrideGroundTrafficINISettings(ATCIdentifier.AirlineAndFlightNumber,True, 0, 0)
FSUIPCConnection.AITrafficServices.OverrideAirborneTrafficINISettings(ATCIdentifier.AirlineAndFlightNumber, RangeInNM:=0)
FSUIPCConnection.AITrafficServices.RefreshAITrafficInformation()
[/CODE]

If you still think there's a problem (e.g. you can't see flight numbers on active ground AI) let me know and I'll look into it some more.

Paul

Guest
This topic is now closed to further replies.
×
×
  • 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.