Chapter 19 - Create a Write Response For Your Driver

The write response is typically a very simple class to develop. Most driver protocols return back a small amount of data, just enough to indicate whether the field-device accepted the write request. Many drivers can get away with essentially having an empty implementation for the write response.

Please note that in our examples for the previous chapters in today's lesson, we coded the processReceive method of our hypothetical write request to throw a DdfResponseException if the field-device denied the driver's request to write data values. If the field device accepted the driver's request, then we return an empty instance of BYourDriverWriteResponse.

Create your driver's write response as follows:

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

  1. Make a Java class that extends BDdfResponse. Name it BYourDriverWriteResponse. Create this in a package named com.yourCompany.yourDriver.comm.rsp. Also add an empty slotomatic comment immediately after the opening brace for the class declaration.

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

    package com.yourCompany.yourDriver.comm.rsp;
    
    import com.tridium.ddf.comm.rsp.*;
    import javax.baja.sys.*;
    
    public class BYourDriverWriteResponse
      extends BDdfResponse
    {
      /*-
      class BYourDriverWriteResponse
      {
      }
      -*/
    }
    

    NOTE: If you do not define any constructors at all then Java automatically creates an empty constructor for you. By not defining any constructors for BYourDriverWriteResponse in this example, we implicitly create an empty constructor with full, public access.

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