示例#1
0
        private void recieveCan(CanPacket cp)
        {
            try
            {
                switch (cp.canIdBase10)
                {
                case 513:     // 0x501
                    this.throttlePercentage = cp.getFloat(0);
                    this.regenPercentage    = cp.getFloat(1);
                    break;

                case CanIds.DC_BASE + CanIds.DC_DRIVE:     // 0x501
                    this.rpmPercentage     = cp.getFloat(0);
                    this.currentPercentage = cp.getFloat(1);
                    break;

                case CanIds.DC_BASE + CanIds.DC_POWER:     // 0x502
                    this.busCurrentPercentage = cp.getFloat(1);
                    break;

                case CanIds.DC_BASE + CanIds.DC_CRUISE2:     // 0x508
                    //this.driveMode = cp.getInt8(7);
                    this.cruiseMode = cp.getInt8(7);
                    break;

                case CanIds.DC_BASE + CanIds.DC_DEBUG:     // 0x50D
                    this.errorMode  = cp.getInt8(0);
                    this.driveMode  = cp.getInt8(1);
                    this.cruiseMode = cp.getInt8(2);
                    this.flashMode  = cp.getInt8(3);
                    break;
                }
            } catch {
                //Let it go, let it go. Can't hold it back anymore...
            }
        }