Chapter 26 - Create Your Manager Device Discovery Preferences

In the previous chapters of today's lesson, you defined a device discovery parameters object, device discovery request, and device discovery response. This chapter will tie all these classes together so that the developer driver's device manager can use them to discover the devices on your field-bus.

  1. Create a class named BYourDriverDeviceDiscoveryPreferences that extends BDdfAutoDiscoveryPreferences. Create this in the package com.yourCompany.yourDriver.discover.
  2. Redefine the timeOut property and specify the default amount of time that your driver should wait after transmitting your device discovery request before timing out.
  3. Redefine the retryCount property and specify the default number of retries that your driver should attempt after a request times-out (before giving up on that particular request).
  4. NOTE: Sometimes during a discovery process it could be helpful to specify shorter time-outs and less retries so that the entire device discovery process can complete sooner.
  5. Redefine the min property and make the default be a copy of whatever your device discovery params class returns from its getFirst method.
  6. Redefine the max property and make the default be a copy of whatever your device discovery params class returns from its getLast method.
  7. OPTIONAL: Redefine the doNotAskAgain property and declare the default value as true if you do not want the integrator to receive a special prompt when he or she clicks the Discover button on the device manager. If you set this to true then the discovery process will automatically loop from the min to the max that you also specify here. Once you finish today's lesson, we encourage you to try this both ways and decide which way makes the most sense for your driver.
  8. NOTE: Your min and max properties will be instances of the device id if you re-use your ping request as the discovery request. If not, your min and max will be instances of the BYourDriverDeviceDiscoverParams object that you created during today's lesson.

    package com.yourCompany.yourDriver.discover;
    
    import com.tridium.ddf.identify.*;
    import com.tridium.ddf.discover.auto.*;
    
    import com.yourCompany.yourDriver.identify.*;
    
    import javax.baja.sys.*;
    
    public class BYourDriverDeviceDiscoveryPreferences
      extends BDdfAutoDiscoveryPreferences
    {
      /*-
      class BYourDriverDeviceDiscoveryPreferences
      {
        properties
        {
          timeout : BRelTime
            -- This is the amount of time to wait per field-bus request before timing out
            default{[BRelTime.makeSeconds(3)]}
            slotfacets{[BFacets.make(BFacets.make(BFacets.SHOW_MILLISECONDS,BBoolean.TRUE),
                                     BFacets.MIN,BRelTime.make(0))]}
          retryCount : int
            -- This is the number of discovery field-message retransmissions
            -- per request.
            default{[1]}
            slotfacets{[BFacets.make(BFacets.MIN,BInteger.make(0))]}
          min : BDdfIdParams
            -- This is the id of the lowest device for your driver to attempt to
            -- learn by default
            default{[(BDdfIdParams)new BYourDriverDeviceId().getFirst()]}
          max : BDdfIdParams
            -- This is the id of the highest device for your driver to attempt to
            -- learn by default
            default{[(BDdfIdParams)new BYourDriverDeviceId().getLast()]}
        }
      }
      -*/
    }
    

  9. Redefine the discoveryPreferences property on BYourDriverNetwork and specify the default value to be an instance of BYourDriverDeviceDiscoveryPreferences.
  10. Run slotomatic and perform a full build on your driver (as described in Chapter 2).