public static KWPHandler getInstance() { if (m_kwpDevice == null) Console.WriteLine("KWPDevice not set."); if (m_instance == null) m_instance = new KWPHandler(); return m_instance; }
public static KWPHandler getInstance() { if (m_kwpDevice == null) { Console.WriteLine("KWPDevice not set."); } if (m_instance == null) { m_instance = new KWPHandler(); } return(m_instance); }
public static void setKWPHandler(KWPHandler a_kwpHandler) { if (m_kwpHandler != null) throw new Exception("KWPHandler already set"); m_kwpHandler = a_kwpHandler; }
private bool CheckCANConnectivity() { // write log information to "CanTrace.txt" if (flash == null) { AddToCanTrace("Initializing CANbus interface"); System.Windows.Forms.Application.DoEvents(); AddToLog("Initializing CAN interface, please stand by..."); AddToCanTrace("Creating new connection to CANUSB device!"); if (useCombiAdapter) { // connect to adapter LPCCANDevice_T7 lpc = (LPCCANDevice_T7)this.canUsbDevice; if (!lpc.connect()) return false; //<GS-09122010> // kwpCanDevice.setCANDevice(canUsbDevice); // KWPHandler.setKWPDevice(kwpCanDevice); //<GS-09122010> // get flasher object this.flash = lpc.createFlasher(); flash.EnableCanLog = checkBox1.Checked; AddToCanTrace("T7CombiFlasher object created"); AddToLog("CombiAdapter ready"); } else { //flash = new T7.Flasher.T7Flasher(); //AddToCanTrace("Object T7.Flasher.T7Flasher created"); kwpCanDevice.setCANDevice(canUsbDevice); kwpCanDevice.EnableCanLog = checkBox1.Checked; KWPHandler.setKWPDevice(kwpCanDevice); if (checkBox1.Checked) { KWPHandler.startLogging(); } kwpHandler = KWPHandler.getInstance(); try { T7.Flasher.T7Flasher.setKWPHandler(kwpHandler); } catch (Exception E) { Console.WriteLine(E.Message); AddToCanTrace("Failed to set flasher object to KWPHandler"); } flash = T7.Flasher.T7Flasher.getInstance(); flash.onStatusChanged += new T7.Flasher.IFlasher.StatusChanged(flash_onStatusChanged); //AddToLog("Set callback event on flasher"); flash.EnableCanLog = checkBox1.Checked; if (kwpHandler.openDevice()) { AddToLog("Canbus channel opened"); } else { AddToLog("Unable to open canbus channel"); kwpHandler.closeDevice(); return false; } if (kwpHandler.startSession()) { AddToLog("Session started"); } else { AddToLog("Unable to start session"); kwpHandler.closeDevice(); return false; } } } m_connectedToECU = true; return m_connectedToECU; }