public IDataWriter CreateDataWriter( ITopic topic, IDataWriterListener listener, StatusKind mask) { return(CreateDataWriter(topic, defaultDataWriterQos, listener, mask)); }
internal override ReturnCode wlReq_deinit() { ReturnCode result = DDS.ReturnCode.Ok; IDataWriterListener dwListener = listener as IDataWriterListener; if (dwListener != null) { this.SetListener(dwListener, (DDS.StatusKind) 0); } this.DisableCallbacks(); result = base.wlReq_deinit(); if (result == DDS.ReturnCode.Ok) { if (this.topic != null) { result = (this.topic as ITopicDescriptionImpl).DecrNrUsers(); if (result == DDS.ReturnCode.Ok) { this.topic = null; } } this.publisher = null; } return(result); }
internal override void NotifyListener(Entity source, V_EVENT triggerMask, DDS.OpenSplice.Common.EntityStatus status) { IDataWriterListener dwListener = listener as IDataWriterListener; if (dwListener != null) { DDS.OpenSplice.Common.WriterStatus writerStatus = status as DDS.OpenSplice.Common.WriterStatus; if ((triggerMask & V_EVENT.LIVELINESS_LOST) == V_EVENT.LIVELINESS_LOST) { dwListener.OnLivelinessLost(source as IDataWriter, writerStatus.LivelinessLost); } if ((triggerMask & V_EVENT.OFFERED_DEADLINE_MISSED) == V_EVENT.OFFERED_DEADLINE_MISSED) { dwListener.OnOfferedDeadlineMissed(source as IDataWriter, writerStatus.DeadlineMissed); } if ((triggerMask & V_EVENT.OFFERED_INCOMPATIBLE_QOS) == V_EVENT.OFFERED_INCOMPATIBLE_QOS) { dwListener.OnOfferedIncompatibleQos(source as IDataWriter, writerStatus.IncompatibleQos); } if ((triggerMask & V_EVENT.PUBLICATION_MATCHED) == V_EVENT.PUBLICATION_MATCHED) { dwListener.OnPublicationMatched(source as IDataWriter, writerStatus.PublicationMatch); } } }
internal void CreateListener(out OpenSplice.Gapi.gapi_publisherDataWriterListener listener) { onOfferedDeadlineMissedDelegate = PrivateOfferedDeadlineMissed; onLivelinessLostDelegate = PrivateLivelinessLost; onOfferedIncompatibleQosDelegate = PrivateOfferedIncompatibleQos; onPublicationMatchDelegate = PrivatePublicationMatched; listener = new DDS.OpenSplice.Gapi.gapi_publisherDataWriterListener(); listener.listener_data = IntPtr.Zero; listener.on_offered_deadline_missed = onOfferedDeadlineMissedDelegate; listener.on_liveliness_lost = onLivelinessLostDelegate; listener.on_offered_incompatible_qos = onOfferedIncompatibleQosDelegate; listener.on_publication_match = onPublicationMatchDelegate; }
internal void CreateListener(out OpenSplice.Gapi.gapi_publisherDataWriterListener listener) { onOfferedDeadlineMissedDelegate = PrivateOfferedDeadlineMissed; onLivelinessLostDelegate = PrivateLivelinessLost; onOfferedIncompatibleQosDelegate = PrivateOfferedIncompatibleQos; onPublicationMatchDelegate = PrivatePublicationMatched; listener = new DDS.OpenSplice.Gapi.gapi_publisherDataWriterListener(); listener.listener_data = IntPtr.Zero; listener.on_offered_deadline_missed = onOfferedDeadlineMissedDelegate; listener.on_liveliness_lost = onLivelinessLostDelegate; listener.on_offered_incompatible_qos = onOfferedIncompatibleQosDelegate; listener.on_publication_match = onPublicationMatchDelegate; }
public ReturnCode SetListener(IDataWriterListener listener, StatusKind mask) { ReturnCode result = DDS.ReturnCode.AlreadyDeleted; ReportStack.Start(); lock (this) { if (this.rlReq_isAlive) { result = wlReq_SetListener(listener, mask); } } ReportStack.Flush(this, result != ReturnCode.Ok); return(result); }
public ReturnCode SetListener(IDataWriterListener listener, StatusKind mask) { ReturnCode result = ReturnCode.Error; if (listener != null) { Gapi.gapi_publisherDataWriterListener gapiListener; if (listenerHelper == null) { // Since the real DataWriter is created from the TypeSupport, // the listenerHelper is not "readonly" listenerHelper = new PublisherDataWriterListenerHelper(); } listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); lock (listener) { using (PublisherDataWriterListenerMarshaler marshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { result = Gapi.DataWriter.set_listener( GapiPeer, marshaler.GapiPtr, mask); } } } else { result = Gapi.DataWriter.set_listener( GapiPeer, IntPtr.Zero, mask); } return result; }
public ReturnCode SetListener(IDataWriterListener listener, StatusKind mask) { ReturnCode result = ReturnCode.Error; if (listener != null) { Gapi.gapi_publisherDataWriterListener gapiListener; if (listenerHelper == null) { // Since the real DataWriter is created from the TypeSupport, // the listenerHelper is not "readonly" listenerHelper = new PublisherDataWriterListenerHelper(); } listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); lock (listener) { using (PublisherDataWriterListenerMarshaler marshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { result = Gapi.DataWriter.set_listener( GapiPeer, marshaler.GapiPtr, mask); } } } else { result = Gapi.DataWriter.set_listener( GapiPeer, IntPtr.Zero, mask); } return(result); }
public IDataWriter CreateDataWriter( ITopic topic, DataWriterQos qos, IDataWriterListener listener, StatusKind mask) { ReturnCode result = DDS.ReturnCode.AlreadyDeleted; DataWriter dataWriter = null; Topic topicObj = topic as Topic; ReportStack.Start(); lock (this) { if (this.rlReq_isAlive) { if (topicObj == null) { result = DDS.ReturnCode.BadParameter; ReportStack.Report(result, "topic is invalid (null), or not of type " + "DDS::OpenSplice::Topic."); } else { result = QosManager.checkQos(qos); } if (result == DDS.ReturnCode.Ok) { lock (topicObj) { if (topicObj.rlReq_isAlive) { TypeSupport ts = (topicObj as ITopicDescriptionImpl).rlReq_TypeSupport; DatabaseMarshaler marshaler = DatabaseMarshaler.GetMarshaler(participant, ts.TypeSpec); dataWriter = ts.CreateDataWriter(marshaler); result = dataWriter.init(this, qos, topicObj, "writer <" + topicObj.Name + ">"); if (result == ReturnCode.Ok) { dataWriter.wlReq_ListenerDispatcher = this.wlReq_ListenerDispatcher; result = dataWriter.SetListener(listener, mask); } else { dataWriter = null; } if (result == DDS.ReturnCode.Ok) { writerList.Add(dataWriter); if (rlReq_AutoEnableCreatedEntities) { result = dataWriter.Enable(); } } } else { // ALREADY_DELETED may only apply to the Publisher in this context, // so for a deleted topic use BAD_PARAMETER instead. result = DDS.ReturnCode.BadParameter; } } } if (result != ReturnCode.Ok && dataWriter != null) { // Ignore result because we prefer the original error. DeleteDataWriter(dataWriter); dataWriter = null; } } } ReportStack.Flush(this, result != ReturnCode.Ok); return(dataWriter); }
public IDataWriter CreateDataWriter( ITopic topic, DataWriterQos qos, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler = new OpenSplice.CustomMarshalers.DataWriterQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); } } } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return dataWriter; }
public IDataWriter CreateDataWriter( ITopic topic, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataWriter = tsFactory.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataWriter = tsFactory.CreateDataWriter(gapiPtr); } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return dataWriter; }
public IDataWriter CreateDataWriter( ITopic topic, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return(dataWriter); }
public IDataWriter CreateDataWriter( ITopic topic, DataWriterQos qos, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler = new OpenSplice.CustomMarshalers.DataWriterQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataWriter = tsFactory.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataWriter = tsFactory.CreateDataWriter(gapiPtr); } } } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return(dataWriter); }