Пример #1
0
 /// <summary>
 /// Set the CAN device to be used by this class.
 /// </summary>
 /// <param name="a_canDevice">A ICANDevice.</param>
 public override void setCANDevice(ICANDevice a_canDevice)
 {
 }
Пример #2
0
 void canUsbDevice_onReceivedAdditionalInformation(object sender, ICANDevice.InformationEventArgs e)
 {
     CastInfoEvent(e.Info, ActivityType.ConvertingFile);
 }
Пример #3
0
 void canUsbDevice_onReceivedAdditionalInformationFrame(object sender, ICANDevice.InformationFrameEventArgs e)
 {
     CastFrameEvent(e.Message);
 }
Пример #4
0
 public abstract void setCANDevice(ICANDevice a_canDevice);
Пример #5
0
        /// <summary>
        /// Set the CAN device to be used by this class.
        /// </summary>
        /// <param name="a_canDevice">A ICANDevice.</param>
        public override void setCANDevice(ICANDevice a_canDevice)
        {
            if (m_canDevice == null)
            {
                lock (m_lockObject)
                {
                    Console.WriteLine("******* KWPCANDevice: m_CanDevice set");

                    m_canDevice = a_canDevice;
                }
            }
            else
            {
                Console.WriteLine("KWPCANDevice, candevice was already set");
            }
        }
Пример #6
0
        public void setT7CANDevice(CANBusAdapter adapterType)
        {
            if (adapterType == CANBusAdapter.LAWICEL)
            {
                canUsbDevice = new CANUSBDevice();
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.ELM327)
            {
                Sleeptime = SleepTime.ELM327;
                canUsbDevice = new CANELM327Device() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.JUST4TRIONIC)
            {
                canUsbDevice = new Just4TrionicDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                kwpHandler.ResumeAlivePolling();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.COMBI)
            {
                canUsbDevice = new LPCCANDevice();
            }
            else if (adapterType == CANBusAdapter.LAWICEL_VCP)
            {
                canUsbDevice = new CANUSBDirectDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }

            canUsbDevice.EnableCanLog = m_EnableCanLog;
            canUsbDevice.UseOnlyPBus = m_OnlyPBus;
            canUsbDevice.DisableCanConnectionCheck = m_DisableCanConnectionCheck;
            canUsbDevice.TrionicECU = ECU.TRIONIC7;
            canUsbDevice.onReceivedAdditionalInformation += new ICANDevice.ReceivedAdditionalInformation(canUsbDevice_onReceivedAdditionalInformation);
            //canUsbDevice.onReceivedAdditionalInformationFrame += new ICANDevice.ReceivedAdditionalInformationFrame(canUsbDevice_onReceivedAdditionalInformationFrame);
            //canUsbDevice.acceptOnlyMessageIds = new List<uint> { 0x258,0x238 }; //t7suite
        }
Пример #7
0
 public void setCANDevice(CANBusAdapter adapterType)
 {
     if (adapterType == CANBusAdapter.LAWICEL)
     {
         canUsbDevice = new CANUSBDevice();
     }
     else if (adapterType == CANBusAdapter.ELM327)
     {
         Sleeptime = SleepTime.ELM327;
         canUsbDevice = new CANELM327Device() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
     }
     else if (adapterType == CANBusAdapter.JUST4TRIONIC)
     {
         canUsbDevice = new Just4TrionicDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate };
     }
     else if (adapterType == CANBusAdapter.COMBI)
     {
         canUsbDevice = new LPCCANDevice();
     }
     else if (adapterType == CANBusAdapter.LAWICEL_VCP)
     {
         canUsbDevice = new CANUSBDirectDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
     }
     canUsbDevice.EnableCanLog = m_EnableCanLog;
     canUsbDevice.UseOnlyPBus = m_OnlyPBus;
     canUsbDevice.DisableCanConnectionCheck = m_DisableCanConnectionCheck;
     canUsbDevice.TrionicECU = ECU.TRIONIC8;
     canUsbDevice.onReceivedAdditionalInformation += new ICANDevice.ReceivedAdditionalInformation(canUsbDevice_onReceivedAdditionalInformation);
     //canUsbDevice.onReceivedAdditionalInformationFrame += new ICANDevice.ReceivedAdditionalInformationFrame(canUsbDevice_onReceivedAdditionalInformationFrame);
     if (m_canListener == null)
     {
         m_canListener = new CANListener();
     }
     canUsbDevice.addListener(m_canListener);
     canUsbDevice.AcceptOnlyMessageIds = new List<uint> { 0x645, 0x7E0, 0x7E8, 0x311, 0x5E8 };
 }
Пример #8
0
        /// <summary>
        /// Cleans up connections and resources in use by the TrionicCAN DLL
        /// </summary>
        public void Cleanup()
        {
            try
            {
                tmr.Stop();
                MM_EndPeriod(1);
                Console.WriteLine("Cleanup called in TrionicCAN");
                //m_canDevice.removeListener(m_canListener);
                if (m_canListener != null)
                {
                    m_canListener.FlushQueue();
                }
                if (flash != null)
                {
                    flash.onStatusChanged -= flash_onStatusChanged;
                    flash = null;
                }
                KWPHandler.stopLogging();
                if (kwpHandler != null)
                {
                    kwpHandler.SuspendAlivePolling();
                    kwpHandler.closeDevice();
                }
                if (canUsbDevice != null)
                {
                    if (canUsbDevice is LPCCANDevice)
                    {
                        LPCCANDevice lpc = (LPCCANDevice)canUsbDevice;
                        lpc.disconnect();
                        canUsbDevice.close();
                        canUsbDevice = null;
                        Console.WriteLine("Closed m_canDevice in TrionicCAN");
                    }
                    else
                    {
                        canUsbDevice.close();
                        canUsbDevice = null;
                    }
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }

            TrionicCANLib.Log.LogHelper.Flush();
        }