Example #1
0
        /*
         * Once a database is loaded, this method will be called
         * to add all the messages to the ComboBox.
         */
        public List <Message> LoadMessages()
        {
            Kvadblib.MessageHnd mh;
            Kvadblib.Status     status;
            Kvadblib.NodeHnd    nh;

            List <Message> messages = new List <Message>();

            status = Kvadblib.GetFirstMsg(dh, out mh);
            while (status == Kvadblib.Status.OK)
            {
                string           name;
                int              id;
                int              dlc;
                string           nodeName;
                Kvadblib.MESSAGE flags;
                status = Kvadblib.GetMsgName(mh, out name);
                status = Kvadblib.GetMsgId(mh, out id, out flags);
                status = Kvadblib.GetMsgDlc(mh, out dlc);
                status = Kvadblib.GetMsgSendNode(mh, out nh);
                status = Kvadblib.GetNodeName(nh, out nodeName);

                Kvadblib.AttributeHnd ah;
                int attEunmVal = 8;
                status = Kvadblib.GetAttributeByName(dh, "GenMsgSendType", out ah);    //获取ah用于存储对应message的ah
                status = Kvadblib.GetMsgAttributeByName(mh, "GenMsgSendType", ref ah); //获取对应message的attribute信息
                Kvadblib.GetAttributeValueEnumeration(ah, out attEunmVal);

                int GenMsgCycleTime = 0;
                status = Kvadblib.GetAttributeByName(dh, "GenMsgCycleTime", out ah);    //获取ah用于存储对应message的ah
                status = Kvadblib.GetMsgAttributeByName(mh, "GenMsgCycleTime", ref ah); //获取对应message的attribute信息
                Kvadblib.GetAttributeValueInt(ah, out GenMsgCycleTime);


                Message message = new Message();
                message.id              = id;
                message.name            = name;
                message.dlc             = dlc;
                message.tx_node         = nodeName;
                message.GenMsgSendType  = this.GenMsgSendType[attEunmVal];
                message.GenMsgCycleTime = GenMsgCycleTime;
                message.CycleCount      = 0;

                messages.Add(message);


                status = Kvadblib.GetNextMsg(dh, out mh);
            }
            return(messages);
        }