Jump to content
The simFlight Network Forums

Continuously check an Offset


djp122
 Share

Recommended Posts

Hey everyone,

 

            EDIT: I answered my own question by reviewing the examples in the FSUIPC Client DLL for .NET zip file.

 

 

 

            I am trying to figure out how to continuously check an offset to see if it is at a current value or not. The variable I am looking to check is the COM1 radio, when it is transmitting and when it is receiving.

 

           It works as long as I press the update button on my form. I am trying to figure out how to continuously check it in the background with a backgroundworker.

 

           The end goal is to do something if the COM1 is transmitting or receiving. Such as, Streaming SkyBlue radio, but having it mute when I am talking or someone is transmitting over the radio. Figure I would give it a shot anyway.

 

          This is some of the code, but kind of stuck on how to implement the continuous variable check.

 Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        BackgroundWorker1.RunWorkerAsync()
    End Sub 

Private Sub btnUpdate_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdate.Click
        FSUIPCConnection.Process()
        Dim COM1Recieve As Integer = COM1Rx.Value
        Dim COM1Transmit As Integer = COM1Tx.Value
        Me.lblRx.Text = COM1Recieve.ToString
        Me.lblTx.Text = COM1Transmit.ToString
    End Sub


Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            FSUIPCConnection.Process()
            Dim COM1Recieve As Integer = COM1Rx.Value
            Dim COM1Transmit As Integer = COM1Tx.Value
            Me.lblRx.Text = COM1Recieve.ToString
            Me.lblTx.Text = COM1Transmit.ToString
            ReadCom(COM1Recieve, COM1Transmit)
    End Sub
Edited by djp122
Link to comment
Share on other sites

1) download the latest download by Paul Henty

 

2) Read the complete VB.net example. FSUIPCClientExample_VB (Form1.vb)

 

3) Refer to the "Timer1_Tick" Section. You need the Timer Tick. Within this Timer Tick you declare for example:

    The Timer tick is reading data every 200 ms for example.

    Me.Timer1.Interval = 200

    Me.Timer1.Enabled = True

    ecc.....

 

' COM2 frequency

' Shows decoding a DCD frequency to a string

' a. Convert to a string in Hexadecimal format

Dim com2String As String = com2bcd.Value.ToString("X")

' b. Add the assumed '1' and insert the decimal point

com2String = "1" & com2String.Substring(0, 2) & "." & com2String.Substring(2, 2)

Me.txtCOM2.Text = com2String

 

    This is the way you get a continous update for all data you declare.

    You do not need any Button for it.

 

    You can read and Set all data.

 

regards,

Friedrich

.

 

Link to comment
Share on other sites

3) Refer to the "Timer1_Tick" Section. You need the Timer Tick. Within this Timer Tick you declare for example:

    The Timer tick is reading data every 200 ms for example.

    Me.Timer1.Interval = 200

    Me.Timer1.Enabled = True

    ecc.....

.

 

No you wouldn't set the interval nor enable the timer within the 'tick' routine as it would never start

 

Set the interval in the form load section or at design time if the interval does not need to be changed and start the timer when the app is started

Link to comment
Share on other sites

No you wouldn't set the interval nor enable the timer within the 'tick' routine as it would never start

 

Set the interval in the form load section or at design time if the interval does not need to be changed and start the timer when the app is started

Yes you are right. I forgot to mention it separately.

Anyhow the import thing is the Timer1_Tick section for our friend 'djp122'.

 

regards,

Friedrich

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.