Delphi Posted July 17, 2013 Report Posted July 17, 2013 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)FSUIPCConnection.Process().....process datareadoffset.Disconnect() Next This works fine for a small amount of user definitions. But because this code snipped might have to be executed for 100 or evenmore user definitions, several times per second, I have some doubt that this is the way I should go. Even after some "brainstorming" I could not find a better solution. Perhaps you can help me to break through the mental block, with an idea for abetter solution.Thanks in advance!Ruediger
Paul Henty Posted July 17, 2013 Report Posted July 17, 2013 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 UserOffsets.Clear() ' Delete the user offsets group FSUIPCConnection.DeleteGroup("UserOffsets") ' 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) UserOffsets.Add(User_Offset) Next 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 FSUIPCConnection.Process("UserOffsets") ' 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 ' ... Next Paul
Delphi Posted July 17, 2013 Author Report Posted July 17, 2013 Many thanks, Paul That will help me to continue with the implementation. Ruediger
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now