NOTE: This class is similar to your driver's read request, write request, ping request, and device discovery request classes. Please follow either A or B but not both:
To do this, create a text file named BYourDriverPointDiscoverRequest.java in the jarFileName/src/com/yourCompany/yourDriver/comm/req folder. Inside the text file, start with the following text:
package com.yourCompany.yourDriver.comm.req; import javax.baja.sys.*; import com.tridium.ddf.identify.*; import com.tridium.ddf.comm.*; import com.tridium.ddf.comm.req.*; import com.tridium.ddf.comm.rsp.*; import com.yourCompany.yourDriver.identify.*; public class BYourDriverPointDiscoverRequest extends BDdfDiscoveryRequest { /*- class BYourDriverPointDiscoverRequest { } -*/ }
In the toByteArray method, call getDiscoverParameters() and cast the result to BYourDriverPointDiscoverParams. Most of the information that you need will be available in this instance of your driver's BYourDriverPointDiscoverParams class. You created this class previously during today's lesson.
package com.yourCompany.yourDriver.comm.req; import javax.baja.sys.*; import com.tridium.ddf.identify.*; import com.tridium.ddf.comm.*; import com.tridium.ddf.comm.req.*; import com.tridium.ddf.comm.rsp.*; import com.yourCompany.yourDriver.identify.*; import com.yourCompany.yourDriver.comm.rsp.*; public class BYourDriverPointDiscoverRequest extends BDdfDiscoveryRequest { /*- class BYourDriverPointDiscoverRequest { } -*/ public byte[] toByteArray() { BYourDriverPointDiscoverParams ptDscvParams = (BYourDriverPointDiscoverParams)getDiscoverParameters(); return new byte[]{ //... // Substitute value1 and value2 with your own properties // As necessary to construct the outgoing frame that your // Driver's protocol defines for requesting all points or // A series (group) of points from a field-device. (byte)ptDscvParams.getValue1(), (byte)ptDscvParams.getValue2(), //... }; } }
HINT: If you require information about the field-device in order to construct the byte array that the toByteArray method returns then simply call the getDeviceId method and cast the result to BYourDriverDeviceId! In fact, all requests have access to the device id in this fashion.
... import com.tridium.ddf.discover.*; import com.tridium.ddf.identify.*; ... public class BYourDriverReadRequest extends BDdfReadRequest implements BIDdfDiscoverRequest { ... }
/*- class BYourDriverReadRequest { properties { ... discoverParameters : BDdfIdParams -- This provides the necessary data that the toByteArray method -- Needs in order to construct the byte array. Since this class -- Is the read request and also serves as the discovery request, -- Then this property's value will be a copy of the value of the -- Read Parameters property. default{[new BYourDriverReadParams()]} ... } } -*/
/** * 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-2016 Tridium Inc. All rights reserved.