001: /*
002: * DDS (Data Distribution Service) for JacORB
003: *
004: * Copyright (C) 2005 , Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad
005: * allaoui <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Library General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Library General Public License for more details.
016: *
017: * You should have received a copy of the GNU Library General Public
018: * License along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
020: * 02111-1307, USA.
021: *
022: * Coontact: Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad allaoui
023: * <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
024: * Contributor(s)
025: *
026: **/
027: package demo.dds.dcps.temperaturesample;
028:
029: import java.util.Iterator;
030: import java.util.Vector;
031:
032: import org.jacorb.dds.SubscriberImpl;
033: import org.omg.dds.DataReaderListener;
034: import org.omg.dds.DataReaderQos;
035: import org.omg.dds.DataReaderQosHolder;
036: import org.omg.dds.Duration_t;
037: import org.omg.dds.InstanceHandleSeqHolder;
038: import org.omg.dds.LivelinessChangedStatus;
039: import org.omg.dds.PublicationBuiltinTopicDataHolder;
040: import org.omg.dds.QueryCondition;
041: import org.omg.dds.RETCODE_OK;
042: import org.omg.dds.ReadCondition;
043: import org.omg.dds.RequestedDeadlineMissedStatus;
044: import org.omg.dds.RequestedIncompatibleQosStatus;
045: import org.omg.dds.SampleInfoHolder;
046: import org.omg.dds.SampleInfoSeqHolder;
047: import org.omg.dds.SampleLostStatus;
048: import org.omg.dds.SampleRejectedStatus;
049: import org.omg.dds.StatusCondition;
050: import org.omg.dds.Subscriber;
051: import org.omg.dds.SubscriptionMatchStatus;
052: import org.omg.dds.Topic;
053: import org.omg.dds.TopicDescription;
054:
055: public class TemperatureDataReaderImpl extends TemperatureDataReaderPOA {
056:
057: // represent the data stockage space of a dataReader
058: private Vector Vector_Temperature;
059: private DataReaderQos qos;
060: private DataReaderListener a_listener;
061: private Subscriber SubParent;
062: private Topic topic;
063: private org.omg.CORBA.ORB orb;
064: private org.omg.PortableServer.POA poa;
065: private DataReaderListener _listener;
066:
067: /**
068: * @param qos
069: * @param a_listener
070: * @param subParent
071: * @param topic_name
072: */
073: public TemperatureDataReaderImpl(DataReaderQos qos,
074: DataReaderListener a_listener, Subscriber subParent,
075: Topic topic, org.omg.CORBA.ORB orb,
076: org.omg.PortableServer.POA poa) {
077: this .qos = qos;
078: this .a_listener = a_listener;
079: SubParent = subParent;
080: this .topic = topic;
081: Vector_Temperature = new Vector();
082: this .orb = orb;
083: this .poa = poa;
084: }
085:
086: /**
087: * @param received_data
088: * @param info_seq
089: * @param max_samples
090: * @param sample_states
091: * @param view_states
092: * @param instance_states
093: * @return
094: */
095: public int read(TemperatureSeqHolder received_data,
096: SampleInfoSeqHolder info_seq, int max_samples,
097: int sample_states, int view_states, int instance_states) {
098:
099: try {
100: int i = 0;
101: Temperature tab[] = new Temperature[getVector_Temperature()
102: .size()];
103: Iterator it = getVector_Temperature().iterator();
104:
105: while (it.hasNext()) {
106: tab[i] = (Temperature) it.next();
107: i++;
108: }
109: received_data.value = tab;
110: } catch (Exception e) {
111: System.out.println("Error e = " + e);
112: e.printStackTrace();
113: }
114:
115: return RETCODE_OK.value;
116: }
117:
118: /**
119: * @param received_data
120: * @param info_seq
121: * @param max_samples
122: * @param sample_states
123: * @param view_states
124: * @param instance_states
125: * @return
126: */
127: public int take(TemperatureSeqHolder received_data,
128: SampleInfoSeqHolder info_seq, int max_samples,
129: int sample_states, int view_states, int instance_states) {
130:
131: int i = 0;
132: Temperature tab[] = new Temperature[getVector_Temperature()
133: .size()];
134: Iterator it = getVector_Temperature().iterator();
135:
136: while (it.hasNext()) {
137: tab[i] = (Temperature) it.next();
138: i++;
139: }
140: received_data.value = tab;
141: // remove all element from the vector
142: clear();
143:
144: return RETCODE_OK.value;
145: }
146:
147: /**
148: * Not Implemented
149: */
150: public int read_w_condition(TemperatureSeqHolder received_data,
151: SampleInfoSeqHolder info_seq, int max_samples,
152: ReadCondition a_condition) {
153: return 0;
154: }
155:
156: /**
157: * Not Implemented
158: */
159: public int take_w_condition(TemperatureSeqHolder received_data,
160: SampleInfoSeqHolder info_seq, int max_samples,
161: ReadCondition a_condition) {
162: return 0;
163: }
164:
165: /**
166: * Not Implemented
167: */
168: public int read_next_sample(TemperatureHolder received_data,
169: SampleInfoHolder sample_info) {
170: return 0;
171: }
172:
173: /**
174: * Not Implemented
175: */
176: public int take_next_sample(TemperatureHolder received_data,
177: SampleInfoHolder sample_info) {
178: return 0;
179: }
180:
181: /**
182: * Not Implemented
183: */
184: public int read_instance(TemperatureSeqHolder received_data,
185: SampleInfoSeqHolder info_seq, int max_samples,
186: int a_handle, int sample_states, int view_states,
187: int instance_states) {
188: return 0;
189: }
190:
191: /**
192: * Not Implemented
193: */
194: public int take_instance(TemperatureSeqHolder received_data,
195: SampleInfoSeqHolder info_seq, int max_samples,
196: int a_handle, int sample_states, int view_states,
197: int instance_states) {
198: return 0;
199: }
200:
201: /**
202: * Not Implemented
203: */
204: public int read_next_instance(TemperatureSeqHolder received_data,
205: SampleInfoSeqHolder info_seq, int max_samples,
206: int a_handle, int sample_states, int view_states,
207: int instance_states) {
208: return 0;
209: }
210:
211: /**
212: * Not Implemented
213: */
214: public int take_next_instance(TemperatureSeqHolder received_data,
215: SampleInfoSeqHolder info_seq, int max_samples,
216: int a_handle, int sample_states, int view_states,
217: int instance_states) {
218: return 0;
219: }
220:
221: /**
222: * Not Implemented
223: */
224: public int read_next_instance_w_condition(
225: TemperatureSeqHolder received_data,
226: SampleInfoSeqHolder info_seq, int max_samples,
227: int a_handle, ReadCondition a_condition) {
228: return 0;
229: }
230:
231: /**
232: * Not Implemented
233: */
234: public int take_next_instance_w_condition(
235: TemperatureSeqHolder received_data,
236: SampleInfoSeqHolder info_seq, int max_samples,
237: int a_handle, ReadCondition a_condition) {
238: return 0;
239: }
240:
241: /**
242: * Not Implemented
243: */
244: public int return_loan(TemperatureSeqHolder received_data,
245: SampleInfoSeqHolder info_seq) {
246: return 0;
247: }
248:
249: /**
250: * Not Implemented
251: */
252: public int get_key_value(TemperatureHolder key_holder, int handle) {
253: return 0;
254: }
255:
256: /**
257: * Not Implemented
258: */
259: public ReadCondition create_readcondition(int sample_states,
260: int view_states, int instance_states) {
261: return null;
262: }
263:
264: /**
265: * Not Implemented
266: */
267: public QueryCondition create_querycondition(int sample_states,
268: int view_states, int instance_states,
269: String query_expression, String[] query_parameters) {
270: return null;
271: }
272:
273: /**
274: * Not Implemented
275: */
276: public int delete_readcondition(ReadCondition a_condition) {
277: return 0;
278: }
279:
280: /**
281: * Not Implemented
282: */
283: public int delete_contained_entities() {
284: return 0;
285: }
286:
287: /**
288: * Not Implemented
289: */
290: public int set_qos(DataReaderQos qos) {
291: return 0;
292: }
293:
294: /**
295: * Not Implemented
296: */
297: public void get_qos(DataReaderQosHolder qos) {
298: }
299:
300: /**
301: * @param a_listener
302: * @param mask
303: * @return
304: */
305: public int set_listener(org.omg.dds.DataReaderListener a_listener,
306: int mask) {
307:
308: try {
309: this ._listener = a_listener;
310: } catch (Exception e) {
311: System.out.println(" Exception e :" + e);
312: e.printStackTrace();
313: }
314: return 0;
315: }
316:
317: /**
318: * @return _listener
319: */
320: public DataReaderListener get_listener() {
321: return _listener;
322: }
323:
324: /**
325: * @return _topic
326: */
327: public TopicDescription get_topicdescription() {
328: return topic;
329: }
330:
331: /**
332: * Not Implemented
333: */
334: public Subscriber get_subscriber() {
335: return null;
336: }
337:
338: /**
339: * Not Implemented
340: */
341: public SampleRejectedStatus get_sample_rejected_status() {
342: return null;
343: }
344:
345: /**
346: * Not Implemented
347: */
348: public LivelinessChangedStatus get_liveliness_changed_status() {
349: return null;
350: }
351:
352: /**
353: * Not Implemented
354: */
355: public RequestedDeadlineMissedStatus get_requested_deadline_missed_status() {
356: return null;
357: }
358:
359: /**
360: * Not Implemented
361: */
362: public RequestedIncompatibleQosStatus get_requested_incompatible_qos_status() {
363: return null;
364: }
365:
366: /**
367: * Not Implemented
368: */
369: public SubscriptionMatchStatus get_subscription_match_status() {
370: return null;
371: }
372:
373: /**
374: * Not Implemented
375: */
376: public SampleLostStatus get_sample_lost_status() {
377: return null;
378: }
379:
380: /**
381: * Not Implemented
382: */
383: public int wait_for_historical_data(Duration_t max_wait) {
384: return 0;
385: }
386:
387: /**
388: * Not Implemented
389: */
390: public int get_matched_publications(
391: InstanceHandleSeqHolder publication_handles) {
392: return 0;
393: }
394:
395: /**
396: * Not Implemented
397: */
398: public int get_matched_publication_data(
399: PublicationBuiltinTopicDataHolder publication_data,
400: int publication_handle) {
401: return 0;
402: }
403:
404: /**
405: * Not Implemented
406: */
407: public int enable() {
408: return 0;
409: }
410:
411: /**
412: * Not Implemented
413: */
414: public StatusCondition get_statuscondition() {
415: return null;
416: }
417:
418: /**
419: * Not Implemented
420: */
421: public int get_status_changes() {
422: return 0;
423: }
424:
425: /**
426: * @param arg0
427: * @return
428: */
429: public boolean add(Object arg0) {
430: return Vector_Temperature.add(arg0);
431: }
432:
433: public void clear() {
434: Vector_Temperature.clear();
435: }
436:
437: /**
438: * @param arg0
439: * @return
440: */
441: public boolean remove(Object arg0) {
442: return Vector_Temperature.remove(arg0);
443: }
444:
445: /**
446: * @return Returns the vector_Temperature.
447: */
448: public Vector getVector_Temperature() {
449: return Vector_Temperature;
450: }
451:
452: /**
453: * @return Returns the a_listener.
454: */
455: public DataReaderListener getA_listener() {
456: return a_listener;
457: }
458:
459: /**
460: * @return Returns the qos.
461: */
462: public DataReaderQos getQos() {
463: return qos;
464: }
465:
466: /**
467: * @return Returns the subParent.
468: */
469: public Subscriber getSubParent() {
470: return SubParent;
471: }
472:
473: /**
474: * take instance of Temperature from suscriber
475: */
476: public void take_instance_from_subscriber() {
477: try {
478: SubscriberImpl Subscriber_Parent = (SubscriberImpl) _poa()
479: .reference_to_servant(getSubParent());
480: add((Temperature) Subscriber_Parent.getInstance());
481: }
482:
483: catch (Exception e) {
484:
485: }
486: }
487:
488: }
|