Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not stop the scope #5

Closed
gjzamiar opened this issue Jan 29, 2017 · 8 comments
Closed

Can not stop the scope #5

gjzamiar opened this issue Jan 29, 2017 · 8 comments

Comments

@gjzamiar
Copy link

Hello,
I have every thing running and can copy the data to a new array. However I can not make the scope run again, without shutting down.
These are buttons on a Windows form some work and some do not.
I have the scope set to Running False during configuration , and it takes all my config, after a commit
The data returned from the first click of the button2 is great, however read my comments ( Comments )for the next click.

I could really use some help
Thanks
George Zamiar
502-494-6792

     public void button4_Click_1(object sender, EventArgs e)
    {
        // STOP Button **This button never works**
        scope.CommitSettings();
        scope.Running = false;
            Application.DoEvents();
            scope.CommitSettings();
    }

    public void btnFireScope_Click(object sender, EventArgs e)
    {
       // Trigger **This button Never works**
        scope.ForceTrigger();
    }



    // Set scope to run
    public void button2_Click(object sender, EventArgs e)
    {
        // RUN BUTTON  **This button set the scope running, gets the first set of data and updates the Scope.Running.  However you do not hear it click and status never up dates to to "Armed"  **
        scope.Running = true;
        scope.CommitSettings();
    }

    // Increment trigger Up
    public void button1_Click(object sender, EventArgs e)
    {
        // INCREMENT plus  **This button works just fine**
        float InTrig = scope.TriggerValue.level + .20F;
        var tv = scope.TriggerValue;
        tv.level = InTrig;
        scope.TriggerValue = tv;
        scope.CommitSettings();
    }

    // Increment trigger Down
    public void button3_Click(object sender, EventArgs e)
    {
        
        // DECREMENT **This button works just fine**
        float InTrig = scope.TriggerValue.level - .020F;
        var tv = scope.TriggerValue;
        tv.level = InTrig;
        scope.TriggerValue = tv;
        scope.CommitSettings();
        Application.DoEvents();
    }
    private void tmrMain_Tick(object sender, EventArgs e)
    {
        if (scope != null)  **All these fields up Date**
        {
            label4.Text = DateTime.Now.ToString();
            label1.Text = "Scope is Runing: " +
                scope.Running.ToString();
            label2.Text = "Current Trigger Value: " +
                scope.TriggerValue.level.ToString();
            label3.Text = "Scope is Armed: " +
                scope.Armed.ToString();
            label5.Text = "Mode: " +
                scope.AcquisitionMode.ToString();
            label6.Text = "Awaiting Trig: " +
               scope.AwaitingTrigger.ToString();
            label7.Text="Scope Ready "+
               scope.Ready.ToString();
            textBox1.Text = scope.ToString();
            label8.Text = "Dat Source is Running: "+
                scope.DataSourceScope.IsRunning.ToString();
        }
        else if (scope==null)
        {
            label7.Text = "Scope Ready " +
               "Scope IS NULL"; **Never get Here**

        }
    }

    private void button5_Click(object sender, EventArgs e) **This button works just fine**
    {
        scope.AcquisitionMode = AcquisitionMode.SINGLE;

    }

    private void button6_Click(object sender, EventArgs e) **This button works just fine**
    {
        scope.AcquisitionMode = AcquisitionMode.NORMAL;

    }
@louiecaulfield
Copy link
Contributor

First off, you don't need to use Application.DoEvents() since you're using a windows forms app. This is only necessary for console apps (on windows).

Secondly, I don't see you using IScope.GetScopeData() anywhere, nor are you using the IScope.DataSourceScope (which calls GetScopeData() in its own thread). You need to call this method, otherwise the software doesn't know what state the scope is in.

Check out https://github.com/labnation/DeviceInterface#iscope-usage

@gjzamiar
Copy link
Author

gjzamiar commented Jan 30, 2017 via email

@louiecaulfield
Copy link
Contributor

I believe the UI reports a different viewport offset than the one used in the API. Check the source:

        public void SetViewPort(double offset, double timespan)
        {
            /*                maxTimeSpan
             *            <---------------->
             *  .--------------------------,
             *  |        ||       ||       |
             *  `--------------------------`
             *  <--------><------->
             *    offset   timespan
             */

@louiecaulfield
Copy link
Contributor

If you don't care about the viewport vs acquisition window, best is to set offset to 0 and timespan to AcquisitionLength.

@gjzamiar
Copy link
Author

gjzamiar commented Feb 1, 2017

I wish to thank you all for the help, I am capturing my event and on my way, getting all the math right. Doing RMS on the samples. It would be nice to have an automatic "Delete Double Value" when working at a relatively slow 43ms you end up with a lot of doubles

Thanks again,
George

@louiecaulfield
Copy link
Contributor

What do you mean with "double value"?

Can you describe the inconvenience?

@gjzamiar
Copy link
Author

gjzamiar commented Feb 2, 2017 via email

@louiecaulfield
Copy link
Contributor

I don't understand what you're asking. Are you referring to the SmartScope app's measurements? Or features of the DeviceInterface library?

Average() is a built-in function of C# (or to be more precise, Linq).

If you're trying to calculate the RMS and don't want to write the code yourself, I suggest you just google and copy paste a few lines of code

This question has nothing left to do with the original topic of this issue, so I'm closing it. Feel free to open new ones if you have more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants