Example #1
0
        static Program()
        {
            tclsErrlog.OpenLog(AppDomain.CurrentDomain.BaseDirectory);

            tclsDataPage.vSetWorkingBaseAddress(tclsASAM.u32GetCharMinAddress());
            tclsErrlog.LogAppend("ASAM parsed...");

            mProgramTextForecolor       = System.Drawing.Color.Aquamarine;
            mProgramTextBackcolor       = System.Drawing.Color.Black;
            mProgramTextToggleBackcolor = System.Drawing.Color.DarkSlateGray;
            mSplashLoading        = true;
            mSplashWorker         = new BackgroundWorker();
            mSplashWorker.DoWork += new DoWorkEventHandler(Splash);
            tclsErrlog.LogAppend("Splash started...");
            mFileOpenWorker         = new BackgroundWorker();
            mFileOpenWorker.DoWork += new DoWorkEventHandler(FileOpen);
            mSplashWorker.RunWorkerAsync();

            try
            {
                mszAdapterDeviceName = mAPP_mclsIniParser.GetSetting("NetworkConnection", "SelectedDevice");
                tclsErrlog.LogAppend("Adapter Device Name: " + mszAdapterDeviceName);
            }
            catch
            {
                mszAdapterDeviceName = "Unknown";
            }

            mszCalibrationFilePath = null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mFormUDP = new tclsMDIParent();
            tclsErrlog.LogAppend("MDI created...");

            mAPP_clsUDPComms = new tclsUDSComms(mszAdapterDeviceName, mFormUDP.Handle);
            mboCommsOnline   = mAPP_clsUDPComms.Connected;
            tclsErrlog.LogAppend("CommsOnline: " + mboCommsOnline.ToString());

            if (false == mboCommsOnline)
            {
                mAPP_clsUDPComms.vDispose();
            }

            mboCommsSuspend = true;

            UInt16 u16ASAMCRC = tclsASAM.u16GetCRC16();

            //if (0 != u16ASAMCRC)
            if (39430 != u16ASAMCRC)
            {
                Program.vNotifyProgramEvent(tenProgramEvent.enProgramMessage, 0, "ASAM file does not contain a correct CRC");
            }
            else
            {
                tclsErrlog.LogAppend("ASAM CRC correct...");
            }
        }
Example #2
0
        public static void vNotifyProgramEvent(tenProgramEvent enRPCResponse, int iData, string szErrOrMessage)
        {
            if (null != mFormUDP)
            {
                switch (enRPCResponse)
                {
                case tenProgramEvent.enRPCUploadComplete:
                {
                    tclsDataPage.vSetChangeLock(true);
                    mboCommsSuspend = true;
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIDataPageRefreshed, 0, "", "");
                    tclsDataPage.vSetChangeLock(false);
                    mboCommsSuspend = false;
                    vNotifyProgramState(tenProgramState.enProgNormal, 0);
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, 100, szErrOrMessage, "Upload complete");
                    break;
                }

                case tenProgramEvent.enRPCDownloadComplete:
                {
                    vNotifyProgramState(tenProgramState.enProgNormal, 0);
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, 100, szErrOrMessage, "Download complete");
                    break;
                }

                case tenProgramEvent.enWindowElementsLoaded:
                {
                    vNotifyProgramState(tenProgramState.enProgNormal, 0);
                    mFormUDP.vNotify(tenMDIParentNotify.enMDILoaded, 0, "", "");
                    mboCommsSuspend = false;
                    mSplashLoading  = false;
                    break;
                }

                case tenProgramEvent.enLoadCalibrationComplete:
                {
                    tclsDataPage.vSetChangeLock(true);
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIDataPageRefreshed, 0, "", "");
                    tclsDataPage.vSetChangeLock(false);
                    vNotifyProgramState(tenProgramState.enProgNormal, 0);
                    break;
                }

                case tenProgramEvent.enProgramError:
                {
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIShowError, 0, szErrOrMessage, "");
                    break;
                }

                case tenProgramEvent.enProgramMessage:
                {
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIShowMessage, 0, szErrOrMessage, "");
                    break;
                }

                case tenProgramEvent.enProgramOnline:
                {
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, 0, szErrOrMessage, "");
                    mboCommsOnline = true;
                    break;
                }

                case tenProgramEvent.enProgramOffline:
                {
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOffline, 0, szErrOrMessage, "");
                    mboCommsOnline = false;
                    break;
                }

                case tenProgramEvent.enRPCUploadIncrement:
                {
                    if (75 > iData)
                    {
                        mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, iData, szErrOrMessage, "Uploading " + iData.ToString() + "%");
                    }
                    else
                    {
                        mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, iData, szErrOrMessage, "Uploaded data processing 80 %");
                    }
                    break;
                }

                case tenProgramEvent.enRPCDownloadIncrement:
                {
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, iData, szErrOrMessage, "Downloading " + iData.ToString() + "%");
                    break;
                }

                case tenProgramEvent.enSlowTaskProgress:
                {
                    if (true == mboCommsOnline)
                    {
                        mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOnline, iData, szErrOrMessage, szErrOrMessage);
                    }
                    else
                    {
                        mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOffline, iData, szErrOrMessage, szErrOrMessage);
                    }

                    break;
                }

                case tenProgramEvent.enCommDisconnectOrError:
                {
                    mboCommsSuspendError = true;
                    mFormUDP.vNotify(tenMDIParentNotify.enMDIToolStripOffline, 100, szErrOrMessage, "Comm disconnect or error, now offline please save and restart");
                    mboCommsOnline = false;
                    break;
                }

                case tenProgramEvent.enCommRequestSuspend:
                {
                    mboCommsSuspend = true;
                    break;
                }

                case tenProgramEvent.enCommRequestUnSuspend:
                {
                    mboCommsSuspend = false;
                    break;
                }

                case tenProgramEvent.enCommRequestDDDIReset:
                {
                    mAPP_clsUDPComms.vResetDDDI();
                    break;
                }

                case tenProgramEvent.enUSBConnectDetected:
                {
                    if (false == mboCommsOnline)
                    {
                        mAPP_clsUDPComms = new tclsUDSComms(mszAdapterDeviceName, mFormUDP.Handle);
                        mboCommsOnline   = mAPP_clsUDPComms.Connected;

                        if (false == mboCommsOnline)
                        {
                            mAPP_clsUDPComms.vDispose();
                        }
                        else
                        {
                            mAPP_clsUDPComms.vResetDDDI();

                            int iDDDIIDX;

                            for (iDDDIIDX = 0; iDDDIIDX < ConstantData.BUFFERSIZES.u16UDS_MEASURE_RATE_COUNT; iDDDIIDX++)
                            {
                                tclsASAM.vSetDDDIResetPending(iDDDIIDX, true);
                            }

                            mboCommsSuspendError = false;
                        }
                    }

                    break;
                }

                case tenProgramEvent.enUSBDisconnectDetected:
                {
                    if (true == mboCommsOnline)
                    {
                        mboCommsOnline = false;
                        mAPP_clsUDPComms.CommsDisconnect();
                        mAPP_clsUDPComms.vDispose();
                    }

                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }