internal ConditionOrErrorEventArgs(ISmartDataDistributionChannelInfo channelInfo, OPERATION_RESULT errorCode, int nativeCode, string subSystemReason) { ChannelInfo = channelInfo; ErrorCode = errorCode; NativeCode = nativeCode; SubSystemReason = subSystemReason; }
internal ConditionOrErrorEventArgs(string channelName, OPERATION_RESULT errorCode, int nativeCode, string subSystemReason) { ChannelName = channelName; ErrorCode = errorCode; NativeCode = nativeCode; SubSystemReason = subSystemReason; }
/// <inheritdoc/> public OPERATION_RESULT ReadFromChannel(Int64 offset, long length, out byte[] buffer) { try { IntPtr dataBuffer = IntPtr.Zero; long dataLen = 0; buffer = null; // Call unmanaged code IntPtr len = new IntPtr(length); OPERATION_RESULT status = DataDistributionManagerInvokeWrapper.DataDistributionEnv.GetDelegate <IDataDistributionSubsystem_ReadFromChannel>().Invoke( IDataDistributionSubsystemManager_ptr, channelHandle, offset, dataBuffer, len); if (status.Failed) { return(status); } buffer = new byte[dataLen]; Marshal.Copy(dataBuffer, buffer, 0, len.ToInt32()); return(status); } finally { } }
void InternalDeactivate() { lock (CriticalSection) { if (Status.Status == StatusEnum.DEACTIVATED || Status.Status == StatusEnum.ERROR || Status.Status == StatusEnum.INITIALIZED || Status.Status == StatusEnum.UNDEFINED ) { return; } dataDistribution.LoggingEvent -= DataDistribution_LoggingEvent; Channel.DataAvailable -= Channel_DataAvailable; Channel.ConditionOrError -= Channel_ConditionOrError; OPERATION_RESULT Res = Channel.StopChannel(10000); if (Res.Succeeded) { Status = new ExtendedStatus { Status = StatusEnum.INITIALIZED, Description = "Channel Stopped" }; } else { Status = new ExtendedStatus { Status = StatusEnum.DEACTIVATION_ERROR, Description = "Error in channel deactivation" }; } Res = dataDistribution.Stop(10000); if (Res.Succeeded) { Status = new ExtendedStatus { Status = StatusEnum.DEACTIVATED, Description = "Communication module Stopped" }; } else { Status = new ExtendedStatus { Status = StatusEnum.DEACTIVATION_ERROR, Description = "Error in communication module deactivation" }; } //dataDistribution = null; } }
/// <inheritdoc/> public OPERATION_RESULT Initialize(string[] arrayParams, string szMyAddress = null, string channelTrailer = null) { m_DataDistributionCallbackLow = new DataDistributionCallbackLow(IDataDistribution_ptr, this); OPERATION_RESULT result = DataDistributionManagerInvokeWrapper.DataDistributionEnv.GetDelegate <IDataDistribution_Initialize2>().Invoke( IDataDistribution_ptr, m_DataDistributionCallbackLow.Pointer, arrayParams, arrayParams.Length, szMyAddress, channelTrailer); if (result.Succeeded) { IDataDistributionSubsystemManager_ptr = DataDistributionManagerInvokeWrapper.DataDistributionEnv.GetDelegate <IDataDistribution_GetSubsystemManager>().Invoke(IDataDistribution_ptr); } return(result); }
async Task InternalSendMessage <T>(T message, string key = null) { await Task.Run(() => { if (!(Status.Status == StatusEnum.CONNECTED || Status.Status == StatusEnum.COMMUNICATING || Status.Status == StatusEnum.COMMUNICATION_ERROR)) { throw new Exception("Unable to send messages in status: " + Status.Status); } if (Id == null) { throw new Exception("Id not configured"); } if (!(message is string)) { throw new NotImplementedException("Only string messages are implemented"); } byte[] msg = ASCIIEncoding.ASCII.GetBytes(message as string); string strMessage = message as string; OPERATION_RESULT res = Channel.WriteOnChannel(key, message as string); //OPERATION_RESULT res = Channel.WriteOnChannel(key, msg); if (res.Failed) { Status = new ExtendedStatus { Status = StatusEnum.COMMUNICATION_ERROR, Description = "Error sending message" }; } else { Status = new ExtendedStatus { Status = StatusEnum.COMMUNICATING, Description = "Ok" }; } }); }
//---------------------------------------------------------------------------- /// <summary> /// Конструктор /// </summary> /// <param name="result"> /// Результат выполнеия операции /// </param> /// <param name="message"> /// Описание ошибки /// </param> internal OperationResult(OPERATION_RESULT result, String message) { _result = result; _message = message; }
//---------------------------------------------------------------------------- #endregion //---------------------------------------------------------------------------- #region Constructors //---------------------------------------------------------------------------- /// <summary> /// Конструктор по умолчанию /// </summary> internal OperationResult() { _result = OPERATION_RESULT.FAILURE; _message = String.Empty; }
static void Main(string[] args) { DDM_CHANNEL_DIRECTION direction = DDM_CHANNEL_DIRECTION.RECEIVER; SmartDataDistribution dataDistribution = new SmartDataDistribution(); dataDistribution.LoggingEvent += DataDistribution_LoggingEvent; OpenDDSConfiguration conf = null; OPERATION_RESULT hRes = OPERATION_RESULT.DDM_NO_ERROR_CONDITION; if (args.Length == 0) { conf = new OpenDDSConfiguration() { OpenDDSArgs = new OpenDDSConfiguration.OpenDDSArgsConfiguration() { DCPSConfigFile = "dds_tcp_conf.ini", DCPSTransportDebugLevel = 10, }, DCPSInfoRepo = new OpenDDSConfiguration.DCPSInfoRepoConfiguration() { Autostart = direction.HasFlag(DDM_CHANNEL_DIRECTION.RECEIVER), // start only on receiver Monitor = true, Resurrect = true, PersistenceFile = "persistance.file", ORBEndpoint = "iiop://localhost:12345", }, DomainParticipantQos = new DomainParticipantQosConfiguration() { EntityFactoryQosPolicy = new EntityFactoryQosPolicyConfiguration() { AutoenableCreatedEntities = true }, PropertyQosPolicy = new PropertyQosPolicyConfiguration() { DDSSEC_PROP_IDENTITY_CA = new PropertyQosPolicyConfiguration.Property("1"), DDSSEC_PROP_IDENTITY_CERT = new PropertyQosPolicyConfiguration.Property("2"), DDSSEC_PROP_IDENTITY_PRIVKEY = new PropertyQosPolicyConfiguration.Property("3"), DDSSEC_PROP_PERM_CA = new PropertyQosPolicyConfiguration.Property("4"), DDSSEC_PROP_PERM_DOC = new PropertyQosPolicyConfiguration.Property("5"), DDSSEC_PROP_PERM_GOV_DOC = new PropertyQosPolicyConfiguration.Property("6", true), } } }; hRes = dataDistribution.Initialize(conf); } else { hRes = dataDistribution.Initialize(args[0]); } if (hRes.Failed) { Console.WriteLine("Error in configuration."); Console.ReadKey(); return; } if (!dataDistribution.Start(uint.MaxValue)) { Console.ReadKey(); return; } OpenDDSChannelConfiguration channelConf = new OpenDDSChannelConfiguration(conf) { TopicQos = new TopicQosConfiguration() { TopicDataQosPolicy = new TopicDataQosPolicyConfiguration() { Value = new byte[] { 100, 23 } }, DurabilityQosPolicy = new DurabilityQosPolicyConfiguration() { Kind = DurabilityQosPolicyConfiguration.DurabilityQosPolicyKind.TRANSIENT_DURABILITY_QOS } }, SubscriberQos = new SubscriberQosConfiguration() { EntityFactoryQosPolicy = new EntityFactoryQosPolicyConfiguration() { AutoenableCreatedEntities = true } } }; SmartDataDistributionChannel testChannel = dataDistribution.CreateSmartChannel <SmartDataDistributionChannel>("test", channelConf); testChannel.DataAvailable += TestChannel_DataAvailable; testChannel.ConditionOrError += TestChannel_ConditionOrError; Console.WriteLine("After CreateSmartChannel...\n"); testChannel.StartChannel(uint.MaxValue); uint counter = 100; int pid = Process.GetCurrentProcess().Id; var str = string.Format("{0:10}", pid); Console.WriteLine("Starting operations...\n"); while (true) { if (direction.HasFlag(DDM_CHANNEL_DIRECTION.TRANSMITTER)) { if (testChannel.WriteOnChannel(str).Succeeded) { str = string.Format("{0:10}", counter++); if ((counter % THRESHOLD) == 0) { string key = string.Format("SendData Reached {0}", counter); testChannel.WriteOnChannel(key, str); Console.WriteLine(key); } } } Thread.Sleep(1000); } }
public override void OnConditionOrError(OPERATION_RESULT errorCode, int nativeCode, string subSystemReason) { base.OnConditionOrError(errorCode, nativeCode, subSystemReason); }
/// <inheritdoc/> public virtual void OnConditionOrError(string channelName, OPERATION_RESULT errorCode, int nativeCode, string subSystemReason) { }
void InternalActivate() { lock (CriticalSection) { if (Status.Status == StatusEnum.CONNECTED || Status.Status == StatusEnum.COMMUNICATING || Status.Status == StatusEnum.COMMUNICATION_ERROR || Status.Status == StatusEnum.INITIALIZED || Status.Status == StatusEnum.COMMUNICATION_ERROR ) { return; } OPERATION_RESULT Res = new OPERATION_RESULT(); //dataDistribution = new SmartDataDistribution(); dataDistribution.LoggingEvent += DataDistribution_LoggingEvent; try { if (Status.Status == StatusEnum.UNDEFINED) { Res = dataDistribution.Initialize(Configuration); } Status = new ExtendedStatus { Status = StatusEnum.INITIALIZED, Description = "INITIALIZED" }; if (Res.Failed) { Status = new ExtendedStatus { Status = StatusEnum.ERROR, Description = "Initialization error" }; } Res = dataDistribution.Start(uint.MaxValue); if (Res.Failed) { Status = new ExtendedStatus { Status = StatusEnum.ERROR, Description = "Start error" }; } Channel = dataDistribution.CreateSmartChannel <SmartDataDistributionChannel>(ChannelName, Configuration); Channel.DataAvailable += Channel_DataAvailable; Channel.ConditionOrError += Channel_ConditionOrError; Res = Channel.StartChannel(uint.MaxValue); if (Res.Succeeded) { Status = new ExtendedStatus { Status = StatusEnum.CONNECTED, Description = "Channel connection OK" }; } if (Res.Failed) { Status = new ExtendedStatus { Status = StatusEnum.ERROR, Description = "Channel Start error" }; } Channel.SeekChannel(0); } catch (Exception ex) { Status = new ExtendedStatus { Status = StatusEnum.ERROR, Description = ex.Message }; } } }