Beispiel #1
0
        void downloader_threadAbort(object sender, EventArgs e)
        {
            sc.newIncommingCanMessage += sc_newIncommingCanMessage;

            try
            {
                this.BeginInvoke((ThreadStart)delegate
                {
                    threadAbortEvent e2 = (threadAbortEvent)e;
                    switch (e2.getAbortMode())
                    {
                        case eeDownloader.abortMode.PROGRAM:
                            log("Download done. Time spent: " + e2.getTimeS().ToString() + " seconds. " + Math.Round(e2.getBps(), 0) + " Bps");
                            break;

                        case eeDownloader.abortMode.USER:
                            log("Download aborted.");
                            break;
                    }

                    downloader = null;
                });
            }
            catch (InvalidOperationException) { }
        }
Beispiel #2
0
 public threadAbortEvent(int diffms, ulong bytes, eeDownloader.abortMode abortmode)
 {
     if (abortmode == eeDownloader.abortMode.PROGRAM)
     {
         this.timems = diffms-1000;
         this.times = this.timems/1000;
         this.bytes = bytes;
         this.bps = ((double)bytes / ((double)this.timems/1000.0));
     }
     this.abortmode = abortmode;
 }
Beispiel #3
0
        private void cmdDownload_Click(object sender, EventArgs e)
        {
            byte MY_ID = 0x91;
            byte TARGET_ID = 0x36;
            ulong eestart = 0;

            if (downloader != null) { log("Process in progress..."); return; }

            byte[] eebytes = new byte[eeDownloader.MAX_EE_SIZE];
            ulong eelength = 0;

            foreach (irCommand ic in lstIrcommands.Items)
            {
                byte[] icbytes = new byte[irCommand.BYTES_LENGTH];
                Array.Copy(ic.getBytes(), icbytes, irCommand.BYTES_LENGTH);
                Array.Reverse(icbytes);
                Array.Copy(icbytes, 0, eebytes, (int)eelength, (int)irCommand.BYTES_LENGTH);
                eelength += irCommand.BYTES_LENGTH;
            }

            if (eelength == 0) { log("Nothing to download."); return; }

            if (!sc.isConnected()) { log("Port is not open."); return; }

            downloader = new eeDownloader(eebytes, eelength, eestart, eeDownloader.eeType.INTERNAL, sc, MY_ID, TARGET_ID);

            if (!downloader.go()) { log("Error starting download. Reason: " + downloader.lastError); return; }

            sc.newIncommingCanMessage -= sc_newIncommingCanMessage;

            downloader.threadAbort += new EventHandler(downloader_threadAbort);

            log("Downloading...");

            saveTable();
        }