예제 #1
0
        private void ReceiveCan(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...
            }
        }
예제 #2
0
        public override void CanPacketReceived(CanPacket canPacket)
        {
            int canOffset = (int)canPacket.CanIdBase10 - (int)BaseAddress;

            if (IdMatch("0", canOffset))
            {
                SerialNumber = canPacket.GetInt32(1);
                DeviceId     = canPacket.GetInt32(0);
            }
            else

            if (IdMatch("F4", canOffset))
            {
                SOCPercentage = canPacket.GetFloat(1);
                SOCAh         = canPacket.GetFloat(0);
            }

            if (IdMatch("F5", canOffset))
            {
                BalancePercentage = canPacket.GetFloat(1);
                BalanceAh         = canPacket.GetFloat(0);
            }

            if (IdMatch("F6", canOffset))
            {
                TotalPackCapacity         = canPacket.GetUint16(3);
                DischargeCellVoltageError = canPacket.GetInt16(2);
                CellTempMargin            = canPacket.GetInt16(1);
                ChargeCellVoltageError    = canPacket.GetInt16(0);
            }

            if (IdMatch("F7", canOffset))
            {
                PrechargeTimer  = canPacket.GetUint8(7);
                TimerFlag       = canPacket.GetUint8(6);
                PrechargeState  = canPacket.GetUint8(1);
                ContactorStatus = canPacket.GetUint8(0);
            }

            if (IdMatch("F8", canOffset))
            {
                CellNumberMaxCell = canPacket.GetInt8(7);
                CMUNumberMaxCell  = canPacket.GetInt8(6);
                CellNumberMinCell = canPacket.GetInt8(5);
                CMUNumberMinCell  = canPacket.GetInt8(4);
                MaxCellVoltage    = canPacket.GetUint16(1);
                MinCellVoltage    = canPacket.GetUint16(0);
            }

            if (IdMatch("F9", canOffset))
            {
                CMUNumberMaxTemp = canPacket.GetInt8(6);
                CMUNumberMinTemp = canPacket.GetInt8(4);
                MaxCellTemp      = canPacket.GetUint16(1);
                MinCellTemp      = canPacket.GetUint16(0);
            }

            if (IdMatch("FA", canOffset))
            {
                BatteryCurrent = canPacket.GetInt32(1);
                BatteryVoltage = canPacket.GetUint32(0);
            }


            if (IdMatch("FB", canOffset))
            {
                BMUFirmwareBuildNumber = canPacket.GetUint16(3);
                CMUCount    = canPacket.GetUint8(5);
                StatusFlags = canPacket.GetUint8(4);
                BalanceVoltageThresholdFalling = canPacket.GetUint16(1);
                BalanceVoltageThresholdRising  = canPacket.GetUint16(0);
            }


            if (IdMatch("FC", canOffset))
            {
                TwelveVoltCurrentCMUs           = canPacket.GetUint16(3);
                TwelveVoltCurrentFansContactors = canPacket.GetUint16(2);
                FanSpeed1RPM = canPacket.GetUint16(1);
                FanSpeed0RPM = canPacket.GetUint16(0);
            }

            if (IdMatch("FD", canOffset))
            {
                BMUModelId         = canPacket.GetInt8(5);
                BMUHardwareVersion = canPacket.GetInt16(3);
                ExtendedStausFlag  = canPacket.GetUint32(0);
            }
        }