2005 Cavalier lives again!

The recently purchased 2005 Cavalier has been resurrected from the near scrapyard experience!
CAM00012

After the pistons and piston rings were installed the oil pan went back on. Without taking the engine out of the car installing the timing chain was difficult. The static chain guide has a bolt that is only accessible by a port in the side of the head that can only be accessed when the head is not on the engine. The engine block mount restricts access to the port which takes 50 ft/lbs of torque to get off. After some quick thinking the static guide was installed in the head through the port and then the head was lowered onto the engine block. Care was taken while lowering the head because the static guide only fits in a certain way. We also had to guide the timing chain during the head install because once the static guide was in place there was not enough room to get the chain into the guide.

After the timing chain was installed and head bolted down the reconstruction began. Valve and timing chain cover, intake manifold, fuel injectors, spark plugs, plug assembly, serpentine belt, motor mounts, battery, the list went on and on!

The engine managed to start on the first try after cranking a few times! I was quite pleased with that result. After letting it run for a few minutes while monitoring the coolant levels (the coolant lines still had some air in them) I took it for a quick spin. I got out of the neighborhood successfully but couldn’t get out of first gear! Automatic transmissions shift on their own depending on current speed and throttle position etc, but I got the revs up into 5k range without shifting. I tried revving the engine up a few times to see if I could get it to shift but nothing would work. Some quick googling couldn’t find the solution either, most of the fixes were geared toward the actual shifting cable that runs from inside car car to the transmission.

After looking under the engine some more, one pair of wires running around the transmission had a cut in it! It looks like an animal or malicious user had cut the line? After some soldering and insulation of the wire the transmission started shifting correctly. Quite relieved with that result. It seems something as important as the engine telling the transmission to shift would be more secure than just dangling from the bottom of the car.

Either way, time to get it listed on Craigslist and get it out of the driveway!

CAM00014

SignalR with MVC 5

I had some difficulty getting SignalR set up with a recent web application being developeed for a client. Some of the documentation found online were geared towards older versions of SignalR, while others didn’t seem to work with my setup.

I am creating additional functionality for a web client that allows a server to push information to a client when certain events trigger. Being a MVC and HTML5 application I decided to utilize Web Sockets.

  • With Visual Studio 2012 I installed the SignalR nuget package to speed up the installation.
  • I created a Startup.cs file in the project’s App_Start folder placing the following code inside of it:
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;
using Desking.SignalR;

[assembly: OwinStartup(typeof(Desking.Startup))]
namespace Desking
   {
      public class Startup
      {
         public void Configuration(IAppBuilder app)
         {
            app.MapSignalR();
         }
      }
   }
  • SignalR has the ability to dynamically generate the hub js file found at signalr/hub at the applications root used for talking to the server, but the generated file was not minified and I couldn’t find a way to integrate it with MVC’s script bundles I use across the application. I decided instead to take the dynamically generated file and place into a normal js file.
  • At the end of the hub.js file I needed to modify the relative path url
signalR.hub = $.hubConnection("/applicationPath/signalr", { useDefaultPath: false });
  • I created the following hub file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using Desking.Models;

namespace Desking.SignalR
{
    [HubName("deskingHub")]
    public class DeskingHub : Hub
    {
        public void sendNotification(String Name, String Message)
        {
            Clients.Client(Context.ConnectionId).addMessage(Name + ": " + Message);
        }

        public void registerClient(long DeskingDraftRevisionID)
        {
            DealMethods.RegisterClient(DeskingDraftRevisionID, Guid.Parse(Context.ConnectionId));
        }

        public enum Statuses
        {
            FinancingConfirmed = 0,
            NeedManager,
            ReadyForDocuments,
        }
    }
}
  • The registerClient method is used when the client first loads the application by registering and linking the draft id they have opened to the connection ID generated by SignalR. This allows the server to send notifications based on the draft id needing to be notified
  • The following js is included on the initial page load:
function SetupFinancingNotifications() {
    // Declare a proxy to reference the hub. 
    var chat = $.connection.deskingHub;

    // Create a function that the hub can call to broadcast messages.
    chat.client.addMessage = function (message) {
        alert(message);
    };

    // Start the connection.
    $.connection.hub.start().done(function () {
        chat.server.registerClient($('#labelDealStatusQuoteNumber').text());
        $('#sendmessage').click(function () {
            // Call the Send method on the hub. 
            chat.server.sendNotification($('#displayname').val(), $('#message').val());
            // Clear text box and reset focus for next comment. 
            $('#message').val('').focus();
        });
    });
}
  • The js registers itself with the server given the revision id currently opened. The SignalR’s client instance ID is taken from the request context on the server side and isn’t needed to be pass in manually.
  • After the client is set up all that is left to do is create a method that will signal the web client:
public static void NotifyClient(long DealID, DeskingHub.Statuses DealStatus, String Message)
{
   using (CRMEntities db = new CRMEntities())
   {
       DeskingDraftFinancingNotification notification = db.DeskingDraftFinancingNotifications.Where(x => x.DealID == DealID).FirstOrDefault();

       if (notification != null)
       {
           try
           {
               IHubContext notificationHub = GlobalHost.ConnectionManager.GetHubContext<DeskingHub>();

               notificationHub.Clients.Client(notification.ConnectionID.ToString()).addMessage(DealStatus, Message);
           }
           catch (Exception ex)
           {
               ex.LogToElmah();
           }
       }
   }
}

In the future I will need to add more functionality to allow client -> server communication, as well as getting SignalR to function behind a load balancer across 3 servers using the SQL backplane.