
Paul Henty
Members-
Posts
1,728 -
Joined
-
Days Won
78
Content Type
Profiles
Forums
Events
Gallery
Downloads
Everything posted by Paul Henty
-
The only place is this sub-forum. The official/supported release (at the moment 2.4) is always pinned to the top of the sub forum. That's the one people should use. If you've seen a new feature mentioned in the forum that's included in 3.0 and you want to help test it then I'm happy to make it available to you on request. Paul
-
Here is the relevant documentation: So you need to also declare another offset (before 0D70) of type int for 0x0D6C. In there you need to write the offset you'll be using to receive, along with the type code. In this case 0x366C0. (int at 66C0). Write this as a number obviously, not as a string. Then in 0D70 you just write the LVar name preceded by a single colon (meaning read): offset_sendlvar.Value = ":VC_GSLD_CP_EFIS_ND_Mode_Knob"; After processing, 0x66C0 will now contain the value. Paul
-
You should probably declare the offset as UInteger because the value is unsigned (it will never be -20 degrees for example). Dim HDG As Offset(Of UInteger) = New FSUIPC.Offset(Of UInteger)(&H580) ' aircraft heading When you say it's inaccurate, what are you comparing it to? This offset gives the True heading, not the magnetic heading shown on the aircraft instruments. Paul
-
UShort is an unsigned value so the values range from 0 to 65,535. Short is signed so the values are from -32,768 to 32,767 In this instance either UShort or Short will work because the values are only 0 to 12. Value 10 is for P3D v1/2/3. Value 11 has been reserved for Flight Sim World by Dovetail I think.
-
The offset you need is 0x3308. It's only 2 bytes, not 4 so you need to declare it as UShort, not integer: Dim SimVers As Offset(Of UShort) = New FSUIPC.Offset(Of UShort)(&H3308) ' Shows what sim its connected to It's not in the documentation, but 64bit versions of P3D (V4 and future) will return 12. Paul
-
vb.net FSUIPC sending keypresses to sim
Paul Henty replied to sniperfull's topic in FSUIPC Client DLL for .NET
Minimized windows cannot get focus, so it will not work when minimised. Do you really need key presses? It would be better to send controls to the flight sim if you can. E.g. Turning on aircraft lights etc can be done with controls on default planes. Paul -
vb.net FSUIPC sending keypresses to sim
Paul Henty replied to sniperfull's topic in FSUIPC Client DLL for .NET
Yes, if you use Version 3 of my DLL (.NET 4 or above only) then it's easy: This example sends CTRL-SHIFT-A and returns focus to the current form. The focus must be given to the flight sim window for the key press to work. The DLL will do this for you and then return the focus to your form. FSUIPCConnection.SendKeyToFS(Keys.A, SendModifierKeys.Control Or SendModifierKeys.Shift, Me) I've attached version 3. Paul FSUIPCClient3.0_RC2.zip -
"Transition" from one point to another
Paul Henty replied to CAG2's topic in FSUIPC Client DLL for .NET
It's possible. You will need to experiment with putting the Sim in Pause or Slew mode. This will stop Flight Sim from updating the plane's position. You'll also have to work out the Lon/Lat positions along the path you want to move. Then, using some kind of timer loop, write each position along the path to 'animate' the plane. There are some helper classes in the DLL that can help with this. See the UserGuide.pdf and look at the FsLatLonPoint class. Especially the methods BearingTo, BearingFrom and OffsetBy... Paul -
You don't need a new FSUIPCClient.dll for FSUIPC5. Any version of the DLL will connect fine with FSUIPC5. It's doesn't matter if your client application is compiled as 32 bit. I can still talk to 64 bit P3D via FSUIPC. You only need the new Version 3 if you want to compile your .NET client application as a 64 bit dll (or a Dual 32/64 binary). It has nothing to do with the Flight Sim being 32 or 64 bit. For your connection problem I'll need more information to help e.g. any exceptions that get thrown. Also posting your connection code might help. You could also try the sample solutions from the 2.4 zip and just use the new Version 3 DLL if that's what you're using. See if that has the same problems or not. Paul
-
Because your code isn't correct yet. It still has bugs. The main problem is that the distance function is always returning 0 because the last line is 'return distance' instead of 'return dist'. The reader loop stops because it thinks you are at the same location as the first gate (distance = 0). I've fixed up all the code, so this should work now: Public Function getgate(ByVal icaocode As String) As String ' Get the point for the current plane position 'Dim currentPosition As FsLatLonPoint = New FsLatLonPoint(lat, lon) Dim lon As FsLongitude = New FsLongitude(playerLongitude.Value) Dim lat As FsLatitude = New FsLatitude(playerLatitude.Value) ' Returns the current gate or "" is not parked at any gate. Dim pathto As String = My.Application.Info.DirectoryPath Using MyReader As New FileIO.TextFieldParser(pathto & "\g5.csv"") MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(",") Dim gatename As String Dim gatenumber As String Dim gatereturn As String = "" Dim currentRow As String() While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() If currentRow(0) = icaocode Then gatename = currentRow(1) gatenumber = currentRow(2) Dim aaa As String = currentRow(3) Dim bbb As String = currentRow(4) Dim aaaa As Double = Double.Parse(aaa, CultureInfo.InvariantCulture) Dim bbbb As Double = Double.Parse(bbb, CultureInfo.InvariantCulture) 'Dim rwyThresholdLat As FsLatitude = New FsLatitude(aaaa) 'Dim rwyThresholdLon As FsLongitude = New FsLongitude(bbbb) Dim gateRadius As String = currentRow(5) Dim gateRadiusKm As Double = Double.Parse(gateRadius, CultureInfo.InvariantCulture) / 1000D 'Dim thresholdCentre As FsLatLonPoint = New FsLatLonPoint(rwyThresholdLat, rwyThresholdLon) 'Dim trueHeading As Double = rwyMagHeading + rwyMagVariation 'runwayQuad = FsLatLonQuadrilateral.ForRunway(thresholdCentre, trueHeading, rwyWidth, rwyLength) 'Dim LatitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560) 'Latitude 'Dim LongitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568) 'Longitude ' *** Distance now returned in Km *** 'Dim distance As Double = FsuipcData.distance(LatitudeAircraft.Value, LongitudeAircraft.Value, aaaa, bbbb, "K") Dim distance As Double = FsuipcData.distance(lat.DecimalDegrees, lon.DecimalDegrees, aaaa, bbbb, "K") If distance <= gateRadiusKm Then 'gatereturn = gatename + " " + gatenumber gatereturn = gatename + gatenumber MyReader.Close() MyReader.Dispose() Return gatereturn End If End If Catch ex As FileIO.MalformedLineException 'MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While MyReader.Close() MyReader.Dispose() Return "" ' Not near any gate End Using End Function 'convert decimal degreees to radians Function deg2rad(ByVal Deg) deg2rad = CDbl(Deg * Math.PI / 180) End Function 'convert radians to decimal degrees Function rad2deg(ByVal Rad) rad2deg = CDbl(Rad * 180 / Math.PI) End Function Public Function distance(ByVal lat As Double, ByVal lon As Double, ByVal lat2 As Double, ByVal lon2 As Double, Optional ByVal unit As Char = "M"c) As Double 'd = distance(Lat1, Lon1, lat2, lon2, "N") 'distance between 2 Pos Dim theta As Double = lon - lon2 Dim dist As Double = Math.Sin(deg2rad(lat)) * Math.Sin(deg2rad(lat2)) + Math.Cos(deg2rad(lat)) * Math.Cos(deg2rad(lat2)) * Math.Cos(deg2rad(theta)) dist = Math.Acos(dist) dist = rad2deg(dist) dist = dist * 60 * 1.1515 If unit = "K" Then dist = dist * 1.609344 ElseIf unit = "N" Then dist = dist * 0.8684 End If Return dist End Function Paul
-
getgate() function: You already have the player lon/lat at the top of the method: Dim lon As FsLongitude = New FsLongitude(playerLongitude.Value) Dim lat As FsLatitude = New FsLatitude(playerLatitude.Value) You should use these instead of creating new offsets. So, delete these lines: Dim LatitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560) 'Latitude Dim LongitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568) 'Longitude Then change the call to distance, using the lat/lon variables like this: Dim distance As Double = FsuipcData.distance(lat.Value.DecimalDegrees, lon.Value.DecimalDegrees, aaaa, bbbb, "K") Note that you need the DecimalDegrees property. The raw Value is in FS Units and not degrees. Distance() function: You are passing in values for lon1 and lat1 so you don't need to reassign them. Delete all of these lines from the top of that function: Dim LatitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560) 'Latitude Dim LongitudeAircraft As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568) 'Longitude Lat1 = LatitudeAircraft.Value Lon1 = LongitudeAircraft.Value You should never declare offsets in subs or functions. You must only declare offsets at the form or class level. Paul
-
Yes, lots of timers can get difficult to manage. Unfortunately this is how it has to be done. FSUIPC was designed for C, C++, not for .NET. Although the DLL can make FSUIPC look more like a .NET class library, it can't change the way FSUIPC works fundamentally. As I discuss in this thread, I've thought about adding events but I don't believe it's practical. Paul
-
lat1 and lon1 should be the longitude and latitude of the player. You can get these from offset 0560 and 0568. lon2 and lat2 should be the lon/lat of whatever you are measuring the distance from. In Helder's code it was Gates. If you want the distance to runways, for example, then use: rwyThresholdLat and rwyThresholdLon from your code. Paul
-
It's Helder's code so I don't have it. What getGate() does is read through the file called g5.csv which is a list of gate information for each airport. The file is generated from MakeRunways.exe (written by Pete and available in the downloads section of the forum). For each gate it tests the distance between the player and gate. It keeps track of the nearest gate. After checking all gates it returns the nearest gate. The 'Form1.distance()' function is shown in post 5 of this thread. It measures the distance between the player lon/lat (you can read this from FSUIPC) and a given Lon/Lat of the gate (aaaa and bbbb). You can use this or the FsLatLonPoint class from the DLL. This has a number of DistanceFromXXX methods to calculate the distance to another lon/lat point. Paul
-
Hi Didier To call a macro you need to declare the 0D70 offset as a string like this: Private macroName As Offset(Of String) = New Offset(Of String)("macros", &HD70, 40, True) I've made it "write only" and put it in its own group called "macros". This way you can process this offset on its own. To call a macro you need to set the value of this offset to a string made up like this: <Name of .mcro file>:<Name of macro or LVAR> For your example it will be "MD530F:L: key_on" macroName.Value = "MD530F:L: key_on" FSUIPCConnection.Process("macros") In your post you show the contents of the mcro file. All your LVars have a space after the L:. Is that correct? I've included that space in my example above, but I don't think that's correct. You may need to take that space out: macroName.Value = "MD530F:L:key_on" FSUIPCConnection.Process("macros") One limitation I can see if that you can't have the same L:VAR in the MCRO file more than once. There doesn't seem to be a way of addressing different functions using the same LVAR. For example there is no way I can see to call line 2 of your file. The string "MD530F: L:B407_Eng_Start_Switch" will always call line 1 because it's the same name. If you want to use any of the operations that need a parameter you have to declare another offset BEFORE 0D70: Private macroParam As Offset(Of Integer) = New Offset(Of Integer)("macros", &HD70, True) Private macroName As Offset(Of String) = New Offset(Of String)("macros", &HD70, 40, True) Then just set the parameter value in your code: macroParam.Value = 1 macroName.Value = "MD530F:L:VarToSet" FSUIPCConnection.Process("macros") Paul
-
It sounds like it's possible using a VB.NET application. VB.NET is similar to VBA in syntax so you should be able work from examples fairly easily. What I would advise is trying a single offset or instrument and see how you get on with it. The DLL package (V2.4) has an example application in VB.NET that reads basic offset information in a timer loop and displays it on a form. You should look at this code to get an idea of how the DLL works and get familiar with VB.NET, forms, timers, error handling etc. Maybe add an offset that you are interested in and display the value on the form to start with. Then you can add in the code to construct your string and write it to the serial port. Here's a link to how to write strings to COM ports in VB: https://docs.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports Also in the DLL package is a User Guide which you should read at least the "Getting Started" section. If you have questions about using the DLL or the COM port code I can help you here in this thread. Maybe try the same thing in LUA and see which you like the best. Paul
-
Mark, You'll need version 3 which I haven't officially released yet. I've attached the latest (release candidate) version here. There are copies in various threads in the sub-forum but it would be difficult to find them. Note that version 3 will only work with the .NET4 framework or higher. Also there is one breaking change from version 2.5: * BREAKING CHANGE: You cannot write to an offset than has never been read. (Not applicable to Write-Only offsets). It's a duel 32/64 binary so it will work as either depending on your how your client application is set. Paul FSUIPCClient3.0_RC2.zip
-
Draw Wind - Detect gate via G5.CSv
Paul Henty replied to Frédéric-O DUCHEMIN's topic in FSUIPC Client DLL for .NET
Is it just the arrow drawing you want to know, or how to get the wind direction and speed at the aircraft as well? Paul -
In addition to my post above, I've found a previous post helping someone with the VNAV switch. It goes into more detail of how to use the information in the PDMG SDK: ---------------------------------------------------------------------------- If you're using FSUIPC to send the controls then you just need the event ID number. For example, let's say you want to press the VNAV switch on the MCP on the 737. In the PMDG SDK header file it's defined like this: #define EVT_MCP_VNAV_SWITCH (THIRD_PARTY_EVENT_ID_MIN + 386) THIRD_PARTY_EVENT_ID_MIN is defined as: #define THIRD_PARTY_EVENT_ID_MIN 0x00011000 // equals to 69632 So the control number for EVT_MCP_VNAV_SWITCH = 69632 + 386 = 70018. The parameter value is usually one of the mouse buttons: #define MOUSE_FLAG_RIGHTSINGLE 0x80000000 #define MOUSE_FLAG_MIDDLESINGLE 0x40000000 #define MOUSE_FLAG_LEFTSINGLE 0x20000000 ... etc ------------------------ The Control Value would be 70018. (Decimal) The Parameter to left click on this button would be 0x20000000 (Hex) Paul
-
private Offset<int> sendControl = new Offset<int>(0x3110, true); private Offset<int> controlParameter = new Offset<int>(0x3114); 1. These are the wrong way round. The sendControl should be declared after the parameter. This forces the control to be written after the parameter which is how it should work. controlParameter.Value = EVT_OH_LIGHTS_ANT_COL; sendControl.Value = Convert.ToInt32(state); 2. This code above looks wrong. The sendControl should be set to the control number. The parameter should be set to the state of the lights. It looks like you have this the wrong way round. 3, Another thing to check is that the EVT_OH_LIGHTS_ANT_COL includes the BASE control value. This value needs to be added to all the control numbers defined in the SDK. EVT_OH_LIGHTS_ANT_COL should equal 69756. 4. The parameter value normally needs to be one of the mouse commands. e.g Left click, right click etc. These are also defined in the SDK. Paul
-
Plane with Fsuipc Client DLL refuel
Paul Henty replied to skino's topic in FSUIPC Client DLL for .NET
I'm not sure why that would happen. I don't have P3D so I can't test this myself. You could ask Pete on the main support forum. Paul -
Plane with Fsuipc Client DLL refuel
Paul Henty replied to skino's topic in FSUIPC Client DLL for .NET
The fuel tanks are accessed through the PayloadServices module. Here is an example of setting the level of the centre-main tank with a level typed into a text box: Private Sub LoadFuel() ' Connection must already be open Dim ps As PayloadServices = FSUIPCConnection.PayloadServices Dim requestedFuel As Double ' Turn the text into a number If Double.TryParse(Me.txtFuelGallons.Text, requestedFuel) Then ' set the level on the centre main tank ps.FuelTanks(FSFuelTanks.Centre_Main).LevelUSGallons = requestedFuel ' sent new levels to the sim ps.RefreshData() Else ' Not a number in the text box End If End Sub To work with a different tank, just change the value of the FSFuelTanks enum. For example: ps.FuelTanks(FSFuelTanks.Left_Main) All possible fuel tanks are included in the FsFuelTanks enumeration. The popup menu will show you all tanks when you type . after FSFuelTanks. Each fuel tank must be processed separately. You can't specify a level for all tanks globally. If you want your user to be able to enter a level of fuel for all tanks then your program will need to split the fuel across all the available tanks, keeping the aircraft as balanced as possible. To find out which tanks are available on the aircraft you can test the capacity. If the capacity is 0 then this fuel tank does not exist on the loaded aircraft. e.g. If ps.FuelTanks(FSFuelTanks.Centre_Main).CapacityUSGallons = 0 Then ' This aircraft has no centre fuel tank. End If Paul -
Sorry for the delay in replying. I think working with METARs would be difficult because of reading the string and changing it to add turbulence. The extended METAR format for SimConnect is quite obscure and not well documented. It might be easier to use the 'New Weather Interface' in FSUIPC. Below is an example of how to use it from my DLL. I also attach the latest version that has these weather facilities. Version 3 only targets the .NET 4.0 Framework (or later). By altering the weather you can add turbulence to the current wind layers (or even add your own wind layers), or do the same with cloud layers. You would probably need to set GLOBAL weather to ensure it has an effect. If you just set nearby weather stations then you're not guaranteed to get the exact weather at the aircraft. This might interfere with other weather programs however, so that might be something to think about. As you say, the other way of doing turbulence is to directly control the plane to simulate it. I think this is favoured way for add-ons that simulate turbulence like Accu-Feel as it doesn't mess with the weather. Paul private void weatherExample() { // 1. grab a reference to the weather services to save typing... // NOTE: Connection must already be open. WeatherServices ws = FSUIPCConnection.WeatherServices; // 2. Get METAR string at London, Heathrow // string METAR = ws.GetMetarAtLocation("EGLL"); // 2. Now get a weather object or create a new one. Examples below... // Get the current weather at the aircraft // so we don't have to fill in every bit of weather data, // just modify what's currently set. FsWeather weather = ws.GetWeatherAtAircraft(); // You can also get weather from a specific station, e.g. London Heathrow // Note that the player must be near to the weather station so it's active. // If the station is not active you'll get an FSUIPCException thrown which you can catch. // If the player moves the aircraft using Goto Airport menu, the weather stations take a few seconds // to initialise. // FsWeather weather = ws.GetWeatherAtLocation("EGLL"); // Or from a specific Lon, Lat point (see other overloads of GetWeatherAtLocation()) // Or start from scratch and fill in everything you need to: // FsWeather weather = new FsWeather(); // 3. Setup or modify the weather object... // Setup a single wind layer FsWindLayer wind = new FsWindLayer(); wind.Direction = 270; // west wind.DirectionVariance = 5; // 5 degree variance wind.SpeedKnots = 12; // 12 Knots wind.GustKnots = 16; // 16 knot gusts wind.UpperAltitudeFeet = 5000; // layer active up to 5000 ft wind.Turbulence = FsTurbulenceLevel.Light; // Set up seom turbulance // Clear all existing wind layers and add the new wind layer weather.WindLayers.Clear(); weather.WindLayers.Add(wind); // Change the visibility weather.Visibility.RangeNauticalMiles = 1; // 1nm visibility // Set the pressure weather.Pressure.PressureMillibars = 1023; // Add turbulance to existing cloud layers foreach (FsCloudLayer cloudLayer in weather.CloudLayers) { cloudLayer.Turbulence = FsTurbulenceLevel.Moderate; } // 4. Now write this weather as global weather (everywhere) ws.SetGlobalWeather(weather); // If not using global mode you can write the weather to a specific station: e.g. Heathrow, UK // ws.SetWeatherStation("EGLL", weather); // NOTES: // * See the intellisense for details for all the available weather options // * METAR strings can be read via the appropriate methods on the WeatherServices. // * METAR can be written in theory but no one seems to know the format. (It's not he same as the read format) // * Cloud layers can be cleared and setup in the same way as Wind layers. // * More visibility layers can be managed via the VisibilityUpperLayers list on the weather object. // * All weather can be cleared using ws.ClearWeather(); } FSUIPCClient3.0_RC2.zip
- 7 replies
-
- turbulence
- weather
-
(and 1 more)
Tagged with:
-
Error 12 means the DLL cannot send any messages to FS9. Check that FSUIPC is actually running (Do you see the menu item?) Also make sure that FS9 and your copy of Visual Studio are running at the same privilege level. Both have to run "As Administrator" or both need to be running not "As Administrator". It wont work is one is running As Admin but the other isn't. Try another FSUIPC application and see if that can connect to your FS9. e.g. TrafficLook.exe available from the Downloads section on Pete's forum. Paul
-
Yes, NET 4.0 code will run on the 4.5 or 4.6 framework as well. I've attached the latest version as we're up to RC2 now. Paul FSUIPCClient3.0_RC2.zip