Example #1
0
        public Logger_Debug_Data Trame_To_Data(Communication.Communication_Trame input_trame)
        {
            Logger_Debug_Data output = new Logger_Debug_Data();

            output = (Logger_Debug_Data)Communication.GetStructFromArray <Logger_Debug_Data>(input_trame.Data);
            return(output);
        }
    private void Decodage_Logger(Communication_Trame input_trame)
    {
        if (LogMessages.Count >= Max_Log_Message_Number)
        {
            Destroy(LogMessages[0].textobject.gameObject);
            LogMessages.RemoveAt(0);
        }


        Structures_Echange.Logger_Debug Logger = new Structures_Echange.Logger_Debug();
        //Transforme la trame en Message utile
        Logger_Debug_Data received_message = Logger.Trame_To_Data(input_trame);

        string recieved_log = "[" + DateTime.Now.ToLongTimeString() + ":" + DateTime.Now.Millisecond.ToString() + "] ";


        recieved_log += new string(received_message.Text, 0, received_message.Nombre_Carateres);
        Logger_Debug_Color color = received_message.Color;

        //Crée un nouveau message de Log
        Log_Message newLogMessage = new Log_Message();

        newLogMessage.text        = recieved_log;
        newLogMessage.messageType = received_message.Color;

        //Crée le gameObject associé
        GameObject newgameobject = Instantiate(Log_Message_Prefab, Fenetre_Logger.transform);

        newLogMessage.textobject      = newgameobject.GetComponent <Text>();
        newLogMessage.textobject.text = newLogMessage.text;

        switch (received_message.Color)
        {
        default:
        case Logger_Debug_Color.Color_Black:
            newLogMessage.textobject.color = Color.black;
            break;

        case Logger_Debug_Color.Color_Blue:
            newLogMessage.textobject.color = Color.blue;
            break;

        case Logger_Debug_Color.Color_Red:
            newLogMessage.textobject.color = Color.red;
            break;
        }

        //Ajoute ce log à la liste
        LogMessages.Add(newLogMessage);
    }
Example #3
0
        public List <Communication> Send_Logger(string str, Structures_Echange.Logger_Debug.Logger_Debug_Color color)
        {
            //Création locale de le liste de messages à envoyer
            List <Communication> List_trame_echange = new List <Communication>();

            //Création de la trame de base d'un message
            Communication trame_echange = new Communication();

            trame_echange.Set_Instruction(Communication.Com_Instruction.LOGGER_DEBUG);

            trame_echange.Set_SlaveAdress(Communication.Slave_Adresses.ALL_CARDS);

            //Création de la structure du message de Log à envoyer
            Logger_Debug_Data logger_Debug = new Logger_Debug_Data();

            logger_Debug.Color = color;

            if (str.Length < Max_Char_per_Log)
            {
                //Une seule trame suffit
                logger_Debug.Nombre_Carateres = (byte)str.Length;

                //Copie la string dans la structure du Logger
                str.CopyTo(0, logger_Debug.Text, 0, str.Length);

                //Ajoute un 0 de fin de chaine de caractere
                if (str.Length < Max_Char_per_Log - 1)
                {
                    logger_Debug.Text[str.Length] = (char)0;
                }

                //Copie la structure du Logger dans la trame à envoyer
                trame_echange.Set_Data(logger_Debug);

                //Ajoute cette trame à la liste des trames à envoyer
                List_trame_echange.Add(trame_echange);

                return(List_trame_echange);
            }
            else
            {
                //Plusieurs trames serront necessaires
            }
            return(List_trame_echange);
        }