4 * Class Publication provides methods for creating and working
5 * with the ORTE publisher.
7 * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
8 * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
9 * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
10 * @author dedication to Kj
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
25 package org.ocera.orte;
26 import java.nio.ByteBuffer;
28 import org.ocera.orte.types.*;
31 public class Publication {
34 private org.ocera.orte.types.MessageData msgData;
38 private int callbackEnvHandle = 0;
41 * getHandle - returns handler of the publication
43 * @return handler of the publication
45 public long getHandle()
57 * nemelo by se v jORTEPublicationCreate misto cele instance predavat
58 * jen instance.data ????? resp instance.getData????
62 public Publication(Domain d,
66 this.handle = jORTEPublicationCreate(d.handle,
68 publProp.getTypeName(),
70 publProp.getPersistence(),
71 publProp.getStrength());
79 * destroy - Removes a publication.
80 * @return False if bad publication handle, True if succesful.
85 /* TODO vyradit vypis na nasledujici radce */
86 System.out.println(":j: publication destroy called..");
87 // destroy publication
88 if(!jORTEPublicationDestroy(this.handle))
90 System.out.println(":j!: publication destroy fault!");
93 System.out.println(":j: publication destroy successfull..");
99 * send - Send the publication.
102 public void send(MessageData instance)
104 //this.msgData.write(); // volat v Publisher.java
107 b = jORTEPublicationSend(this.handle);
108 if(!b) System.out.println(":j!: Sending Publication Fault!");
114 * Get Publication properties.
115 * @return Publication properties.
117 public PublProp getProperties()
119 PublProp sp = new PublProp();
120 sp = jORTEPublicationPropertiesGet(this.handle);
125 * Set Publication properties.
126 * @return True - setting new properties Ok, False - setting new properties fault.
128 public boolean setProperties(PublProp sp)
132 // modify PublProp object - sp
133 b = jORTEPublicationPropertiesSet(this.handle, sp);
136 System.out.println(":j!: set PublProp failed! (bad Subs. handle)");
144 * Get Publication status.
145 * @return Status of Publication.
147 public Status getStatus()
149 Status ps = new Status();
150 ps = jORTEPublicationGetStatus(this.handle);
156 * Waits for given number of subscriptions.
157 * @param Time how long to wait.
158 * @param Number of retries if specified number of subscriptions not reached.
159 * @param Desired number of subscriptions.
160 * @return ORTE_OK if succesful, ORTE_BAD_HANDLE if bad publication handle,
161 * ORTE_TIMEOUT if number of retries has been exhausted.
163 public int waitForSubscriptions(NtpTime wait,
168 i = jORTEPublicationWaitForSubscriptions(this.handle,
176 /* ****************************************************************** *
180 * ****************************************************************** */
183 long jORTEPublicationCreate(long appDomainHandle,
189 // int sendCallBack, -->NULL
190 // sendCallBackParam,--> NULL
191 // NtpTime sendCallBackDelay
194 boolean jORTEPublicationDestroy(long publHandle);
197 boolean jORTEPublicationSend(long publHandle);
201 PublProp jORTEPublicationPropertiesGet(long publHandle);
204 boolean jORTEPublicationPropertiesSet(long publHandle,
208 Status jORTEPublicationGetStatus(long publHandle);
211 int jORTEPublicationWaitForSubscriptions(long publHandle,
214 long noSubscription);