Chapter 3 - Create Your Driver's Device Component & Associate it to Your Driver's Device Id

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 class named BYourDriverDevice in the package named com.yourCompany.yourDriver.
  2. To do this, create a text file named BYourDriverDevice.java in the jarFileName/src/com/yourCompany/yourDriver folder. Inside the text file, start with the text that follows.

    package com.yourCompany.yourDriver;
    
    import javax.baja.sys.*;
    
    import com.tridium.ddf.identify.*;
    
    import com.yourCompany.yourDriver.identify.*;
    
    public class BYourDriverDevice
    {
    }
    

  3. If your driver will communicate over the serial port of the station platform computer:
  4. If your driver will communicate over Tcp/Ip through the station platform computer's LAN or network adapter then:
  5. If your driver will communicate over Udp/Ip through the station platform computer's LAN or network adapter then:
  6. In any case (serial, Tcp/Ip, or Udp/Ip device), add a slotomatic properties declaration and re-define the 'deviceId' property as follows (make sure you give it the MGR_INCLUDE slotfacet).
  7. Place the following text on the line immediately following the opening brace for the Java class declaration. This is the Niagara slotomatic declaration. The properties section redefines the deviceId property. The deviceId type should be BDdfIdParams. The deviceId's default value should be an instance of BYourDriverDeviceId.

      /*-
      class BYourDriverDevice
      {
        properties
        {
          deviceId : BDdfIdParams
            -- This plugs in an instance of yourDriver's
            -- device id as this device's deviceId
            default {[new BYourDriverDeviceId()]}
            slotfacets{[MGR_INCLUDE]}
        }
      }
      -*/
    

  8. Place the following text on the line immediately following the slotomatic declaration that you just added. We will revisit this method (function) later in the tutorial.
  9.   public Type getNetworkType()
      { // We will soon create a driver network and return
        // The driver network type instead of null
        return null;
      }
    

  10. Do not forget to save the BYourDriverDevice.java file.
  11. Run slotomatic and perform a full build on your driver (as described in Chapter 2).

Summary

In Chapter 1 you created a ping request class and started defining the outgoing frame. In Chapter 2 you created a deviceId class that feeds data to your ping request. In Chapter 3 you created a device and put a deviceId property on your device. You have just used a deviceId to glue your Niagara AX device to your ping request class.

At this point, you should have gained some familiarity with your protocol's messaging format. By defining the toByteArray method in Chapters 1 and 2 above, you have already let Niagara know how to frame an outgoing request. Next, you need to let Niagara know how to 'frame' up incoming messages that Niagara receives back from the field bus.