public void Execute(frmProgress fp) { this.fp = fp; ExecutionBlock currentNode = root.NormalChild; object lastObject = null; while (currentNode != null) { AddText("Executing block " + currentNode.DataBinding.Name + "\r\n"); ExecutionUnitOutput output = currentNode.Execute(lastObject); currentNode = currentNode.NormalChild; if (output == null) { lastObject = null; } else { lastObject = output.ObjectOutput; if (currentNode is DecisionUnit) { if (!output.DecisionOutput) { currentNode = currentNode.NegationChild; } } } } AddText("Execution done!"); }
private void GoModel(frmProgress progress) { Random rand = new Random(); int tmp_count = Convert.ToInt32(edCount.Value); rand_max = Convert.ToInt32(edRandMax.Value); double point; double a = radius * Math.Sin(Math.PI / 3); wanted = GetIndexFromCoordinate(a); max_frequency = 0; chords.Clear(); for (int i = 0; i < rand_max; ++i) chords.Add(0); wanted_count = 0; for (count = 0; count < tmp_count; ++count) { if (progress.Step()) break; int i = rand.Next(rand_max); point = Math.Abs(drandom(-radius, +radius, i)); max_frequency = Math.Max(max_frequency, ++chords[i]); if (point > a) ++wanted_count; } edCount.Value = count; lblInfo.Text = String.Format("Частота: {0}", wanted_count * 1.0 / count); pbGraphics.Invalidate(); }
private void btnFind_Click(object sender, EventArgs e) { txtProductMo.Focus(); if (rdgIsSetCosting.SelectedIndex != 0) { if (txtMatFrom.Text.Trim() == "" && txtPrdTypeFrom.Text.Trim() == "" && txtArtFrom.Text.Trim() == "" && txtSizeFrom.Text.Trim() == "" && txtClrFrom.Text.Trim() == "" && txtProductMo.Text.Trim() == "" && txtDateFrom.Text.Trim() == "" && txtDateTo.Text.Trim() == "") { MessageBox.Show("請輸入查詢條件!"); return; } } frmProgress wForm = new frmProgress(); new Thread((ThreadStart) delegate { wForm.TopMost = true; wForm.ShowDialog(); }).Start(); //********************** findProcess(); //数据处理 //genBomTree(pid); //********************** wForm.Invoke((EventHandler) delegate { wForm.Close(); }); }
private void btnRecompute_Click(object sender, EventArgs e) { double total = 0; List <clsAccountInfo> tmpAccounts = clsAccountInfo.GetAccounts(txtSearch.Text); frmProgress progress = new frmProgress(tmpAccounts.Count); progress.Caption = "Processing Accounts"; progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progress.Show(); if (tmpAccounts != null) { dgvAccounts.Rows.Clear(); foreach (clsAccountInfo a in m_Accounts) { a.LoadTransInfo(); AddItemToGrid(a); total += a.AccountReceivable; progress.Val += 1; } } progress.Close(); lblTotalReceivable.Text = string.Format("Accounts Receivable: P {0:0.00}", total); UpdateAccounts(); }
private void btnUpdateYTD_Click(object sender, EventArgs e) { double total = 0; List <clsAccountInfo> tmpAccounts = clsAccountInfo.GetAccounts(txtSearch.Text); frmProgress progress = new frmProgress(tmpAccounts.Count); progress.Caption = "Processing Accounts"; progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progress.Show(); if (tmpAccounts != null) { dgvAccounts.Rows.Clear(); foreach (clsAccountInfo a in m_Accounts) { double ytd = a.YTDTransaction; a.YTDTransaction = clsChargedTransaction.GetYTDTransactions(a.AccountId); if (a.YTDTransaction != ytd) { a.Save(); } progress.Val += 1; } } progress.Close(); lblTotalReceivable.Text = string.Format("Accounts Receivable: P {0:0.00}", total); DisplayAccounts(txtSearch.Text); }
/// <summary> /// Setup the backgroundworker and progress forms (Main thread) /// </summary> /// <param name="args"></param> public void WorkerLoadFileSetup(LoadFileArgs args) { MainController.Get().ProjectStatus = EProjectStatus.Busy; this.Text = Path.GetFileName(args.Filename) + " [" + args.Filename + "]"; if (!backgroundWorker1.IsBusy) { ProgressForm = new frmProgress() { Text = "Loading File...", StartPosition = FormStartPosition.CenterScreen, FormBorderStyle = FormBorderStyle.None }; workerAction = WorkerLoadFile; backgroundWorker1.RunWorkerAsync(args); var dr = ProgressForm.ShowDialog(this); } else { MainController.LogString("The background worker is currently busy.\r\n", Logtype.Error); } MainController.Get().ProjectStatus = EProjectStatus.Ready; }
private void DisplayAccounts(string name) { double total = 0; m_Accounts = clsAccountInfo.GetAccounts(name); frmProgress progress = new frmProgress(m_Accounts.Count); progress.Caption = "Loading Accounts"; progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progress.Show(); if (m_Accounts != null) { dgvAccounts.Rows.Clear(); foreach (clsAccountInfo a in m_Accounts) { AddItemToGrid(a); total += a.AccountReceivable; progress.Val += 1; } } progress.Close(); lblTotalReceivable.Text = string.Format("Accounts Receivable: P {0:0.00}", total); UpdateAccounts(); }
public static DialogResult showDialog( Form parent, baseFlikForm aktivFlik, vdCamera.vdCamera camera) { using (var dlg = new FImporteraBildfiler()) { dlg._aktivFlik = aktivFlik; dlg._requireRaw = eosPresets.UsesRaw( aktivFlik.PresetType, camera ); var sz = aktivFlik.FlikKategori == FlikKategori.Porträtt ? new Size(120, 180) : new Size(180, 120); dlg._thumbnails = new Thumbnails(null, Global.Skola, sz.Width, sz.Height, 10); if (dlg.ShowDialog(parent) != DialogResult.OK) return DialogResult.Cancel; Global.Preferences.LastImportFolder = dlg._strPath; Global.sparaInställningar(); var images = dlg.SelectedImages.ToArray(); var progress = new frmProgress("Hämtar bilder...", images.Length); progress.Owner = parent; progress.Show(); try { foreach (var filename in images) { byte[] rawData = null; foreach (var ext in new[] {".raw", ".cr2", ".tif"}) { var rawFile = Path.ChangeExtension(filename, ext); if (File.Exists(rawFile)) rawData = File.ReadAllBytes(rawFile); } aktivFlik.nyttFoto( true, File.ReadAllBytes(filename), rawData); progress.increaseValue(); } return DialogResult.OK; } catch (Exception ex) { Global.showMsgBox(null, "mnuImporteraBildfiler:\r\n{0}", ex.ToString()); } finally { progress.Close(); } return DialogResult.Cancel; } }
private void btnExport_Click(object sender, EventArgs e) { if (dgvReceipt.Rows.Count == 0) { MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } clsExportToExcel export = new clsExportToExcel(); SaveFileDialog savedlg = new SaveFileDialog(); savedlg.Filter = "Excel File (*.xls)|*.xls"; savedlg.InitialDirectory = Application.StartupPath; if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string columns = ""; foreach (DataGridViewColumn col in dgvReceipt.Columns) { columns += col.HeaderText + (col != dgvReceipt.Columns[dgvReceipt.Columns.Count - 1] ? "\t" : ""); } List <string> lstValues = new List <string>(); frmProgress progress = new frmProgress(dgvReceipt.Rows.Count); progress.Caption = "Loading Data"; progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progress.Show(); int ctr2 = 0; foreach (DataGridViewRow row in dgvReceipt.Rows) { string val = "HEADER1"; for (int ctr = 0; ctr < dgvReceipt.Columns.Count; ctr++) { val += row.Cells[ctr].Value.ToString() + (ctr != dgvReceipt.Columns.Count - 1 ? "\t" : ""); } lstValues.Add(val); Receipt r = new Receipt(Convert.ToInt32(row.Cells[1].Value)); if (r != null) { val = "BARCODE\tDESCRIPTION\tQTY\tAMOUNT\tTOTAL\tHEADER2"; lstValues.Add(val); foreach (KeyValuePair <string, clsPurchasedItem> p in r.PurchasedItems) { val = string.Format("[{0}]\t{1}\t{2}\t{3}\t{4}\t", p.Value.BarCode, p.Value.Description, p.Value.Qty, p.Value.Amount - p.Value.Discount, p.Value.Qty * (p.Value.Amount - p.Value.Discount)); lstValues.Add(val); } //lstValues.Add("\t"); } progress.Val = ++ctr2; } progress.Close(); export.SaveToExcelWithSummary(savedlg.FileName, columns, lstValues, "Total Sales\tAccounts Receivable\tNet Profit", string.Format("{0}\t{1}\t{2}", TotalIncome - TotalDiscounts, TotalAccountsReceivable, NetProfit)); } }
private void btnFind_Click(object sender, EventArgs e) { frmProgress wForm = new frmProgress(); new Thread((ThreadStart) delegate { wForm.TopMost = true; wForm.ShowDialog(); }).Start(); //********************** selectFind(); //数据处理 //genBomTree(pid); //********************** wForm.Invoke((EventHandler) delegate { wForm.Close(); }); }
private void findData() { txtPrd_dep.Focus(); frmProgress wForm = new frmProgress(); new Thread((ThreadStart) delegate { wForm.TopMost = true; wForm.ShowDialog(); }).Start(); //********************** findDataProcess(); //数据处理 //********************** wForm.Invoke((EventHandler) delegate { wForm.Close(); }); if (dgvDetails.Rows.Count == 0) { MessageBox.Show("沒有找到符合條件的記錄!"); } }
public override void Run(object sender, System.EventArgs e) { mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } bool bBind = mapView.Bind(this); if (!bBind) { return; } app = (DF2DApplication)this.Hook; if (app == null || app.Current2DMapControl == null) { return; } List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine"); if (list == null) { return; } List <DF2DFeatureClass> List = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode"); if (List == null) { return; } int nMax; nMax = list.Count + List.Count; m_frmPro = new frmProgress(nMax); m_frmPro.Update(); m_frmPro.Show(); checkTrueRoad(); m_frmPro.Text = "检查完成"; m_frmPro.Close(); }
private void BTNINPORT_Click(object sender, EventArgs e) { Load_Excel(); if (flag_inport) //導入EXCEL成功 { //顯示進度 frmProgress wForm = new frmProgress(); new Thread((ThreadStart) delegate { wForm.TopMost = true; wForm.ShowDialog(); }).Start(); //************************ Load_Data(); //数据处理 //************************ wForm.Invoke((EventHandler) delegate { wForm.Close(); }); } }
private void btnExport_Click(object sender, EventArgs e) { if (dgvExpenses.Rows.Count == 0) { MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } clsExportToExcel export = new clsExportToExcel(); SaveFileDialog savedlg = new SaveFileDialog(); savedlg.Filter = "Excel File (*.xls)|*.xls"; savedlg.InitialDirectory = Application.StartupPath; if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string columns = ""; foreach (DataGridViewColumn col in dgvExpenses.Columns) { columns += col.HeaderText + (col != dgvExpenses.Columns[dgvExpenses.Columns.Count - 1]?"\t":""); } List <string> lstValues = new List <string>(); frmProgress progress = new frmProgress(dgvExpenses.Rows.Count); progress.Caption = "Loading Data"; progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; progress.Show(); int ctr2 = 0; foreach (DataGridViewRow row in dgvExpenses.Rows) { string val = ""; for (int ctr = 0; ctr < dgvExpenses.Columns.Count; ctr++) { val += row.Cells[ctr].Value.ToString() + (ctr != dgvExpenses.Columns.Count - 1?"\t":""); } lstValues.Add(val); progress.Val = ++ctr2; } progress.Close(); export.SaveToExcelWithSummary(savedlg.FileName, columns, lstValues, "Total Expenses", string.Format("{0}", TotalExpenses)); } }
private void DoModel(frmProgress progress) { Random rand = new Random(); Int64 tmp_count = Convert.ToInt64(edCount.Value); frequency = new int[MAX_CARDS_SUM - MIN_CARDS_SUM + 1]; max_frequency = 1; preview = cbPreview.Checked; if (cards == null) { cards = new List<int>(CARDS_NUM * 4); for (int j = 0; j < 4; ++j) { for (int i = MIN_CARD; i <= MAX_CARD; ++i) cards.Add(i); } } for (count = 1; count <= tmp_count ; ++count) { if (progress.Step()) break; int sum = 0; for (int j = 0; j < EXTRACT_CARDS_COUNT; ++j) { int k = rand.Next(CARDS_NUM - j - 1); sum += cards[k]; cards.Add(cards[k]); cards.Remove(cards[k]); } max_frequency = Math.Max(max_frequency, ++frequency[sum - MIN_CARDS_SUM]); if (preview) pbGraphic.Invalidate(); } --count; edCount.Value = count; progress.Stop(); preview = true; pbGraphic.Invalidate(); }
private void DownloadFile(string file) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Binary files|*.bin"; sfd.FileName = file; if (sfd.ShowDialog() == DialogResult.OK) { frmProgress progress = new frmProgress(); progress.SetProgress("Downloading file"); progress.Show(); Application.DoEvents(); try { WebClient client = new WebClient(); client.DownloadFile("http://trionic.mobixs.eu/t7tunes/" + file, sfd.FileName); client.Dispose(); } catch (Exception E) { logger.Debug(E.Message); } progress.Close(); } /* string command = "http://trionic.mobixs.eu/t7tunes/" + file; * try * { * System.Diagnostics.Process.Start(command); * } * catch (Exception E) * { * //PumpString("Exception when checking new update(s): " + E.Message, false, false, new Version()); * logger.Debug(E.Message); * }*/ }
private void TuneToStageNew(int stage, double maxairmass, double maxtorque, double peakHP, EngineType enginetype, bool E85) { frmProgress progress = new frmProgress(); progress.Show(); progress.SetProgress("Checking current configuration..."); resumeTuning = new System.Data.DataTable(); resumeTuning.Columns.Add("Description"); AddToResumeTable("Tuning your binary to stage: " + stage.ToString()); progress.SetProgress("Creating backup file..."); int imaxairmass = Convert.ToInt32(maxairmass); File.Copy(m_currentfile, Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-beforetuningto-" + imaxairmass.ToString() + "-mg.bin", true); AddToResumeTable("Backup file created (" + Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-beforetuningto-" + imaxairmass.ToString() + "-mg.bin" + ")"); // tune maps //TorqueCal.M_EngXSP progress.SetProgress("Tuning TorqueCal.M_EngXSP..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngXSP") > 0) { byte[] TorqCal = GetTorqueCalEngineSupportPoints(Convert.ToInt32(maxairmass)); //<GS-11042011> leave the left three columns out savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngXSP") + 6, GetSymbolLength(m_symbols, "TorqueCal.M_EngXSP") - 6, TorqCal, m_currentfile, true); AddToResumeTable("Tuned x axis for torque calibration map (TorqueCal.M_EngXSP)"); } UpdateChecksum(m_currentfile); /* maximum allowable airmass per rpm site to protect turbine (overrev protection) */ progress.SetProgress("Tuning LimEngCal.TurboSpeedTab..."); if ((int)GetSymbolAddress(m_symbols, "LimEngCal.TurboSpeedTab") > 0) { // fill the entire table with maxairmass * 1.1 double max_airmassTurboSpeed = maxairmass * 1.1; byte[] TorqCal = GetTurboSpeedLimiter(Convert.ToInt32(max_airmassTurboSpeed), GetSymbolLength(m_symbols, "LimEngCal.TurboSpeedTab")/2); savedatatobinary((int)GetSymbolAddress(m_symbols, "LimEngCal.TurboSpeedTab"), GetSymbolLength(m_symbols, "LimEngCal.TurboSpeedTab"), TorqCal, m_currentfile, true); AddToResumeTable("Tuned turbo speed limiter (LimEngCal.TurboSpeedTab)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning LimEngCal.TurboSpeedTab2..."); if ((int)GetSymbolAddress(m_symbols, "LimEngCal.TurboSpeedTab2") > 0) { // fill the entire table with 1000 (= correction factor 1) byte[] TorqCal = GetTurboSpeedLimiter(1000, GetSymbolLength(m_symbols, "LimEngCal.TurboSpeedTab2") / 2); savedatatobinary((int)GetSymbolAddress(m_symbols, "LimEngCal.TurboSpeedTab2"), GetSymbolLength(m_symbols, "LimEngCal.TurboSpeedTab2"), TorqCal, m_currentfile, true); AddToResumeTable("Tuned turbo speed limiter correction factors (LimEngCal.TurboSpeedTab2)"); } UpdateChecksum(m_currentfile); /* APC error trigger airmass maximum */ progress.SetProgress("Tuning BoosDiagCal.ErrMaxMReq..."); if ((int)GetSymbolAddress(m_symbols, "BoosDiagCal.ErrMaxMReq") > 0) { // fill the entire table with maxairmass * 1.1 double max_airmassTurboSpeed = maxairmass; byte[] TorqCal = GetTurboSpeedLimiter(Convert.ToInt32(max_airmassTurboSpeed), GetSymbolLength(m_symbols, "BoosDiagCal.ErrMaxMReq") / 2); savedatatobinary((int)GetSymbolAddress(m_symbols, "BoosDiagCal.ErrMaxMReq"), GetSymbolLength(m_symbols, "BoosDiagCal.ErrMaxMReq"), TorqCal, m_currentfile, true); AddToResumeTable("Tuned APC error triggered maximum airmass (BoosDiagCal.ErrMaxMReq)"); } UpdateChecksum(m_currentfile); //BoosDiagCal.p_BefLimit = 2.00 bar (absolute pressure) [ 2000 ] //BoosDiagCal.p_BefOkLimit = 1.60bar (absolute pressure) [ 1600 ] // set to 3000 both (2.0 bar boost)??? /* maximum airmass per that lets I factor grow */ progress.SetProgress("Tuning AirCtrlCal.m_MaxAirTab..."); if ((int)GetSymbolAddress(m_symbols, "AirCtrlCal.m_MaxAirTab") > 0) { // fill the entire table with maxairmass * 1.1 double max_airmassTurboSpeed = maxairmass * 1.1; byte[] TorqCal = GetTurboSpeedLimiter(Convert.ToInt32(max_airmassTurboSpeed), GetSymbolLength(m_symbols, "AirCtrlCal.m_MaxAirTab") / 2); savedatatobinary((int)GetSymbolAddress(m_symbols, "AirCtrlCal.m_MaxAirTab"), GetSymbolLength(m_symbols, "AirCtrlCal.m_MaxAirTab"), TorqCal, m_currentfile, true); AddToResumeTable("Tuned I factor airmass limiter (AirCtrlCal.m_MaxAirTab)"); } UpdateChecksum(m_currentfile); /* progress.SetProgress("Tuning X_AccPedalAutSP..."); if ((int)GetSymbolAddress(m_symbols, "X_AccPedalAutSP") > 0) { byte[] TorqCal = GetAutAccelPedalSupportPoints(Convert.ToInt32(maxairmass)); savedatatobinary((int)GetSymbolAddress(m_symbols, "X_AccPedalAutSP"), GetSymbolLength(m_symbols, "X_AccPedalAutSP"), TorqCal, m_currentfile); AddToResumeTable("Tuned x axis for accelerator pedal map (AUT) (X_AccPedalAutSP)"); } UpdateChecksum(m_currentfile); */ //step 1a) Alter x axis for TorqueCal.M_NominalMap (=TorqueCal.m_AirXSP) so that the airmass // reaches the maximum desired airmass at the last column (e.g. for a stage 4 1400 mg/c) progress.SetProgress("Tuning TorqueCal.m_AirXSP..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.m_AirXSP") > 0) { byte[] TorqCal = GetTorqueCalSupportPoints(Convert.ToInt32(maxairmass)); //<GS-11042011> leave the left three columns out savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.m_AirXSP") + 6, GetSymbolLength(m_symbols, "TorqueCal.m_AirXSP") - 6, TorqCal, m_currentfile, true); AddToResumeTable("Tuned x axis for nominal torquemap (TorqueCal.m_AirXSP)"); } UpdateChecksum(m_currentfile); /*** TorqueCal.M_NominalMap ***/ /*** Data-matrix for nominal Torque. Engine speed and airmass are used as support points. The value in the matrix will be the engine output torque when inlet airmass (- friction airmass) is used together with actual engine speed as pointers ***/ // formula = replace last column with estimated values of max_torque (= last column * 1.3) int max_torque = GetMaxTorque(); if ((int)GetSymbolAddress(m_symbols, "BoostCal.RegMap") > 0) { byte[] BoostMap = GetBoostRegMap(Convert.ToInt32(maxairmass)); savedatatobinary((int)GetSymbolAddress(m_symbols, "BoostCal.RegMap"), GetSymbolLength(m_symbols, "BoostCal.RegMap"), BoostMap, m_currentfile, true); AddToResumeTable("Tuned boost calibration map (BoostCal.RegMap)"); } UpdateChecksum(m_currentfile); // now also do BoostCal.SetLoadXSP (!!!) mg/c 8 values // run from 500 upto maxairmass if ((int)GetSymbolAddress(m_symbols, "BoostCal.SetLoadXSP") > 0) { byte[] BoostMap = GetBoostMapSupportPoints(Convert.ToInt32(maxairmass)); savedatatobinary((int)GetSymbolAddress(m_symbols, "BoostCal.SetLoadXSP"), GetSymbolLength(m_symbols, "BoostCal.SetLoadXSP"), BoostMap, m_currentfile, true); AddToResumeTable("Tuned nominal torque map x axis (BoostCal.SetLoadXSP)"); } UpdateChecksum(m_currentfile); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_NominalMap") > 0) { byte[] nominalMap = GetNominalTorqueMap(Convert.ToInt32(maxairmass)); //<GS-11042011> leave the left three columns out int baseAddress = (int)GetSymbolAddress(m_symbols, "TorqueCal.M_NominalMap"); for (int iRow = 0; iRow < 16; iRow++) { byte[] nominalMapPart = new byte[30]; for (int iColumn = 0; iColumn < 30; iColumn++) { nominalMapPart[iColumn] = nominalMap[(iRow * 36) + 6 + iColumn]; } savedatatobinary(baseAddress + (iRow * 36) + 6, 30, nominalMapPart, m_currentfile, true); } //savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_NominalMap"), GetSymbolLength(m_symbols, "TorqueCal.M_NominalMap"), nominalMap, m_currentfile, true); AddToResumeTable("Tuned nominal torque map (TorqueCal.M_NominalMap)"); } UpdateChecksum(m_currentfile); // step 1b) Alter TorqueCal.m_AirTorqMap so that the maximum torquecolumn requests the desired airmass. /*** TorqueCal.m_AirTorqMap ***/ /*** Data-matrix for nominal airmass. Engine speed and torque are used as support points. The value in the matrix + friction airmass (idle airmass) will create the pointed torque at the pointed engine speed. Resolution is 1 mg/c. ***/ progress.SetProgress("Tuning TorqueCal.m_AirTorqMap..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.m_AirTorqMap") > 0) { byte[] AirTorqueCalibration = GetAirTorqueCalibration(Convert.ToInt32(maxairmass)); //<GS-11042011> leave the left three columns out int baseAddress = (int)GetSymbolAddress(m_symbols, "TorqueCal.m_AirTorqMap"); for (int iRow = 0; iRow < 16; iRow++) { byte[] nominalMapPart = new byte[26]; for (int iColumn = 0; iColumn < 26; iColumn++) { nominalMapPart[iColumn] = AirTorqueCalibration[(iRow * 32) + 6 + iColumn]; } savedatatobinary(baseAddress + (iRow * 32) + 6, 26, nominalMapPart, m_currentfile, true); } //savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.m_AirTorqMap"), GetSymbolLength(m_symbols, "TorqueCal.m_AirTorqMap"), AirTorqueCalibration, m_currentfile, true); AddToResumeTable("Tuned nominal airmass map (TorqueCal.m_AirTorqMap)"); } // update the checksum UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.m_PedYSP..."); //TODO: PedelMap Y axis with fixed data! // step 1c) Alter the pedal request Y axis to meet the airmass request. TorqueCal.m_PedYSP /********** TorqueCal.m_PedYSP ***********/ if ((int)GetSymbolAddress(m_symbols, "TorqueCal.m_PedYSP") > 0) { byte[] pedalmapysp = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.m_PedYSP"), GetSymbolLength(m_symbols, "TorqueCal.m_PedYSP")); // up the highest three rows with respectively 1.1, 1.2 and 1.3 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.m_PedYSP", out cols, out rows); if (isSixteenBitTable("TorqueCal.m_PedYSP")) rows /= 2; // row > 5 and col > 4 int ioffset1 = ((rows-4) * cols * 2); int ioffset2 = ((rows-4) * cols * 2) + 1; int pos4value = Convert.ToInt32(pedalmapysp[ioffset1]) * 256 + Convert.ToInt32(pedalmapysp[ioffset2]); int airmassperstep = (Convert.ToInt32(maxairmass) - pos4value)/3; int step = 1; for (int rt = rows - 3; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(pedalmapysp[offset1]) * 256 + Convert.ToInt32(pedalmapysp[offset2]); /*if (rt == rows - 3) { boostcalvalue *= 11; boostcalvalue /= 10; } else if (rt == rows - 2) { boostcalvalue *= 12; boostcalvalue /= 10; } else { boostcalvalue *= 13; boostcalvalue /= 10; }*/ boostcalvalue = pos4value + (airmassperstep * step); step++; if (boostcalvalue > maxairmass) boostcalvalue = (int)maxairmass; byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); pedalmapysp[offset1] = b1; pedalmapysp[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.m_PedYSP"), GetSymbolLength(m_symbols, "TorqueCal.m_PedYSP"), pedalmapysp, m_currentfile, true); AddToResumeTable("Tuned airmass pedalmap y axis (TorqueCal.m_PedYSP)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning PedalMapCal.m_RequestMap..."); // step 1d) Alter the pedal request map to meet the desired airmass in the top 2 rows (90-100%). PedalMapCal.m_RequestMap /********** PedalMapCal.m_RequestMap ***********/ if ((int)GetSymbolAddress(m_symbols, "PedalMapCal.m_RequestMap") > 0) { byte[] ReferencePedalMap = GetPedalMap(Convert.ToInt32(maxairmass), Convert.ToInt32(peakHP), E85); savedatatobinary((int)GetSymbolAddress(m_symbols, "PedalMapCal.m_RequestMap"), GetSymbolLength(m_symbols, "PedalMapCal.m_RequestMap"), ReferencePedalMap, m_currentfile, true); AddToResumeTable("Tuned airmass request map (PedalMapCal.m_RequestMap)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning BstKnkCal.MaxAirmass..."); // step 2) Increase the airmass limit table to allow for more airmass in the desired areas. BstKnkCal.MaxAirmass. /********** BstKnkCal.MaxAirmass ***********/ if ((int)GetSymbolAddress(m_symbols, "BstKnkCal.MaxAirmass") > 0) { byte[] AirmassLimiter = GetAirmassLimiter(Convert.ToInt32(maxairmass)); savedatatobinary((int)GetSymbolAddress(m_symbols, "BstKnkCal.MaxAirmass"), GetSymbolLength(m_symbols, "BstKnkCal.MaxAirmass"), AirmassLimiter, m_currentfile, true); AddToResumeTable("Tuned airmass limiter for manual transmission (BstKnkCal.MaxAirmass)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning BstKnkCal.MaxAirmassAu..."); if ((int)GetSymbolAddress(m_symbols, "BstKnkCal.MaxAirmassAu") > 0) { /********** BstKnkCal.MaxAirmassAu ***********/ byte[] AirmassLimiter = GetAirmassLimiter(Convert.ToInt32(maxairmass)); savedatatobinary((int)GetSymbolAddress(m_symbols, "BstKnkCal.MaxAirmassAu"), GetSymbolLength(m_symbols, "BstKnkCal.MaxAirmassAu"), AirmassLimiter, m_currentfile, true); AddToResumeTable("Tuned airmass limiter for automatic transmission (BstKnkCal.MaxAirmassAu)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_EngMaxAutTab..."); // step 3 – Increasing engine torque limiters. Up the engine limiters so that the limiter // is higher than the maximum torque in the request maps. // (TorqueCal.M_EngMaxTab, TorqueCal.M_ManGearLim, TorqueCal.M_CabGearLim, TorqueCal.M_5GearLimTab) /********** TorqueCal.M_EngMaxAutTab ***********/ if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxAutTab") > 0) { byte[] maxtorqueaut = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxAutTab")); // up with 1.3 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_EngMaxAutTab", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_EngMaxAutTab")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorqueaut[offset1]) * 256 + Convert.ToInt32(maxtorqueaut[offset2]); boostcalvalue = 320; byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorqueaut[offset1] = b1; maxtorqueaut[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxAutTab"), maxtorqueaut, m_currentfile, true); AddToResumeTable("Tuned torque limiter for automatic transmission (TorqueCal.M_EngMaxAutTab)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_EngMaxTab..."); /********** TorqueCal.M_EngMaxTab ***********/ if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxTab") > 0) { byte[] maxtorquetab = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxTab")); // up with 1.3 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_EngMaxTab", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_EngMaxTab")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorquetab[offset1]) * 256 + Convert.ToInt32(maxtorquetab[offset2]); if (boostcalvalue > maxtorque) boostcalvalue = (int)maxtorque; boostcalvalue = 320; byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorquetab[offset1] = b1; maxtorquetab[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxTab"), maxtorquetab, m_currentfile, true); AddToResumeTable("Tuned torque limiter for manual transmission (TorqueCal.M_EngMaxTab)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_EngMaxE85Tab..."); /********** TorqueCal.M_EndMaxE85Tab ***********/ if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxE85Tab") > 0) { byte[] maxtorquetab = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxE85Tab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxE85Tab")); // up with 1.3 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_EngMaxE85Tab", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_EngMaxE85Tab")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorquetab[offset1]) * 256 + Convert.ToInt32(maxtorquetab[offset2]); if (boostcalvalue > maxtorque) boostcalvalue = (int)maxtorque; boostcalvalue = 320; byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorquetab[offset1] = b1; maxtorquetab[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_EngMaxE85Tab"), GetSymbolLength(m_symbols, "TorqueCal.M_EngMaxE85Tab"), maxtorquetab, m_currentfile, true); AddToResumeTable("Tuned torque limiter for manual transmission on E85 fuel (TorqueCal.M_EngMaxE85Tab)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_ManGearLim..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_ManGearLim") > 0) { //TorqueCal.M_ManGearLim byte[] maxtorquemangear = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_ManGearLim"), GetSymbolLength(m_symbols, "TorqueCal.M_ManGearLim")); // up with 1.4 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_ManGearLim", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_ManGearLim")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorquemangear[offset1]) * 256 + Convert.ToInt32(maxtorquemangear[offset2]); if (boostcalvalue > maxtorque) boostcalvalue = (int)maxtorque; if (rt <= 1) { boostcalvalue = 200; } else { boostcalvalue = 320; } byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorquemangear[offset1] = b1; maxtorquemangear[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_ManGearLim"), GetSymbolLength(m_symbols, "TorqueCal.M_ManGearLim"), maxtorquemangear, m_currentfile, true); AddToResumeTable("Tuned torque limiter for manual transmission gears (TorqueCal.M_ManGearLim)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_CabGearLim..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_CabGearLim") > 0) { //TorqueCal.M_ManGearLim byte[] maxtorquemangear = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_CabGearLim"), GetSymbolLength(m_symbols, "TorqueCal.M_CabGearLim")); // up with 1.4 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_CabGearLim", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_CabGearLim")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorquemangear[offset1]) * 256 + Convert.ToInt32(maxtorquemangear[offset2]); if (boostcalvalue > maxtorque) boostcalvalue = (int)maxtorque; if (rt <= 1) { boostcalvalue = 200; } else { boostcalvalue = 320; } byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorquemangear[offset1] = b1; maxtorquemangear[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_CabGearLim"), GetSymbolLength(m_symbols, "TorqueCal.M_CabGearLim"), maxtorquemangear, m_currentfile, true); AddToResumeTable("Tuned torque limiter for cabrialet cars (TorqueCal.M_CabGearLim)"); } UpdateChecksum(m_currentfile); progress.SetProgress("Tuning TorqueCal.M_5GearLimTab..."); if ((int)GetSymbolAddress(m_symbols, "TorqueCal.M_5GearLimTab") > 0) { //TorqueCal.M_ManGearLim byte[] maxtorquemangear = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TorqueCal.M_5GearLimTab"), GetSymbolLength(m_symbols, "TorqueCal.M_5GearLimTab")); // up with 1.4 factor int cols = 0; int rows = 0; GetTableMatrixWitdhByName(m_currentfile, m_symbols, "TorqueCal.M_5GearLimTab", out cols, out rows); if (isSixteenBitTable("TorqueCal.M_5GearLimTab")) rows /= 2; // row > 5 and col > 4 for (int rt = 0; rt < rows; rt++) { int offset1 = (rt * cols * 2); int offset2 = (rt * cols * 2) + 1; int boostcalvalue = Convert.ToInt32(maxtorquemangear[offset1]) * 256 + Convert.ToInt32(maxtorquemangear[offset2]); if (boostcalvalue > maxtorque) boostcalvalue = (int)maxtorque; boostcalvalue = 320; byte b1 = Convert.ToByte(boostcalvalue / 256); byte b2 = Convert.ToByte(boostcalvalue - (int)b1 * 256); maxtorquemangear[offset1] = b1; maxtorquemangear[offset2] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "TorqueCal.M_5GearLimTab"), GetSymbolLength(m_symbols, "TorqueCal.M_5GearLimTab"), maxtorquemangear, m_currentfile, true); AddToResumeTable("Tuned torque limiter for manual transmission in 5th gear (TorqueCal.M_5GearLimTab)"); } UpdateChecksum(m_currentfile); // step 4 – Adapt fuel delivery. // step 4a) You should make sure the fuel supply is good in all ranges by recalibrating BFuelCal.Map. Altering the maximum allowed airmass will also require more fuel. Check this with a wideband O2 sensor. // step 4b) If you change injectors you should change the injector constant InjCorrCal.InjectorConst and the battery voltage correction table InjCorrCal.BattCorrTab accordingly. //Step 5 – Increase fuel cur level // Increase the fuelcut limit to above the airmass desired. E.g. if you target 1350 mg/c the fuelcut limit should be higher e.g. 1450 or 1500. FCutCal.m_AirInletLimit. /********** FCutCal.m_AirInletLimit ***********/ progress.SetProgress("Tuning FCutCal.m_AirInletLimit..."); // write xxx to fuelcut limit if ((int)GetSymbolAddress(m_symbols, "FCutCal.m_AirInletLimit") > 0) { byte[] fuelcutmap = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "FCutCal.m_AirInletLimit"), GetSymbolLength(m_symbols, "FCutCal.m_AirInletLimit")); if (fuelcutmap.Length == 2) { // airmass fuelcut should be ~20% higher than max request double m_AirmassFuelcut = maxairmass * 1.2; int i_AirmassFuelcut = Convert.ToInt32(m_AirmassFuelcut); //if (i_AirmassFuelcut >= 1800) i_AirmassFuelcut = 1800; byte b1 = Convert.ToByte(i_AirmassFuelcut / 256); byte b2 = Convert.ToByte(i_AirmassFuelcut - (int)b1 * 256); fuelcutmap[0] = b1; fuelcutmap[1] = b2; } savedatatobinary((int)GetSymbolAddress(m_symbols, "FCutCal.m_AirInletLimit"), GetSymbolLength(m_symbols, "FCutCal.m_AirInletLimit"), fuelcutmap, m_currentfile, true); AddToResumeTable("Tuned fuelcut limiter (FCutCal.m_AirInletLimit)"); } UpdateChecksum(m_currentfile); //Boost regulation error supression //If boost regulation reports errors you can increase the difference between boost pressure and requested pressure above which a fault report is generated. BoostDiagCal.m_FaultDiff. Set to 200 in stead of 100 for example. progress.SetProgress("Tuning BoosDiagCal.m_FaultDiff..."); if ((int)GetSymbolAddress(m_symbols, "BoosDiagCal.m_FaultDiff") > 0) { byte[] fuelcutmap = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "BoosDiagCal.m_FaultDiff"), GetSymbolLength(m_symbols, "BoosDiagCal.m_FaultDiff")); if (fuelcutmap.Length == 2) { fuelcutmap[0] = 0x00; fuelcutmap[1] = 0xC8; } savedatatobinary((int)GetSymbolAddress(m_symbols, "BoosDiagCal.m_FaultDiff"), GetSymbolLength(m_symbols, "BoosDiagCal.m_FaultDiff"), fuelcutmap, m_currentfile, true); AddToResumeTable("Tuned boost fault indication level (BoosDiagCal.m_FaultDiff)"); } UpdateChecksum(m_currentfile); // mark binary as tuned to stage I //AddToResumeTable("Updated binary description with tuned stage"); progress.SetProgress("Generating report..."); AddToResumeTable("Updated checksum."); progress.Close(); // refresh open viewers }
private void StartCompareToSRAMFile(string sramfilename) { SymbolCollection scdiff = new SymbolCollection(); frmProgress progress = new frmProgress(); progress.SetProgress("Comparing to SRAM snapshot"); progress.Show(); int cnt = 0; foreach (SymbolHelper sh in m_symbols) { int percentage = cnt * 100 / m_symbols.Count; cnt++; progress.SetProgressPercentage(percentage); if (sh.Flash_start_address > 0 && sh.Start_address > 0) { // get sram content and binfile content for this symbol string symbolname = sh.Varname; if (symbolname.StartsWith("Symbol:")) symbolname = sh.Userdescription; if (IsSymbolCalibration(symbolname)) { int address = (int)sh.Flash_start_address; if (IsSoftwareOpen()/*length > 0x10*/) { address = address - GetOpenFileOffset();// 0xEFFC34; // this should autodetect!!! //tabdet.Map_address = address; //tabdet.IsOpenSoftware = _softwareIsOpen; //mapdata = readdatafromfile(m_currentfile, address, length); } if (address < m_currentfile_size) { byte[] sramsymbol = readdatafromSRAMfile(sramfilename, (int)sh.Start_address, (int)sh.Length); byte[] flashsymbol = readdatafromfile(m_currentfile, address, (int)sh.Length); int bdifferent = 0; if (sh.Varname == "BFuelCal.Map") { logger.Debug("break!"); } for (int btel = 0; btel < sh.Length; btel++) { if (sramsymbol[btel] != flashsymbol[btel]) { bdifferent++; } } if (bdifferent > 0) { // symbol is not equal! scdiff.Add(sh); } } } } } progress.Close(); dockManager1.BeginUpdate(); try { DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); CompareResults tabdet = new CompareResults(); tabdet.HideMissingSymbolIndicators(); tabdet.Dock = DockStyle.Fill; tabdet.Filename = sramfilename; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectRAM); dockPanel.Controls.Add(tabdet); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "SRAM <> BIN Compare results: " + Path.GetFileName(sramfilename); dockPanel.DockTo(dockManager1, DockingStyle.Left, 1); dockPanel.Width = 700; //CompareSymbolTable(filename, compSymbols, compAddressLookup, tabdet.gridControl1); tabdet.CompareSymbolCollection = scdiff; System.Data.DataTable dt = new System.Data.DataTable(); // T7 dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean")); dt.Columns.Add("CATEGORY", Type.GetType("System.Int32")); //0 dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double")); dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32")); dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double")); dt.Columns.Add("CATEGORYNAME"); dt.Columns.Add("SUBCATEGORYNAME"); dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32")); dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32")); dt.Columns.Add("Userdescription"); foreach (SymbolHelper sh in scdiff) { float diffperc = 0; int diffabs = 0; float diffavg = 0; dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, sh.Length, sh.Description, false, 0, diffperc, diffabs, diffavg, sh.Category.ToString().Replace("_", " "), sh.Subcategory.ToString().Replace("_", " "), sh.Symbol_number, sh.Symbol_number, sh.Userdescription); } tabdet.gridControl1.DataSource = dt; //tabdet.CompareAddressLookupCollection = compAddressLookup; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); }
private void StartAssemblerViewer(string filename, frmProgress progress) { if (m_currentfile != "") { dockManager1.BeginUpdate(); try { DockPanel dockPanel = dockManager1.AddPanel(DockingStyle.Right); dockPanel.Text = "Assembler: " + Path.GetFileName(filename); AsmViewer av = new AsmViewer() { Dock = DockStyle.Fill }; dockPanel.Width = 800; dockPanel.Controls.Add(av); progress.SetProgress("Loading assembler file ..."); av.LoadDataFromFile(filename, m_symbols); progress.SetProgress("Finding starting address in file"); av.FindStartAddress(m_currentfile); } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } }
private void SpawnSaabOpenTech(string arguments, bool showWindow) { TerminateOnlineProcesses(); if (showWindow) { frmInfoBox info = new frmInfoBox("Please note that you will have to be connected to the cars I-bus for this to work!"); } System.Windows.Forms.Application.DoEvents(); string Exename = Path.Combine(System.Windows.Forms.Application.StartupPath, "SaabOpenTech.exe"); ProcessStartInfo startinfo = new ProcessStartInfo(Exename); startinfo.CreateNoWindow = true; startinfo.UseShellExecute = false; startinfo.WindowStyle = ProcessWindowStyle.Hidden; startinfo.RedirectStandardOutput = true; startinfo.WorkingDirectory = System.Windows.Forms.Application.StartupPath; // set parameters startinfo.Arguments = arguments; frmProgress progress = new frmProgress(); progress.SetProgress("Communicating with the car, please wait. This can take upto 30 seconds"); progress.Show(); System.Windows.Forms.Application.DoEvents(); System.Diagnostics.Process conv_proc = System.Diagnostics.Process.Start(startinfo); string o = conv_proc.StandardOutput.ReadToEnd(); conv_proc.WaitForExit(30000); // wait for 10 seconds max if (!conv_proc.HasExited) { progress.Close(); System.Windows.Forms.Application.DoEvents(); conv_proc.Kill(); frmInfoBox info2 = new frmInfoBox("Maintainance tool was termined, something went wrong."); } else { progress.Close(); System.Windows.Forms.Application.DoEvents(); frmMaintainanceResult result = new frmMaintainanceResult(); result.commReport = o; result.ShowDialog(); } }
private void Actions_SearchMapContent_ItemClick(object sender, ItemClickEventArgs e) { // ask the user for which value to search and if searching should include symbolnames and/or symbol description if (ValidateFile()) { SymbolCollection result_Collection = new SymbolCollection(); frmSearchMaps searchoptions = new frmSearchMaps(); if (searchoptions.ShowDialog() == DialogResult.OK) { frmProgress progress = new frmProgress(); progress.SetProgress("Start searching data..."); progress.SetProgressPercentage(0); progress.Show(); System.Windows.Forms.Application.DoEvents(); int cnt = 0; foreach (SymbolHelper sh in m_symbols) { progress.SetProgress("Searching " + sh.Varname); progress.SetProgressPercentage((cnt * 100) / m_symbols.Count); bool hit_found = false; if (searchoptions.UseSpecificMapLength) { if (sh.Length != (int)searchoptions.MapLength) { continue; } } if (searchoptions.IncludeSymbolNames) { if (searchoptions.SearchForNumericValues) { if (sh.Varname.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Varname.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (searchoptions.IncludeSymbolDescription) { if (searchoptions.SearchForNumericValues) { if (sh.Description.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Description.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } // now search the symbol data if (sh.Flash_start_address < m_currentfile_size) { byte[] symboldata = readdatafromfile(m_currentfile, (int)sh.Flash_start_address, sh.Length); if (searchoptions.SearchForNumericValues) { if (isSixteenBitTable(sh.Varname)) { for (int i = 0; i < symboldata.Length / 2; i += 2) { float value = Convert.ToInt32(symboldata.GetValue(i)) * 256; value += Convert.ToInt32(symboldata.GetValue(i + 1)); value *= (float)GetMapCorrectionFactor(sh.Varname); value += (float)GetMapCorrectionOffset(sh.Varname); if (value == (float)searchoptions.NumericValueToSearchFor) { hit_found = true; } } } else { for (int i = 0; i < symboldata.Length; i++) { float value = Convert.ToInt32(symboldata.GetValue(i)); value *= (float)GetMapCorrectionFactor(sh.Varname); value += (float)GetMapCorrectionOffset(sh.Varname); if (value == (float)searchoptions.NumericValueToSearchFor) { hit_found = true; } } } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor.Length > symboldata.Length) { // possible... string symboldataasstring = System.Text.Encoding.ASCII.GetString(symboldata); if (symboldataasstring.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (hit_found) { // add to collection result_Collection.Add(sh); } cnt++; } progress.Close(); if (result_Collection.Count == 0) { frmInfoBox info = new frmInfoBox("No results found..."); } else { // start result screen dockManager1.BeginUpdate(); try { SymbolTranslator st = new SymbolTranslator(); DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); CompareResults tabdet = new CompareResults(); tabdet.ShowAddressesInHex = m_appSettings.ShowAddressesInHex; tabdet.SetFilterMode(m_appSettings.ShowAddressesInHex); tabdet.Dock = DockStyle.Fill; tabdet.UseForFind = true; tabdet.Filename = m_currentfile; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectForFind); dockPanel.Controls.Add(tabdet); dockPanel.Text = "Search results: " + Path.GetFileName(m_currentfile); dockPanel.DockTo(dockManager1, DockingStyle.Left, 1); dockPanel.Width = 700; System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean")); dt.Columns.Add("CATEGORY"); //0 dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double")); dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32")); dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double")); dt.Columns.Add("CATEGORYNAME"); dt.Columns.Add("SUBCATEGORYNAME"); dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32")); dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32")); //string category = ""; string ht = string.Empty; //double diffperc = 0; //int diffabs = 0; //double diffavg = 0; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; foreach (SymbolHelper shfound in result_Collection) { string helptext = st.TranslateSymbolToHelpText(shfound.Varname, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage); if (shfound.Varname.Contains(".")) { try { shfound.Category = shfound.Varname.Substring(0, shfound.Varname.IndexOf(".")); } catch (Exception cE) { logger.Debug("Failed to assign category to symbol: " + shfound.Varname + " err: " + cE.Message); } } dt.Rows.Add(shfound.Varname, shfound.Start_address, shfound.Flash_start_address, shfound.Length, shfound.Length, helptext, false, 0, 0, 0, 0, shfound.Category, "", shfound.Symbol_number, shfound.Symbol_number); } tabdet.CompareSymbolCollection = result_Collection; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); tabdet.gridControl1.DataSource = dt.Copy(); } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } } } }
private void btnSync_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; //异步执行开始 worker.RunWorkerAsync(); frmProgress frm = new frmProgress(this.worker); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(this); frm.Close(); this.Cursor = Cursors.Default; }
private void btnShowFullDisassembly_ItemClick(object sender, ItemClickEventArgs e) { string outputfile = Path.GetDirectoryName(m_currentfile); outputfile = Path.Combine(outputfile, Path.GetFileNameWithoutExtension(m_currentfile) + "_full.asm"); if (!AssemblerViewerActive(true, outputfile)) { frmProgress progress = new frmProgress(); progress.Show(); progress.SetProgress("Start disassembler"); if (!File.Exists(outputfile)) { progress.SetProgress("Disassembler running..."); Disassembler dis = new Disassembler(); dis.DisassembleFileRtf(m_currentfile, outputfile, m_currentfile_size, m_symbols); progress.SetProgress("Disassembler done..."); } progress.SetProgress("Loading assembler file"); StartAssemblerViewer(outputfile, progress); progress.Close(); } }
private void btnProcess_Click(object sender, EventArgs e) { _ProgressForm = frmProgress.ShowForm(); List <string> statementFileList = new List <string>(); this.Cursor = Cursors.WaitCursor; statements = new Statements { statements = new List <Statement>() }; Dictionary <String, bool> hasStatements = new Dictionary <string, bool>(); foreach (DataGridViewRow dvr in dgBuildings.Rows) { if ((bool)dvr.Cells[0].Value) { String buildingName = dvr.Cells[1].Value.ToString(); AddProgressString("Loading Building " + buildingName); SetBuildingStatement(buildingName); String datapath = dvr.Cells[5].Value.ToString(); int period = (int)dvr.Cells[6].Value; if (dvr.Cells[2].Value == null) { MessageBox.Show("ishoa"); } StatementBuilding strm = dvr.DataBoundItem as StatementBuilding; List <Statement> bStatements = SetBuildings(strm.GetBuildingId(), buildingName, datapath, period, (bool)dvr.Cells[2].Value); int idx = dvr.Index; DataRow dr = dsBuildings.Tables[0].Rows[idx]; String pm = dr["pm"].ToString(); String bankName = dr["bankName"].ToString(); String accName = dr["accName"].ToString(); String bankAccNumber = dr["bankAccNumber"].ToString(); String branch = dr["branch"].ToString(); bool isStd = bankName.ToLower().Contains("standard"); foreach (Statement s in bStatements) { s.pm = pm; s.bankName = bankName; s.accName = accName; s.BankAccountNumber = bankAccNumber; s.branch = branch; s.isStd = isStd; statements.statements.Add(s); } } } PDF generator = new PDF(true); foreach (Statement stmt in statements.statements) { String fileName = String.Empty; bool canProcess = false; if (stmt.IsInTransfer && stmt.InTransferLetter != null) { string folderPath = generator.StatementFolderPath; fileName = Path.Combine(folderPath, String.Format("{0} - InTransfer - {1}{2}.pdf", stmt.AccNo.Replace(@"/", "-").Replace(@"\", "-"), DateTime.Now.ToString("dd-MMMM-yyyy"), "")); if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } if (File.Exists(fileName)) { File.Delete(fileName); } File.WriteAllBytes(fileName, stmt.InTransferLetter); canProcess = true; } else { canProcess = generator.CreateStatement(stmt, stmt.BuildingName != "ASTRODON RENTALS" ? true : false, out fileName, stmt.isStd); } if (canProcess) { #region Upload Letter String actFileTitle = Path.GetFileNameWithoutExtension(fileName); String actFile = Path.GetFileName(fileName); #endregion Upload Letter string statementURL = string.Empty; #region Upload Me try { AddProgressString(stmt.BuildingName + ": " + stmt.accName + " - Upload statement to website"); string emailAddress = ""; if (stmt.email1 != null && stmt.email1.Length > 0) { emailAddress = stmt.email1[0]; } statementURL = _ClientPortal.InsertStatement(stmt.BuildingId, stmt.AccNo, stmt.StmtDate, fileName, File.ReadAllBytes(fileName), emailAddress); } catch (Exception ex) { statementURL = ""; AddProgressString(stmt.BuildingName + ": " + stmt.accName + " - Error Upload statement to website " + ex.Message); } #endregion #region Email Me if (stmt.EmailMe) { if (!String.IsNullOrEmpty(fileName)) { if (!hasStatements.ContainsKey(stmt.BuildingName)) { hasStatements.Add(stmt.BuildingName, true); } if (Controller.user.id != 1 && !String.IsNullOrWhiteSpace(statementURL)) { SetupEmail(stmt, fileName, statementURL); } } } #endregion #region Print Me if (stmt.PrintMe && Controller.user.id != 1) { if (!String.IsNullOrWhiteSpace(fileName)) { AddProgressString(stmt.BuildingName + ": " + stmt.AccNo + " - Add Statement to List - " + Path.GetFileName(fileName)); statementFileList.Add(fileName); // SendToPrinter(fileName, stmt.BuildingName , stmt.AccNo); } else { AddProgressString(stmt.BuildingName + ": " + stmt.AccNo + " - Error Printing Statement - file name blank"); } } #endregion Application.DoEvents(); } else { AddProgressString(stmt.BuildingName + ": " + stmt.AccNo + " - ERROR Processing Statement"); Application.DoEvents(); } } foreach (DataGridViewRow dvr in dgBuildings.Rows) { dvr.Cells[0].Value = false; } foreach (KeyValuePair <String, bool> hasStatement in hasStatements) { String query = "INSERT INTO tblStatements(building, lastProcessed) VALUES(@building, @lastProcessed)"; Dictionary <String, Object> sqlParms = new Dictionary <string, object>(); sqlParms.Add("@building", hasStatement.Key); sqlParms.Add("@lastProcessed", DateTime.Now); dh.SetData(query, sqlParms, out status); } CombinePDFsAndPrint(statementFileList); this.Cursor = Cursors.Arrow; _ProgressForm.Focus(); _ProgressForm.ProcessComplete(); _ProgressForm = null; }
private void DownloadFile(string file) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Binary files|*.bin"; sfd.FileName = file; if (sfd.ShowDialog() == DialogResult.OK) { frmProgress progress = new frmProgress(); progress.SetProgress("Downloading file"); progress.Show(); Application.DoEvents(); try { WebClient client = new WebClient(); client.DownloadFile("http://trionic.mobixs.eu/t7tunes/" + file, sfd.FileName); client.Dispose(); } catch (Exception E) { logger.Debug(E.Message); } progress.Close(); } /* string command = "http://trionic.mobixs.eu/t7tunes/" + file; try { System.Diagnostics.Process.Start(command); } catch (Exception E) { //PumpString("Exception when checking new update(s): " + E.Message, false, false, new Version()); logger.Debug(E.Message); }*/ }
private void btnImport_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.txtGroupName.Text.Trim())) { MessageBox.Show("请输入组名"); txtGroupName.Focus(); return; } //异步执行开始 worker.RunWorkerAsync(); frmProgress frm = new frmProgress(this.worker); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(this); frm.Close(); this.btnImport.Enabled = false; }
private void btnImport_Click(object sender, EventArgs e) { //异步执行开始 worker.RunWorkerAsync(); frmProgress frm = new frmProgress(this.worker); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(this); frm.Close(); this.btnImport.Enabled = false; }
private void GoModel(frmProgress progress) { Random rand = new Random(); double middle = 0.0; ClearModel(); for (long i = 0; i < m_variates_count; ++i) { if (progress.Step()) { m_variates_count = i; break; } double r = rand.NextDouble(); for (int j = 0; j < SUMS_COUNT; ++j) { if (r > PROBABILITIES[j]) continue; m_max_frequency = Math.Max(m_max_frequency, ++m_sum_frequencies[j]); middle += SUMS[j]; break; } } ProcessVariates(middle); }
public async Task <int> AddNewScheduleCall(ScheduleCallAddEditModel model, int createdBy) { string strMessage = string.Empty; string strAssignees = string.Empty; string strRequirements = string.Empty; try { progressForm = new frmProgress(); progressForm.Text = "CREATING A NEW SCHEDULE CALL"; progressForm.lblProgressText.Text = "Inserting a New Business Schecule Call"; progressForm.Show(); Application.DoEvents(); model.DB_MODEL.EntityType = (int)model.SOURCE_ENTITY; model.DB_MODEL.EntityID = (int)model.SOURCE_ENTITY_ID; model.DB_MODEL.CreatedBy = createdBy; model.DB_MODEL.CreatedDatetime = AppCommon.GetServerDateTime(); model.DB_MODEL.Reminder = model.DB_MODEL.Reminder; model.DB_MODEL.IsDeleted = false; model.DB_MODEL.Completed = false; _dbContext.TBL_MP_CRM_ScheduleCallLog.Add(model.DB_MODEL); _dbContext.SaveChanges(); model.ScheduleID = model.DB_MODEL.ScheduleID; progressForm.SetProgress(30, string.Format("\nSuccess ID: {0}\n\nInserting Assignees for this schedule in Database.", model.ScheduleID)); Application.DoEvents(); string mailTo = string.Empty; foreach (MultiSelectListItem item in model.listAssignees) { _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Add(new TBL_MP_CRM_ScheduleCallLogAssignee() { EmployeeID = item.ID, IsDeleted = false, ScheduleID = model.ScheduleID }); strAssignees += item.Description.Split('\n')[0] + " , "; _dbContext.SaveChanges(); mailTo += ServiceEmployee.GetEmployeeEmailByID(item.ID) + ";"; } strAssignees = strAssignees.TrimEnd(' ').TrimEnd(','); mailTo += "*****@*****.**"; progressForm.SetProgress(60, string.Format("\nSuccess: {0} Assignee(s) inserted in Database for Schdeule #{1}", model.listAssignees.Count, model.ScheduleID)); progressForm.SetProgress(60, string.Format("\n\n\nSending Email to {0}", mailTo.Replace(";", "; "))); Application.DoEvents(); ServiceEmail mail = new ServiceEmail(); string strSubject = string.Format("New Schedule Call: {0}", model.DB_MODEL.Subject.ToUpper()); switch (model.SOURCE_ENTITY) { case APP_ENTITIES.SALES_LEAD: LeadMasterInfoModel lead = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID); if (lead != null) { strMessage += String.Format("\n\n\nLead No.: {0} dt. {1}\nParty Name: {2}\n", lead.LeadNo, lead.LeadDate.Value.ToString("dd MMMyy"), lead.LeadName); strRequirements = string.Format("Lead Requirements:\n{0}", lead.LeadRequirement); } break; case APP_ENTITIES.SALES_ENQUIRY: TBL_MP_CRM_SalesEnquiry enquiry = (new ServiceSalesEnquiry(_dbContext)).GetEnquiryMasterDBInfo(model.SOURCE_ENTITY_ID); if (enquiry != null) { strMessage += String.Format("\n\n\nEnquiry No.: {0} dt. {1}\nParty Name: {2}\n", enquiry.SalesEnquiry_No, enquiry.SalesEnquiry_Date.ToString("dd MMMyy"), enquiry.Tbl_MP_Master_Party.PartyName); strRequirements = string.Format("Description:\n{0}", enquiry.General_Description); } break; case APP_ENTITIES.SALES_QUOTATION: TBL_MP_CRM_SalesQuotation quotation = (new ServiceSalesQuotation(_dbContext)).GetSalesQuotationMasterDBInfo(model.SOURCE_ENTITY_ID); if (quotation != null) { strMessage += String.Format("\n\n\n Quotation No.: {0} dt. {1}\nParty Name: {2}\n", quotation.Quotation_No, quotation.Quotation_Date.ToString("dd MMMyy"), quotation.Tbl_MP_Master_Party.PartyName); strRequirements = string.Format("Special Note:\n{0}", quotation.SpecialNotes); } break; case APP_ENTITIES.SALES_ORDER: TBL_MP_CRM_SalesOrder order = (new ServiceSalesOrder(_dbContext)).GetSalesOrderDBInfoByID(model.SOURCE_ENTITY_ID); if (order != null) { strMessage += String.Format("\n\n\n Order No.: {0} dt. {1}\nParty Name: {2}\n", order.SalesOrderNo, order.SalesOrderDate.ToString("dd MMMyy"), order.Tbl_MP_Master_Party.PartyName); strRequirements = string.Empty; } break; } strMessage += string.Format("\nContact Person(s) : {0}", model.DB_MODEL.ContactPerson); strMessage += string.Format("\nContact Number(s) : {0}", model.DB_MODEL.ContactNumber); strMessage += string.Format("\nAddress : {0}", model.DB_MODEL.Location); strMessage += string.Format("\n\nSCHEDULE\nSchedule Type: {0}", (new ServiceMASTERS(_dbContext)).GetAllScheduleCallActions().Where(x => x.ID == model.DB_MODEL.ActionID).FirstOrDefault().Description); strMessage += string.Format("\nSchdeule Date: {0}\nSchedule Time:{1}", model.DB_MODEL.StartAt.Value.ToString("dd MMM yyyy"), model.DB_MODEL.StartAt.Value.ToString("hh:mm tt")); strMessage += string.Format("\nPlan/Action: {0}", model.DB_MODEL.Subject.ToUpper()); strMessage += string.Format("\nRemarks: {0}\n", model.DB_MODEL.Remarks); strMessage += string.Format("\nAssigned To : {0}", strAssignees); strMessage += string.Format("\n\n{0}", strRequirements); string strEmailFrom = ServiceEmployee.GetEmployeeEmailByID(createdBy); await mail.SendScheduleCallCreatedEmailNotification(createdBy, strEmailFrom, mailTo, strSubject, strMessage); Application.DoEvents(); progressForm.Close(); this.IsScuccess = true; return(model.ScheduleID); } catch (Exception ex) { MessageBox.Show(ex.Message, "ServiceScheduleCallLog::AddNewScheduleCall", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model.ScheduleID); }
private void ConvertFileToDif(string filename, bool AutoExport) { System.Windows.Forms.Application.DoEvents(); DateTime startDate = DateTime.MaxValue; DateTime endDate = DateTime.MinValue; try { SymbolCollection sc = new SymbolCollection(); string[] alllines = File.ReadAllLines(filename); //using (StreamReader sr = new StreamReader(filename)) { //string line = string.Empty; char[] sep = new char[1]; char[] sep2 = new char[1]; //int linecount = 0; sep.SetValue('|', 0); sep2.SetValue('=', 0); //while ((line = sr.ReadLine()) != null) foreach(string line in alllines) { string[] values = line.Split(sep); if (values.Length > 0) { try { //dd/MM/yyyy HH:mm:ss //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|"; string dtstring = (string)values.GetValue(0); DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2))); if (dt > endDate) endDate = dt; if (dt < startDate) startDate = dt; for (int t = 1; t < values.Length; t++) { string subvalue = (string)values.GetValue(t); string[] subvals = subvalue.Split(sep2); if (subvals.Length == 2) { string varname = (string)subvals.GetValue(0); bool sfound = false; foreach (SymbolHelper sh in sc) { if (sh.Varname == varname || sh.Userdescription == varname) { sfound = true; } } SymbolHelper nsh = new SymbolHelper(); nsh.Varname = varname; if (!sfound) sc.Add(nsh); } } } catch (Exception pE) { logger.Debug(pE.Message); } } } } if (AutoExport) { foreach (SymbolHelper sh in sc) { sh.Color = GetColorFromRegistry(sh.Varname); } DifGenerator difgen = new DifGenerator(); difgen.AppSettings = m_appSettings; //difgen.LowAFR = m_appSettings.WidebandLowAFR; //difgen.HighAFR = m_appSettings.WidebandHighAFR; //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage; //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage; difgen.WidebandSymbol = m_appSettings.WideBandSymbol; //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol; difgen.UseWidebandInput = false; difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress); frmProgressLogWorks = new frmProgress(); frmProgressLogWorks.SetProgress("Exporting to LogWorks"); frmProgressLogWorks.Show(); System.Windows.Forms.Application.DoEvents(); try { difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale); } catch (Exception expE1) { logger.Debug(expE1.Message); } frmProgressLogWorks.Close(); } else { // show selection screen frmPlotSelection plotsel = new frmPlotSelection(); foreach (SymbolHelper sh in sc) { plotsel.AddItemToList(sh.Varname); } plotsel.Startdate = startDate; plotsel.Enddate = endDate; plotsel.SelectAllSymbols(); if (plotsel.ShowDialog() == DialogResult.OK) { sc = plotsel.Sc; endDate = plotsel.Enddate; startDate = plotsel.Startdate; DifGenerator difgen = new DifGenerator(); LogFilters filterhelper = new LogFilters(); difgen.SetFilters(filterhelper.GetFiltersFromRegistry()); difgen.AppSettings = m_appSettings; //difgen.LowAFR = m_appSettings.WidebandLowAFR; //difgen.HighAFR = m_appSettings.WidebandHighAFR; //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage; //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage; difgen.WidebandSymbol = m_appSettings.WideBandSymbol; //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol; difgen.UseWidebandInput = false; difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress); frmProgressLogWorks = new frmProgress(); frmProgressLogWorks.SetProgress("Exporting to LogWorks"); frmProgressLogWorks.Show(); System.Windows.Forms.Application.DoEvents(); try { if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale)) { StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif"); } else { frmInfoBox info = new frmInfoBox("No data was found to export!"); } } catch (Exception expE2) { logger.Debug(expE2.Message); } frmProgressLogWorks.Close(); } TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks); //MessageBox.Show("LogFile should be " + ts.ToString()); } } catch (Exception E) { logger.Debug(E.Message); } }
private void barSyncToECU_ItemClick(object sender, ItemClickEventArgs e) { if (m_currentfile != "") { if (MessageBox.Show("This will overwrite data in your ECU. Are you sure you want to proceed?", "Warning!", MessageBoxButtons.OKCancel) == DialogResult.OK) { if (CheckCANConnectivity()) { frmProgress progress = new frmProgress(); progress.Show(); progress.SetProgress("Start synchronization from binary to ECU"); System.Windows.Forms.Application.DoEvents(); int percentage = 0; int symCnt = 0; foreach (SymbolHelper sh in m_symbols) { // read from ECU, write to binary if (sh.Start_address > 0x80000) { //if (sh.Varname.EndsWith("Map")) //TODO: <GS-28012011> REMOVE AFTER DEBUGGING { string symbolname = sh.Varname; if (IsSymbolCalibration(symbolname)) { if (symbolname.StartsWith("Symbolnumber") && sh.Userdescription != "") symbolname = sh.Userdescription; percentage = symCnt * 100 / m_symbols.Count; if (symCnt % 5 == 0) { progress.SetProgress("Sync to ECU: " + symbolname); progress.SetProgressPercentage(percentage); } byte[] mapdata = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, symbolname), sh.Length); // store in the ECU WriteMapToSRAM(symbolname, mapdata, false); Thread.Sleep(1); } } } symCnt++; } if (progress != null) progress.Close(); } else { frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to get data from the ECU"); } } } }
private void btnGenerateTuningPackage_ItemClick(object sender, ItemClickEventArgs e) { // generate the default maps as a tuning package from the ECUs SRAM if (m_currentfile != "") { if (CheckCANConnectivity()) { frmProgress progress = new frmProgress(); progress.SetProgress("Downloading tuning package..."); progress.Show(); SymbolCollection scToExport = new SymbolCollection(); PackageExporter pe = new PackageExporter(); SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Trionic 7 packages|*.t7p"; if (sfd.ShowDialog() == DialogResult.OK) { AddToSymbolCollection(scToExport, "LimEngCal.TurboSpeedTab"); // add axis AddToSymbolCollection(scToExport, "LimEngCal.p_AirSP"); AddToSymbolCollection(scToExport, "AirCtrlCal.m_MaxAirTab"); // add axis AddToSymbolCollection(scToExport, "TempLimPosCal.Airmass"); //AddToSymbolCollection(scToExport, "X_AccPedalAutSP"); AddToSymbolCollection(scToExport, "BoostCal.RegMap"); // add axis AddToSymbolCollection(scToExport, "BoostCal.SetLoadXSP"); AddToSymbolCollection(scToExport, "BoostCal.n_EngSP"); AddToSymbolCollection(scToExport, "PedalMapCal.m_RequestMap");// add axis AddToSymbolCollection(scToExport, "PedalMapCal.n_EngineMap"); AddToSymbolCollection(scToExport, "PedalMapCal.X_PedalMap"); AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmass"); // add axis AddToSymbolCollection(scToExport, "BstKnkCal.OffsetXSP"); AddToSymbolCollection(scToExport, "BstKnkCal.n_EngYSP"); AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmassAu"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxAutTab"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxTab"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxE85Tab"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_ManGearLim"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_CabGearLim"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.n_Eng5GearSP"); AddToSymbolCollection(scToExport, "TorqueCal.M_5GearLimTab"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_NominalMap"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.m_AirXSP"); AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP"); AddToSymbolCollection(scToExport, "TorqueCal.m_AirTorqMap"); // add axis AddToSymbolCollection(scToExport, "TorqueCal.M_EngXSP"); AddToSymbolCollection(scToExport, "TorqueCal.m_PedYSP"); AddToSymbolCollection(scToExport, "FCutCal.m_AirInletLimit"); AddToSymbolCollection(scToExport, "BoosDiagCal.m_FaultDiff"); AddToSymbolCollection(scToExport, "BoosDiagCal.ErrMaxMReq"); AddToSymbolCollection(scToExport, "BFuelCal.Map"); AddToSymbolCollection(scToExport, "BFuelCal.StartMap"); AddToSymbolCollection(scToExport, "BFuelCal.E85Map"); AddToSymbolCollection(scToExport, "BFuelCal.AirXSP"); AddToSymbolCollection(scToExport, "BFuelCal.RpmYSP"); AddToSymbolCollection(scToExport, "InjCorrCal.InjectorConst"); AddToSymbolCollection(scToExport, "IgnNormCal.Map"); AddToSymbolCollection(scToExport, "IgnE85Cal.fi_AbsMap"); AddToSymbolCollection(scToExport, "IgnNormCal.m_AirXSP"); AddToSymbolCollection(scToExport, "IgnNormCal.n_EngYSP"); AddToSymbolCollection(scToExport, "IgnKnkCal.IndexMap"); AddToSymbolCollection(scToExport, "KnkFuelCal.fi_MapMaxOff"); AddToSymbolCollection(scToExport, "KnkFuelCal.m_AirXSP"); AddToSymbolCollection(scToExport, "BoostCal.PMap"); AddToSymbolCollection(scToExport, "BoostCal.IMap"); AddToSymbolCollection(scToExport, "BoostCal.DMap"); AddToSymbolCollection(scToExport, "BoostCal.PIDXSP"); AddToSymbolCollection(scToExport, "BoostCal.PIDYSP"); AddToSymbolCollection(scToExport, "TorqueCal.M_OverBoostTab"); AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP"); AddToSymbolCollection(scToExport, "KnkFuelCal.EnrichmentMap"); AddToSymbolCollection(scToExport, "IgnKnkCal.m_AirXSP"); AddToSymbolCollection(scToExport, "IgnKnkCal.n_EngYSP"); AddToSymbolCollection(scToExport, "KnkDetCal.RefFactorMap"); AddToSymbolCollection(scToExport, "KnkDetCal.m_AirXSP"); AddToSymbolCollection(scToExport, "KnkDetCal.n_EngYSP"); AddToSymbolCollection(scToExport, "MaxSpdCal.T_EngineSP"); AddToSymbolCollection(scToExport, "MaxSpdCal.n_EngLimAir"); AddToSymbolCollection(scToExport, "MaxVehicCal.v_MaxSpeed"); //pe.ExportPackage(scToExport, m_currentfile, sfd.FileName); if (File.Exists(sfd.FileName)) File.Delete(sfd.FileName); foreach (SymbolHelper sh in scToExport) { //<GS-28012011> progress.SetProgress("Downloading: " + sh.Varname); System.Windows.Forms.Application.DoEvents(); byte[] data = ReadMapFromSRAM(sh, false); pe.ExportMap(sfd.FileName, sh.Varname, sh.Userdescription, sh.Length, data); Thread.Sleep(1); } } if (progress != null) progress.Close(); } else { frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to download a tuning package"); } } }
public static int Main() { var commandLineParser = new clsParseCommandLine(); mInputFilePath = string.Empty; mOutputDirectoryPath = string.Empty; mParameterFilePath = string.Empty; mRecurseDirectories = false; mMaxLevelsToRecurse = 0; mQuietMode = false; mLogMessagesToFile = false; mLogFilePath = string.Empty; mLastSubtaskProgressTime = DateTime.UtcNow; try { var proceed = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { proceed = true; } } if (commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0 && !commandLineParser.NeedToShowHelp) { #if GUI ShowGUI(); #else ShowProgramHelp(); #endif return(0); } if (!proceed || commandLineParser.NeedToShowHelp || mInputFilePath.Length == 0) { ShowProgramHelp(); return(-1); } mMASIC = new clsMASIC(); RegisterMasicEvents(mMASIC); mMASIC.Options.DatasetLookupFilePath = mDatasetLookupFilePath; mMASIC.Options.SICOptions.DatasetID = mDatasetID; if (!string.IsNullOrEmpty(mMASICStatusFilename)) { mMASIC.Options.MASICStatusFilename = mMASICStatusFilename; } mMASIC.LogMessagesToFile = mLogMessagesToFile; mMASIC.LogFilePath = mLogFilePath; mMASIC.LogDirectoryPath = mLogDirectoryPath; if (!mQuietMode) { #if GUI mProgressForm = new frmProgress(); mProgressForm.InitializeProgressForm("Parsing " + Path.GetFileName(mInputFilePath), 0, 100, false, true); mProgressForm.InitializeSubtask(string.Empty, 0, 100, false); mProgressForm.ResetKeyPressAbortProcess(); mProgressForm.Show(); Application.DoEvents(); #else Console.WriteLine("Parsing " + Path.GetFileName(mInputFilePath)); #endif } int returnCode; if (mRecurseDirectories) { if (mMASIC.ProcessFilesAndRecurseDirectories(mInputFilePath, mOutputDirectoryPath, mOutputDirectoryAlternatePath, mRecreateDirectoryHierarchyInAlternatePath, mParameterFilePath, mMaxLevelsToRecurse)) { returnCode = 0; } else { returnCode = (int)mMASIC.ErrorCode; } } else if (mMASIC.ProcessFilesWildcard(mInputFilePath, mOutputDirectoryPath, mParameterFilePath)) { returnCode = 0; } else { returnCode = (int)mMASIC.ErrorCode; if (returnCode != 0) { Console.WriteLine("Error while processing: " + mMASIC.GetErrorMessage()); } } if (returnCode != 0) { ProgRunner.SleepMilliseconds(1500); } return(returnCode); } catch (Exception ex) { ShowErrorMessage("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); ProgRunner.SleepMilliseconds(1500); return(-1); } #if GUI finally { if (mProgressForm != null) { mProgressForm.HideForm(); mProgressForm = null; } } #endif }
private void btnUploadTuningPackage_ItemClick(object sender, ItemClickEventArgs e) { // upload a t7p file to the ECU if (m_currentfile != "") { if (CheckCANConnectivity()) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Trionic 7 packages|*.t7p"; ofd.Multiselect = false; char[] sep = new char[1]; sep.SetValue(',', 0); SymbolCollection scToImport = new SymbolCollection(); if (ofd.ShowDialog() == DialogResult.OK) { //TODO: create a list of maps to import .. maybe? frmProgress progress = new frmProgress(); progress.SetProgress("Uploading tuning package..."); progress.Show(); using (StreamReader sr = new StreamReader(ofd.FileName)) { string line = string.Empty; SymbolHelper sh_Import = new SymbolHelper(); while ((line = sr.ReadLine()) != null) { if (line.StartsWith("symbol=")) { // sh_Import = new SymbolHelper(); sh_Import.Varname = line.Replace("symbol=", ""); } else if (line.StartsWith("length=")) { sh_Import.Length = Convert.ToInt32(line.Replace("length=", "")); } else if (line.StartsWith("data=")) { // try { string dataBytes = line.Replace("data=", ""); // split using ',' string[] bytesInStrings = dataBytes.Split(sep); byte[] dataToInsert = new byte[sh_Import.Length]; for (int t = 0; t < sh_Import.Length; t++) { byte b = Convert.ToByte(bytesInStrings[t], 16); dataToInsert.SetValue(b, t); } int addressInFile = (int)GetSymbolAddress(m_symbols, sh_Import.Varname); if (addressInFile > 0) { if (sh_Import.Varname != "MapChkCal.ST_Enable") { progress.SetProgress("Uploading: " + sh_Import.Varname); WriteMapToSRAM(sh_Import.Varname, dataToInsert, false); System.Windows.Forms.Application.DoEvents(); Thread.Sleep(1); } } } catch (Exception E) { // add failure logger.Debug(E.Message); } } } } if (progress != null) progress.Close(); } } else { frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to upload a tuning package"); } } }
public static int currFile = 0; //Holds the current file being processed #endregion #region Copy Files /// <summary> /// This method is used to copy directories and files from sourceDirName /// to destDirName. Will copy sub directories if bool copySubDirs is true and /// overwrite files if bool overwriteFiles is true. It takes in a form to update the UI controls /// to report progress. /// /// Fills the following variables /// ----- /// totalFilesCopied /// filesNotCopied /// currFile /// /// </summary> /// <param name="sourceDirName"></param> /// <param name="destDirName"></param> /// <param name="copySubDirs"></param> /// <param name="overwriteFiles"></param> /// <param name="main"></param> public static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs, bool overwriteFiles, /*Needs to be changed per project*/ frmProgress main) { #region Variables //Holds the Directory variables #region Directory Variables DirectoryInfo dir = new DirectoryInfo(sourceDirName); //Holds sourceDirName DirectoryInfo DirectoryInfo[] dirs = dir.GetDirectories(); //Holds an array of DirectoryInfo DirectoryInfo destinationDirectory; // Holds the new DirectoryInfo destinationDirectory DirectorySecurity security; //Holds the Directory Security #endregion //Holds the variables to process copying a file #region Copy File Variables string temppath; //Holds the temp file path FileSecurity fileSecurity; //Holds the file security FileInfo[] files; //Holds an array of file information FileInfo copiedFile; //Holds a new FileInfo copiedFile; #endregion #endregion //Check if process is cancelled if (Settings.Default.Cancel == true) { return; //Exit the method } else { #region Directory Info and Security #region Check Source Directory Existance //Check if the source dir exists if (!dir.Exists) { //If not throw exception throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + sourceDirName); } #endregion #region Set Destination Directory //Check if the directory exists in the destination if (!Directory.Exists(destDirName)) { //If not create it and set it to the variable destinationDirectory destinationDirectory = Directory.CreateDirectory(destDirName); } else { //Set it to the variable destinationDirectory destinationDirectory = new DirectoryInfo(destDirName); } #endregion #region Set Security //-----Setting security access to the destination ----- //Get Access Control from dir set it to DirectorySecurity security security = dir.GetAccessControl(); //SetAccessRuleProtection on security security.SetAccessRuleProtection(true, true); //SetAccessControl for the DirectoryInfo destinationDirectory to security destinationDirectory.SetAccessControl(security); //----------------------------------------------------- #endregion #endregion #region FileCopy //Get all of the files from the directory files = dir.GetFiles(); //For each loop to go through the array of files foreach (FileInfo file in files) { //Set the path to combine the destination name and the file name from the source temppath = Path.Combine(destDirName, file.Name); //Get file access control fileSecurity = file.GetAccessControl(); //Set the fileSecurity access control fileSecurity.SetAccessRuleProtection(true, true); //Try to copy the file #region Copy File //Try statement to try and copy the file try { //Copy the file from the source to the destination file.CopyTo(temppath, false); //Increase the total files copied totalFilesCopied++; } //If file already exists catch { //Check if overwriteFiles is true if (overwriteFiles == true) { try { //Copy the file from the source to the destination file.CopyTo(temppath, overwriteFiles); //Increase the total files copied totalFilesCopied++; } catch { //Error issue copying filesNotCopied++; } } else { //Do NOT Copy filesNotCopied++; } } //get file info of copied file copiedFile = new FileInfo(temppath); //Set access control of the new file copiedFile.SetAccessControl(fileSecurity); //increase the numfiles processed by 1 to get current file currFile++; #endregion //Try statement to update the Progress UI providing progress reporting //Needs to be at end of method to be accurate!!! #region Update UI try { //Use the beginInvoke method to access the main forms UI controls to update them while copying main.BeginInvoke((ThreadStart) delegate() { main.lblCurrentFile.Text = "File: " + file.Name; //Current file name being copied to display main.lblFiles.Text = "Files Copied: " + currFile + " out of " + totalFiles; //Current file number out of the total files main.lblPercentComplete.Text = (currFile * 100 / totalFiles) + "% complete"; //Set the percent complete after every file main.progCurrentFile.Value = currFile * 100 / totalFiles; //Shows the progress on the form main.lblFilesSkipped.Text = "Files Skipped: " + filesNotCopied; //Show if any files were skipped }); } catch { //Error } #endregion }//End loop #endregion #region SubDirectory Copy //Check if the copySubDirectories is true if (copySubDirs) { //Use a foreach loop to go through all of the subdirectories in the dirs array foreach (DirectoryInfo subdir in dirs) { //Check that the subdirectory is not System Volume Information if (subdir.ToString() == "System Volume Information") { //If it is skip this as this has hightened security and cannot be copied } else { #region Copy SubDirectory //Get a temp path of the destination name and the subdir name temppath = Path.Combine(destDirName, subdir.Name); //Recursively call the DirectCopy method with the temp name as the destination DirectoryCopy(subdir.FullName, temppath, copySubDirs, overwriteFiles, main); //dirNumber++; #endregion } //End if statement } //End loop } //End if statement #endregion } }//End DirectoryCopy
private void Actions_btnCompareSRAMSnapshots_ItemClick(object sender, ItemClickEventArgs e) { // ask user to point out 2 SRAM files. OpenFileDialog ofd1 = new OpenFileDialog(); ofd1.Title = "First SRAM dump..."; ofd1.Filter = "SRAM dumps|*.ram"; ofd1.Multiselect = false; if (ofd1.ShowDialog() == DialogResult.OK) { string filename_1 = ofd1.FileName; ofd1.Title = "Second SRAM dump..."; if (ofd1.ShowDialog() == DialogResult.OK) { string filename_2 = ofd1.FileName; // now compare System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean")); dt.Columns.Add("CATEGORY", Type.GetType("System.Int32")); //0 dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double")); dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32")); dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double")); dt.Columns.Add("CATEGORYNAME"); dt.Columns.Add("SUBCATEGORYNAME"); dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32")); dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32")); dt.Columns.Add("Userdescription"); int cnt = 0; frmProgress progress = new frmProgress(); progress.SetProgress("Comparing SRAM snapshots"); progress.Show(); foreach (SymbolHelper sh in m_symbols) { int percentage = cnt * 100 / m_symbols.Count; cnt++; progress.SetProgressPercentage(percentage); //SetTaskProgress(percentage, true); string symbolname = sh.Varname; if (symbolname.StartsWith("Symbol:")) symbolname = sh.Userdescription; if (IsSymbolCalibration(symbolname)) { byte[] data_1 = readdatafromSRAMfile(filename_1, (int)sh.Start_address, (int)sh.Length); byte[] data_2 = readdatafromSRAMfile(filename_2, (int)sh.Start_address, (int)sh.Length); if (data_1.Length != data_2.Length) { frmInfoBox info = new frmInfoBox("Sram data structure invalid... " + sh.Varname); return; } else { double diffperc = 0; int diffabs = 0; double diffavg = 0; bool isdifferent = false; if (isSixteenBitTable(sh.Varname)) { for (int i = 0; i < data_1.Length; i += 2) { try { int value1 = (int)(byte)data_1.GetValue(i) * 256; value1 += (int)(byte)data_1.GetValue(i + 1); int value2 = (int)(byte)data_2.GetValue(i) * 256; value2 += (int)(byte)data_2.GetValue(i + 1); if (value1 != value2) { isdifferent = true; diffabs++; } } catch (Exception E) { logger.Debug(E.Message); } } } else { for (int i = 0; i < data_1.Length; i++) { if ((byte)data_1.GetValue(i) != (byte)data_2.GetValue(i)) { isdifferent = true; diffabs++; } } } if (isdifferent) { int lengthvalues = sh.Length; if (isSixteenBitTable(sh.Varname)) lengthvalues /= 2; diffperc = (diffabs * 100) / lengthvalues; dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, lengthvalues, sh.Description, false, 0, diffperc, diffabs, diffavg, sh.Category.ToString().Replace("_", " "), sh.Subcategory.ToString().Replace("_", " "), sh.Symbol_number, sh.Symbol_number, sh.Userdescription); } } } } progress.Close(); SymbolCollection compSymbols = new SymbolCollection(); //AddressLookupCollection compAddressLookup = new AddressLookupCollection(); dockManager1.BeginUpdate(); try { DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); SRAMCompareResults tabdet = new SRAMCompareResults(); tabdet.Dock = DockStyle.Fill; tabdet.Filename1 = filename_1; tabdet.Filename2 = filename_2; tabdet.onSRAMSymbolSelect += new SRAMCompareResults.NotifySRAMSelectSymbol(tabdet_onSRAMSymbolSelect); dockPanel.Controls.Add(tabdet); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "SRAM compare results: " + Path.GetFileName(filename_1) + " " + Path.GetFileName(filename_2); bool isDocked = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("SRAM compare results: ") && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Left, 1); dockPanel.Width = 700; } //CompareSymbolTable(filename, compSymbols, compAddressLookup, tabdet.gridControl1); tabdet.gridControl1.DataSource = dt; //tabdet.CompareTrionic5Tools.SymbolCollection = compSymbols; //tabdet.CompareAddressLookupCollection = compAddressLookup; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); SetStatusText("SRAM compare done"); //SetTaskProgress(0, false); } } }
public async Task <bool> UpdateScheduleCall(ScheduleCallAddEditModel model, int empID) { try { progressForm = new frmProgress(); progressForm.Text = "UPDAING SCHEDULE CALL ID: " + model.ScheduleID; progressForm.lblProgressText.Text = "Updating Business Schecule Call Master Info"; progressForm.Show(); Application.DoEvents(); int statusClose = _dbContext.APP_DEFAULTS.Where(x => x.ID == (int)APP_DEFAULT_VALUES.ScheduleCallStatusClose).FirstOrDefault().DEFAULT_VALUE; if (model.DB_MODEL.ScheduleStatus == statusClose) { model.DB_MODEL.Completed = true; } model.DB_MODEL.EntityType = (int)model.SOURCE_ENTITY; model.DB_MODEL.EntityID = (int)model.SOURCE_ENTITY_ID; model.DB_MODEL.ModifiedBy = empID; model.DB_MODEL.ModifiedDatetime = AppCommon.GetServerDateTime(); model.DB_MODEL.Reminder = model.DB_MODEL.Reminder; TBL_MP_CRM_ScheduleCallLog dbModel = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault(); if (dbModel != null) { dbModel.Subject = model.DB_MODEL.Subject; dbModel.Priority = model.DB_MODEL.Priority; dbModel.ActionID = model.DB_MODEL.ActionID; dbModel.ScheduleStatus = model.DB_MODEL.ScheduleStatus; dbModel.Completed = model.DB_MODEL.Completed; dbModel.ContactNumber = model.DB_MODEL.ContactNumber; dbModel.ContactPerson = model.DB_MODEL.ContactPerson; dbModel.CustomerName = model.DB_MODEL.CustomerName; dbModel.EndsAt = model.DB_MODEL.EndsAt; dbModel.StartAt = model.DB_MODEL.StartAt; dbModel.Reminder = model.DB_MODEL.Reminder; dbModel.EntityID = model.DB_MODEL.EntityID; dbModel.EntityType = model.DB_MODEL.EntityType; dbModel.ModifiedBy = empID; dbModel.ModifiedDatetime = AppCommon.GetServerDateTime(); dbModel.Remarks = model.DB_MODEL.Remarks; _dbContext.SaveChanges(); } progressForm.SetProgress(25, string.Format("\nSuccess: Updated Schedule Call Information into the Database")); Application.DoEvents(); progressForm.SetProgress(30, string.Format("\nSuccess ID: \n\nUpdating Assignees for this schedule in Database.")); Application.DoEvents(); string mailTo = string.Empty; // MARK ALL ASSIGNEES AS DELETED List <TBL_MP_CRM_ScheduleCallLogAssignee> dbAssignees = _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Where(x => x.ScheduleID == model.ScheduleID).ToList(); foreach (TBL_MP_CRM_ScheduleCallLogAssignee item in dbAssignees) { item.IsDeleted = true; } _dbContext.SaveChanges(); // OF EMPLOYEE FOUND SET DELETED=FALSE OR INSERT IF NOT FOUND foreach (MultiSelectListItem item in model.listAssignees) { TBL_MP_CRM_ScheduleCallLogAssignee emp = _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Where(x => x.ScheduleID == model.ScheduleID).Where(x => x.EmployeeID == item.ID).FirstOrDefault(); if (emp != null) { emp.IsDeleted = false; } else { _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Add(new TBL_MP_CRM_ScheduleCallLogAssignee() { EmployeeID = item.ID, IsDeleted = false, ScheduleID = model.ScheduleID }); } _dbContext.SaveChanges(); mailTo += ServiceEmployee.GetEmployeeEmailByID(item.ID) + ";"; } mailTo += "*****@*****.**"; progressForm.SetProgress(60, string.Format("\nSuccess: {0} Assignee(s) updated in Database for Schdeule #{1}", model.listAssignees.Count, model.ScheduleID)); progressForm.SetProgress(60, string.Format("\n\n\nSending Email to {0}", mailTo.Replace(";", "; "))); Application.DoEvents(); List <SelectListItem> scheduleStatusList = (new ServiceMASTERS()).GetAllScheduleCallsStatus(); ServiceEmail mail = new ServiceEmail(); string strSubject = string.Format("Updated Schedule Call: {0}", model.DB_MODEL.Subject); string strMessage = string.Empty; strMessage += string.Format("{0}\nStatus: {1}", model.DB_MODEL.Subject.ToUpper(), scheduleStatusList.Where(x => x.ID == model.DB_MODEL.ScheduleStatus).FirstOrDefault().Description); strMessage += string.Format("\nRemarks:{0}\n", model.DB_MODEL.Remarks); strMessage += string.Format("\nParty : {0}", model.DB_MODEL.CustomerName); strMessage += string.Format("\nContact Person(s) : {0}", model.DB_MODEL.ContactPerson); strMessage += string.Format("\nContact Number(s) : {0}", model.DB_MODEL.ContactNumber); strMessage += string.Format("\nLocation : {0}", model.DB_MODEL.Location); strMessage += string.Format("\n\nStarts At : {0}", model.DB_MODEL.StartAt.Value.ToString("dd MMMyy hh:mmtt")); strMessage += string.Format("\nEnds At : {0}", model.DB_MODEL.StartAt.Value.ToString("dd MMMyyy hh:mmtt")); switch (model.SOURCE_ENTITY) { case APP_ENTITIES.SALES_LEAD: LeadMasterInfoModel lead = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID); if (lead != null) { strMessage += String.Format("\n\n\nSOURCE INFO.\nLead: {0} dt. {1}\n{2}", lead.LeadNo, lead.LeadDate.Value.ToString("dd MMMyy"), lead.LeadRequirement); } break; } string strEmailAddress = ServiceEmployee.GetEmployeeEmailByID(empID); await mail.SendScheduleCallCreatedEmailNotification(empID, strEmailAddress, mailTo, strSubject, strMessage); Application.DoEvents(); progressForm.Close(); this.IsScuccess = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ServiceScheduleCallLog::UpdateScheduleCall", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(IsScuccess); }