Index |
Prev |
Next
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):
- Make a class named BYourDriverDevice in the package named com.yourCompany.yourDriver.
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
{
}
|
- If your driver will communicate over the serial port of the station platform computer:
- Extend BDdfSerialDevice.
- Import com.tridium.ddfSerial.* in BYourDriverDevice.java.
package com.yourCompany.yourDriver;
import javax.baja.sys.*;
import com.tridium.ddf.identify.*;
import com.tridium.ddfSerial.*;
import com.yourCompany.yourDriver.identify.*;
public class BYourDriverDevice
extends BDdfSerialDevice
{
}
|
- Add the following lines to the <-- Dependencies --> section of the build.xml file that your created in the Preparation section.
<dependency name="serial" vendor="Tridium" vendorVersion="3.0" />
<dependency name="devSerialDriver" vendor="Tridium" vendorVersion="3.2" />
|
- If your driver will communicate over Tcp/Ip through the station platform computer's LAN or network adapter then:
- Extend BDdfTcpDevice.
- Import com.tridium.ddfIp.tcp.* in BYourDriverDevice.java.
package com.yourCompany.yourDriver;
import javax.baja.sys.*;
import com.tridium.ddf.identify.*;
import com.tridium.ddfIp.tcp.*;
import com.yourCompany.yourDriver.identify.*;
public class BYourDriverDevice
extends BDdfTcpDevice
{
}
|
- Add the following line to the <-- Dependencies --> section of the build.xml file that your created in the Preparation chapter.
<dependency name="devIpDriver" vendor="Tridium" vendorVersion="3.2" />
|
- If your driver will communicate over Udp/Ip through the station platform computer's LAN or network adapter then:
- Extend BDdfUdpDevice.
- Import com.tridium.ddfIp.udp.* in BYourDriverDevice.java.
package com.yourCompany.yourDriver;
import javax.baja.sys.*;
import com.tridium.ddf.identify.*;
import com.tridium.ddfIp.udp.*;
import com.yourCompany.yourDriver.identify.*;
public class BYourDriverDevice
extends BDdfUdpDevice
{
}
|
- Add the following line to the <-- Dependencies --> section of the build.xml file that your created in the Preparation chapter.
<dependency name="devIpDriver" vendor="Tridium" vendorVersion="3.2" />
|
- 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).
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]}
}
}
-*/
|
- 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.
public Type getNetworkType()
{ // We will soon create a driver network and return
// The driver network type instead of null
return null;
}
|
- Do not forget to save the BYourDriverDevice.java file.
- 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.
Index |
Prev |
Next
Copyright © 2000-2014 Tridium Inc. All rights reserved.