Пример #1
0
        /// <inheritdoc/>
        public T CreateSmartChannel <T>(string channelName, string[] arrayParams, DDM_CHANNEL_DIRECTION direction = DDM_CHANNEL_DIRECTION.ALL)
            where T : SmartDataDistributionChannel
        {
            T smartChannelReference = Activator.CreateInstance(typeof(T)) as T;

            IntPtr handle = DataDistributionManagerInvokeWrapper.DataDistributionEnv.GetDelegate <IDataDistributionSubsystem_CreateChannel>().Invoke(
                IDataDistributionSubsystemManager_ptr, channelName, smartChannelReference.m_DataDistributionChannelCallbackLow.Pointer, direction, arrayParams, (arrayParams != null) ? arrayParams.Length : 0);

            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Failed to allocate a channel");
            }

            smartChannelReference.m_direction = direction;
            smartChannelReference.IDataDistributionSubsystemManager_ptr = IDataDistributionSubsystemManager_ptr;
            smartChannelReference.channelHandle = handle;

            return(smartChannelReference);
        }
Пример #2
0
 /// <inheritdoc/>
 public T CreateSmartChannel <T>(string channelName, IConfiguration configuration = null, DDM_CHANNEL_DIRECTION direction = DDM_CHANNEL_DIRECTION.ALL)
     where T : SmartDataDistributionChannel
 {
     return(CreateSmartChannel <T>(channelName, (configuration != null) ? configuration.Configuration : null, direction));
 }
 /// <inheritdoc/>
 public OPERATION_RESULT ChangeChannelDirection(DDM_CHANNEL_DIRECTION direction)
 {
     return(DataDistributionManagerInvokeWrapper.DataDistributionEnv.GetDelegate <IDataDistributionSubsystem_ChangeChannelDirection>().Invoke(IDataDistributionSubsystemManager_ptr, channelHandle, direction));
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
 /// <summary>
 /// Converts enum in string
 /// </summary>
 /// <param name="level"><see cref="DDM_CHANNEL_DIRECTION"/></param>
 /// <returns>Numeric string representation</returns>
 public static string ToIntString(this DDM_CHANNEL_DIRECTION level)
 {
     return(ToString((int)level));
 }