public MainWindow()
        {
            InitializeComponent();

            window.ResizeMode = ResizeMode.NoResize; // Disable resize of the window

            // Initialize images for the UI //
            headlightsOn             = new BitmapImage(new Uri(resourcePath + "1.png"));
            headligtsOff             = new BitmapImage(new Uri(resourcePath + "2.png"));
            seatbeltBuckled          = new BitmapImage(new Uri(resourcePath + "seatbelt_buckled.png"));
            seatbeltUnbuckled        = new BitmapImage(new Uri(resourcePath + "seatbelt_unbuckled.png"));
            turnLightLeft            = new BitmapImage(new Uri(resourcePath + "turn_light_left.png"));
            turnLightLeftGreen       = new BitmapImage(new Uri(resourcePath + "turn_light_left_green.png"));
            turnLightRight           = new BitmapImage(new Uri(resourcePath + "turn_light_right.png"));
            turnLightRightGreen      = new BitmapImage(new Uri(resourcePath + "turn_light_right_green.png"));
            batteryLevelNormal       = new BitmapImage(new Uri(resourcePath + "battery_level.png"));
            batteryLevelWarning      = new BitmapImage(new Uri(resourcePath + "battery_level_red.png"));
            engineTemperatureNormal  = new BitmapImage(new Uri(resourcePath + "engine_temp.png"));
            engineTemperatureWarning = new BitmapImage(new Uri(resourcePath + "engine_temp_red.png"));
            fuelLevelNormal          = new BitmapImage(new Uri(resourcePath + "fuel_level.png"));
            fuelLevelWarning         = new BitmapImage(new Uri(resourcePath + "fuel_level_red.png"));
            hornImage = new BitmapImage(new Uri(resourcePath + "horn_button.png"));

            // Set speedometer arrow position intially //
            RotateTransform rotateTransform = new RotateTransform(startAngle);

            speedometer_arrow.RenderTransform = rotateTransform;

            // Bind events to buttons & sliders //
            headlightsButton.Click        += HeadlightsButtonClicked;
            seatbeltButton.Click          += SeatbeltButtonClicked;
            speedSlider.ValueChanged      += ValueChanged;
            turnLeftButton.Click          += TurnLeftClicked;
            turnRightButton.Click         += TurnRightClicked;
            batteryLevelButton.Click      += BatteryLevelClicked;
            engineTemperatureButton.Click += EngineTemperatureClicked;
            fuelLevelButton.Click         += FuelLevelClicked;
            hornButton.Click += HornButtonClicked;
            window.Closed    += WindowClosed;

            // Initialize thread for blinkers //
            blink = new Thread(CheckBlink);
            blink.Start();

            // Initialize the can manager //
            can_manager = new CANManager();

            System.Timers.Timer timer = new System.Timers.Timer(200);
            timer.Elapsed  += CANManager.TimerHandler;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
        /// <summary>
        /// Calculates masks and speed for the CAN Manager
        /// </summary>
        private void CalculateMaskAndSpeed()
        {
            mask  = 0;
            speed = (int)speedSlider.Value;

            if (currentBlinker == 0)
            {
                mask = mask | blinkerState;
                mask = mask << 1;
                mask = mask | 0;
            }

            if (currentBlinker == 1)
            {
                mask = mask | 0;
                mask = mask << 1;
                mask = mask | blinkerState;
            }

            mask = mask << 1;
            mask = mask | Convert.ToUInt32(engineTempState);

            mask = mask << 1;
            mask = mask | Convert.ToUInt32(batteryLevelState);

            mask = mask << 1;
            mask = mask | Convert.ToUInt32(headlightsState);

            mask = mask << 1;
            mask = mask | Convert.ToUInt32(!seatbeltState);

            mask = mask << 1;
            mask = mask | Convert.ToUInt32(fuelLevelState);

            mask = mask << 1;

            curr_time = DateTime.Now.ToString("HH:mm");

            CANManager.SetInfo(mask, speed, Convert.ToInt32(hornButtonState), int.Parse(curr_time.Split(':')[0]), int.Parse(curr_time.Split(':')[1]));
        }
 /// <summary>
 /// Window closed event handler
 /// </summary>
 private void WindowClosed(object sender, EventArgs e)
 {
     blink.Abort(); // stops blink thread
     CANManager.ResetCluster();
 }