Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Reading Meter events

James Whiteway
edited January 2018 in SmartSDR API
I hate to post this, but, I keep bumping my head against the wall  on this one. (and others, but, that might be solved once I get a handle on this one)
  Using the Object Browser in Visual Studio 2010, I can see in Flexlib, the MeterDataReadyEventHandler, which I believe is what I need to work with in order to read things like the S meter etc. BUT, I cannot seem to grasp how to go about using that event to provide input to something like the Progress Bar, or even a Label with numbers that change corresponding to changes in Signal Strength. I am slowly relearning C#, and I'm sure that is a big part of the problem.
   I have read all the posts here on this subforum and I have seen one that said I needed to "subscribe" to an event in order to use it. Do I need to read the actual packets and separate  them according to Header info ? Or is there a Method in Flexlib that gets around that?
  A bit of sample code on handling streaming data might be helpful. ( I know, I've been using a lot of others examples already and I'm very grateful for it)
   I knew none of this would be simple, and I like a challenge, but, getting my head wrapped about using C# instead of VB.NET  again, is tough for this old brain of mine!!!  :-)
I hope someone here takes pity on an old guy and offers a few crumbs!!
Thanks for reading this.
james
WD5GWY
 

Answers

  • Paul Burton
    Paul Burton Member ✭✭
    edited March 2017

    You first need to specify a method in initialization which will be called in response to the event.  It is called an “event handler”.  This is what is meant by subscribing to the event.Then in the class, you define the event handler of the proper type.  If you look at the source for my small program called "Flexit",  you will see in the initialization area

     

    API.RadioAdded += API_RadioAdded;          //This is subscribing to the event.

     

    Then in the region ON RADIO ADDED OR REMOVED, 

    private void API_RadioAdded(Radio radio)

    {

    …….

    }                                     // This is the definition of the event handler. 

     

    Let me know if you need “Flexit”.

     

    Paul

      
  • James Whiteway
    edited November 2014
    Thanks Paul, you sent me Flexit along with it's source code via email a while back. I couldn't open it in Visual Studio 2010 and so I could not see what you have done. BUT, I am downloading VS 2012 Express Edition and should be able to solve that one. Or, I could start Windows 7 and use VS 2013 Community Edition that I have installed there. Either way, thanks for the info and the pointers.
    Usually, I can open almost any project with Wordpad and at least see the code, if I cannot open it in VS 2010. For some reason that didn't work with your project. I can only guess that VS 2012 Express saves the files in a different format that Wordpad cannot handle.
    I'll let you know how things go.
    james
    WD5GWY

  • James Whiteway
    edited November 2014
    Paul, I downloaded VS 2012 Express and it would not install in Vista. THEN, I checked the system requirements!! Vista is not supported. So, I switched to Win7 and looked at your code from VS 2013 Community Edition. It did the same thing that VS 2010 did, it shows the project as being incomplete. No form data displayed nor any code. Might be that the zip file you originally sent did not contain the completed project, only the exe and the references it needed.
      (although it does show the basic folder structure and file names, eg, form1.cs etc. Just no code there!)
    Thanks for your help.
    james
    WD5GWY
     
  • Paul Burton
    Paul Burton Member ✭✭
    edited March 2017

    James, I'm not sure what you did, but the folder I sent you for the VSE Flexit project is titled FlexitVSProj.zip.  The other folder just contains the executable.  You should extract the FlexitVSProj.zip folder to a folder of your choice.  Then you need to go down in the subfolders to find a file called Flexit.csproj.  Double click on that one to  open the project (assuming you have installed VSE 2012. 

    That should do it for you.

     

  • James Whiteway
    edited November 2014
    I think not having VS 2012 installed is the problem Paul. But, I finally got around not being able to read the source code by opening it in  Word. I will have to re-download VS 2012 and install it on my Win7 drive. I would have thought that VS 2013 Community Edition would be able to open the project and if there were any incompatibilities, offer to convert the project to that edition.
    I'm betting once I do that, things should click.
    james
    WD5GWY
     
  • Paul Burton
    Paul Burton Member ✭✭
    edited March 2017
    You may be able to IMPORT the VS 2012 project into VS 2013, but I don't know.  I had to convert a 2010 project into 2012 by importing.
  • James Whiteway
    edited November 2014
    That's exactly what I just did and now it works and I can see your code! Thanks for putting up with all my questions Paul. I really do appreciate it.
    james
    WD5GWY

  • James Whiteway
    edited March 2017
    Hoping to keep this subject alive a bit longer. I am still not sure how, using Flexlib, to read an ever changing event like the S meter in real time. And reflect that change in a Label's text property and have it update correctly. I can read static properties like Nam, Call, etc. ( which is obvious as Paul and others here posted example code to do that) I can even read the current VFO / SLICE freq. but, if it changes, I have to refresh mt test program to reflect the change. I'm on the road right now, so no computer here to check, do Labels in C# have a Property Changed Event that could be used in real time to keep a running update for something like the s meter or vfo changing? I would feel beyond dumb if it were as simple as that! :-)
  • James Whiteway
    edited December 2014
    I just love making myself look **** on a public forum! Google Search from my phone works! MSDN is online and the answer to part of my question was there. Labels do have a Property Changed event. But, that is not what I need to do what I want. Earlier posts from Steve and Paul both have, what appears to me, the answer. Binding a label's Text property to one of the Meter's changed events. So, maybe a SMALL amount of light is showing in this dim bulb I call my brain!
  • Paul Burton
    Paul Burton Member ✭✭
    edited May 2015
    James - I'm just guessing, but I don't think you want to wait on an event which signals  meter change.  What I think you want is to create a separate program thread which runs continuously and continuously samples the meter.  This sampling will be concurrent with other code function you might have.  You might read up on "threads" in MSDN. 
  • James Whiteway
    edited February 2015
    Believe it or not, I'm still having issues working with Meter Events trying to get Signal Strength info to update a simple label. I look at the Meter Event Handler code in the Object Browser in Visual Studio and see what I "thnk"  I need to do to create the event handler. But, VS keeps gripping about how I go about writing up the code to handle the call to the Meter events. (intellisense is having a field day today with me!)
    james
    WD5GWY

  • N7BCP
    N7BCP Member ✭✭
    edited July 2017
    slice.SMeterDataReady += slice_SMeterDataReady;
    static void slice_SMeterDataReady(float data)        { }
  • James Whiteway
    edited February 2015
    Thanks Larry, I had forgot the first bit of code you posted. I was trying to get the second part going and that was where Visual Studio was complaining. Now I see why!
    Live and learn!
    james
    WD5GWY

  • MH_Flexer
    MH_Flexer Member ✭✭
    edited January 2018

    Paul,

    I am just getting started writing .net programs for Flex. Could you send me your sample program as well?  n6dmr at dmreese dot com

    Thanks in advance,

    Duane


  • Paul Burton
    Paul Burton Member ✭✭
    edited May 2015
    Email sent to you Duane.
  • James Whiteway
    edited March 2015
    Paul, thanks again for the advice on Threading. I have found that several things I have been working on started working, (so far) once I made a few changes that included threading. Still playing with the S Meter thing. Larry's example above helped a lot. ( sometimes I miss the obvious) But, still struggling/learning!
    james
    WD5GWY

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.