Example #1
0
    // Update is called once per frame
    void Update()
    {
        while (client.Count() > 0)
        {
            string s = client.Receive();
            msgq.Enqueue(s);
            Debug.Log("received :" + s);
        }

        if (BirdMovement1.gameOver && !check)
        {
            client.Publish(topic, System.Text.Encoding.ASCII.GetBytes("0/ON/10"));
            StartCoroutine("Spegni");
            check = true;
        }

        if (BirdMovement1.inviaMessaggio)
        {
            if (alterna)
            {
                client.Publish(topic, System.Text.Encoding.ASCII.GetBytes("1/PULSE/1"));
            }
            else
            {
                client.Publish(topic, System.Text.Encoding.ASCII.GetBytes("2/PULSE/1"));
            }
            alterna = !alterna;
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        while (client.Count() > 0)
        {
            s = client.Receive();
            msgq.Enqueue(s);
            // Debug.Log("received :" + s);

            Console.WriteLine(s);

            if (s.Contains("box1:"))
            {
                TextMesh textObject = GameObject.Find("rack1:").GetComponent <TextMesh>();
                textObject.text = s;
                PlaceHolder[0]  = s;
            }
            if (s.Contains("box2:"))
            {
                TextMesh textObject = GameObject.Find("rack2:").GetComponent <TextMesh>();
                textObject.text = s;
                PlaceHolder[1]  = s;
            }
            if (s.Contains("box3:"))
            {
                TextMesh textObject = GameObject.Find("rack3:").GetComponent <TextMesh>();
                textObject.text = s;
                PlaceHolder[2]  = s;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        while (client.Count() > 0)
        {
            //for(int i =0;i<100;i++)
            //{
            string s = client.Receive();
            msgq.Enqueue(s);
            // Debug.Log("received :" + s);
            Console.WriteLine(s);
            if (s.Contains("rack1:"))
            {
                TextMesh textObject = GameObject.Find("rack1:").GetComponent <TextMesh>();
                textObject.text = s;
            }
            if (s.Contains("rack2:"))
            {
                TextMesh textObject = GameObject.Find("rack2:").GetComponent <TextMesh>();
                textObject.text = s;
            }
            if (s.Contains("rack3:"))
            {
                TextMesh textObject = GameObject.Find("rack3:").GetComponent <TextMesh>();
                textObject.text = s;
            }

            // }
        }
    }
Example #4
0
 /// <summary>
 /// Listen payload from broker
 /// </summary>
 private void listenMqtt()
 {
     while (client.Count() > 0)
     {
         string s = client.Receive();
         payload = s.Split(',');
     }
 }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        while (client.Count() > 0)
        {
            string s = client.Receive();
            msgq.Enqueue(s);
            Debug.Log("received :" + s);
            lastMessage = s;
            //GUILayout.Label(s);
        }

        if (Input.GetMouseButtonDown(0) == true)
        {
            client.Publish(topic, System.Text.Encoding.ASCII.GetBytes("nice click!"));
        }
    }
Example #6
0
    void ReadTopics()
    {
        while (client.Count() > 0)
        {
            MqttMsgPublishEventArgs args = client.ReceiveEvent();

            string strData = string.Empty;
            for (int i = 0; i < args.Message.Length; i++)
            {
                strData += ((char)args.Message[i] - '0').ToString();
            }
            float val = float.Parse(strData);

            if (args.Topic == innerTempTopic)
            {
                EventManager.UpdateInnerTemp(val);
            }
            else if (args.Topic == innerHumidityTopic)
            {
                EventManager.UpdateInnerHumidity(val);
            }
            else if (args.Topic == shadeStateTopic)
            {
                EventManager.UpdateShadeState(val);
            }
            else if (args.Topic == windowStateTopic)
            {
                EventManager.UpdateWindowState(val);
            }
            else if (args.Topic == outerTempTopic)
            {
                EventManager.UpdateOuterTemp(val);
            }
            else if (args.Topic == outerLightTopic)
            {
                EventManager.UpdateOuterLight(val);
            }
            else if (args.Topic == outerWindTopic)
            {
                EventManager.UpdateOuterWind(val);
            }
            else
            {
                Debug.Log("This topic is not registered!!!: " + args.Topic);
            }
        }
    }
Example #7
0
    void Update()
    {
        //received data
        while (client.Count() > 0 && send == false)
        {
            string s = client.Receive();
            Debug.Log(s);
            position.text = s;

            if (s != oldmessage)
            {
                //sendaudrino.GetComponent<SendingAudrino>().sendmessage(s);
                SendingAudrino.sendmessage(s);
                oldmessage = s;
            }
        }

        //if(!Message.Equals(PrevMsg))
        //client.Publish(topic, System.Text.Encoding.ASCII.GetBytes(Message));

        // PrevMsg = Message;
    }
Example #8
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }
        while (client.Count() > 0)
        {
            meanindex = (meanindex + 1) % mean_size;
            string jsonLine = client.Receive().Split('\n')[0];
            var    json     = MiniJSON.Json.Deserialize(jsonLine) as Dictionary <string, object>;
            Debug.Log(jsonLine);

            if (json == null)
            {
                continue;
            }
            Debug.Log(json["AcX"].GetType() + "type of json");
            Debug.Log(json["AcX"]);
            acX = (Int64)json["AcX"] / AccRatio;
            acY = (Int64)json["AcY"] / AccRatio;
            acZ = (Int64)json["AcZ"] / AccRatio;
            _lastGyX[meanindex] = ((Int64)json["GyX"]);
            _lastGyY[meanindex] = ((Int64)json["GyY"]);
            _lastGyZ[meanindex] = ((Int64)json["GyZ"]);
            gyX = gyY = gyZ = 0.0f;
            for (var i = 0; i < mean_size; i++)
            {
                gyX += _lastGyX[i];
                gyY += _lastGyY[i];
                gyY += _lastGyY[i];
            }
            gyX = gyX / GyroRatio;
            gyY = gyY / GyroRatio;
            gyZ = gyZ / GyroRatio;

            Debug.LogFormat("{0} {1} {2} {3} {4} {5}", acX, acY, acZ, gyX, gyY, gyZ);
            break;
        }


        live2DModel.setParamFloat("PARAM_ANGLE_X", acX);             // head panning : value range -30.0 to 30.0 (degree)
        live2DModel.setParamFloat("PARAM_ANGLE_Y", acY);             // head banking back and forth : -30 to 30

        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", acZ);        // body angle sideway : -30.0 to 30.0

        live2DModel.setParamFloat("PARAM_EYE_L_OPEN", gyX + 0.5f);   // 0 to 1
        live2DModel.setParamFloat("PARAM_EYE_R_OPEN", gyX + 0.5f);   //

        live2DModel.setParamFloat("PARAM_BROW_L_Y", gyX);            // -1.0 to 1.0
        live2DModel.setParamFloat("PARAM_BROW_R_Y", gyX);            //

        live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", gyY + 0.5f); // 0 to 1.0
        live2DModel.setParamFloat("PARAM_MOUTH_FORM", gyZ);          //  -1.0 to 1.0


        live2DModel.setParamFloat("PARAM_BREATH", 1);

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        live2DModel.update();
    }