1 /* Subscription.java */
4 * Class Subscription provides methods for creating and working
5 * with the ORTE subscribtion.
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 Subscription {
34 private long callbackContextHandle = 0;
37 * Get Subscription's handle.
38 * @return Handle of the subscription.
40 public long getHandle()
49 /* PROC protected??? - aby sel volat jen z tridy Domain */
50 protected Subscription(Domain appDomain,
53 SubscriptionCallback subsCallback)
55 this.handle = jORTESubscriptionCreate(appDomain.handle,
59 subsProp.getTypeName(),
62 subsProp.getDeadline(),
63 subsProp.getMinSeparation(),
66 subsProp.getMulticastIPAddr());
70 * Removes a Subscription.
71 * @return False if bad Publication handle, True if succesful
76 /* TODO vyradit vypis na nasledujici radce */
77 System.out.println(":j: subscription destroy called..");
78 // destroy subscription
79 if(!jORTESubscriptionDestroy(this.handle))
81 System.out.println(":j!: subscription destroy fault!");
84 System.out.println(":j: subscription destroy successfull..");
90 * Get Subscription properties.
91 * @return Subscription properties.
93 public SubsProp getProperties()
95 SubsProp sp = new SubsProp();
96 sp = jORTESubscriptionPropertiesGet(this.handle);
101 * Set Subscription properties.
102 * @return True - setting new properties Ok, False - setting new properties fault.
104 public boolean setProperties(SubsProp sp)
108 // modify SubsProp object - sp
109 b = jORTESubscriptionPropertiesSet(this.handle, sp);
112 System.out.println(":j!: set SubsProp failed! (bad Subs. handle)");
120 * Get Subscription status.
121 * @return Status of Subscription.
123 public Status getStatus()
125 Status ss = new Status();
126 ss = jORTESubscriptionGetStatus(this.handle);
132 * Waits for given number of publications.
133 * @param Time how long to wait.
134 * @param Number of retries if specified number of publications not reached.
135 * @param Desired number of publications.
136 * @return ORTE_OK if succesful, ORTE_BAD_HANDLE if bad subscription handle,
137 * ORTE_TIMEOUT if number of retries has been exhausted.
139 public int waitForPublications(NtpTime wait,
144 i = jORTESubscriptionWaitForPublications(this.handle,
151 /* TODO - dodelat middle C zdrojak !! */
154 * @param Time how long to wait.
155 * @param Number of retries if specified number of publications not reached.
156 * @param Desired number of publications.
157 * @return ORTE_OK if succesful, ORTE_BAD_HANDLE if bad subscription handle,
158 * ORTE_TIMEOUT if number of retries has been exhausted.
160 public boolean pull(long subsHandle)
162 int b = jORTESubscriptionPull(subsHandle);
163 if (b == ORTEConstant.ORTE_BAD_HANDLE)
165 System.out.println(":j!: method pull failed [bad subsHandle]!");
171 /* TODO - dodelat!! */
172 public void patternCreate()
174 /* TODO - dodelat!! */
175 public void patternRemove()
177 /* TODO - dodelat!! */
178 public void patternDelete()
183 /* ****************************************************************** *
187 * ****************************************************************** */
190 long jORTESubscriptionCreate(long appDomainHandle,
191 int subsmode, /*! union */
192 int substype, /*! union */
198 NtpTime minSeparation,
199 SubscriptionCallback cb,
201 long multicastIPAddress);
204 boolean jORTESubscriptionDestroy(long subsHandle);
207 SubsProp jORTESubscriptionPropertiesGet(long subsHandle);
210 boolean jORTESubscriptionPropertiesSet(long subsHandle, SubsProp subProps);
213 Status jORTESubscriptionGetStatus(long subsHandle);
216 int jORTESubscriptionWaitForPublications(long subsHandle,
219 long noPublications);
221 int jORTESubscriptionPull(long subsHandle);