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.

New Slice creation - slice.Index set to -1

Paul RN3A
Paul RN3A Member
edited February 2017 in SmartSDR API
Hi all,

I can create new slice with the following example:

           double freq = 14.123d;
            string RXA = "ANT1";
            string Mode = "CW";

             Slice Slice1 = new Slice(radio);

            Slice1 = radio.CreateSlice(freq, RXA, Mode);
            Slice1.RequestSliceFromRadio();

The slice is successfully created in the readio, but...

- Slice1.Index shows  -1
- The actual slice frequency and mode are different from requested.

The slice Index cannot be changed, it is read-only, so I cannot place newly created slice in my existing slice array.

What am I doing wrong?

Paul RN3A


Answers

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited February 2017
    When are you checking the slice index?  It is going to be -1 initially until the radio receives the slice create command (sent via the RequestSliceFromRadio function) and sends back a reply.  Have you tried waiting before checking index?  The best way to do this is probably to subscribe to the PropertyChanged event for the slice before calling RequestSliceFromRadio and then look for a change to RadioAck to true.  When this happens, look at index and I bet it will be valid.

    Obviously there are times when you request a slice and one won't be available.  Like if you already have 8 slices on a 6700 (4 slices on a 6500).  I'm sure this isn't the case here, but figured I would put it in the answer for completeness when others see this.
  • Paul RN3A
    Paul RN3A Member
    edited February 2017
    Thank you Eric.

    I still must be doing something wrong. Can you please explain.

    When I create and request a new slice, it goes through Slice Add call, when it first appears, and then it several times calls slice Property change, and every time it does different things. The slice number appears to be correct at this point. But sometimes slice does not show up on the SSDR screen. And it obviously requires some time for the process to complete. Simply adding timer does not seem to be a good idea. There should be a reliable pattern. Which properties do I need to monitor to make a reliable decison that slice has been created and I can start changing it inside my program? And why new slice sometimes do not appear on SSDR screen? 
  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited December 2016
    The pattern we use in SmartSDR-Win is:

    1. Create the object -- usually through a call to the Radio class
    Slice slc = radio.CreateSlice();

    2. Attach to the PropertyChanged event to catch changes.
    slc.PropertyChanged += new PropertyChangedHandler(slc_PropertyChanged);

    3. Request the object from the radio using the class.
    slc.RequestSliceFromRadio();

    4. Wait for the RadioAck property to go from false to true in the PropertyChanged handler.

    private void slc_PropertyChanged(object sender, PropertyChangedEventsArgs e)
    {
        Slice slc = sender as Slice;
        if(slc == null) return; // caller wasn't a Slice -- program logic error likely
        switch(e.PropertyName)
        {
            case "RadioAck":
                if(slc.RadioAck)
                    // now go do interesting stuff since the radio is aware of the object
                break;
        }
    }
  • Paul RN3A
    Paul RN3A Member
    edited April 2014
    Thank you, Eric.

    There are 8 slices possible in the radio (4 for 6500). How many slice property change event subscriptions need? One fits all, or equal to number of open slices?

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited December 2016
    This is really up to the application developer.  Some people might want to do different things for different Slices.  For example, the CAT code uses 2 different handlers I think as it handles things differently for VFOA and VFOB.  In SmartSDR-Win, we end up needing access to the changing properties at several different levels, so you'll find PropertyChanged event handlers in several places in our code.
  • Paul RN3A
    Paul RN3A Member
    edited April 2014
    Thank you, Eric.

    I have palyed with it, and I have some findings.

    1. When I create new slice, sometimes it does not appear on SSDR pan screen. However, it is there, because I can read it's frequency, mode, etc. Is it a bug?

    2. For example, I create a new slice with the following command:

     Slice1 = radio.CreateSlice(14.080d, "ANT1", "DIGL");
     bool b = Slice1.RequestSliceFromRadio();

    The slice which already exist in the current pan is set to CW, 14,023. The new slice seems to not accept frequency and mode settings. The slice is created, but on 14.000 and CW. New slice seems to follow the the nearest slice mode, antenna and other settings, with the exception of frequency. Is it a bug?

    3. For example, my existing slice is set to 14.200, and Panadapter zoom level is set so,  that 14.000 frequency mark is off the screen. When I create new slice, and as in #2 it defaults to 14.000, the new slice never appears on the Panadapter screen. The slice is still created, I can read it's properties. But if I change Pan zoom level in such a way that 14.000 is visible on the screen, in 90% of the cases slice appears there. The same behaviour exist on all bands, and depends on pan zoom level. Is it a bug?

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited December 2016
    I'm not sure about #1.  I will have to double check our code to find out what the expected behavior is when you add a Slice outside of SmartSDR-Win.

    I tested #2 and this looks like a bug.  Thanks for reporting this.

    If I understand what you are doing in #3, I think this is the same as #1.  I will get back to you on this.
  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited December 2016
    #2 is definitely a bug and has been entered as DE1986.  Thanks for reporting this.

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.