Chapter 6 - Create Your Driver's Communicator Component

(And Plug Your Receiver Into It)

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

  1. Create a class named BYourDriverCommunicator that extends one of the following:

    Choosing the proper class to extend could prove tricky. For Tcp/Ip protocols you should always extend BDdfTcpCommunicator.

    However for serial protocols (or wireless protocols where a wireless router or radio connects to a serial port on the platform computer) then you will need to choose either BDdfSerialSitCommunicator or BDdfSerialMutCommunicator. If your driver's protocol is strictly master-slave in nature (that is, if your protocol indicates that the platform computer transmits serial data onto the serial port at will but the field-devices will only transmit in response to such a message) then you should extend BDdfSerialSitCommunicator. If your driver's serial protocol is more complicated than this then you should probably extend BDdfSerialMutCommunicator. You can certainly modify this later if you change your mind.

    Likewise, for Udp/Ip protocols you need to choose between a BDdfUdpMutCommunicator or a BDdfUdpSitCommunicator. The choice depends on the nature of the protocol. The same rules for choosing the Mut version as opposed to the Sit version apply as for serial drivers, as explained in the previous paragraph.

  2. Create the class in package com.yourCompany.yourDriver.comm.

    To create the class for BYourDriverCommunicator, create a text file named BYourDriverCommunicator.java in the jarFileName/src/com/yourCompany/yourDriver/comm folder. Inside the text file, start with the text that follows. Please replace the right side of the extends clause, if necessary, as described in the previous two paragraphs.

    This example extends BDdfSerialSitCommunicator so it imports com.tridium.ddfSerial.comm.singleTransaction.*;

  3. Add a slotomatic statement with a properties declaration.
  4. Redefine the property named receiver. The type must be BDdfReceiver. The default value should be an instance of BYourDriverReceiver.
  5. package com.yourCompany.yourDriver.comm;
    
    import javax.baja.sys.*;
    
    import com.tridium.ddf.comm.defaultComm.*;
    
    import com.tridium.ddfSerial.comm.singleTransaction.*;
    
    public class BYourDriverCommunicator
      extends BDdfSerialSitCommunicator
    {
      /*-
      class BYourDriverCommunicator
      {
        properties
        {
          receiver : BDdfReceiver
            -- Plugs yourDriver's custom receiver
            -- into yourDriver's communicator
            default{[new BYourDriverReceiver()]}
        }
      }
      -*/
    }
    

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