Esempio n. 1
0
    public void GraphSemanal(string parametro, int atributo, string corHex)
    {
        UIManager.HideRightOther();
        UIManager.HideLeftInformation();
        //Debug.Log("Graph Semanal");
        XYBarValues        newXY  = new XYBarValues();
        List <XYBarValues> listXY = new List <XYBarValues>();

        listXY.Clear();
        Color color = new Color();

        ColorUtility.TryParseHtmlString(corHex, out color);
        int countNanS = 0;
        int Ano       = int.Parse(GetYear()) - 2020;

        for (int i = 0; i < 4; i++)
        {
            float[,,,] mediaSemanalMensal = Sensor4.getInstance().GetMediaSemanalMensal();

            //if (!float.IsNaN(mediaSemanalMensal[i, indexMonth, atributo, Ano]))
            if (mediaSemanalMensal[i, indexMonth, atributo, Ano] != 0 && !float.IsNaN(mediaSemanalMensal[i, indexMonth, atributo, Ano]))
            {
                ///Debug.Log("MediaSemanalMensal: " + mediaSemanalMensal[i, indexMonth, atributo, Ano].ToString());
                float media = (float)Math.Round(mediaSemanalMensal[i, indexMonth, atributo, Ano], 1);  // [i, MES, Atributo]

                newXY = new XYBarValues(semanaNome[i], media);
                listXY.Add(newXY);

                debugText.text = "";
            }
            else if (float.IsNaN(mediaSemanalMensal[i, indexMonth, atributo, Ano]) || mediaSemanalMensal[i, indexMonth, atributo, Ano] == 0)
            {
                countNanS++;
                //Debug.Log("countNan: " + countNanS);
            }
        }

        if (countNanS <= 3)
        {
            //Debug.Log("GraaphSemanal::: CountNan >= 3 __CountNan: " +countNanS);
            CreateGraphFromData(listXY, parametro, color);
            chooseAnim = true;
        }
        else
        {
            debugText.text = "Não contem dados deste mês";
            chooseAnim     = false;
            //AnimateForNoData();
        }
    }
Esempio n. 2
0
    public void GraphMensalAnual(string parametro, int atributo, string corHex)
    {
        UIManager.HideRightOther();
        UIManager.HideLeftInformation();
        XYBarValues        newXY  = new XYBarValues();
        List <XYBarValues> listXY = new List <XYBarValues>();

        listXY.Clear();
        Color color = new Color();

        ColorUtility.TryParseHtmlString(corHex, out color);
        int countNan = 0;
        int Ano      = int.Parse(GetYear()) - 2020;

        //if getInstance1
        //if getInstance2
        float[,,] mediaMensalAnual = Sensor4.getInstance().GetMediaGeralMesAno();

        for (int y = Ano; y <= Ano; y++)
        {
            for (int m = fromMonth; m <= toMonth; m++)
            {
                //Debug.Log("DatA: " + mediaMensalAnual[atributo, m, y]);
                if (float.IsNaN(mediaMensalAnual[atributo, m, y]) || mediaMensalAnual[atributo, m, y] == 0)
                {
                    countNan++;
                    //Debug.Log("Conta: countNan: " + countNan);
                }
                else if (!float.IsNaN(mediaMensalAnual[atributo, m, y]))
                {
                    float media = (float)Math.Round(mediaMensalAnual[atributo, m, y], 2);
                    newXY = new XYBarValues(mesesNome[m], media);
                    listXY.Add(newXY);
                }
            }
        }

        //Debug.Log("CountNan:: " +countNan);
        if (countNan >= 3)
        {
            debugText.text = "Não contem dados deste período";
            chooseAnim     = false;
        }
        else
        {
            chooseAnim     = true;
            debugText.text = "";
            CreateGraphFromData(listXY, parametro, color);
        }
    }
Esempio n. 3
0
    public void StreamingFile(string filePath, int regiao)
    {
        string[] lines   = File.ReadAllLines(filePath);
        string[] valores = new string[6];
        string   valor   = "";

        //Debug.Log("Lines: " + lines.Length);

        for (int k = 0; k < lines.Length; k++)
        {
            //Debug.Log("Value: " + lines[k].Length);
            //if (lines[k].Contains("null") || lines[k].Contains(" ") || lines[k].StartsWith(" ") || lines[k].Length > 50)
            if (lines[k].Length >= 60 || lines[k].Contains("GMT") || !lines[k].Contains("") || lines[k].Contains(" "))
            {
                if (GetRegiaoAberta() == 0)
                {
                    errorDebug  = "System.QuantityException(Castro);";
                    dontRead[0] = true;
                    ShowText();
                }
                if (GetRegiaoAberta() == 1)
                {
                    errorDebug  = "System.QuantityException(Seda);";
                    dontRead[1] = true;
                    ShowText();
                }
                if (GetRegiaoAberta() == 2)
                {
                    errorDebug  = "System.QuantityException(ETAR);";
                    dontRead[2] = true;
                    ShowText();
                }
                if (GetRegiaoAberta() == 3)
                {
                    errorDebug  = "System.QuantityException(IPB);";
                    dontRead[3] = true;
                    ShowText();
                }
            }

            else
            {
                //Debug.Log("Number of Arguments Between ',' : " + lines[0].Split(',').Count());
                for (int coluna = 0; coluna < lines[k].Split(',').Count(); coluna++)
                {
                    //Get Humidade
                    if (coluna == 0)
                    {
                        char   c1       = lines[k][1];
                        char   c2       = lines[k][2];
                        string humidade = c1.ToString() + c2.ToString();

                        int number;
                        if (int.TryParse(humidade, out number))
                        {
                            valores[coluna] = number.ToString();
                        }
                        //Debug.Log("Humidade:: " + valores[coluna]);
                    }

                    //Get Date
                    else if (coluna == 5)
                    {
                        string   value      = lines[k].Split(',')[coluna];
                        char[]   delimiter1 = new char[] { '"', 'T' };
                        string[] array2     = value.Split(delimiter1, StringSplitOptions.RemoveEmptyEntries);

                        //Debug.Log("Posicao 0: " + array2[0]);
                        try
                        {
                            dateTime = DateTime.Parse(array2[0]);
                        }
                        catch (Exception e)
                        {
                            errorDebug += e.ToString() + "/";
                            //debugText.text = e.ToString();
                            if (regiao == 0)
                            {
                                dontRead[0] = true;
                                Debug.LogException(e, this);
                            }
                            if (regiao == 1)
                            {
                                dontRead[1] = true;
                                Debug.LogException(e, this);
                            }
                            if (regiao == 2)
                            {
                                dontRead[2] = true;
                                Debug.LogException(e, this);
                            }
                            if (regiao == 3)
                            {
                                dontRead[3] = true;
                                Debug.LogException(e, this);
                            }
                        }

                        //print("Datetime: " + dateTime.ToString("dd/MM/yyyy"));
                    }
                    //Get Other values
                    else
                    {
                        valor           = (lines[k].Split(',')[coluna]);
                        valores[coluna] = valor;
                        //Debug.Log("Pegou:: " + valor);
                    }

                    //Verificando se tem valores 0
                    for (int v = 0; v < valores.Length; v++)
                    {
                        if (valores[v] == "0")
                        {
                            //int linha = k + 1;
                            //int column = v + 1;
                            //string text = "Contem '0' na linha [" + linha + "] coluna [" + column + "]";
                            //debugText.text = " \n" + text;
                            //Debug.Log(text);
                        }
                        else
                        {
                            //debugText.text = "";
                        }
                    }
                }

                if (regiao == 1)
                {
                    Sensor sensor1 = new Sensor();
                    sensor1.setCodigo(k);

                    //Debug.Log("Regiao (1) Antes de Enviar: " + valores[0].ToString() + " "  + dateTime.ToString("dd/MM/yyyy"));
                    sensor1.SetHumidadeAr(int.Parse(valores[0]));
                    sensor1.SetTempAgua(int.Parse(valores[1]));
                    sensor1.SetTempAmb(int.Parse(valores[2]));
                    sensor1.SetCondutividade(float.Parse(valores[3], CultureInfo.InvariantCulture));
                    sensor1.SetPH(float.Parse(valores[4], CultureInfo.InvariantCulture));
                    sensor1.SetDate(dateTime);
                    Sensor.getInstance().AddToArray(sensor1);
                }

                else if (regiao == 2)
                {
                    Sensor2 sensor2 = new Sensor2();
                    sensor2.setCodigo(k);

                    //Debug.Log("Regiao (2)  Antes de Enviar: " + valores[0].ToString() + " "  + dateTime.ToString("dd/MM/yyyy"));
                    sensor2.SetHumidadeAr(int.Parse(valores[0]));
                    sensor2.SetTempAgua(int.Parse(valores[1]));
                    sensor2.SetTempAmb(int.Parse(valores[2]));
                    sensor2.SetCondutividade(float.Parse(valores[3], CultureInfo.InvariantCulture));
                    sensor2.SetPH(float.Parse(valores[4], CultureInfo.InvariantCulture));
                    sensor2.SetDate(dateTime);
                    Sensor2.getInstance().AddToArray(sensor2);
                }

                else if (regiao == 3)
                {
                    Sensor3 sensor3 = new Sensor3();
                    sensor3.setCodigo(k);

                    //Debug.Log("Regiao (3) Antes de Enviar: " + valores[0].ToString() + " "  + dateTime.ToString("dd/MM/yyyy"));
                    sensor3.SetHumidadeAr(int.Parse(valores[0]));
                    sensor3.SetTempAgua(int.Parse(valores[1]));
                    sensor3.SetTempAmb(int.Parse(valores[2]));
                    sensor3.SetCondutividade(float.Parse(valores[3], CultureInfo.InvariantCulture));
                    sensor3.SetPH(float.Parse(valores[4], CultureInfo.InvariantCulture));
                    sensor3.SetDate(dateTime);
                    Sensor3.getInstance().AddToArray(sensor3);
                }
                else if (regiao == 4)
                {
                    Sensor4 sensor4 = new Sensor4();
                    sensor4.setCodigo(k);

                    //Debug.Log("Regiao (3) Antes de Enviar: " + valores[0].ToString() + " "  + dateTime.ToString("dd/MM/yyyy"));
                    sensor4.SetHumidadeAr(int.Parse(valores[0]));
                    sensor4.SetTempAgua(int.Parse(valores[1]));
                    sensor4.SetTempAmb(int.Parse(valores[2]));
                    sensor4.SetCondutividade(float.Parse(valores[3], CultureInfo.InvariantCulture));
                    sensor4.SetPH(float.Parse(valores[4], CultureInfo.InvariantCulture));
                    sensor4.SetDate(dateTime);
                    Sensor4.getInstance().AddToArray(sensor4);
                }
            }
        }

        if (regiao == 1)
        {
            year = yearTxT.text.ToString();
            Sensor.getInstance().MediaMensalSemanal();
        }
        else if (regiao == 2)
        {
            year = yearTxT.text.ToString();
            Sensor2.getInstance().MediaMensalSemanal();
        }
        else if (regiao == 3)
        {
            year = yearTxT.text.ToString();
            Sensor3.getInstance().MediaMensalSemanal();
        }
        else if (regiao == 4)
        {
            year = yearTxT.text.ToString();
            Sensor4.getInstance().MediaMensalSemanal();
        }
    }
Esempio n. 4
0
    public void UpdateTextData(string newFilePath)
    {
        int RegiaoAberta = 999;

        DestroyBefore();
        if (System.IO.File.Exists(newFilePath))
        {
            bool[] regiao = sceneManager.GetRegiaoAberta();

            for (int i = 0; i < regiao.Length; i++)
            {
                if (regiao[i] == true)
                {
                    //Debug.Log("Regiao:: " + regiao[i] + " _position:" + i);
                    RegiaoAberta = i;
                }
            }

            if (RegiaoAberta == 0)
            {
                debugText.text = "";

                if (dontRead[0])
                {
                    ShowText();
                }
                smartRiver.ClearDataset();
                Sensor.getInstance().getArray().Clear();
                Sensor.getInstance().DeleteList();
                StreamingFile(newFilePath, 1);
                smartRiver.FileReady(true);
            }
            else if (RegiaoAberta == 1)
            {
                debugText2.text = "";

                if (dontRead[1])
                {
                    ShowText();
                }
                smartRiver2.ClearDataset();
                Sensor2.getInstance().getArray().Clear();
                Sensor2.getInstance().DeleteList();
                StreamingFile(newFilePath, 2);
                smartRiver2.FileReady(true);
            }
            else if (RegiaoAberta == 2)
            {
                debugText3.text = "";

                if (dontRead[2])
                {
                    ShowText();
                }
                smartRiver3.ClearDataset();
                Sensor3.getInstance().getArray().Clear();
                Sensor3.getInstance().DeleteList();
                StreamingFile(newFilePath, 3);
                smartRiver3.FileReady(true);
            }
            else if (RegiaoAberta == 3)
            {
                debugText4.text = "";

                if (dontRead[3])
                {
                    ShowText();
                }
                smartRiver4.ClearDataset();
                Sensor4.getInstance().getArray().Clear();
                Sensor4.getInstance().DeleteList();
                StreamingFile(newFilePath, 4);
                smartRiver4.FileReady(true);
            }
        }
        else if (RegiaoAberta != 999)
        {
            debugText.text = "Configure Arquivo de leitura: " + RegiaoAberta;
        }
    }