public void LogData(Message completedMessage)
        {
            String message;

            MessageFormat format = GetMessageFormat(completedMessage.IdHigh, completedMessage.IdLow);

            if (format == null)
            {
                message = completedMessage.ToString();
            }
            else
            {
                message = completedMessage.GetTimestamp() + format.Name;
                if (completedMessage.Data == null || completedMessage.Data.Length == format.Length)
                {
                    String formattedString = FormatParser.Parse(format.FormatString, completedMessage.Data);      // if data length == 0, this can still return string via external program

                    if (formattedString != null && formattedString.Length != 0)
                    {
                        message += ":  " + formattedString;
                    }
                }
                else
                {
                    message += ":  Message Format Does Not Match Data Length";
                }
            }

            recordedMessages.Add(message);

            if (cmbViews.SelectedItem.ToString().Equals(ALL_MESSAGES) || message.Contains(cmbViews.SelectedItem.ToString()))
            {
                if (listBoxOneSelected)
                {
                    lstDisplayWindowOne.Items.Add(message);
                    lstDisplayWindowOne.SelectedIndex = lstDisplayWindowOne.Items.Count - 1;
                }
                else
                {
                    lstDisplayWindowTwo.Items.Add(message);
                    lstDisplayWindowTwo.SelectedIndex = lstDisplayWindowTwo.Items.Count - 1;
                }
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int index = lstMessageSummary.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            MessageFormat mf = (MessageFormat)lstMessageSummary.Items[index];

            if (companyMessages.Contains(mf))
            {
                return;
            }

            addLocalMessageForm = new AddMessageForm(this, MessageType.Local, index);
            addLocalMessageForm.ShowDialog();
        }
Пример #3
0
        /// <summary>
        /// Reads the message table into a list of objects.
        /// </summary>
        /// <returns>Returns a list of Message objects.</returns>
        public List <MessageFormat> GetMessageList()
        {
            List <MessageFormat> messages = new List <MessageFormat>();

            try
            {
                conn.Open();
                cmd    = new SqlCommand("SELECT id, version_major, version_minor, name, id_high, id_low, length, format FROM " + table, conn);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    string line = safeRead(reader, "id") + "," +
                                  ((byte[])safeRead(reader, "version_major"))[0].ToString() + "," +
                                  ((byte[])safeRead(reader, "version_minor"))[0].ToString() + "," +
                                  safeRead(reader, "name") + "," +
                                  ((byte[])safeRead(reader, "id_high"))[0].ToString() + "," +
                                  ((byte[])safeRead(reader, "id_low"))[0].ToString() + "," +
                                  ((byte[])safeRead(reader, "length"))[0].ToString() + "," +
                                  safeRead(reader, "format");

                    MessageFormat m = new MessageFormat();

                    m.FromCSVString(line);
                    messages.Add(m);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
                cmd    = null;
                reader = null;
            }

            return(messages);
        }
        private void btnRemove_Click(object sender, EventArgs e)
        {
            int index = lstMessageSummary.SelectedIndex;

            if (index < 0)
            {
                return;
            }


            MessageFormat mf = (MessageFormat)lstMessageSummary.Items[index];

            if (mf.IdHigh >= 0x80)
            {
                MessageBox.Show("You cannot remove company messages.");
                return;
            }
            RemoveMessageFormat(index);
        }
        public void AddMessageFormat(MessageFormat messageFormat, MessageType type)
        {
            if (type == MessageType.Company)
            {
                companyMessages.Add(messageFormat);
            }
            else
            {
                localMessages.Add(messageFormat);
            }

            lstMessageSummary.Items.Add(messageFormat);
            lstMessageSummary.SelectedIndex = lstMessageSummary.Items.Count - 1;
            cmbViews.Items.Add(messageFormat.Name);
            //bool allSelected = cmbViews.SelectedItem.ToString().Equals(ALL_MESSAGES);
            //cmbViews.Items.Remove(ALL_MESSAGES);
            //cmbViews.Items.Insert(0,ALL_MESSAGES);
            //if (allSelected)
            //     cmbViews.SelectedItem = ALL_MESSAGES;
        }
        /// <summary>
        /// Reads the message table into a list of objects.
        /// </summary>
        /// <returns>Returns a list of Message objects.</returns>
        public List<MessageFormat> GetMessageList()
        {
            List<MessageFormat> messages = new List<MessageFormat>();
            try
            {
                conn.Open();
                cmd = new SqlCommand("SELECT id, version_major, version_minor, name, id_high, id_low, length, format FROM " + table, conn);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    string line = safeRead(reader, "id") + "," +
                        ((byte[])safeRead(reader, "version_major"))[0].ToString() + "," +
                        ((byte[])safeRead(reader, "version_minor"))[0].ToString() + "," +
                        safeRead(reader, "name") + "," +
                        ((byte[])safeRead(reader, "id_high"))[0].ToString() + "," +
                        ((byte[])safeRead(reader, "id_low"))[0].ToString() + "," +
                        ((byte[])safeRead(reader, "length"))[0].ToString() + "," +
                        safeRead(reader, "format");

                    MessageFormat m = new MessageFormat();

                    m.FromCSVString(line);
                    messages.Add(m);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                if (conn!=null)
                    conn.Close();
                cmd = null;
                reader = null;
            }

            return messages;
        }
Пример #7
0
        public bool RemoveMessageFormat(MessageFormat messageFormat)
        {
            bool flag = false;

            if (localMessages.Remove(messageFormat))
            {
                flag = true;
            }
            if (IsAdministrator)
            {
                if (companyMessages.Remove(messageFormat))
                {
                    flag = true;
                }
            }

            if (flag)
            {
                lstMessageSummary.Items.Remove(messageFormat);
                totalNumberOfMessages--;
            }

            return(flag);
        }
        /// <summary>
        /// Writes the values of a Message object to the database in a new row.
        /// </summary>
        /// <param name="message">Message object to write from.</param>
        /// <returns>Returns true on success.</returns>
        public bool Write(MessageFormat message)
        {
            bool flag = true;
            try
            {
                conn.Open();
                cmd = new SqlCommand("INSERT INTO " + table + " (version_major, version_minor, name, id_high, id_low, length, format) " +
                    "VALUES (@version_major, @version_minor, @name, @id_high, @id_low, @length, @format)", conn);

                cmd.Parameters.AddWithValue("version_major", message.VersionMajor);
                cmd.Parameters.AddWithValue("version_minor", message.VersionMinor);
                cmd.Parameters.AddWithValue("name", message.Name);
                cmd.Parameters.AddWithValue("id_high", message.IdHigh);
                cmd.Parameters.AddWithValue("id_low", message.IdLow);
                cmd.Parameters.AddWithValue("length", message.Length);
                cmd.Parameters.AddWithValue("format", message.FormatString);

                flag = (cmd.ExecuteNonQuery() > 0);

            }
            catch (Exception e)
            {
                flag = false;
                Console.WriteLine(e.ToString());
            }
            finally
            {
                conn.Close();
                cmd = null;
            }
            return flag;
        }
 public bool Remove(MessageFormat m)
 {
     return Remove(m.Id);
 }
Пример #10
0
 public bool Remove(MessageFormat m)
 {
     return(Remove(m.Id));
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            lblNameError2.Visible = false;
            lblIdError3.Visible   = false;
            error = false;
            txtName_check(sender, e);
            txtID_check(sender, e);
            txtLength_check(sender, e);
            if (error == true)
            {
                return;
            }
            ID = ushort.Parse(txtID.Text, System.Globalization.NumberStyles.HexNumber);
            byte[] versionBytes = BitConverter.GetBytes(MainForm.SOFTWARE_VERSION);
            byte[] IdBytes      = BitConverter.GetBytes(ID);

            for (int i = 0; i < parentForm.GetMessagesCount(msgType); i++)
            {
                if (i == editIndex)
                {
                    continue;
                }

                if ((IdBytes[1] == parentForm.GetMessageHighByte(i, msgType)) && (IdBytes[0] == parentForm.GetMessageLowByte(i, msgType)))
                {
                    lblIdError3.Visible = true;
                    error = true;
                }
                if (txtName.Text.Trim() == parentForm.GetMessageName(i, msgType))
                {
                    lblNameError2.Visible = true;
                    error = true;
                }
            }
            if (error == true)
            {
                return;
            }

            if (cmbFormatType.SelectedIndex == 0)
            {
                txtFormat.Text = "* " + cmbUniformGroup.Text + " " + Format.getTokenString(cmbUniformFormat.Text);
                if (cmbUniformFormat.Text == "decimal")
                {
                    if (cmbUniformSigned.Text == "unsigned")
                    {
                        txtFormat.Text = "* " + cmbUniformGroup.Text + " " + Format.getTokenString("unsigned");
                    }
                }


                if (txtFormat.Text == "* 1 h")
                {
                    txtFormat.Text = "%"; //slight optimization, the parser will skip some extra work
                }
            }
            else if (cmbFormatType.SelectedIndex == 1)
            {
                if ((bytes - bytes_used) < 0)
                {
                    lblCustomError.Visible = true;
                    return;
                }
                else
                {
                    lblCustomError.Visible = false;
                }
                foreach (FormatLine f in lstFormats.Items)
                {
                    txtFormat.Text += f.ToFormatString();
                }
            }
            else if (cmbFormatType.SelectedIndex == 2)
            {
                txtFormat.Text = "call " + txtExternalFile.Text;
            }

            MessageFormat message = new MessageFormat(
                versionBytes[1],
                versionBytes[0],
                IdBytes[1],
                IdBytes[0],
                Byte.Parse(txtLength.Text, System.Globalization.NumberStyles.HexNumber),
                txtName.Text.Trim(),
                txtFormat.Text);

            if (msgType == MessageType.Company)
            {
                if (cmbConnections.SelectedIndex < 0)
                {
                    lblCompanyError1.Visible = true;
                    return;
                }
                else
                {
                    lblCompanyError1.Visible = false;
                }
                Connection           c   = (Connection)cmbConnections.Items[cmbConnections.SelectedIndex];
                SqlMessageConnection sql = new SqlMessageConnection(c.connection);
                if (sql.Write(message) == false)
                {
                    lblCompanyError2.Visible = true;
                    return;
                }
                else
                {
                    lblCompanyError2.Visible = false;
                }
            }
            if (editIndex > -1)
            {
                parentForm.RemoveMessageFormat(editIndex);
            }
            parentForm.AddMessageFormat(message, msgType);
            this.Visible = false;
        }
Пример #12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < parentForm.GetMessagesCount(msgType); i++)
            {
                if ((Byte.Parse(txtID1.Text, System.Globalization.NumberStyles.HexNumber) == parentForm.GetMessageHighByte(i, msgType)) && (Byte.Parse(txtID2.Text, System.Globalization.NumberStyles.HexNumber) == parentForm.GetMessageLowByte(i, msgType)))
                {
                    MessageBox.Show("Message ID already exists", "Duplicate ID", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
                if (txtName.Text == parentForm.GetMessageName(i, msgType))
                {
                    MessageBox.Show("Message name already exists", "Duplicate name", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }

            if (cmbFormatType.SelectedIndex == 0)
            {
                txtFormat.Text += "g * " + cmbUniformGroup.Text + " " + Format.getTokenString(cmbUniformFormat.Text);

                if (txtFormat.Text == "g * 1 h")
                {
                    txtFormat.Text = "%"; //slight optimization, the parser will skip some extra work
                }
            }
            else if (cmbFormatType.SelectedIndex == 1)
            {
                foreach (FormatLine f in lstFormats.Items)
                {
                    txtFormat.Text += f.ToFormatString();
                }
            }
            else if (cmbFormatType.SelectedIndex == 2)
            {
                txtFormat.Text = "call " + txtExternalFile.Text;
            }

            parentForm.PrintStatusMessage("Format string: " + txtFormat.Text);
            MessageFormat message = new MessageFormat(
                Byte.Parse(txtVersion1.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtVersion2.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtID1.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtID2.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtLength.Text, System.Globalization.NumberStyles.HexNumber),
                txtName.Text,
                txtFormat.Text);

            if (msgType == MessageType.Company)
            {
                if (cmbConnections.SelectedIndex < 0)
                {
                    MessageBox.Show("Please select a database connection.", "Company message failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
                Connection           c   = (Connection)cmbConnections.Items[cmbConnections.SelectedIndex];
                SqlMessageConnection sql = new SqlMessageConnection(c.connection);
                if (sql.Write(message) == false)
                {
                    MessageBox.Show("Company message failed", "Company message failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
                MessageBox.Show("Company message created", "Company message created", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                MessageBox.Show("Local message created", "Local message created", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            parentForm.AddMessageFormat(message, msgType);
            this.Visible = false;
            reset();
        }
        public bool RemoveMessageFormat(MessageFormat messageFormat)
        {
            bool flag = false;

              if (localMessages.Remove(messageFormat))
                  flag = true;
              if (IsAdministrator)
                  if (companyMessages.Remove(messageFormat))
                      flag = true;

              if (flag)
              {
                  lstMessageSummary.Items.Remove(messageFormat);
                  totalNumberOfMessages--;
              }

              return flag;
        }
        public void AddMessageFormat(MessageFormat messageFormat, MessageType type)
        {
            if (type == MessageType.Company)
                    companyMessages.Add(messageFormat);
               else
                    localMessages.Add(messageFormat);

               lstMessageSummary.Items.Add(messageFormat);
               lstMessageSummary.SelectedIndex = lstMessageSummary.Items.Count-1;
               cmbViews.Items.Add(messageFormat.Name);
               //bool allSelected = cmbViews.SelectedItem.ToString().Equals(ALL_MESSAGES);
               //cmbViews.Items.Remove(ALL_MESSAGES);
               //cmbViews.Items.Insert(0,ALL_MESSAGES);
               //if (allSelected)
               //     cmbViews.SelectedItem = ALL_MESSAGES;
        }
        private void Edit(int index)
        {
            MessageFormat m = null;

            if (index < 0)
            {
                return;
            }
            m = parentForm.GetMessageFormat(index);

            txtLength.Text = m.Length.ToString("X");
            txtName.Text   = m.Name;
            byte[] id = { m.IdHigh, m.IdLow };
            try { txtID.Text = ushort.Parse(Format.AsUnsignedDecimal(id)).ToString("X"); }
            catch { }
            if (m.FormatString == "%" || m.FormatString == "")
            {
                return;
            }

            string[] tokens = m.FormatString.Split(' ');

            if (tokens.Length < 2)
            {
                return;
            }

            if (tokens[0] == "call")
            {
                cmbFormatType.SelectedIndex = 2;
                txtExternalFile.Text        = tokens[1];
            }
            else if (tokens[0] == "*")
            {
                cmbFormatType.SelectedIndex = 0;
                try { int.Parse(tokens[1]); cmbUniformGroup.Text = tokens[1]; }
                catch { }
                switch (tokens[2])
                {
                case "b":
                    cmbUniformFormat.Text = "binary";
                    break;

                case "h":
                    cmbUniformFormat.Text = "hex";
                    break;

                case "d":
                    cmbUniformFormat.Text = "decimal";
                    cmbUniformSigned.Text = "signed";
                    break;

                case "u":
                    cmbUniformFormat.Text = "decimal";
                    cmbUniformSigned.Text = "unsigned";
                    break;
                }
            }
            else
            {
                cmbFormatType.SelectedIndex = 1;

                string formatline = "";
                for (int i = 0; i < tokens.Length; i++)
                {
                    formatline += tokens[i] + " ";
                    if (i % 3 == 2)
                    {
                        formatline = formatline.Trim();
                        FormatLine f = new FormatLine(formatline);
                        bytes_used += f.getSize();
                        lstFormats.Items.Add(f);
                        formatline = "";
                    }
                }
            }
            UpdateControls();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            lblNameError2.Visible = false;
            lblIdError3.Visible = false;
            error = false;
            txtName_check(sender, e);
            txtID_check(sender, e);
            txtLength_check(sender, e);
            if (error == true)
                return;
            ID = ushort.Parse(txtID.Text, System.Globalization.NumberStyles.HexNumber);
            byte[] versionBytes = BitConverter.GetBytes(MainForm.SOFTWARE_VERSION);
            byte[] IdBytes = BitConverter.GetBytes(ID);

            for (int i = 0; i < parentForm.GetMessagesCount(msgType); i++)
            {
                if (i == editIndex)
                    continue;

                if ((IdBytes[1] == parentForm.GetMessageHighByte(i, msgType)) && (IdBytes[0] == parentForm.GetMessageLowByte(i, msgType)))
                {
                    lblIdError3.Visible = true;
                    error = true;
                }
                if (txtName.Text.Trim() == parentForm.GetMessageName(i, msgType))
                {
                    lblNameError2.Visible = true;
                    error = true;
                }
            }
            if (error == true)
                return;

            if (cmbFormatType.SelectedIndex == 0)
            {
                txtFormat.Text = "* " + cmbUniformGroup.Text + " " + Format.getTokenString(cmbUniformFormat.Text);
                if (cmbUniformFormat.Text == "decimal")
                    if (cmbUniformSigned.Text == "unsigned")
                        txtFormat.Text = "* " + cmbUniformGroup.Text + " " + Format.getTokenString("unsigned");

                if (txtFormat.Text == "* 1 h")
                    txtFormat.Text = "%"; //slight optimization, the parser will skip some extra work
            }
            else if (cmbFormatType.SelectedIndex == 1)
            {
                if ((bytes - bytes_used) < 0)
                {
                    lblCustomError.Visible = true;
                    return;
                }
                else
                    lblCustomError.Visible = false;
                foreach (FormatLine f in lstFormats.Items)
                    txtFormat.Text += f.ToFormatString();
            }
            else if (cmbFormatType.SelectedIndex == 2)
            {
                txtFormat.Text = "call " + txtExternalFile.Text;
            }

            MessageFormat message = new MessageFormat(
                versionBytes[1],
                versionBytes[0],
                IdBytes[1],
                IdBytes[0],
                Byte.Parse(txtLength.Text, System.Globalization.NumberStyles.HexNumber),
                txtName.Text.Trim(),
                txtFormat.Text);

            if (msgType == MessageType.Company)
            {
                if (cmbConnections.SelectedIndex < 0)
                {
                    lblCompanyError1.Visible = true;
                    return;
                }
                else
                    lblCompanyError1.Visible = false;
                Connection c = (Connection)cmbConnections.Items[cmbConnections.SelectedIndex];
                SqlMessageConnection sql = new SqlMessageConnection(c.connection);
                if (sql.Write(message) == false)
                {
                    lblCompanyError2.Visible = true;
                    return;
                }
                else
                    lblCompanyError2.Visible = false;
            }
            if (editIndex > -1)
                parentForm.RemoveMessageFormat(editIndex);
            parentForm.AddMessageFormat(message, msgType);
            this.Visible = false;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < parentForm.GetMessagesCount(msgType); i++)
            {
                if ((Byte.Parse(txtID1.Text, System.Globalization.NumberStyles.HexNumber) == parentForm.GetMessageHighByte(i, msgType)) && (Byte.Parse(txtID2.Text, System.Globalization.NumberStyles.HexNumber) == parentForm.GetMessageLowByte(i, msgType)))
                {
                    MessageBox.Show("Message ID already exists", "Duplicate ID", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
             if (txtName.Text == parentForm.GetMessageName(i, msgType))
                {
                    MessageBox.Show("Message name already exists", "Duplicate name", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }

            if (cmbFormatType.SelectedIndex == 0)
            {
                txtFormat.Text += "g * " + cmbUniformGroup.Text + " " + Format.getTokenString(cmbUniformFormat.Text);

                if (txtFormat.Text == "g * 1 h")
                    txtFormat.Text = "%"; //slight optimization, the parser will skip some extra work
            }
            else if (cmbFormatType.SelectedIndex == 1)
            {
                foreach (FormatLine f in lstFormats.Items)
                    txtFormat.Text += f.ToFormatString();
            }
            else if (cmbFormatType.SelectedIndex == 2)
            {
                txtFormat.Text = "call " + txtExternalFile.Text;
            }

            parentForm.PrintStatusMessage("Format string: " + txtFormat.Text);
            MessageFormat message = new MessageFormat(
                Byte.Parse(txtVersion1.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtVersion2.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtID1.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtID2.Text, System.Globalization.NumberStyles.HexNumber),
                Byte.Parse(txtLength.Text, System.Globalization.NumberStyles.HexNumber),
                txtName.Text,
                txtFormat.Text);

            if (msgType == MessageType.Company)
            {
                if (cmbConnections.SelectedIndex < 0)
                {
                    MessageBox.Show("Please select a database connection.", "Company message failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
                Connection c = (Connection)cmbConnections.Items[cmbConnections.SelectedIndex];
                SqlMessageConnection sql = new SqlMessageConnection(c.connection);
                if (sql.Write(message) == false)
                {
                    MessageBox.Show("Company message failed", "Company message failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
                MessageBox.Show("Company message created", "Company message created", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                MessageBox.Show("Local message created", "Local message created", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            parentForm.AddMessageFormat(message, msgType);
            this.Visible = false;
            reset();
        }
        public bool RemoveMessageFormat(MessageFormat messageFormat)
        {
            bool flag = false;

               if (cmbViews.SelectedItem.ToString().Equals(messageFormat.Name))
               {
                    cmbViews.SelectedItem = ALL_MESSAGES;
               }

               if (localMessages.Remove(messageFormat))
               {
                    flag = true;
               }
               else if (IsAdministrator)
               {
                    if (companyMessages.Remove(messageFormat))
                         flag = true;
               }

               if (flag)
               {
                    lstMessageSummary.Items.Remove(messageFormat);
                    cmbViews.Items.Remove(messageFormat.Name);
               }

               return flag;
        }
        public void AddMessageFormat(MessageFormat messageFormat, MessageType type)
        {
            if (type == MessageType.Company)
                    companyMessages.Add(messageFormat);
               else
                    localMessages.Add(messageFormat);

               lstMessageSummary.Items.Add(messageFormat);
               lstMessageSummary.SelectedIndex = totalNumberOfMessages;
               totalNumberOfMessages++;
        }