コード例 #1
0
ファイル: Light.cs プロジェクト: temur03/imBMW
 static void LightControlModule_LightStatusReceived(iBus.Message message, LightStatusEventArgs args)
 {
     if (IgnoreFrontLightsError && args.ErrorFrontLeftLights && args.ErrorFrontRightsLights)
     {
         var data = (byte[])message.Data.Clone();
         data[4] = data[4].RemoveBits(0x30);
         var m = new Message(DeviceAddress.LightControlModule, DeviceAddress.GlobalBroadcastAddress, data);
         Manager.EnqueueMessage(m);
     }
 }
コード例 #2
0
        static void OnLightStatusReceived(Message m)
        {
            // TODO Hack Data[3] and other bits meaning
            var on          = m.Data[1];
            var error       = m.Data[2];
            var errorUnk    = m.Data[3];
            var errorReason = m.Data[4];

            string description = "";
            var    args        = new LightStatusEventArgs();

            if (on == 0)
            {
                description = "Lights Off ";
            }
            else
            {
                if (on.HasBit(0))
                {
                    args.ParkingLightsOn = true;
                    on           = on.RemoveBit(0);
                    description += "Park ";
                }
                if (on.HasBit(1))
                {
                    args.LowBeamOn = true;
                    on             = on.RemoveBit(1);
                    description   += "LowBeam ";
                }
                if (on != 0)
                {
                    description += "Unknown=" + on.ToHex() + " ";
                }
            }
            if (error != 0 || errorReason != 0)
            {
                description += "| Errors";
                if (error != 0x01)
                {
                    description += "=" + error.ToHex();
                }
                description += ": ";
            }
            args.ErrorCode = error;
            if (errorReason == 0)
            {
                if (error != 0)
                {
                    description += "Unknown=" + errorUnk.ToHex() + "00";
                }
                else
                {
                    description += "| Lights OK";
                }
            }
            else
            {
                if (errorReason.HasBit(4))
                {
                    args.ErrorFrontRightsLights = true;
                    errorReason  = errorReason.RemoveBit(4);
                    description += "FrontRight ";
                }
                if (errorReason.HasBit(5))
                {
                    args.ErrorFrontLeftLights = true;
                    errorReason  = errorReason.RemoveBit(5);
                    description += "FrontLeft ";
                }
                if (errorReason != 0)
                {
                    description += "Unknown=" + errorReason.ToHex();
                }
            }
            m.ReceiverDescription = description;

            var e = LightStatusReceived;

            if (e != null)
            {
                e(m, args);
            }
        }
コード例 #3
0
        static void OnLightStatusReceived(Message m)
        {
            // TODO Hack Data[3] and other bits meaning
            var on = m.Data[1];
            var error = m.Data[2];
            var errorUnk = m.Data[3];
            var errorReason = m.Data[4];

            string description = "";
            var args = new LightStatusEventArgs();
            if (on == 0)
            {
                description = "Lights Off ";
            }
            else
            {
                if (on.HasBit(0))
                {
                    args.ParkingLightsOn = true;
                    on = on.RemoveBit(0);
                    description += "Park ";
                }
                if (on.HasBit(1))
                {
                    args.LowBeamOn = true;
                    on = on.RemoveBit(1);
                    description += "LowBeam ";
                }
                if (on != 0)
                {
                    description += "Unknown=" + on.ToHex() + " ";
                }
            }
            if (error != 0 || errorReason != 0)
            {
                description += "| Errors";
                if (error != 0x01)
                {
                    description += "=" + error.ToHex();
                }
                description += ": ";
            }
            args.ErrorCode = error;
            if (errorReason == 0)
            {
                if (error != 0)
                {
                    description += "Unknown=" + errorUnk.ToHex() + "00";
                }
                else
                {
                    description += "| Lights OK";
                }
            }
            else
            {
                if (errorReason.HasBit(4))
                {
                    args.ErrorFrontRightsLights = true;
                    errorReason = errorReason.RemoveBit(4);
                    description += "FrontRight ";
                }
                if (errorReason.HasBit(5))
                {
                    args.ErrorFrontLeftLights = true;
                    errorReason = errorReason.RemoveBit(5);
                    description += "FrontLeft ";
                }
                if (errorReason != 0)
                {
                    description += "Unknown=" + errorReason.ToHex();
                }
            }
            m.ReceiverDescription = description;

            var e = LightStatusReceived;
            if (e != null)
            {
                e(m, args);
            }
        }