using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace arinc_1553_CSharpGUI
{
    public class MajorFrame
    {
        /* List of messages that are in this major frame */
        public List<Msg1553> msgs = new List<Msg1553>();

        /* The minor frames contained within this major frame */
        public List<MinorFrame> minorFrames = new List<MinorFrame>();

        /* Frequency of minor frame in milliseconds */
        public ushort minorFramePeriod;

        /* If the retry should be on same or alternative bus */
        public string retryType;

        /**
         * @brief This function searches for and returns a pointer to the message object in the message
         *          list whose name matches that passed as argument to this function.
         * @param msgName The name of the message to match
         * @return A pointer to the matched message object
         */
        public bool FindMessageInList(string msgName, ref Msg1553 pMsg)
        {
            /* Travers through the message list and look for a message with the name as in
             * msgName argument */
            foreach (Msg1553 msg in msgs)
            {
                if (msg.name == msgName)
                {
                    /* Found it! Stop search and return this message pointer */
                    pMsg = msg;
                    return true;
                }
            }

            pMsg = null;
            return false;
        }

    }
}
