Ejemplo n.º 1
0
        // Operate NOT on each data
        public override bool Equals(object obj)
        {
            if (!this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            CANData cdobj = (CANData)obj;

            if (this.ID != cdobj.ID)
            {
                return(false);
            }
            if (this.getDataLen() != cdobj.getDataLen())
            {
                return(false);
            }
            int cmpSize = this.getDataLen();

            for (int i = 0; i < cmpSize; i++)
            {
                if (this.GetData(i) != cdobj.GetData(i))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        //For js us only
        public static CANData getNewJS(int initID, int[] initData)
        {
            CANData cd = new CANData();

            cd.ID = initID;
            cd.SetDataJS(initData);
            return(cd);
        }
Ejemplo n.º 3
0
        // Operate NOT on each data
        public static CANData operator ~(CANData cd)
        {
            CANData cdrtn   = new CANData(cd.ID, cd.Data);
            int     invSize = cdrtn.getDataLen();

            for (int i = 0; i < invSize; i++)
            {
                cdrtn.SetData(i, (byte)~cdrtn.GetData(i));
            }
            return(cdrtn);
        }
Ejemplo n.º 4
0
        // Operate AND on each data
        public static CANData operator &(CANData d1, CANData d2)
        {
            int dlen = d1.getDataLen();

            if (dlen != d2.getDataLen() && d1.ID != d2.ID)
            {
                throw new Exception("Can't make OR operation in two byte array in different size or ID.");
            }
            else
            {
                byte[]  src   = new byte[dlen];
                byte[]  s1    = d1.GetData();
                byte[]  s2    = d2.GetData();
                CANData cdrtn = new CANData();
                cdrtn.ID = d1.ID;
                for (int i = 0; i < dlen; i++)
                {
                    src[i] = (byte)(s1[i] & s2[i]);
                }
                cdrtn.SetData(src);
                return(cdrtn);
            }
        }
Ejemplo n.º 5
0
 public TransmitData(CANData cd, int cycleMills)
 {
     this.data  = cd;
     this.cycle = (long)cycleMills;
 }