Exemple #1
0
 /// <summary>
 /// Färbt Zeilen (und Zellen) entsprechend ein. muss immer am Ende der <see cref="addVisualMethod">addVisualMethod</see> aufgerufen werden.
 /// </summary>
 private void colorRows()
 {
     for (int i = 1; i < dgv.RowCount - 1; i++)
     {
         M3sLogFrame frame = (M3sLogFrame)(base[i]);
         if (frame.IsFrame)
         {
             dgv.Rows[i].DefaultCellStyle.BackColor = protocolCol[(int)(frame.ValidFrame.Protocol)];
         }
         else
         {
             // Color Interference
         }
     }
 }
Exemple #2
0
        // TODO: Update if Resetframe is detected... Visual problem
        public override int Add(object value)
        {
            int addedAt = -1;

            byte[] test = value as byte[];

            M3sLogFrame loggedFrame;

            loggedFrame = new M3sLogFrame(value);             // Loggframe erzeugen

            // Sonderfall Resetframe
            if (loggedFrame.IsFrame)
            {
                if (loggedFrame.ValidFrame.Protocol == M3SProtocol.Reset)
                {
                    if (base.Count > 0)
                    {
                        M3sLogFrame lastFrame = base[base.Count - 1] as M3sLogFrame;
                        if (lastFrame.IsFrame)
                        {
                            if (lastFrame.ValidFrame.Protocol == M3SProtocol.Reset)
                            {
                                lastFrame.ResetCounter++;


                                return(base.Count - 1);
                            }
                        }
                    }
                }
            }

            addedAt = base.Add(loggedFrame);            // In Liste aufnehmen...

            visualize(addedAt);                         // Hinzufügen im Datagridview...
            return(addedAt);
        }
Exemple #3
0
        // TODO: Update if Resetframe is detected... Visual problem
        public override int Add(object value)
        {
            int addedAt = -1;

            byte[] test = value as byte[];

            M3sLogFrame loggedFrame;
            loggedFrame = new M3sLogFrame(value); // Loggframe erzeugen

            // Sonderfall Resetframe
            if(loggedFrame.IsFrame)
            {
                if(loggedFrame.ValidFrame.Protocol == M3SProtocol.Reset)
                {
                    if(base.Count > 0)
                    {
                        M3sLogFrame lastFrame = base[base.Count-1] as M3sLogFrame;
                        if(lastFrame.IsFrame)
                        {
                            if(lastFrame.ValidFrame.Protocol == M3SProtocol.Reset)
                            {
                                lastFrame.ResetCounter++;

                                return base.Count-1;
                            }
                        }
                    }
                }
            }

            addedAt =  base.Add(loggedFrame);	// In Liste aufnehmen...

            visualize(addedAt);		// Hinzufügen im Datagridview...
            return(addedAt);
        }
Exemple #4
0
        /// <summary>
        /// Fügt eine Zeile zum Datagridview hinzu. Diese Methode soll nur Threadsicher aufgerufen werden!
        /// </summary>
        /// <param name="vPosition">Position in Liste, die hinzugefügt werden soll</param>
        private void addVisualMethod(int vPosition)
        {
            /*
             * dgv.Columns[0].Name = "No.";
             *      dgv.Columns[1].Name = "Time";
             *      dgv.Columns[2].Name = "DDR";
             *      dgv.Columns[3].Name = "Master";
             *      dgv.Columns[4].Name = "Slave";
             *      dgv.Columns[5].Name = "Protocol";
             *      dgv.Columns[6].Name = "Info / Details";
             * */

            M3sLogFrame frame = base[vPosition] as M3sLogFrame;

            string[] rowToAdd = new string[dgv.ColumnCount];
            rowToAdd[0] = vPosition.ToString();
            rowToAdd[1] = frame.LogTime.ToString("HH:mm");
            rowToAdd[2] = "x";
            rowToAdd[fieldIdxSender] = rowToAdd[fieldIdxReceiver] = "";             // empty


            if (frame.IsFrame)
            {
                rowToAdd[fieldIdxReceiver] = frame.ValidFrame.SlaveAddress.ToString();
                rowToAdd[fieldIdxSender]   = frame.ValidFrame.MasterAddress.ToString();
                rowToAdd[5] = frame.ValidFrame.InfoProtocolAcrynonym.ToString();


                if (frame.ValidFrame.Protocol == M3SProtocol.Reset)
                {
                    if (frame.ResetCounter > 0)
                    {
                        rowToAdd[6] = "[SEQUENCE of " + frame.ResetCounter.ToString() + " frames] ";
                    }
                    else
                    {
                        rowToAdd[6] = "";
                    }
                }
                else
                {
                    rowToAdd[6] = "";
                }

                rowToAdd[6] += frame.ValidFrame.GetInterpretation();
            }
            else
            {
                rowToAdd[5] = "Intfrce";
                rowToAdd[6] = frame.Hexdump;
            }



            dgv.Rows.Add(rowToAdd);

            colorRows();
            dgv.FirstDisplayedScrollingRowIndex = vPosition;                    // Etwas hässliche notation, aber scrollt ganz nach unten...

            dgv.Refresh();
        }