Esempio n. 1
0
    private void disconnectFromMQTTBroker()
    {
    #if !UNITY_EDITOR
        try
        {
            if (client.IsConnected)
            {
                // unregister from broker
                NetworkMessage nM = new NetworkMessage();
                nM.action = "unsubscribe";
                nM.value  = MQTT_OWN_TOPIC;

                this.sendMessage(MQTT_SERVER_TOPIC, JsonUtility.ToJson(nM));

                client.Disconnect();
                Debug.Log("Disconnected from broker!");

                SystemAlert systemAlert = new SystemAlert();
                systemAlert.mode    = SystemAlert.SYSTEM_PROMPT_MODE_INFO;
                systemAlert.message = "Verbindung zum Broker beendet!";

                this.systemAlerts.Add(systemAlert);
            }
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);

            SystemAlert systemAlert = new SystemAlert();
            systemAlert.mode    = SystemAlert.SYSTEM_PROMPT_MODE_ERROR;
            systemAlert.message = "Broker kann nicht erreicht werden!";
            this.systemAlerts.Add(systemAlert);
        }
    #endif
    }
Esempio n. 2
0
        public static readonly string op1 = @"{""op"": 1, ""d"": 251}"; // ""presence"": { ""game"": { ""name"": ""test"", ""type"": 0 } }



        static void OnSystemAlert(SystemAlert e)
        {
            if (SysAlert != null)
            {
                SysAlert(e);
            }
        }
Esempio n. 3
0
    private void setSystemAlert(NetworkMessage msg)
    {
        // Check if message is navigation message
        if (12 <= msg.systemAlert.id && msg.systemAlert.id <= 16)
        {
            for (int i = 0; i < systemAlerts.Count; i++)
            {
                SystemAlert alert = systemAlerts[i];
                // Remove deprecated navigation messages
                if (12 <= alert.id && alert.id < 16)
                {
                    Debug.Log("removed " + alert.id);
                    systemAlerts.Remove(alert);
                }
            }
        }

        this.systemAlerts.Add(msg.systemAlert);
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        this.originalColor   = recommendationPanel1.GetComponent <Image>().color;
        this.highlightColor  = new Color(0.63f, 0.40f, 0.15f, 1);
        this.errorColor      = new Color(0.52f, 0.1f, 0.1f, 1);
        this.efficiencyColor = new Color(0.82f, 0.38f, 0.14f, 1);

        this.resetApplication();

        this.degree = 360;
        this.systemAlertDisplayCounter  = 0;
        this.systemAlertBackgroundColor = this.systemAlertPanel.GetComponent <Image>();

        this.recommendationPanel1Background = this.recommendationPanel1.GetComponent <Image>();
        this.recommendationPanel2Background = this.recommendationPanel2.GetComponent <Image>();
        this.recommendationPanel3Background = this.recommendationPanel3.GetComponent <Image>();

        this.progressBarRect = this.progressBar.GetComponent <RectTransform>();

        // default base64 string for raw image insertion
        this.base64Image = "iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAW/SURBVGhD7dlPqH1TFAfw50+iFAPFwMDAwMDAwEBSFAMDAwOFMlCIgQFRKJIMDAwMDCgDBkr+FKIoioGiKAoRA4oiFKH8Ldbn3rO07n773Hufd95971fvW9/Ovuees/dae3/X2mvfu3WIQxyZuDb4ysCb3DjIOD14VfDS4PFuDHgo+Fvw4YG/DPcSxwa941197CsYwsB/Bn4ffCCYhl8QPDN4xtB2z3f3B78J5nvuXx7cF5h9xjAMTg7eHPwkmE6Ae5fNm/8580Xw9uApQbBSPwb1sXFcHzQ4hx4LXhRMnDZce6gyOif4SJDMTMotwf+FY4brOjBblwTPDzLg1uAzQYFsFT4L/hmEX4crmPXjgr/PPm1t/Txc4afgx8EfgicEbwhaMf1z+LtgvjcJBKQBUhZJ2u/BaiHcHbxm3pz1M5a9rOLnwew7x8t3dw0rocMHgye6MQKySGl4ricv97IPjupzDCR7b1DmmySrCVSOMICeq4EGyxnWXuZoi/q8Wa+BbgxxJ3bE4RXBpTh6uC4DjdMw3d83tBMGynig5Robq1Cf/zuor4Qx7gm6L452MkGjsDvTbIWgP3fenBT6tDdVGJsNS7FsRSw9Hd82+7QZmP1v580F3BEk4R2vjFmR1+lTQGZ2ouNeEE8NY2TMCHTVgqoBc3NdCS8Kbju2VakQlJOlwyUQ3Jm+E2xhkyw2lvYXwFD1D6iJ1Er7DTZkwflVcFsF0IsROgVL+2IwNUuj7QrtJ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VMn3meUMWaiHSKA97pxdVG4LQndnLXRTPstJfOqJMYnE74jvPizTPiQSys3Cv2GmozGcuvgFlWkIpTHGNlJhnP6tWTHeeUQt5du3baD2T6dB7305B2OnGIQxwZ2Nr6F/KiTfXMUIM2AAAAAElFTkSuQmCC";

        this.connectToMQTTBroker();

        this.progressBarOrgSize     = progressBar.GetComponent <RectTransform>().sizeDelta;
        this.progressBarCurrentSize = this.progressBarOrgSize;

        this.errorTxtr = Resources.Load("error") as Texture2D;
        this.infoTxtr  = Resources.Load("info") as Texture2D;


        // prevent app from mapping surrounding
        UnityEngine.VR.WSA.WorldManager.OnPositionalLocatorStateChanged += WorldManager_OnPositionalLocatorStateChanged;

        SystemAlert systemAlert = new SystemAlert();

        systemAlert.mode    = SystemAlert.SYSTEM_PROMPT_MODE_INFO;
        systemAlert.message = "Willkommen!";

        this.systemAlerts.Add(systemAlert);
    }
Esempio n. 5
0
    private void connectToMQTTBroker()
    {
        #if !UNITY_EDITOR
        try
        {
            // Default port is 1883
            client = new MqttClient(MQTT_BROKER_ADDRESS);

            // register to message received
            client.MqttMsgPublishReceived += clientMqttMsgPublishReceived;
            client.MqttMsgPublished       += clientMqttMsgPublished;

            string clientId = Guid.NewGuid().ToString();

            if (client.IsConnected)
            {
                client.Disconnect();
            }

            client.Connect(clientId);

            // subscribe to the topic with QoS 2
            client.Subscribe(new string[] { MQTT_OWN_TOPIC }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });

            registerOnServer();

            Debug.Log("Connected to MQTT broker");
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);

            SystemAlert systemAlert = new SystemAlert();
            systemAlert.mode    = SystemAlert.SYSTEM_PROMPT_MODE_ERROR;
            systemAlert.message = "MQTT Broker kann nicht erreicht werden!";

            this.systemAlerts.Add(systemAlert);
        }
        #endif
    }
        public FrayteResult SaveUpdateSystemAlerts(FrayteSystemAlert frayteSystemAlert)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                if (frayteSystemAlert != null)
                {
                    SystemAlert systemAlert;
                    if (frayteSystemAlert.SystemAlertId == 0)
                    {
                        systemAlert                 = new SystemAlert();
                        systemAlert.IsActive        = true;
                        systemAlert.Heading         = frayteSystemAlert.Heading;
                        systemAlert.Description     = frayteSystemAlert.Description;
                        systemAlert.OperationZoneId = frayteSystemAlert.OperationZoneId;
                        systemAlert.FromDate        = UtilityRepository.ConvertDateTimetoUniversalTime(frayteSystemAlert.FromDate);
                        systemAlert.FromTime        = UtilityRepository.TimeSpanConversion(systemAlert.FromDate.Hour, systemAlert.FromDate.Minute, systemAlert.FromDate.Second);
                        systemAlert.ToDate          = UtilityRepository.ConvertDateTimetoUniversalTime(frayteSystemAlert.ToDate);
                        systemAlert.ToTime          = UtilityRepository.TimeSpanConversion(systemAlert.ToDate.Hour, systemAlert.ToDate.Minute, systemAlert.ToDate.Second);;
                        if (frayteSystemAlert.TimeZoneDetail != null)
                        {
                            systemAlert.TimeZoneId = frayteSystemAlert.TimeZoneDetail.TimezoneId;
                        }

                        dbContext.SystemAlerts.Add(systemAlert);
                        dbContext.SaveChanges();
                        result.Status = true;
                    }
                    else
                    {
                        systemAlert = dbContext.SystemAlerts.Find(frayteSystemAlert.SystemAlertId);
                        if (systemAlert != null)
                        {
                            systemAlert.FromDate    = UtilityRepository.ConvertDateTimetoUniversalTime(frayteSystemAlert.FromDate);
                            systemAlert.FromTime    = UtilityRepository.TimeSpanConversion(systemAlert.FromDate.Hour, systemAlert.FromDate.Minute, systemAlert.FromDate.Second);
                            systemAlert.ToDate      = UtilityRepository.ConvertDateTimetoUniversalTime(frayteSystemAlert.ToDate);
                            systemAlert.ToTime      = UtilityRepository.TimeSpanConversion(systemAlert.ToDate.Hour, systemAlert.ToDate.Minute, systemAlert.ToDate.Second);;
                            systemAlert.Description = frayteSystemAlert.Description;
                            if (frayteSystemAlert.TimeZoneDetail != null)
                            {
                                systemAlert.TimeZoneId = frayteSystemAlert.TimeZoneDetail.TimezoneId;
                            }
                            systemAlert.Heading  = frayteSystemAlert.Heading;
                            systemAlert.IsActive = frayteSystemAlert.IsActive;
                            dbContext.Entry(systemAlert).State = System.Data.Entity.EntityState.Modified;
                            dbContext.SaveChanges();
                            result.Status = true;
                        }
                    }
                }
                else
                {
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Status = false;
            }

            return(result);
        }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (this.quitApp)
        {
            if (this.systemAlertDisplayCounter == 0)
            {
                Application.Quit();
            }
            else if (this.systemAlerts.Count > 0 && this.systemAlertDisplayCounter < this.systemAlerts[0].message.Length / 2)
            {
                SystemAlert systemAlert = new SystemAlert();
                systemAlert.mode    = SystemAlert.SYSTEM_PROMPT_MODE_INFO;
                systemAlert.message = "Auf Wiedersehen!";
                this.systemAlerts.Add(systemAlert);
            }
        }

        if (this.items.Count == 0 || this.systemAlerts.Count > 0)
        {
            this.recommendationPanel.SetActive(false);
            this.loadingPanel.SetActive(false);


            if (this.systemAlerts.Count > 0 && this.systemAlertDisplayCounter <= 0)
            {
                this.systemAlertDisplayCounter = this.systemAlerts[0].message.Length * FRAMES_PER_CHAR_PER_WORD;

                char[] delimiters = new char[] { ' ', '-', '\r', '\n' };
                int    numofWords = this.systemAlerts[0].message.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).Length;

                if (numofWords > 1)
                {
                    this.systemAlertDisplayCounter = this.systemAlertDisplayCounter - this.systemAlerts[0].message.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).Length *FRAMES_PER_CHAR_PER_WORD * 3;
                }

                if (this.systemAlertDisplayCounter < 7 * FRAMES_PER_CHAR_PER_WORD)
                {
                    this.systemAlertDisplayCounter = 7 * FRAMES_PER_CHAR_PER_WORD;
                }
            }

            if (this.systemAlerts.Count > 0)
            {
                SystemAlert currentAlert = this.systemAlerts[0];

                if (String.Equals(currentAlert.mode, SystemAlert.SYSTEM_PROMPT_MODE_ERROR))
                {
                    this.systemAlertBackgroundColor.color = this.errorColor;
                    this.systemAlertIcon.texture          = this.errorTxtr;
                }
                else if (String.Equals(currentAlert.mode, SystemAlert.SYSTEM_PROMPT_MODE_EFFICIENCY))
                {
                    this.systemAlertBackgroundColor.color = this.efficiencyColor;
                    this.systemAlertIcon.texture          = this.infoTxtr;
                }
                else
                {
                    this.systemAlertBackgroundColor.color = this.originalColor;
                    this.systemAlertIcon.texture          = this.infoTxtr;
                }

                this.systemMessage.text = currentAlert.message;
                this.systemAlertPanel.SetActive(true);

                this.systemAlertDisplayCounter = this.systemAlertDisplayCounter - 1;

                if (this.systemAlertDisplayCounter <= 0)
                {
                    this.systemAlerts.RemoveAt(0);
                }

                return;
            }
        }

        if (this.systemAlertDisplayCounter <= 0)
        {
            this.systemAlertPanel.SetActive(false);
        }


        if (this.progressBarCurrentSize.x <= 0 || this.navigationEnabled || this.hideAll)
        {
            #if !UNITY_EDITOR
            // Inform controller
            if (this.recommendationPanel.activeSelf && this.client.IsConnected)
            {
                NetworkMessage nM = new NetworkMessage();
                nM.action = "hideAll";
                nM.value  = "false";

                this.sendMessage(MQTT_SERVER_TOPIC, JsonUtility.ToJson(nM));
            }
            #endif

            this.recommendationPanel.SetActive(false);
            this.loadingPanel.SetActive(false);
            return;
        }

        if (this.calculatingRoute)
        {
            if (degree == 0)
            {
                degree = 359;
            }
            else
            {
                degree--;
            }

            recommendationPanel.SetActive(false);
            loadingPanel.SetActive(true);
            loading.rectTransform.rotation = Quaternion.AngleAxis(Mathf.Lerp(0f, degree, 50), Vector3.forward);
            return;
        }
        else
        {
            recommendationPanel.SetActive(true);
            loadingPanel.SetActive(false);
        }


        // Update progress bar
        if (this.progressBarCurrentSize.x > 0 && !this.detailView && this.selectedItem == 0 && this.items.Count > 0)
        {
            this.progressBarCurrentSize.x = this.progressBarCurrentSize.x - 0.7f;
            this.progressBarWrapper.SetActive(true);
        }
        else
        {
            this.progressBarWrapper.SetActive(false);
        }

        this.progressBarRect.sizeDelta = this.progressBarCurrentSize;


        // Insert item names
        if (this.recommendationPanel.activeSelf && this.items.Count > this.idxOfFirstItemInList)
        {
            recommendationPanel1.SetActive(true);
            title1.text       = items[this.idxOfFirstItemInList].name;
            description1.text = items[this.idxOfFirstItemInList].description;

            this.recommendationPanel1Background.color = (this.selectedItem == this.idxOfFirstItemInList + 1) ? highlightColor : originalColor;
            body1.SetActive(this.selectedItem == this.idxOfFirstItemInList + 1 && detailView);
            setImage(domainIcon1, items[this.idxOfFirstItemInList].domain.image);
        }
        else
        {
            recommendationPanel1.SetActive(false);
            body1.SetActive(false);
        }

        if (this.recommendationPanel.activeSelf && this.items.Count > this.idxOfFirstItemInList + 1)
        {
            recommendationPanel2.SetActive(true);
            title2.text       = items[this.idxOfFirstItemInList + 1].name;
            description2.text = items[this.idxOfFirstItemInList + 1].description;

            this.recommendationPanel2Background.color = (this.selectedItem == this.idxOfFirstItemInList + 2) ? highlightColor : originalColor;
            body2.SetActive(this.selectedItem == this.idxOfFirstItemInList + 2 && detailView);

            setImage(domainIcon2, items[this.idxOfFirstItemInList + 1].domain.image);
        }
        else
        {
            recommendationPanel2.SetActive(false);
            body2.SetActive(false);
        }


        if (this.recommendationPanel.activeSelf && this.items.Count > this.idxOfFirstItemInList + 2)
        {
            recommendationPanel3.SetActive(true);
            title3.text       = items[this.idxOfFirstItemInList + 2].name;
            description3.text = items[this.idxOfFirstItemInList + 2].description;

            this.recommendationPanel3Background.color = (this.selectedItem == this.idxOfFirstItemInList + 3) ? highlightColor : originalColor;
            body3.SetActive(this.selectedItem == this.idxOfFirstItemInList + 3 && detailView);

            setImage(domainIcon3, items[this.idxOfFirstItemInList + 2].domain.image);
        }
        else
        {
            recommendationPanel3.SetActive(false);
            body3.SetActive(false);
        }


        // updates in detail view

        if (body1.activeSelf)
        {
            setImage(itemImage1, items[this.idxOfFirstItemInList].image);
            this.rating1.SetActive(!this.userIsMoving);
        }
        else if (body2.activeSelf)
        {
            setImage(itemImage2, items[this.idxOfFirstItemInList + 1].image);
            this.rating2.SetActive(!this.userIsMoving);
        }
        else if (body3.activeSelf)
        {
            setImage(itemImage3, items[this.idxOfFirstItemInList + 2].image);
            this.rating2.SetActive(!this.userIsMoving);
        }
    }