예제 #1
0
        /*---------------------------------------------------------------------------------------------------*/
        public void toFilter()
        {
            int nDigit = Convert.ToInt32(Math.Floor(DIGIT + 0.6));

            for (int i = 0; i < prevStatus.Count; i++)
            {
                CONTINUOUSID ctID = continousIDs.Find(x => x.obj.ID.Equals(prevStatus[i].ID));
                if (ctID == null)
                {
                    continue;
                }

                CAN_OBJ prevObj = prevStatus[i];
                CAN_OBJ nextObj = nextStatus.Find(x => x.ID.Equals(prevObj.ID));
                if (nextObj == null)
                {
                    continue;
                }

                int d;
                for (d = 0; d <= prevObj.DataLen - nDigit; d++)
                {
                    int idIndexIndex = ctID.indexs.FindIndex(x => x.Equals(d));
                    if (idIndexIndex == -1)
                    {
                        continue;
                    }

                    Int64 prev = 0, next = 0;
                    prev = jointValue(prevObj, d, nDigit, ENDIAN);
                    next = jointValue(nextObj, d, nDigit, ENDIAN);

                    if (DIGIT == 1.5)
                    {
                        prev = prev & 0x0FFF;
                        next = next & 0x0FFF;
                    }

                    //不正确
                    if ((next - prev) * TREND <= 0)
                    {
                        ctID.indexs.RemoveAt(idIndexIndex);
                    }
                }

                //删除后续的索引!
                for (; d < prevObj.DataLen; d++)
                {
                    int idIndexIndex = ctID.indexs.FindIndex(x => x.Equals(d));
                    if (idIndexIndex == -1)
                    {
                        continue;
                    }
                    ctID.indexs.RemoveAt(idIndexIndex);
                }
            }

            //删除多余ID
            removeIndexListNone();
        }
예제 #2
0
 public CAN_OBJ(CAN_OBJ canObj)
 {
     ID         = canObj.ID;
     RemoteFlag = canObj.RemoteFlag;
     ExternFlag = canObj.ExternFlag;
     DataLen    = canObj.DataLen;
     for (int i = 0; i < 8; i++)
     {
         Data[i] = canObj.Data[i];
     }
 }
예제 #3
0
        public DISCRETEID(CAN_OBJ canObj)
        {
            obj.ID         = canObj.ID;
            obj.DataLen    = canObj.DataLen;
            obj.ExternFlag = canObj.ExternFlag;
            obj.RemoteFlag = canObj.RemoteFlag;

            idIndexs.Clear();
            for (int i = 0; i < obj.DataLen * 2; i++)
            {
                idIndexs.Add(new DISCRETEIDINDEX(i));
            }
        }
예제 #4
0
        public CONTINUOUSID(CAN_OBJ canObj)
        {
            obj.ID         = canObj.ID;
            obj.DataLen    = canObj.DataLen;
            obj.ExternFlag = canObj.ExternFlag;
            obj.RemoteFlag = canObj.RemoteFlag;

            indexs.Clear();
            for (int i = 0; i < obj.DataLen; i++)
            {
                indexs.Add(i);
            }
        }
예제 #5
0
        /*---------------------------------------------------------------------------------------------------*/
        unsafe public void saveData(ref VCI_CAN_OBJ canObj)
        {
            CAN_OBJ obj = new CAN_OBJ();

            obj.ID         = canObj.ID;
            obj.DataLen    = canObj.DataLen;
            obj.ExternFlag = canObj.ExternFlag;
            obj.RemoteFlag = canObj.RemoteFlag;
            for (int i = 0; i < 8; i++)
            {
                obj.Data[i] = canObj.Data[i];
            }

            canSet.Add(obj);
        }
        unsafe void getRawPacket(ref VCI_CAN_OBJ canObj)
        {
            if (canObj.ID >= 0x7E8)
            {
                hasGetUds = true;
            }

            CAN_OBJ obj = new CAN_OBJ();

            obj.ID         = canObj.ID;
            obj.RemoteFlag = canObj.RemoteFlag;
            obj.ExternFlag = canObj.ExternFlag;
            obj.DataLen    = canObj.DataLen;
            for (int i = 0; i < 8; i++)
            {
                obj.Data[i] = canObj.Data[i];
            }

            rawPacket.Add(obj);
        }
        void readDataPacket(string path)
        {
            dataPacket.Clear();

            StreamReader sr   = new StreamReader(path);
            string       line = null;

            while ((line = sr.ReadLine()) != null)
            {
                string[] arr = line.Split(' ');
                CAN_OBJ  can = new CAN_OBJ();
                can.ID      = Convert.ToUInt32(arr[0], 16);
                can.DataLen = Convert.ToByte(arr[1]);

                for (int d = 2; d < arr.Length - 1 && d < 10; d++)
                {
                    can.Data[d - 2] = Convert.ToByte(arr[d], 16);
                }

                dataPacket.Add(can);
            }
            sr.Close();
        }
예제 #8
0
        /*---------------------------------------------------------------------------------------------------*/
        Int64 jointValue(CAN_OBJ obj, int start, int digit, int endian)
        {
            Int64 val = 0;

            //大端序
            if (endian == 0)
            {
                for (int d = 0; d < digit; d++)
                {
                    val <<= 8;
                    val  += obj.Data[start + d];
                }
            }
            else
            {
                for (int d = 0; d < digit; d++)
                {
                    val <<= 8;
                    val  += obj.Data[start + digit - d - 1];
                }
            }
            return(val);
        }
        unsafe void fuzzingThread(object objParm)
        {
            FUZZINGPARM      parm = (FUZZINGPARM)objParm;
            Form_ProgressBar form = parm.form;
            CAN_OBJ          obj  = parm.obj;
            int  delay            = parm.delay;
            byte index            = parm.index;
            byte min = parm.min;
            byte max = parm.max;
            int  rep = parm.rep;

            parm.mrEvent.WaitOne();

            usbCAN.arrSendBuf[0].ID         = obj.ID;
            usbCAN.arrSendBuf[0].DataLen    = obj.DataLen;
            usbCAN.arrSendBuf[0].ExternFlag = obj.ExternFlag;
            usbCAN.arrSendBuf[0].RemoteFlag = obj.RemoteFlag;
            for (int d = 0; d < 8; d++)
            {
                usbCAN.arrSendBuf[0].Data[d] = obj.Data[d];
            }

            for (int i = min; i <= max; i++)
            {
                for (int t = 0; t < rep; t++)
                {
                    usbCAN.arrSendBuf[0].Data[index] = (byte)i;
                    usbCAN.sendFame(1);
                    Thread.Sleep(delay);
                }

                form.addValue();
            }

            form.returnResult = DialogResult.OK;
            form.Invoke(new Action(() => { form.Close(); }));
        }
예제 #10
0
        /*---------------------------------------------------------------------------------------------------*/
        public void countingStatus(int step)
        {
            List <CAN_OBJ> pList;

            if (step == 0)
            {
                pList = prevStatus;
            }
            else
            {
                pList = nextStatus;
            }

            pList.Clear();
            for (int i = canSet.Count - 1; i >= 0; i--)
            {
                CAN_OBJ canObj = pList.Find(x => x.ID.Equals(canSet[i].ID));
                if (canObj == null)
                {
                    pList.Add(new CAN_OBJ(canSet[i]));
                }
            }

            /*******************************************************
            *  for (int i = 0; i < canSet.Count; i++)
            *  {
            *   CAN_OBJ canObj = pList.Find(x => x.ID.Equals(canSet[i].ID) );
            *   if (canObj == null)
            *       pList.Add(new CAN_OBJ(canSet[i]));
            *   else
            *   {
            *       for (int d = 0; d < 8; d++)
            *           canObj.Data[d] = canSet[i].Data[d];
            *   }
            *  }
            *******************************************************/
        }
예제 #11
0
        double jointValue(CAN_OBJ obj, int start, int digit, int endian)
        {
            double val = 0;

            //大端序
            if (endian == 0)
            {
                for (int d = 0; d < digit; d++)
                {
                    val *= 256;
                    val += obj.Data[start + d];
                }
            }
            else
            {
                for (int d = 0; d < digit; d++)
                {
                    val *= 256;
                    val += obj.Data[start + digit - d - 1];
                }
            }

            return(val);
        }
예제 #12
0
        void countFramePoint(List <CAN_OBJ> dataPacket, UDSServiceFormat udsReq)
        {
            for (int i = 1; i < udsFrameIndex.Count - 1; i++)
            {
                int prevIndex = udsFrameIndex[i - 1];
                int index     = udsFrameIndex[i];
                int nextIndex = udsFrameIndex[i + 1];

                //检验UDS是否正确
                CAN_OBJ udsFrame = dataPacket[index];
                int     valueIndex = 2, c;
                for (c = 0; c < udsReq.parameterList.Count; c++, valueIndex++)
                {
                    if (udsReq.parameterList[c] != udsFrame.Data[valueIndex])
                    {
                        break;
                    }
                }
                if (c < udsReq.parameterList.Count)
                {
                    continue;
                }

                //计算值
                float udsValue = 0;
                int   cnt      = udsFrame.Data[0] & 0x0f;
                for (int d = valueIndex; d <= cnt; d++)
                {
                    udsValue *= 256;
                    udsValue += udsFrame.Data[d];
                }

                int allIdCount;
                //找前面
                allIdCount = idClasses.Count;
                setNotFoundFramePoint();
                for (int p = index - 1; p > prevIndex && allIdCount > 0; p--)
                {
                    IDCLASS idClass = idClasses.Find(x => x.id.Equals(dataPacket[p].ID));
                    if (idClass.hasFoundFramePoint == false)
                    {
                        idClass.hasFoundFramePoint = true;
                        allIdCount--;
                        idClass.framePoints.Add(new FRAMEPOINT(dataPacket[p], udsValue));
                    }
                }

                //找后面
                allIdCount = idClasses.Count;
                setNotFoundFramePoint();
                for (int n = index + 1; n < nextIndex && allIdCount > 0; n++)
                {
                    IDCLASS idClass = idClasses.Find(x => x.id.Equals(dataPacket[n].ID));
                    if (idClass.hasFoundFramePoint == false)
                    {
                        idClass.hasFoundFramePoint = true;
                        allIdCount--;
                        idClass.framePoints.Add(new FRAMEPOINT(dataPacket[n], udsValue));
                    }
                }
            }
        }
예제 #13
0
 public FRAMEPOINT(CAN_OBJ x, double y)
 {
     frameX = x;
     lfY    = y;
 }