Jump to content
The simFlight Network Forums

Offset definition during run time


Recommended Posts

Hi Paul,
for version 2.0 of FSSymphony I will let the user assign in/outputs of the interface hardware to FSUIPC offset bits or setting values.

The definitions will be stored in a array and have to be defined in .net during run time.

In a first beta implementation I do the like the following sketch:


Loop through the array.....

UserOffsetAddress = Integer.Parse(OffsetAddress, Globalization.NumberStyles.AllowHexSpecifier)

Dim User_Offset As Offset(Of UShort) = New FSUIPC.Offset(Of UShort)(UserOffsetAddress)


.....process data




This works fine for a small amount of user definitions. But because this code snipped might have to be executed for 100 or even

more user definitions, several times per second, I have some doubt that this is the way I should go. Even after some "brain

storming" I could not find a better solution. Perhaps you can help me to break through the mental block, with an idea for a

better solution.

Thanks in advance!


Link to comment
Share on other sites

Hi Ruediger,


My suggestion is to use the grouping facilities so that you process all the user offsets in one go. 


First, you'll need to keep a List<> of the user offsets you create for later use, so declare one at the form (or class) level:

    Private UserOffsets As List(Of Offset(Of UShort)) = New List(Of Offset(Of UShort))

Next, you'll need a method that will take your array of user offset addresses and create the new offsets (assigning them to their own group).

    Private Sub updateUserOffsets(userOffsetAddresses As String())
        ' Clear the user offsets list
        ' Delete the user offsets group
        ' For each user offset, make a new Offset in the "UserOffsets" group and add it to
        ' a list (UserOffsets) for later use.
        For Each OffsetAddress As String In userOffsetAddresses
            Dim UserOffsetAddress As Integer = Integer.Parse(OffsetAddress, Globalization.NumberStyles.AllowHexSpecifier)
            Dim User_Offset As Offset(Of UShort) = New FSUIPC.Offset(Of UShort)("UserOffsets", UserOffsetAddress)
    End Sub

You can call this when your application starts or when the user changes the list of offsets in the application.


When you need to process them, you can just process the entire group at once and then step through each Offset and do whatever you need to with the values:

        ' Process the user offsets
        ' Now do stuff with the data in the user offsets
        For Each UserOffset As Offset(Of UShort) In UserOffsets
            Dim val As UShort = UserOffset.Value
            ' process the data
            ' ...


Link to comment
Share on other sites

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.