public void Publish_Getter()
        {
            using (var connection = this.Container.Resolve <ConnectionManager>())
                using (var queueMananger = connection.CreateQueueManager())
                    using (var exchangeMananger = connection.CreateExchangeManager())
                        using (var publisher = new StringPublisher("test", connection.CreatePublishManager(), this.Logger))
                        {
                            exchangeMananger.Create(Templates.TemporaryExchange("test", ExchangeType.Topic));

                            var info = queueMananger.Create(Templates.UnitTestQueue());
                            queueMananger.Bind(new QueueBindingConfiguration {
                                Action = BindingAction.Bind, DestinationQueue = info.Name, SourceExchange = "test", Topic = Constants.AllTopics
                            });

                            Thread.Sleep(500);

                            var t1 = publisher.Publish("this is string 1");
                            var t2 = publisher.Publish("this is string 2", "topic");
                            t1.Wait();
                            t2.Wait();

                            using (var getter = new StringRetriever(info.Name, false, connection.CreateMessageRetrievalManager(), this.Logger))
                            {
                                var r1 = getter.Retrieve();
                                Assert.IsNotNull(r1);
                                Assert.AreEqual("this is string 1", r1.Content);
                                getter.Ack(r1.DeliveryTag, false);

                                var r2 = getter.Retrieve();
                                Assert.IsNotNull(r2);
                                Assert.AreEqual("this is string 2", r2.Content);
                                getter.Ack(r2.DeliveryTag, false);
                            }
                        }
        }
예제 #2
0
 /// <summary>
 /// Logs the string to the ROS# String Publisher.
 /// If the publisher is not yet publishing, messages are stacked and published later.
 /// </summary>
 /// <param name="msg">Message to log</param>
 /// <param name="showUser">If true, the message will be logged and shown to the user</param>
 private void Log(string msg, bool showUser = false)
 {
     StringPublisher.PublishDebug(msg);
     if (showUser)
     {
         Debug.Log(msg);
     }
 }
예제 #3
0
    protected override void Start()
    {
        base.Start();

        if (DebugLogger == null)
        {
            DebugLogger = this;
        }

        Debug.Log("I came online");
    }
예제 #4
0
        public Communication(string name)
        {
            voiceInput = new StringSubscriber("/voiceInput", 10);

            rawWords       = new List <VoiceWord>();
            processedWords = new List <VoiceWord>();
            base.init(name);

            voiceInputClear = new StringPublisher("/voiceInput");
            voiceOutput     = new StringPublisher("/voiceOutput");


            queueThread = new Thread(new ThreadStart(queueMessage));
            queueThread.Start();

            messageAnalysisThread = new Thread(new ThreadStart(analyzeMessages));
            messageAnalysisThread.Start();

            commandAnalysisThread = new Thread(new ThreadStart(analyzeCommands));
            commandAnalysisThread.Start();
        }
    public void Update()
    {
        //First copy the list to avoid the original list being changed during the foreach loop,
        //which throws an Exception
        var Logs_ = new List <string>(Logs);

        Logs.Clear();
        foreach (var logText in Logs_)
        {
            StringPublisher.PublishDebug(logText);

            if (logText.Contains("Move your device to capture more environment") && lastText.Contains("Move your device to capture more environment"))
            {
                if (GameObjects.Count > 0)
                {
                    GameObjects[0].GetComponentInChildren <TextMeshProUGUI>().text = logText;
                }
            }
            else
            {
                GameObject log = Instantiate(LogItemPrefab);
                log.GetComponentInChildren <TextMeshProUGUI>().text = logText;
                log.transform.SetParent(LogContainer, false);
                GameObjects.Insert(0, log);
            }

            lastText = logText;
        }

        //Destroy the oldest GameObjects.
        //In Exception cases there can be hundreds of Exceptions per Second.
        //HoloLens does not like this many (useless) GameObjects.
        while (GameObjects.Count > maxLogCount)
        {
            GameObject.Destroy(GameObjects.Last());
            GameObjects.RemoveAt(GameObjects.Count - 1);
        }

        LogScrollRect.ScrollToBottom();
    }
    /// <summary>
    /// Handles the event messages and processes the events arguments
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void AsaStatusEventHookHandler(object sender, AsaStatusEventArgs e)
    {
        try
        {
            switch (e.Type)
            {
            case AsaStatusEventType.CreateAnchor_NeedMoreData:
                SetText($"Move device to capture more data: {e.Status.Percentage}%");
                break;

            case AsaStatusEventType.CreateAnchor_AttemptUpload:
                SetText($"Trying to upload anchor...");
                break;

            case AsaStatusEventType.CreateAnchor_Finished:
                SetText("Azure anchor created! :)", SuccessColor);
                StartCoroutine(HideAfterSeconds(3));
                break;

            case AsaStatusEventType.FindAnchor_NeedMoreData:
                SetText($"Move device to capture more data: {e.Status.Percentage}%");
                break;

            case AsaStatusEventType.FindAnchor_Finished:
                SetText("Azure anchor located! :)", SuccessColor);
                StartCoroutine(HideAfterSeconds(3));
                break;

            case AsaStatusEventType.Error:
                SetText($"Error: {e.Status.Error}", WarningColor);
                StartCoroutine(HideAfterSeconds(5));
                break;

            case AsaStatusEventType.FindAnchor_Update:
                SetText($"Looking for your Anchor...");
                break;

            case AsaStatusEventType.FindAnchor_CouldNotLocate:
                SetText($"Your anchor could not be found!", WarningColor);
                StartCoroutine(HideAfterSeconds(5));
                break;

            case AsaStatusEventType.FindAnchor_DoesNotExist:
                SetText($"The anchor does not seem to exist...", WarningColor);
                StartCoroutine(HideAfterSeconds(5));
                break;

            case AsaStatusEventType.FindAnchor_AlreadyTracked:
                SetText($"The anchor is already tracked.");
                StartCoroutine(HideAfterSeconds(3));
                break;

            default:
                SetText($"There was a message - but we forgot what...", WarningColor);
                StartCoroutine(HideAfterSeconds(5));
                break;
            }
        }
        catch (Exception ex)
        {
            StringPublisher.PublishException(ex);
        }
    }