In the previous chapter you reviewed your driver's protocol in search of a protocol request that retrieves information about multiple field-devices. If you were able to find such a request, we will ask you to create a corresponding request class for your driver. If you were unable to find such a request, and if your driver uses a serial, master-slave protocol, then we will ask you update your driver's ping request and ping response classes to make them also serve as the discover request and discover response.
package com.yourCompany.yourDriver.comm.req; import com.tridium.ddf.identify.*; import com.tridium.ddf.comm.req.*; import javax.baja.sys.*; public class BYourDriverDeviceDiscoverRequest extends BDdfDiscoveryRequest { /*- class BYourDriverDeviceDiscoverRequest { } -*/ public byte[] toByteArray() { BYourDriverDeviceDiscoverParams devDscvParams = (BYourDriverDeviceDiscoverParams)getDiscoverParameters(); return new byte[]{ //... // Substitute value1 and value2 with your own properties (byte)devDscvParams.getValue1(), (byte)devDscvParams.getValue2(), //... } }
public Type getDiscoverRequestType() { return BYourDriverDeviceDiscoverRequest.TYPE }
... import com.tridium.ddf.discover.*; import com.tridium.ddf.identify.*; ... public class BTestDriverPingRequest extends BDdfPingRequest implements BIDdfDiscoverRequest { ... }
/*- class BYourDriverPingRequest { properties { ... discoverParameters : BDdfIdParams -- This provides the necessary data that the toByteArray method -- Needs in order to construct the byte array. -- NOTE: During auto-discovery, the auto discovery job loops -- through all possible combinations of discoverParameters. Each -- pass through the loop, the next discoverParameters value for -- your driver is passed to this property. When you implement -- the toByteArray method, you may cast this to your own -- discoveryParameters class (that is what it will ultimately be). default{[new BYourDriverDeviceId()]} ... } } -*/
/** * The setDiscoverer method will be passed an instance of * IDdfDiscoverer. You need to retain the reference on * the instance and return it (whenever requested) from * the getDiscoverer method. */ IDdfDiscoverer discoverer = null; /** * The BDdfAutoDiscoveryJob will pass an inner instance * of itself to the setDiscoverer method. In there, you * need to save away the reference. In here, please return * the most recent reference that was passed to the * setDiscoverer method. */ public IDdfDiscoverer getDiscoverer(){return discoverer;} /** * The BDdfAutoDiscoveryJob will pass an inner instance * of itself here. Please save away the reference. Other * than that, you should not need to concern yourself * with this. */ public void setDiscoverer(IDdfDiscoverer discoverer) { this.discoverer=discoverer; }
Copyright © 2000-2014 Tridium Inc. All rights reserved.