Chapter 18 - Create a Write Parameters Structure For Your Driver

The developer driver framework tries its best to automatically coalesce all control points under that same device, that need written, and that have equivalent write parameters into a single write request. In a previous chapter of today's lesson, you created your write request. We asked you to assume that you had already created the write request and added any data that you needed to construct the write request itself, not including the information needed to specify the values of individual points.

Please create your write parameters structure following these steps as a guide:

While following the examples in this chapter, please replace the text jarFileName, yourDriver and yourCompany as previously described in the Preparation section):

  1. Review your write request's toByteArray method.
  2. Make a Java class that extends BDdfIdParams and implements BIDdfWriteParams. Name it BYourDriverWriteParams. Create this in a package named com.yourCompany.yourDriver.identify. Also add an empty slotomatic comment immediately after the opening brace for the class declaration.

    To do this, create a text file named BYourDriverWriteParams.java in the jarFileName/src/com/yourCompany/yourDriver/identify folder. Inside the text file, start with the following text:

    package com.yourCompany.yourDriver.identify;
    
    import com.tridium.ddf.identify.*;
    import javax.baja.sys.*;
    
    public class BYourDriverWriteParams
      extends BDdfIdParams
      implements BIDdfWriteParams
    {
      /*-
      class BYourDriverWriteParams
      {
      }
      -*/
    }
    

  3. Add a properties section to the slotomatic header and declare properties for any values that you needed in order to make the toByteArray method (function) in your write request.

    In our hypothetical example, we required one boolean property named "forceWrite". In the example toByteArray method, we accessed this by calling the getForceWrite method. We coded the toByteArray like this because we knew that in this chapter, we would add this property to our hypothetical write parameters structure. We knew that by naming the properties forceWrite that the Niagara AX slotomatic utility would automatically generate a getForceWrite method.

    Please make the slotomatic statement on your read parameters structure look something like this:

      /*-
      class BYourDriverWriteParams
      {
        properties
        {
          forceWrite : boolean
            -- This property has nothing to with the dev
            -- driver framework itself. Instead, we need
            -- to construct the toByteArray method of the
            -- driver's write request in following the
            -- driver's protocol to write data values.
            -- In this hypothetical protocol, if we do not
            -- forceWrite then the equipment's internal
            -- program could overwrite any change that
            -- Niagara might make to a data value.
            default{[true]}
        }
      }
      -*/
    

  4. Override the getWriteRequestType method and return the TYPE of your driver's write request. The Niagara AX slotomatic utility automatically adds the TYPE constant to your Java file when you run the utility.

    Add the following code to BYourDriverWriteParams.java:

      public Type getWriteRequestType(){return BYourDriverWriteRequest.TYPE;}
    

  5. Run slotomatic and perform a full build on your driver (as described in Chapter 2).

Redefine the writeParameters property on BYourDriverProxyExt

  1. Open BYourDriverProxyExt.java.
  2. Redefine the 'writeParameters' property by modifying the slotomatic header of BYourDriverProxyExt.java as follows:

    
    
      class BYourDriverProxyExt
      {
        properties
        {
           readParameters : BDdfIdParams
             -- This hooks your driver's read parameters structure into the
             -- proxy extension that is placed on control points that are
             -- under devices in your driver. The read parameter's structure
             -- tells the dev driver framework which read request to use to
             -- read the control point. It also tells your read request's
             -- toByteArray method how to construct the bytes for the request.
             default{[new BYourDriverReadParams()]}
             slotfacets{[MGR_INCLUDE]}
    
           pointId : BDdfIdParams
             -- This tells your read response's parseReadValue method how to
             -- extract the data value for a particular control point.
             default{[new BYourDriverPointId()]}
             slotfacets{[MGR_INCLUDE]}
    
           writeParameters : BDdfIdParams
             -- This hooks your driver's write parameters structure into the
             -- proxy extension that is placed on control points that are
             -- under devices in your driver. The write parameter's structure
             -- tells the dev driver framework which write request to use to
             -- write the control point. It also tells your write request's
             -- toByteArray method how to construct the bytes for the request.
             default{[new BYourDriverWriteParams()]}
             slotfacets{[MGR_INCLUDE]}
    
        }
      }
      -*/
    

    NOTE: Providing the slotfacet of MGR_INCLUDE on each of these structured properties will cause any of their properties that are flagged with MGR_INCLUDE to automatically appear in your point manager for your driver.
  3. Run slotomatic and perform a full build on your driver (as described in Chapter 2).