Beispiel #1
0
        public gridBackLightMessage(gridRow msg, byte[] data, int period, int step)
        {
            // config
            Row    = msg;
            Period = period;
            Step   = step;

            // create the buffers
            Data = new byte[msg.Msg.Dlc];
            Ts   = new int[msg.Msg.Dlc];

            for (int i = 0; i < Ts.Length; i++)
            {
                Ts[i] = Period;         // backlight all the data

                if (i >= data.Length || i >= Data.Length)
                {
                    throw new System.ArgumentException("gridBackLightMessage error", "gridBackLightMessage");
                }
                else
                {
                    Data[i] = data[i];
                }
            }

            // reset the flag (it should by set by parent)
            BacklightFlag = false;
        }
Beispiel #2
0
        // add a new id and a row
        public void add(gridRow item)
        {
            var gr = find(item.Msg);

            if (null == gr)
            {
                dict.Add(item.Msg.GetHashCodeUnique(), item);
            }
        }
Beispiel #3
0
        // push a new message or update an existing one
        public void push(gridRow msg, List <byte[]> dataList)
        {
            long key    = msg.GetHashCodeUnique();
            bool exists = dict.ContainsKey(key);

            if (exists)
            {
                dict[key].update(dataList);
            }
            else
            {
                // create a new one
                gridBackLightMessage item =
                    new gridBackLightMessage(msg, dataList[dataList.Count - 1], BacklightFor, Interval);
                dict.Add(key, item);
            }

            // backlight it immideately
            DoBacklight(dict[key]);
        }
Beispiel #4
0
        // push a message list
        public void push(List <canMessage2> ls)
        {
            if (ls.Count == 0)
            {
                return;
            }

            bool doSortInTheEnd = false;
            // parse
            gridList parsed = Parser.Parse(ref ls);

            // handle
            foreach (gridMessage msg in parsed.List)
            {
                // the message can be empty if we had it before but not now
                if (msg.DataListBuff.Count == 0)
                {
                    continue;
                }

                // get all the data we need
                string   sId    = msg.Id.GetIdAsString();
                string   sDlc   = msg.Id.GetDlcAsString();
                string[] data   = msg.Data.Split(' ');
                int      count  = msg.Count;
                int      period = msg.Period;

                // get a row for the message
                DataGridViewRow row          = getMsgRow(msg.Id);
                bool            isRowEnabled = isRowChecked(row);

                // exist?
                // nope - we have a new message
                // yeap - just update it
                if (null == row)
                {
                    // add a new one
                    row            = addNewRow(sId, sDlc, data, period, count);
                    doSortInTheEnd = true;
                    isRowEnabled   = true;  // it's enabled now
                    // put the current message and the new row inside the row contaiter (for performance)
                    RowList.add(new gridRow(msg.Id, row));
                }
                else
                {
                    // update it
                    if (isRowEnabled)
                    {
                        updateRow(row, data, period, count);
                    }
                }

                // tools
                if (isRowEnabled)
                {
                    // get data for the row
                    gridRow gr = RowList.find(msg.Id);

                    if (use_tools)
                    {
                        // tool 1 - backlight
                        BacklightTool.push(gr, msg.DataListBuff);
                        // tool 2 - tips
                        GridTipTool.tipTextUpdate(row, m_colData.Index, msg.DataListBuff);
                    }
                }
            }

            // sort
            if (doSortInTheEnd)
            {
                doSort();
            }
        }