示例#1
0
        public void updateItem(canSendWorker item)
        {
            canMessage2 m   = item.Params.Message;
            var         row = getRow(item, true);

            row.Cells[m_colId.Index].Value   = m.Id.GetIdAsString();
            row.Cells[m_colData.Index].Value = m.GetDataString(" ");
        }
        private void btnStartStop_Click(object sender, EventArgs e)
        {
            if (!CanTool.IsCommunication)
            {
                return;
            }

            if (stage == scanStage.pause)
            {
                stage = scanStage.waitingForCanSleep;

                // id range
                idStart   = numIdFrom.Value;
                idStop    = numIdTo.Value;
                idCurrent = idStart;
                byte[] d = Tools.hexStringToByteArray(tbData.Text);

                if (d == null || d.Length == 0 || d.Length > canMessage.maxDataBytesNum())
                {
                    return;
                }

                // int only
                messageCountToSend = Convert.ToInt32(tbCount.Text, 10);
                butSleepTmo        = Convert.ToInt32(tbBusSleep.Text, 10);
                idCheckTmo         = Convert.ToInt32(tbIdCheck.Text, 10);

                message = new canMessage2((int)idCurrent, rb29BitId.Checked, d, 0);

                // trace
                if (!string.IsNullOrEmpty(tbTrace.Text))
                {
                    trace(Environment.NewLine);
                }

                trace(Environment.NewLine + string.Format("Scan from {0} to {1}",
                                                          canMessage.getCanIdString((int)idStart, rb29BitId.Checked),
                                                          canMessage.getCanIdString((int)idStop, rb29BitId.Checked)));
                trace(string.Format("DLC = {0}, Data = {1}",
                                    message.Id.GetDlcAsString(),
                                    message.GetDataString(" ")));
                trace("Waiting until the CAN bus is sleeping");

                worker      = new Thread(onWorker);
                worker.Name = "Wrk";
                worker.Start();
            }
            else
            {
                // stop
                stage = scanStage.pause;
                trace("Aborted");
            }

            guiStartStop();
        }
示例#3
0
 // constructor
 public gridMessage(canMessage2 msg)
 {
     // id
     Data = msg.GetDataString(" ");
     Id   = msg.Id;
     // data
     DataListBuff = new List <byte[]>();
     DataListBuff.Add(msg.Data);
     // period
     CanPeriod = null;
     // counter
     counter = 1;
 }
示例#4
0
        // update
        public void update(canMessage2 msg)
        {
            // debug
            // if ( msg.Id.GetHashCodeUnique() != Id.GetHashCodeUnique() )
            // {
            //     int err = 0;
            // }

            // data
            if (DataListBuff.Count < GridTipTool.MaxValues)
            {
                DataListBuff.Add(msg.Data);
            }

            // data string
            if (string.IsNullOrEmpty(Data))
            {
                Data = msg.GetDataString(" ");
            }

            counter++;
        }