Index |
Prev |
Next
Chapter 7 - Create a Device Folder and a Network Component
While following the examples in this chapter, please replace the text jarFileName, yourDriver and yourCompany as previously described in the Preparation section):
Create a Device Folder Component For Your Driver
- Create a class named BYourDriverDeviceFolder in package com.yourCompany.yourDriver
To do this, create a text file named BYourDriverDeviceFolder.java in the jarFileName/src/com/yourCompany/yourDriver folder. Paste the following text into the BYourDriverDeviceFolder.java file:
package com.yourCompany.yourDriver;
import com.tridium.ddf.*;
import javax.baja.sys.*;
public class BYourDriverDeviceFolder
extends BDdfDeviceFolder
{
/*-
class BYourDriverDeviceFolder
{
properties
{
}
}
-*/
}
|
- Run slotomatic and perform a full build on your driver.
|
NOTE: The device folder is practically a formality in the Niagara AX framework.
|
Create a Network Component For Your Driver
- Create a class named BYourDriverNetwork in package com.yourCompany.yourDriver
To do this, create a text file named BYourDriverNetwork.java in the jarFileName/src/com/yourCompany/yourDriver folder. Paste the text from one of the following examples into the BYourDriverDeviceFolder.java file.
- If yourDriver is a serial (or serial-wireless) driver, make your class extend BDdfSerialNetwork and start with the text that follows:
package com.yourCompany.yourDriver;
import com.tridium.ddfSerial.*;
import com.yourCompany.yourDriver.comm.*;
import javax.baja.sys.*;
public class BYourDriverNetwork
extends BDdfSerialNetwork
{
/*-
class BYourDriverNetwork
{
properties
{
}
}
-*/
}
|
- If yourDriver is a Tcp/Ip driver whose driver protocol communicates directly to Tcp/Ip field-devices extend BDdfTcpNetwork and start with the text that follows.
package com.yourCompany.yourDriver;
import com.tridium.ddfIp.tcp.*;
import com.yourCompany.yourDriver.comm.*;
import javax.baja.sys.*;
public class BYourDriverNetwork
extends BDdfTcpNetwork
{
/*-
class BYourDriverNetwork
{
properties
{
}
}
-*/
}
|
- If yourDriver is a Tcp/Ip driver whose driver protocol communicates directly to a field-gateway that has field-devices attached to it then extend BDdfTcpGatewayNetwork and name the class BYourDriverGatewayNetwork instead of just BYourDriverNetwork. Name the text file BYourDriverGatewayNetwork.java too! Also, (only if using a field-gateway) update your device from chapter 3 and make it extend BDdfTcpDeviceBehindGateway instead of BDdfTcpDevice.
Start with the following text in BYourDriverGatewayNetwork.java:
package com.yourCompany.yourDriver;
import com.tridium.ddfIp.tcp.*;
import com.yourCompany.yourDriver.comm.*;
import javax.baja.sys.*;
public class BYourDriverGatewayNetwork
extends BDdfTcpGatewayNetwork
{
/*-
class BYourDriverGatewayNetwork
{
properties
{
}
}
-*/
}
|
And then in this case, also change your driver's device (BYourDriverDevice.java like this:
package com.yourCompany.yourDriver;
import com.tridium.ddf.identify.*;
import com.tridium.ddfSerial.*;
import javax.baja.sys.*;
public class BYourDriverDevice
// NOTE: Replace BDdfTcpDevice with BDdfTcpDeviceBehindGateway in the extends clause
extends BDdfTcpDevice BDdfTcpDeviceBehindGateway
{
/*-
class BYourDriverDevice
{
properties
{
deviceId : BDdfIdParams
-- This plugs in an instance of yourDriver's
-- device id as this device's deviceId
default {[new BYourDriverDeviceId()]}
}
}
-*/
}
|
- If yourDriver is a Udp/Ip driver whose driver protocol communicates directly to Udp/Ip field-devices extend BDdfUdpNetwork and start with the text that follows.
package com.yourCompany.yourDriver;
import com.tridium.ddfIp.udp.*;
import com.yourCompany.yourDriver.comm.*;
import javax.baja.sys.*;
public class BYourDriverNetwork
extends BDdfUdpNetwork
{
/*-
class BYourDriverNetwork
{
properties
{
}
}
-*/
}
|
- If yourDriver is a Udp/Ip driver whose driver protocol communicates directly to a field-gateway that has field-devices attached to it then extend BDdfUdpGatewayNetwork and name the class BYourDriverGatewayNetwork instead of just BYourDriverNetwork. Name the text file BYourDriverGatewayNetwork.java too! Also, (only if using a field-gateway) update your device from chapter 3 and make it extend BDdfUdpDeviceBehindGateway instead of BDdfUdpDevice.
Start with the following text in BYourDriverGatewayNetwork.java:
package com.yourCompany.yourDriver;
import com.tridium.ddfIp.udp.*;
import com.yourCompany.yourDriver.comm.*;
import javax.baja.sys.*;
public class BYourDriverGatewayNetwork
extends BDdfUdpGatewayNetwork
{
/*-
class BYourDriverGatewayNetwork
{
properties
{
}
}
-*/
}
|
And then in this case, also change your driver's device (BYourDriverDevice.java like this:
package com.yourCompany.yourDriver;
import com.tridium.ddf.identify.*;
import com.tridium.ddfSerial.*;
import javax.baja.sys.*;
public class BYourDriverDevice
// NOTE: Replace BDdfUdpDevice with BDdfUdpDeviceBehindGateway in the extends clause
extends BDdfUdpDevice BDdfUdpDeviceBehindGateway
{
/*-
class BYourDriverDevice
{
properties
{
deviceId : BDdfIdParams
-- This plugs in an instance of yourDriver's
-- device id as this device's deviceId
default {[new BYourDriverDeviceId()]}
}
}
-*/
}
|
- Regardless of which sample code example you choose to start with in BYourDriverNetwork.java, add the following methods to your network on the line immediately above the closing brace for the class:
public Type getDeviceType()
{
return BYourDriverDevice.TYPE;
}
public Type getDeviceFolderType()
{
return BYourDriverDeviceFolder.TYPE;
}
|
- Open BYourDriverDevice.java and modify the getNetworkType method to have it return BYourDriverNetwork.TYPE or BYourDriverGatewayNetwork.TYPE (if you choose to use a Tcp/Ip gateway network for your driver).
public Type getNetworkType()
{
return BYourDriverNetwork.TYPE;
}
|
- Run slotomatic and perform a full build on your driver (as described in Chapter 2).
Index |
Prev |
Next
Copyright © 2000-2014 Tridium Inc. All rights reserved.