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;
37 private Domain appDomain;
39 private int callbackEnvHandle = 0;
42 * getHandle - returns handler of the publication
44 * @return handler of the publication
46 public long getHandle()
58 * nemelo by se v jORTEPublicationCreate misto cele instance predavat
59 * jen instance.data ????? resp instance.getData????
63 public Publication(Domain d,
68 this.handle = jORTEPublicationCreate(d.handle,
70 publProp.getTypeName(),
72 publProp.getPersistence(),
73 publProp.getStrength());
81 * destroy - Removes a publication.
82 * @return False if bad publication handle, True if succesful.
87 /* TODO vyradit vypis na nasledujici radce */
88 System.out.println(":j: publication destroy called..");
89 // destroy publication
90 if(!jORTEPublicationDestroy(this.handle))
92 System.out.println(":j!: publication destroy fault!");
95 // destroy application domain
96 if(!appDomain.destroy())
98 System.out.println(":j!: publication destroy fault!");
101 System.out.println(":j: publication destroy successfull..");
107 * send - Send the publication.
110 public void send(MessageData instance)
112 //this.msgData.write(); // volat v Publisher.java
115 b = jORTEPublicationSend(this.handle);
116 if(!b) System.out.println(":j!: Sending Publication Fault!");
122 * Get Publication properties.
123 * @return Publication properties.
125 public PublProp getProperties()
127 PublProp sp = new PublProp();
128 sp = jORTEPublicationPropertiesGet(this.handle);
133 * Set Publication properties.
134 * @return True - setting new properties Ok, False - setting new properties fault.
136 public boolean setProperties(PublProp sp)
140 // modify PublProp object - sp
141 b = jORTEPublicationPropertiesSet(this.handle, sp);
144 System.out.println(":j!: set PublProp failed! (bad Subs. handle)");
152 * Get Publication status.
153 * @return Status of Publication.
155 public Status getStatus()
157 Status ps = new Status();
158 ps = jORTEPublicationGetStatus(this.handle);
164 * Waits for given number of subscriptions.
165 * @param Time how long to wait.
166 * @param Number of retries if specified number of subscriptions not reached.
167 * @param Desired number of subscriptions.
168 * @return ORTE_OK if succesful, ORTE_BAD_HANDLE if bad publication handle,
169 * ORTE_TIMEOUT if number of retries has been exhausted.
171 public int waitForSubscriptions(NtpTime wait,
176 i = jORTEPublicationWaitForSubscriptions(this.handle,
184 /* ****************************************************************** *
188 * ****************************************************************** */
191 long jORTEPublicationCreate(long appDomainHandle,
197 // int sendCallBack, -->NULL
198 // sendCallBackParam,--> NULL
199 // NtpTime sendCallBackDelay
202 boolean jORTEPublicationDestroy(long publHandle);
205 boolean jORTEPublicationSend(long publHandle);
209 PublProp jORTEPublicationPropertiesGet(long publHandle);
212 boolean jORTEPublicationPropertiesSet(long publHandle,
216 Status jORTEPublicationGetStatus(long publHandle);
219 int jORTEPublicationWaitForSubscriptions(long publHandle,
222 long noSubscription);