}//ds30L_Downloading() //--------------------------------------------------------------------- // Constructor //--------------------------------------------------------------------- public void DoMagic(string[] pstrArgs, ref bool pbResult) { pbResult = false; //----------------------------------------------------------------- // If no argumentsa are specified, display help //----------------------------------------------------------------- if (pstrArgs.Length == 0) { PrintHelp(); return; } //----------------------------------------------------------------- // Validate arguments //----------------------------------------------------------------- bool bResult = false; clsParseSettings objParseSettings = new clsParseSettings(); clsDownloadSettings objDownloadSettings = new clsDownloadSettings(); ValidateParseArgs(pstrArgs, objParseSettings, objDownloadSettings, ref bResult); if (bResult == false) { return; } //----------------------------------------------------------------- // Nothing to do? //----------------------------------------------------------------- if (objDownloadSettings.writeProgram == false && objDownloadSettings.writeEEPROM == false && objDownloadSettings.writeConfigs == false) { Console.WriteLine("Nothing to do."); return; } //----------------------------------------------------------------- // Parse //----------------------------------------------------------------- objParseSettings.device = objDevice; DoParse(objParseSettings, objDownloadSettings); //----------------------------------------------------------------- // Create port //----------------------------------------------------------------- objPort = new clsSerialPort(); objPort.Setup(strPort, iBaudrate); //----------------------------------------------------------------- // Increase process priority if polltime is low //----------------------------------------------------------------- if (objDownloadSettings.polltime < 100) { try { System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal; } catch { clsDebugTextbox.OutputInfo("Setting proccess priority failed."); } } //----------------------------------------------------------------- // Print settings //----------------------------------------------------------------- Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("{0,-10} {1, -8}", "File:", strFile); Console.WriteLine("{0,-10} {1, -8}", "Port:", strPort); Console.WriteLine("{0,-10} {1, -8}", "Baudrate:", iBaudrate.ToString()); Console.WriteLine("{0,-10} {1, -8}", "Device:", objDevice.name); //----------------------------------------------------------------- // //----------------------------------------------------------------- Console.WriteLine(""); Console.WriteLine(""); if (bNonInteractive == false) { Console.WriteLine("Press any key to begin download"); Console.WriteLine(""); Console.ReadKey(); } //----------------------------------------------------------------- // Download //----------------------------------------------------------------- bool bDownloadResult = false; int iStartTime = Environment.TickCount; clsds30Loader.Download(objDevice, objPort, objHex, objDownloadSettings, 0, ref bDownloadResult); int iEndTime = Environment.TickCount; //----------------------------------------------------------------- // Restore process priority //----------------------------------------------------------------- if (objDownloadSettings.polltime < 100) { try { System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal; } catch { clsDebugTextbox.OutputInfo("Setting proccess priority failed."); } } //----------------------------------------------------------------- // Download finished //----------------------------------------------------------------- objPort.Close(); if (clsds30Loader.debugMode) { clsDebugTextbox.OutputInfo("Elapsed time: " + String.Format("{0:0.#}", Convert.ToSingle(iEndTime - iStartTime) / 1000.0) + " seconds", 1); } pbResult = bDownloadResult; }// DoMagic()
}//ds30L_Downloading() //--------------------------------------------------------------------- // Constructor //--------------------------------------------------------------------- public void DoMagic( string[] pstrArgs, ref bool pbResult ) { pbResult = false; //----------------------------------------------------------------- // If no argumentsa are specified, display help //----------------------------------------------------------------- if ( pstrArgs.Length == 0 ) { PrintHelp(); return; } //----------------------------------------------------------------- // Validate arguments //----------------------------------------------------------------- bool bResult = false; clsParseSettings objParseSettings = new clsParseSettings(); clsDownloadSettings objDownloadSettings = new clsDownloadSettings(); ValidateParseArgs( pstrArgs, objParseSettings, objDownloadSettings, ref bResult ); if ( bResult == false ) { return; } //----------------------------------------------------------------- // Nothing to do? //----------------------------------------------------------------- if ( objDownloadSettings.writeProgram == false && objDownloadSettings.writeEEPROM == false && objDownloadSettings.writeConfigs == false ) { Console.WriteLine( "Nothing to do." ); return; } //----------------------------------------------------------------- // Parse //----------------------------------------------------------------- objParseSettings.device = objDevice; DoParse( objParseSettings, objDownloadSettings ); //----------------------------------------------------------------- // Create port //----------------------------------------------------------------- objPort = new clsSerialPort(); objPort.Setup( strPort, iBaudrate ); //----------------------------------------------------------------- // Increase process priority if polltime is low //----------------------------------------------------------------- if ( objDownloadSettings.polltime < 100 ) { try { System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal; } catch { clsDebugTextbox.OutputInfo( "Setting proccess priority failed." ); } } //----------------------------------------------------------------- // Print settings //----------------------------------------------------------------- Console.WriteLine( "" ); Console.WriteLine( "" ); Console.WriteLine( "{0,-10} {1, -8}", "File:", strFile ); Console.WriteLine( "{0,-10} {1, -8}", "Port:", strPort ); Console.WriteLine( "{0,-10} {1, -8}", "Baudrate:", iBaudrate.ToString() ); Console.WriteLine( "{0,-10} {1, -8}", "Device:", objDevice.name ); //----------------------------------------------------------------- // //----------------------------------------------------------------- Console.WriteLine( "" ); Console.WriteLine( "" ); if ( bNonInteractive == false ) { Console.WriteLine( "Press any key to begin download" ); Console.WriteLine( "" ); Console.ReadKey(); } //----------------------------------------------------------------- // Download //----------------------------------------------------------------- bool bDownloadResult = false; int iStartTime = Environment.TickCount; clsds30Loader.Download( objDevice, objPort, objHex, objDownloadSettings, 0, ref bDownloadResult ); int iEndTime = Environment.TickCount; //----------------------------------------------------------------- // Restore process priority //----------------------------------------------------------------- if ( objDownloadSettings.polltime < 100 ) { try { System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal; } catch { clsDebugTextbox.OutputInfo( "Setting proccess priority failed." ); } } //----------------------------------------------------------------- // Download finished //----------------------------------------------------------------- objPort.Close(); if ( clsds30Loader.debugMode ) { clsDebugTextbox.OutputInfo( "Elapsed time: " + String.Format( "{0:0.#}", Convert.ToSingle(iEndTime - iStartTime) / 1000.0 ) + " seconds", 1 ); } pbResult = bDownloadResult; }// DoMagic()