Jump to content
The simFlight Network Forums

Recommended Posts

Posted

* Strange issues with this airplane for beacon lights offset is not working by light type method

 

* For auto spoilers detection works but strange if armed by myself is good but when the checklist run the auto spoilers are not  checked in my Acars system

 

example : view log here

 

http://www.skydream-airlines.com/index.php/pireps/view/1594

 

other with Airbus

 

http://www.skydream-airlines.com/index.php/pireps/viewreport/1587

 

For now I can't paste my code here (I'm not at home)

 

Fred

 

Posted

Hi Fred,

 

If your code works fine with the default planes built-in to flight sim then the problem is with the way the third-party plane has been programmed.

 

Some types of third-party add-on aircraft do not always use the underlying Flight Sim systems. They often model their own systems and so you cannot access this data via the usual FSUIPC offsets. I suspect this is the case with the beacon light and spoiler on this Airbus by Aerosoft.

 

Sometimes the authors provide an SDK to access their special data (e.g. PMDG 737NGX). Some have data accessible by L:VARS which you can read with a LUA plugin. Each plane is unique and requires its own research. For some like the PMDG MD-11 its not even possible.

 

Paul

Posted (edited)

Ok thanks Paul,

 

I think those issues made by Aerosoft, so for L:VARS how I can use that ? For the SDK by Aerosoft I don't think exist maybe by Joshua?

 

Once I have catch the L:VAR how I can make that in my VB.net code ?

 

Source:http://forum.avsim.net/topic/451948-aerosoft-airbus-module-43-v2/

function Lights_BEACON_on ()
    LVarSet = "L:LIGHT_BEACON"
    ipc.writeLvar(LVarSet, 1)
    LightSwitch ()
	DspShow ("BCN", "on")
end

function Lights_BEACON_off ()
    LVarSet = "L:LIGHT_BEACON"
    ipc.writeLvar(LVarSet, 0)
    LightSwitch ()
	DspShow ("BCN", "off")
end

An other question about you latest lines docs for know active runways can you help me please ? (sorry I don't have the source code with me here)

 

Sorry for my poor English I try todo the best ;)

 

Fred

Edited by FSX30HD
Posted
Once I have catch the L:VAR how I can make that in my VB.net code ?

 

 

The LUA plug-in will have to write to an offset so you can read it in VB in the normal way. You have two choices:

 

1. Write the data to the normal lights offset to control the normal FS beacon light.

2. Write to a one of the general use offsets (from 0x66C0).

 

Option 1 will mean you don't need to change your program because it's already looking at that offset. However it might do unwanted things to your plane if Aerosoft are using it for something else.

 

I'm not an expert in LUA but the code below is something like what you need to do. I've shown using the normal Beacon indicator (option 1).


-- set the pollrate to 250ms = 4 times per second
pollrate = 250

-- create a function to write the LVAR value to an offset
function writeBeacon(varname, value)
   if value == 1 then
     ipc.setbitsUW(0x0D0C, 2) -- set bit 2
   else
     ipc.clearbitsUW(0x0D0C, 2) -- clear bit 2
   end
end

-- create an event listener to monitor the LVAR
-- this will call the function above when the LVAR changes
event.Lvar("L:LIGHT_BEACON", pollrate, "writeBeacon")

 

An other question about you latest lines docs for know active runways can you help me please ?

 

Do you mean this facility on the AITrafficServices?

Dim AI As AITrafficServices = FSUIPCConnection.AITrafficServices
' Refresh the traffic information
AI.RefreshAITrafficInformation()
' Get the arrival runways in use
Dim runways As List(Of FSRunway) = AI.GetArrivalRunwaysInUse("EGLL")

What do you want to know?

 

Sorry for my poor English I try todo the best

 

 

 

Pas de probleme. Je vous comprends. Je pense que vous parlez l'Anglais mieux que je parle la Francais. :smile:

 

Paul

Posted

Paul I would like to say you thank you for your reply ;)

-- set the pollrate to 250ms = 4 times per second
pollrate = 250

-- create a function to write the LVAR value to an offset
function writeBeacon(varname, value)
   if value == 1 then
     ipc.setbitsUW(0x0D0C, 2) -- set bit 2
   else
     ipc.clearbitsUW(0x0D0C, 2) -- clear bit 2
   end
end

-- create an event listener to monitor the LVAR
-- this will call the function above when the LVAR changes
event.Lvar("L:LIGHT_BEACON", pollrate, "writeBeacon")

This code it's written for VB.Net ? (I'm a nobe)

 

Do you mean this facility on the AITrafficServices?

 

Yes

Dim AI As AITrafficServices = FSUIPCConnection.AITrafficServices
' Refresh the traffic information
AI.RefreshAITrafficInformation()
' Get the arrival runways in use
Dim runways As List(Of FSRunway) = AI.GetArrivalRunwaysInUse("EGLL")
What do you want to know?

 

I would like paste variable to your string "EGGL"  when I get a flight and check if the plane is in the good ICAO. So less my source code You can't view nothing sorry for that

 

Pas de probleme. Je vous comprends. Je pense que vous parlez l'Anglais mieux que je parle la Francais. :smile:

 

Paul

 

Très bon Français Paul ;)

 

So I'm a register FSUIPC and WideFS user so I'm using your DLL I would like to make donation where I can do that ?

 

Fred

Posted

This code it's written for VB.Net ?

 

 

No, it's written in Lua. Lua is a different programming language. It is used by FSUIPC to write plug-ins. Lua is the only way to read L:Vars.

 

FSUIPC will run that Lua program and adjust the Offset value for the beacon light when the LVar changes. You can then read the offset from VB as normal.

 

You can read about Lua plugins for FSUIPC in the document "FSUIPC Lua Plug-ins.pdf" in the "Modules\FSUIPC Documents" folder.

 

The easiest way to run code above is to save it into the modules folder as a file called "ipcready.lua". This will run when FSX is ready to fly.

 

As I said, I'm no expert on Lua and I cannot test this as I don't have the Aerosoft Airbus. I can't say for sure that it will work, but it's close.

 

I would like paste variable to your string "EGGL"

 

 

Yes you can replace the "EGLL" with your own variable. e.g.

Dim myICAO As String = "LFPG"
Dim runways As List(Of FSRunway) = AI.GetArrivalRunwaysInUse(myICAO)

Then you change the value of myICAO to be whatever you want.

 

Is that what you mean?

 

 

There is a PayPal address for donations in Docs/UserGuide.pdf on page 3 ("Licence" section). This is inside the zip file for my DLL.

 

Paul

Posted

Paul,

 

your Lua script works fine

-- set the pollrate to 250ms = 4 times per second
pollrate = 250

-- create a function to write the LVAR value to an offset
function writeBeacon(varname, value)
   if value == 1 then
     ipc.setbitsUW(0x0D0C, 2) -- set bit 2
   else
     ipc.clearbitsUW(0x0D0C, 2) -- clear bit 2
   end
end

-- create an event listener to monitor the LVAR
-- this will call the function above when the LVAR changes
event.Lvar("L:LIGHT_BEACON", pollrate, "writeBeacon")

But this no work for me

Private Sub getActiveRunways()
 ' Get a reference to the AITrafficServices class (saves typing)
 Dim AI As AITrafficServices = FSUIPCConnection.AITrafficServices
 ' Refresh the traffic information 
 AI.RefreshAITrafficInformation() 
 ' Get the arrival runways in use 
 Dim runways As List(Of FSRunway) = AI.GetArrivalRunwaysInUse("EGLL")
 ' Display in the listbox 
 Me.lstArrival.Items.Clear()
 For Each rw As FSRunway In runways
 Me.lstArrival.Items.Add(rw.ToString()) 
 Next rw 
 ' same for departure runways 
 runways = AI.GetDepartureRunwaysInUse("EGLL") 
 Me.lstDeparture.Items.Clear()
 For Each rw As FSRunway In runways
 Me.lstDeparture.Items.Add(rw.ToString()) 
 Next rw 
 End Sub
Posted

The methods GetArrivalRunwaysInUse and GetDepartureRunwaysInUse work by getting the information from the AI traffic.

 

So you will only get runways if:

 

1. The player is in range of the airport (about 50 miles I think). AND...

2. There are currently AI planes at, en-route or departed from that airport.

 

The more AI traffic you have the more chance of getting the information.

 

I don't know any other way of finding out the active runways.

 

Paul

Posted

Paul

 

Finding Active Runways  works fine now (just add filter and make a timer)

FSUIPCConnection.AITrafficServices.ApplyFilter(False, True, 0, 360, Nothing, 10000D, 30D)

So I woul like to add 4 submenu like getflight startlog stoplog pause I have seen the part of code but for C# (with the class UserInputServices)

So can you help me please ? 

 

And I can't give Spoilers Arm status I think LUA is needed 

ipc.control(66066)
ipc.control(66067)

And to finish you now a way where I can give LUA script to pilots ?

 

Fred

Posted

Menu Items:

 

Here is an example in VB of adding some menu items (including sub-menu items) and responding to them.

 

I've included the whole form so you can see where everything goes.

 

You must use the latest version of the DLL (attached). The previous one had a bug which stops menu items working properly.

Imports FSUIPC

Public Class menuTest

    ' create a class level variable to access the UserInputServices
    ' Dim 'WithEvents' as we need to sink some events later
    Private WithEvents ui As UserInputServices

    Private Sub menuTest_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FSUIPCConnection.Open()
        ' set the ui variable so we have access in other methods
        ui = FSUIPCConnection.UserInputServices
    End Sub

    Private Sub menuTest_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        FSUIPCConnection.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        AddMenuItems()
    End Sub

    Private Sub AddMenuItems()
        ' 1. Add our menu items - three main items. Item 3 has two sub items.
        '    IDs (first parameter) can be whatever you want.
        Me.ui.AddMenuItem("MenuItem1", "Menu Item 1", False)
        Me.ui.AddMenuItem("MenuItem2", "Menu Item 2", False)
        Me.ui.AddMenuItem("MenuItem3", "Menu Item 3", False)
        Me.ui.AddSubMenuItem("MenuItem3A", "MenuItem3", "Sub Item A")
        Me.ui.AddSubMenuItem("MenuItem3B", "MenuItem3", "Sub Item B")
        ' 2. Start a timer that will check for input every 200ms (as recomended by the FSUIPC docs)
        Me.timerMenuCheckInput.Interval = 200
        Me.timerMenuCheckInput.Start()
        ' 3. start the timer to keep the menu items alive. If you don't call this every 14 seconds
        ' FSUIPC will remove your menu items.
        Me.timerMenuKeepAlive.Interval = 8000 ' 8 seconds recomended in the FSUIPC documentation
        Me.timerMenuKeepAlive.Start()
    End Sub

    Private Sub timerMenuKeepAlive_Tick(sender As Object, e As EventArgs) Handles timerMenuKeepAlive.Tick
        ' tell FSUIPC that we still need the menu items
        Me.ui.KeepMenuItemsAlive()
    End Sub

    Private Sub timerMenuCheckInput_Tick(sender As Object, e As EventArgs) Handles timerMenuCheckInput.Tick
        Me.ui.CheckForInput()
    End Sub

    ' The event handler that gets called when a menu item is selected
    Private Sub ui_menuItemSelected(sender As Object, e As UserInputMenuEventArgs) Handles ui.MenuSelected
        ' use e.ID to find out which item was selected
        ' NOTE: MenuItem3 can never be selected itself because it has submenus.
        Select Case e.ID
            Case "MenuItem1"
                MessageBox.Show("Item 1")
            Case "MenuItem2"
                MessageBox.Show("Item 2")
            Case "MenuItem3A"
                MessageBox.Show("Item 2 - SubItem A")
            Case "MenuItem3B"
                MessageBox.Show("Item 3 - SubItem B")
        End Select
    End Sub

End Class

Sending Controls (e.g. Spoilers)

 

You don't need Lua for this. You can send any control number through FSUIPC. Here is an example of writing the spoiler arm control via the dll. The second parameter (0 in the example) is where you send values with the control. Not all controls need values. Just pass 0 if they do not.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ' write a control to FS:
        ' either send the number...
        FSUIPCConnection.SendControlToFS(66066, 0)
        ' or use the Enum to make the code easier to read...
        FSUIPCConnection.SendControlToFS(FsControl.SPOILERS_ARM_ON, 0)
        ' (Ils sont la meme chose)
    End Sub

Distributing Lua Scripts

 

It's best not to force the users to run a script called ipcready.lua. They may already have their own script called this name. So call the script file something unique to your application.

 

This will need to be in the 'modules' folder so either your installer will need to copy it there, or the users will need to do this manually.

 

To get the script to run you can just tell FSUIPC to run it. You need to declare this offset: (I've put it in its own group called 'luaControl):

    ' Dim the offset that controls lua files
    Private luaControl As Offset(Of String) = New Offset(Of String)("luaControl", &HD70, 40, True)

Then when your application is connected to FSUIPC you use this code to tell FSUIPC to run the script...

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ' 1. Your LUA file must be in the modules folder of the user.
        '    In this example we imagine it is called 'FredLuaScript.lua'
        ' 2. In your application you need to tell FSUIPC to run this script...
        luaControl.Value = "Lua:FredLuaScript" ' Do not include the .lua extension to the file name
        FSUIPCConnection.Process("luaControl")
    End Sub

Regards,

 

Paul

 

FSUIPCClient3.0_BETA.zip

Posted

Sending Controls (e.g. Spoilers)

 

You don't need Lua for this. You can send any control number through FSUIPC. Here is an example of writing the spoiler arm control via the dll. The second parameter (0 in the example) is where you send values with the control. Not all controls need values. Just pass 0 if they do not.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ' write a control to FS:
        ' either send the number...
        FSUIPCConnection.SendControlToFS(66066, 0)
        ' or use the Enum to make the code easier to read...
        FSUIPCConnection.SendControlToFS(FsControl.SPOILERS_ARM_ON, 0)
        ' (Ils sont la meme chose)
    End Sub

Ok I think there is a misunderstood I don't want to send an event  just check spoilers status like beacon lights it's again for Aerosoft Bus (PM)

 

Regards Fred

Posted

Yes I misunderstood. The controls cannot give you information, they can only make things happen. So they are of no use if you want to check the spoilers.

 

However, these controls are standard FS controls. They are not special Aerosoft ones.

 

How are you reading the state of the spoilers in your application? Which offset?

 

Paul

Posted

Hi Paul,

 

Public autospoiler As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&HBCC, 4)

Public Function getspoilersarmed()
        Return autospoiler.Value(0)
End Function

 Private Sub cbSpoilersarmed_CheckStateChanged(sender As Object, e As EventArgs) Handles cbSpoilersarmed.CheckStateChanged
        'If cbSpoilersarmed.Checked = True Then
        If cbSpoilersarmed.Checked = True Then
            Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Auto spoilers armed" & vbCrLf
            My.Computer.FileSystem.WriteAllText(logname, vt, True)
            Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Auto spoilers armed " & "*"
            My.Computer.FileSystem.WriteAllText(reportname, xml, True)
            'ElseIf cbSpoilersarmed.Checked = False Then
        ElseIf cbSpoilersarmed.Checked = False Then
            Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Auto spoilers disarmed" & vbCrLf
            My.Computer.FileSystem.WriteAllText(logname, vt, True)
            Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Auto spoilers disarmed " & "*"
            My.Computer.FileSystem.WriteAllText(reportname, xml, True)
        End If
    End Sub
Working nice with keyboard but the same problem like beacon lights (before) with checklist no work

Regards Fred

Posted

Okay. We can do that same thing as with the beacon light.

 

Looking at the LiNDA plugin, I can see this L:VAR that seems to check for spoilers:

function Spoilers_arm_toggle ()
    if _tl("ASC_Spoilers_armed", 0) then
       Spoilers_ARM ()
    else
       Spoilers_DISARM ()
    end
end

If that is correct, you can add this to your lua code: (Offset 0x0BCC is the normal spoiler arm command in FS)
 

-- create a function to write the LVAR value to an offset
function writeSpoiler(varname, value)
   if value > 0 then
      ipc.writeUD(0x0BCC, 1) -- Set 0BCC (4 bytes) to 1 = armed
   else
      ipc.writeUD(0x0BCC, 0) -- Set 0BCC (4 bytes)  to 0 = off
   end
end

-- create an event listener to monitor the Spoiler LVAR
-- this will call the function above when the LVAR changes
event.Lvar("L:ASC_Spoilers_armed", pollrate, "writeSpoiler")

Paul

Posted

Thanks Paul,if for this reason I tell you this issue happen only with the bus by Aerosoft. PMDG works fine. I don't undestand why?! Check your PM BOX

 

 

Seem  to work auto spoiler and beacon lights via LUA

Aircraft Used in flight is Airbus A320 easyJet G-EZTB
Aircraft model is A320CFM
Flight Number= SDA7794
Departure= LFPG
Destination= LFBO
[04:19] ZFW: 115030 lbs
[04:19] TOW: 134005
[04:19] METAR for departing airport: 2015/06/04 04:00
LFPG 040400Z 02006KT 010V090 CAVOK 09/07 Q1026 NOSIG
[04:19] Boarding 
[04:19] Parking Brakes Engaged 
[04:20] Transponder set to 2563
[04:20] Paused 
[04:21] Unpaused
[04:23] NAV1 set to 110.35
[04:25] NAV1 set to 109.10
[04:28] Beacon lights ON
[04:28] Engine 2 ON 
[04:29] Engine 1 ON 
[04:30] Auto spoilers armed
[04:31] Flaps at Position 2
[04:31] Taxi lights ON
[04:31] Parking Brakes Released 
[04:32] Taxiing to Runway 
[04:32] Landing lights ON 
[04:32] Strobe lights ON
[04:33] Taking Off
[04:33] Taking Off from Runway 26R
[04:33] You Take off @ 161 Knots and Flaps at Position 2 
[04:33] Pitch angle 9 degrees and 18666lbs FOB
[04:33] Wind 14 @ 6 kt, Temperature 9 deg. C
[04:33] Landing Gear Up @  168 Knots and 480 Feet
[04:33] Taxi lights OFF
[04:33] Auto spoilers disarmed
[04:34] Climbing 
[04:34] Flaps Retracted @ 195 Knots
[04:37] Landing lights OFF @ 10830 ft 
[04:47] TOC reached. Cruise 31000 ft

Regards Fred

  • 2 weeks later...
Posted

I don't think so. Lua is the only way I know of accessing L:VARs.

 

If Aerosoft have an SDK you might be able to access that directly from your program. However, this may be difficult with VB as most SDKs are intended for C.

 

Paul

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.