本文整理汇总了C#中CommonSuite.SymbolCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolCollection.Add方法的具体用法?C# SymbolCollection.Add怎么用?C# SymbolCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonSuite.SymbolCollection
的用法示例。
在下文中一共展示了SymbolCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectedSymbolCollection
public SymbolCollection GetSelectedSymbolCollection()
{
// build a new collection based on the selected rows
SymbolCollection scSelected = new SymbolCollection();
if (gridControl1.DataSource != null)
{
//DataTable dt = (DataTable)gridControl1.DataSource;
int[] selrows = gridView1.GetSelectedRows();
foreach (int rowhandle in selrows)
{
SymbolHelper sh = (SymbolHelper)gridView1.GetRow(rowhandle);
if (sh != null)
{
scSelected.Add(sh);
}
}
}
return scSelected;
}
示例2: edit_FormClosed
void edit_FormClosed(object sender, FormClosedEventArgs e)
{
if (sender is frmEditTuningPackage)
{
frmEditTuningPackage edit = (frmEditTuningPackage)sender;
if (edit.WriteData)
{
// save the package again with altered settings probably.
logger.Debug("We should write the tuning package here!");
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Trionic 7 packages|*.t7p";
if (sfd.ShowDialog() == DialogResult.OK)
{
System.Data.DataTable dt = edit.GetDataTable();
SymbolCollection scToExport = new SymbolCollection();
foreach (DataRow dr in dt.Rows)
{
SymbolHelper sh = new SymbolHelper();
sh.Varname = dr["Map"].ToString();
sh.Currentdata = ConvertTuningPackageDataToByteArray(dr["Data"].ToString());
sh.Flash_start_address = GetSymbolAddress(m_symbols, sh.Varname);
sh.Userdescription = GetUserDescription(m_symbols, sh.Varname);
sh.Length = GetSymbolLength(m_symbols, sh.Varname);
scToExport.Add(sh);
}
PackageExporter pe = new PackageExporter();
if (IsSoftwareOpen())
{
pe.AddressOffset = GetOpenFileOffset();
}
pe.ExportPackage(scToExport, m_currentfile, sfd.FileName);
}
}
}
tunpackeditWindow = null;
}
示例3: ConvertFileToDif
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)
//.........这里部分代码省略.........
示例4: btnViewMatrixFromLog_ItemClick
private void btnViewMatrixFromLog_ItemClick(object sender, ItemClickEventArgs e)
{
// let the user select x axis, y axis and z axis symbols from the logfile
//
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Trionic 7 logfiles|*.t7l";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
avgTable = null;
string[] alllines = File.ReadAllLines(ofd.FileName);
System.Windows.Forms.Application.DoEvents();
DateTime startDate = DateTime.MaxValue;
DateTime endDate = DateTime.MinValue;
SymbolCollection sc = new SymbolCollection();
try
{
// using (StreamReader sr = new StreamReader(ofd.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)
{
sfound = true;
}
}
SymbolHelper nsh = new SymbolHelper();
nsh.Varname = varname;
if (!sfound) sc.Add(nsh);
}
}
}
catch (Exception pE)
{
logger.Debug(pE.Message);
}
}
}
}
}
catch (Exception E)
{
logger.Debug(E.Message);
}
frmMatrixSelection sel = new frmMatrixSelection();
sel.SetSymbolList(sc);
sel.SetXSelection(m_appSettings.LastXAxisFromMatrix);
sel.SetYSelection(m_appSettings.LastYAxisFromMatrix);
sel.SetZSelection(m_appSettings.LastZAxisFromMatrix);
if (sel.ShowDialog() == DialogResult.OK)
{
// get selected for x, y and z
int type = sel.GetViewType(); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
string x = sel.GetXAxisSymbol();
string y = sel.GetYAxisSymbol();
string z = sel.GetZAxisSymbol();
m_appSettings.LastXAxisFromMatrix = x;
m_appSettings.LastYAxisFromMatrix = y;
m_appSettings.LastZAxisFromMatrix = z;
double xmin = Double.MaxValue;
double xmax = Double.MinValue;
double ymin = Double.MaxValue;
double ymax = Double.MinValue;
double zmin = Double.MaxValue;
double zmax = Double.MinValue;
//using (StreamReader sr = new StreamReader(ofd.FileName))
{
// string line = string.Empty;
char[] sep = new char[1];
char[] sep2 = new char[1];
//.........这里部分代码省略.........
示例5: AddToSymbolCollection
private void AddToSymbolCollection(SymbolCollection scToExport, string symbolName)
{
foreach (SymbolHelper sh in m_symbols)
{
if (sh.Varname == symbolName || sh.Userdescription == symbolName)
{
SymbolHelper shNew = new SymbolHelper();
shNew.Start_address = sh.Start_address;
shNew.Symbol_number = sh.Symbol_number;
shNew.Symbol_number_ECU = sh.Symbol_number_ECU;
shNew.Internal_address = sh.Internal_address;
shNew.Varname = symbolName;
shNew.Flash_start_address = sh.Flash_start_address;
shNew.Length = sh.Length;
shNew.Userdescription = symbolName;
scToExport.Add(shNew);
break;
}
}
}
示例6: addToMyMapsToolStripMenuItem_Click
private void addToMyMapsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (gridViewSymbols.FocusedRowHandle >= 0)
{
SymbolHelper sh = (SymbolHelper)gridViewSymbols.GetRow(gridViewSymbols.FocusedRowHandle);
SymbolCollection scmymaps = new SymbolCollection();
SymbolHelper shnewmymap = new SymbolHelper();
shnewmymap.Varname = sh.Varname;
shnewmymap.Description = sh.Varname;
shnewmymap.Category = "Directly added";
scmymaps.Add(shnewmymap);
string filename = System.Windows.Forms.Application.StartupPath + "\\mymaps.xml";
if (File.Exists(filename))
{
try
{
System.Xml.XmlDocument mymaps = new System.Xml.XmlDocument();
mymaps.Load(System.Windows.Forms.Application.StartupPath + "\\mymaps.xml");
foreach (System.Xml.XmlNode category in mymaps.SelectNodes("categories/category"))
{
foreach (System.Xml.XmlNode map in category.SelectNodes("map"))
{
SymbolHelper shmap = new SymbolHelper();
shmap.Varname = map.Attributes["symbol"].Value;
shmap.Category = category.Attributes["title"].Value;
shmap.Description = map.Attributes["title"].Value;
scmymaps.Add(shmap);
}
}
}
catch { }
}
// now save a new file
if (File.Exists(filename))
{
File.Delete(filename);
}
XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
doc.AppendChild(dec);// Create the root element
XmlElement root = doc.CreateElement("categories");
doc.AppendChild(root);
scmymaps.SortColumn = "Category";
scmymaps.SortingOrder = GenericComparer.SortOrder.Ascending;
scmymaps.Sort();
string previouscat = "";
XmlElement title = doc.CreateElement("category");
foreach (SymbolHelper shmm in scmymaps)
{
if (shmm.Category != previouscat)
{
previouscat = shmm.Category;
title = doc.CreateElement("category");
title.SetAttribute("title", previouscat);
root.AppendChild(title);
}
XmlElement map = doc.CreateElement("map");
map.SetAttribute("symbol", shmm.Varname);
map.SetAttribute("title", shmm.Description);
title.AppendChild(map);
}
doc.Save(filename);
if (ribbonControl1.Pages[3].Text == "My Maps")
{
ribbonControl1.Pages.RemoveAt(3);
}
LoadMyMaps();
}
}
示例7: StartCompareToSRAMFile
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);
}
//.........这里部分代码省略.........
示例8: StartBitMaskViewer
private void StartBitMaskViewer(SymbolHelper sh)
{
// check for SRAM file and/or connected ECU if symbol is outside flash area
uint data = 0;
if (sh.Flash_start_address > m_currentfile_size)
{
//TODO: Implement
if (t8can.isOpen())
{
bool success = false;
byte[] bdat = t8can.readMemory((int)sh.Flash_start_address, 2, out success);
if (success)
{
data = Convert.ToUInt32(bdat[0]) * 256;
data += Convert.ToUInt32(bdat[1]);
}
else
{
MessageBox.Show("Symbol outside of flash boundary and failed to read symbol from ECU");
return;
}
}
else
{
MessageBox.Show("Symbol outside of flash boundary and no connection to ECU available");
return;
}
}
else
{
byte[] bdat = readdatafromfile(m_currentfile, (int)sh.Flash_start_address, 2);
data = Convert.ToUInt32(bdat[0]) * 256;
data += Convert.ToUInt32(bdat[1]);
}
// get all other symbols with the same address
SymbolCollection shview = new SymbolCollection();
foreach (SymbolHelper shl in m_symbols)
{
if (shl.Flash_start_address == sh.Flash_start_address)
{
shview.Add(shl);
}
}
// start a viewer with the collection and the real data
frmBitmaskViewer view = new frmBitmaskViewer();
view.SetInformation(shview, data);
if (view.ShowDialog() == DialogResult.OK)
{
// save the data to the file && update checksum if set to auto
byte[] bdata = new byte[2];
byte b1 = Convert.ToByte(view.Data / 256);
byte b2 = Convert.ToByte(view.Data - (int)b1 * 256);
bdata.SetValue(b1, 0);
bdata.SetValue(b2, 1);
if (sh.Flash_start_address > m_currentfile_size)
{
// save to ECU ... if possible
}
else
{
savedatatobinary((int)sh.Flash_start_address, 2, bdata, m_currentfile, true);
if (m_appSettings.AutoChecksum) UpdateChecksum(m_currentfile, true);
}
}
}
示例9: SetupLogFilters
private void SetupLogFilters()
{
// setup the export filters
LogFilters filterhelper = new LogFilters();
frmLogFilters frmfilters = new frmLogFilters();
LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
frmfilters.SetFilters(filters);
SymbolCollection sc = new SymbolCollection();
foreach (SymbolHelper sh in m_symbols)
{
//if (!sh.Varname.Contains("!")) sc.Add(sh);
if (!IsSymbolCalibration(sh.Varname)) sc.Add(sh);
}
frmfilters.SetSymbols(sc);
if (frmfilters.ShowDialog() == DialogResult.OK)
{
filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
}
}
示例10: SaveMyMaps
private void SaveMyMaps(string filename)
{
if (gridControl1.DataSource != null)
{
if (File.Exists(filename))
{
File.Delete(filename);
}
DataTable dt = (DataTable)gridControl1.DataSource;
XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
doc.AppendChild(dec);// Create the root element
XmlElement root = doc.CreateElement("categories");
doc.AppendChild(root);
SymbolCollection sc = new SymbolCollection();
// first get all categories
foreach (DataRow dr in dt.Rows)
{
string category = dr["category"].ToString();
bool found = false;
foreach(SymbolHelper sh in sc)
{
if (sh.Varname == category) found = true;
}
if (!found)
{
SymbolHelper newsh = new SymbolHelper();
newsh.Varname = category;
sc.Add(newsh);
}
}
foreach (SymbolHelper sh in sc)
{
XmlElement title = doc.CreateElement("category");
title.SetAttribute("title", sh.Varname);
foreach (DataRow dr in dt.Rows)
{
if (dr["category"].ToString() == sh.Varname)
{
XmlElement map = doc.CreateElement("map");
map.SetAttribute("symbol", dr["symbol"].ToString());
map.SetAttribute("title", dr["title"].ToString());
title.AppendChild(map);
}
}
root.AppendChild(title);
}
/*
foreach (DataRow dr in dt.Rows)
{
XmlElement title = doc.CreateElement("category");
title.SetAttribute("title", dr["category"].ToString());
XmlElement map = doc.CreateElement("map");
map.SetAttribute("symbol", dr["symbol"].ToString());
map.SetAttribute("title", dr["title"].ToString());
title.AppendChild(map);
root.AppendChild(title);
}
* */
doc.Save(filename);
}
}
示例11: exportAsTuningPackageToolStripMenuItem_Click
private void exportAsTuningPackageToolStripMenuItem_Click(object sender, EventArgs e)
{
// well.. export the entire result set as a tuning package
// export selected maps as tuning package (name the file t7p)
// get selected rows
//<GS-22022011> TODO: Let the user choose from which binary file he/she wants to export the data
// the orginal file or the file that we compared to
frmFileToExportSelection frmSelection = new frmFileToExportSelection();
frmSelection.SetOriginalFileName(m_OriginalFilename);
frmSelection.SetCompareFileName(m_CompareFilename);
if (frmSelection.ShowDialog() == DialogResult.OK)
{
DataTable dt = (DataTable)gridControl1.DataSource;
SymbolCollection scToExport = new SymbolCollection();
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
string varname = dr["SYMBOLNAME"].ToString();
if (varname.StartsWith("Symbolnumber")) varname = dr["Userdescription"].ToString();
if (!varname.StartsWith("Symbolnumber") && !varname.StartsWith("overrun") && !varname.StartsWith("Data_name") && !varname.StartsWith("MapChkCal"))
{
if (frmSelection.UseOriginalFile)
{
foreach (SymbolHelper sh in m_originalSymbolCollection)
{
if (sh.SmartVarname == varname)
{
scToExport.Add(sh);
break;
}
}
}
else
{
foreach (SymbolHelper sh in m_compareSymbolCollection)
{
if (sh.SmartVarname == varname)
{
scToExport.Add(sh);
break;
}
}
}
}
}
frmSymbolSelection symsel = new frmSymbolSelection();
symsel.SetSymbolCollection(scToExport);
symsel.SelectAllSymbols();
if (symsel.ShowDialog() == DialogResult.OK)
{
SymbolCollection scSelected = new SymbolCollection();
scSelected = symsel.GetSelectedSymbolCollection();
PackageExporter pe = new PackageExporter();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Trionic 7 packages|*.t7p";
if (sfd.ShowDialog() == DialogResult.OK)
{
if (frmSelection.UseOriginalFile)
{
pe.ExportPackage(scSelected, m_OriginalFilename, sfd.FileName);
}
else
{
pe.ExportPackage(scSelected, m_filename, sfd.FileName);
}
}
}
}
}
}
示例12: TryToExtractPackedBinary
public static bool TryToExtractPackedBinary(string filename, int filename_size, out SymbolCollection symbol_collection)
{
bool retval = true;
byte[] compressedSymbolTable;
//Test 15092009
//int RealAddressTableOffset = GetAddrTableOffset(filename) + 7; // was 17
int RealAddressTableOffset = GetAddrTableOffsetBySymbolTable(filename) + 7; // was 17 // <GS-22032010>
//Test 15092009
logger.Debug("Real symboltable offset: " + RealAddressTableOffset.ToString("X8"));
int symboltableoffset = 0;
symbol_collection = new SymbolCollection();
CastProgressEvent("Unpacking file... ",5);
bool compr_created = extractCompressedSymbolTable(filename, out symboltableoffset, out compressedSymbolTable);
CastProgressEvent("Finding address table... ",15);
byte[] searchsequence = new byte[9];
searchsequence.SetValue((byte)0x00, 0);
searchsequence.SetValue((byte)0x00, 1);
searchsequence.SetValue((byte)0x00, 2);
searchsequence.SetValue((byte)0x00, 3);
searchsequence.SetValue((byte)0x00, 4);
searchsequence.SetValue((byte)0x00, 5);
searchsequence.SetValue((byte)0x00, 6);
searchsequence.SetValue((byte)0x00, 7);
searchsequence.SetValue((byte)0x20, 8);
int AddressTableOffset = 0;//GetAddressTableOffset(searchsequence);
FileStream fsread = new FileStream(filename, FileMode.Open, FileAccess.Read);
using (BinaryReader br = new BinaryReader(fsread))
{
fsread.Seek(symboltableoffset, SeekOrigin.Begin);
int adr_state = 0;
while ((fsread.Position < filename_size) && (AddressTableOffset == 0))
{
byte adrb = br.ReadByte();
switch (adr_state)
{
case 0:
if (adrb == (byte)searchsequence.GetValue(0))
{
adr_state++;
}
break;
case 1:
if (adrb == (byte)searchsequence.GetValue(1)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 1;
}
break;
case 2:
if (adrb == (byte)searchsequence.GetValue(2)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 2;
}
break;
case 3:
if (adrb == (byte)searchsequence.GetValue(3)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 3;
}
break;
case 4:
if (adrb == (byte)searchsequence.GetValue(4)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 4;
}
break;
case 5:
if (adrb == (byte)searchsequence.GetValue(5)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 5;
}
break;
case 6:
if (adrb == (byte)searchsequence.GetValue(6)) adr_state++;
else
{
adr_state = 0;
fsread.Position -= 6;
}
break;
case 7:
if (adrb == (byte)searchsequence.GetValue(7)) adr_state++;
else
{
adr_state = 0;
//.........这里部分代码省略.........
示例13: ExtractFile
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
/// <param name="languageID"></param>
/// <param name="m_current_softwareversion"></param>
/// <returns></returns>
public SymbolCollection ExtractFile(string filename, int languageID, string m_current_softwareversion)
{
m_fileName = filename;
FileInfo fi = new FileInfo(filename);
m_Filelength = (int)fi.Length;
SymbolTranslator translator = new SymbolTranslator();
XDFCategories category = XDFCategories.Undocumented;
XDFSubCategory subcat = XDFSubCategory.Undocumented;
string help = string.Empty;
try
{
fi.IsReadOnly = false;
}
catch (Exception E)
{
logger.Debug(String.Format("Failed to clear read-only flag: {0}", E.Message));
}
symbol_collection = new SymbolCollection();
try
{
int sym_count = 0; // altered
CastProgressEvent("Opening file", 0);
try
{
symbol_collection = new SymbolCollection();
if (filename != string.Empty)
{
if (File.Exists(filename))
{
if (!IsBinaryPackedVersion(filename, (int)fi.Length))
{
CastProgressEvent("Getting symbol list offset", 5);
int SymbolListOffSet = GetSymbolListOffSet(filename, (int)fi.Length);
if (SymbolListOffSet > 0)
{
using (FileStream fsread = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
using (BinaryReader br = new BinaryReader(fsread))
{
fsread.Seek(SymbolListOffSet, SeekOrigin.Begin); // 0x15FA in 5168646.BIN
string symbolname = "";
bool endoftable = false;
while (!endoftable)
{
byte b = br.ReadByte();
switch (b)
{
case 0xFF: // 0xFF used to keep the start of each string 'word' aligned
break;
case 0x02:
endoftable = true;
break;
case 0x00: // 0x00 end of Symbol name string
SymbolHelper sh = new SymbolHelper() { Varname = symbolname, Description = translator.TranslateSymbolToHelpText(symbolname, out help, out category, out subcat, languageID) };
if (sh.Varname.Contains("."))
{
try
{
sh.Category = sh.Varname.Substring(0, sh.Varname.IndexOf("."));
}
catch (Exception cE)
{
logger.Debug(String.Format("Failed to assign category to symbol: {0} err: {1}", sh.Varname, cE.Message));
}
}
sh.Internal_address = (int)fsread.Position - symbolname.Length - 1;
sh.Symbol_number = sym_count;
symbol_collection.Add(sh);
symbolname = "";
sym_count++;
if ((sym_count % 500) == 0)
{
CastProgressEvent(String.Format("Symbol: {0}", sh.Varname), 10);
}
break;
default: // Another character in the Symbol name
symbolname += Convert.ToChar(b);
break;
}
}
// now, try to get the addresses
// 00 00 00 00 00 00 00 00 20 00 00 00 15 FA
// 00 F0 75 3E 00 01 00 00 24 00 00 00 16 04
// 00 F0 75 3F 00 01 00 00 24 00 00 00 16 10
// 00 F0 75 40 00 01 00 00 24 00 00 00 16 1E
// 00 F0 75 42 00 02 00 00 20 00 00 00 16 2C
// 00 F0 75 44 00 02 00 00 ...
if (symbol_collection.Count > 0)
{
sym_count = 0;
CastProgressEvent("Searching address lookup table", 15);
byte firstaddr_high = (byte)(symbol_collection[0].Internal_address >> 8);
byte firstaddr_low = (byte)(symbol_collection[0].Internal_address);
//.........这里部分代码省略.........
示例14: tryToDecodePackedBinary
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
/// <param name="symbol_collection"></param>
/// <param name="languageID"></param>
/// <returns></returns>
private bool tryToDecodePackedBinary(string filename, out SymbolCollection symbol_collection, int languageID)
{
bool retval = true;
int addressTableOffset;
byte[] compressedSymbolTable;
bool compr_created = extractCompressedSymbolTable(filename, out addressTableOffset, out compressedSymbolTable);
logger.Debug(String.Format("Compr_created: ", compr_created));
CastProgressEvent("Searching address lookup table", 30);
symbol_collection = new SymbolCollection();
if (addressTableOffset != -1)
{
symbol_collection = new SymbolCollection();
logger.Debug(String.Format("SOT: {0:X6}", addressTableOffset));
using (FileStream fsread = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
using (BinaryReader br = new BinaryReader(fsread))
{
fsread.Seek(addressTableOffset, SeekOrigin.Begin);
int symb_count = 0;
bool endoftable = false;
while (!endoftable)
{
// steeds 10 karaketers - each address table entry is 10 bytes in size
try
{
byte[] bytes = br.ReadBytes(10);
if (bytes.Length == 10 && (Convert.ToInt32(bytes.GetValue(0)) != 0x53) && (Convert.ToInt32(bytes.GetValue(1)) != 0x43)) // "SC"
{
Int64 internal_address = 0;
for (int i = 0; i < 4; i++)
{
internal_address <<= 8;
internal_address |= Convert.ToInt64(bytes.GetValue(i));
}
int symbollength = 0;
if (symb_count == 0)
{
symbollength = 0x08; // report only a few bytes of the compressed symbol
}
else
{
for (int i = 4; i < 6; i++)
{
symbollength <<= 8;
symbollength |= Convert.ToInt32(bytes.GetValue(i));
}
}
// might be damaged addresstable by MapTun.. correct it automatically
if (internal_address == 0x00 && symbollength > 0 && symbol_collection.Count > 0)
{
internal_address = symbol_collection[symbol_collection.Count - 1].Start_address + symbol_collection[symbol_collection.Count - 1].Length;
if (symbollength == 0x240 && (internal_address % 2) > 0)
internal_address++;
logger.Debug(String.Format("Corrected symbol with address: {0:X8} and len {1:X4}", internal_address, symbollength));
}
SymbolHelper sh = new SymbolHelper()
{
Symbol_number = symb_count,
Symbol_type = Convert.ToInt32(bytes.GetValue(8)),
Varname = String.Format("Symbolnumber {0}", symbol_collection.Count),
Flash_start_address = internal_address,
Start_address = internal_address,
Length = symbollength
};
symbol_collection.Add(sh);
if (symb_count % 500 == 0)
{
CastProgressEvent(String.Format("{0} : {1:X6}", sh.Varname, sh.Flash_start_address), 35);
}
symb_count++;
}
else
{
//MessageBox.Show("EOT: " + fsread.Position.ToString("X6"));
logger.Debug(String.Format("EOT: {0:X6}", fsread.Position));
endoftable = true;
}
}
catch (Exception E)
{
logger.Debug(E.Message);
retval = false;
}
}
}
}
if (compr_created)
{
//logger.Debug("Decoding packed symbol table");
CastProgressEvent("Decoding packed symbol table", 40);
string[] allSymbolNames;
TrionicSymbolDecompressor.ExpandComprStream(compressedSymbolTable, out allSymbolNames);
//.........这里部分代码省略.........
示例15: InitSkins
void InitSkins()
{
/*
ribbonControl1.ForceInitialize();
BarButtonItem item;
DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly);
DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.OfficeSkins).Assembly);
foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
{
item = new BarButtonItem();
item.Caption = cnt.SkinName;
//iPaintStyle.AddItem(item);
ribbonPageGroup13.ItemLinks.Add(item);
item.ItemClick += new ItemClickEventHandler(OnSkinClick);
}*/
ribbonControl1.ForceInitialize();
BarButtonItem item;
int skinCount = 0;
DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly);
DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.OfficeSkins).Assembly);
SymbolCollection symcol = new SymbolCollection();
foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
{
SymbolHelper sh = new SymbolHelper();
sh.Varname = cnt.SkinName;
symcol.Add(sh);
}
symcol.SortColumn = "Varname";
symcol.SortingOrder = GenericComparer.SortOrder.Ascending;
symcol.Sort();
foreach (SymbolHelper sh in symcol)
{
item = new BarButtonItem();
item.Caption = sh.Varname;
BarItemLink il = ribbonPageGroup13.ItemLinks.Add(item);
if ((skinCount++ % 3) == 0) il.BeginGroup = true;
item.ItemClick += new ItemClickEventHandler(OnSkinClick);
}
try
{
if (IsChristmasTime())
{
// set chrismas skin
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Xmas 2008 Blue"); // don't save
}
else if (IsHalloweenTime())
{
// set Halloween skin
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Pumpkin"); // don't save
}
else if (IsValetineTime())
{
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Valentine"); // don't save
}
else
{
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(m_appSettings.Skinname);
}
}
catch (Exception E)
{
logger.Debug(E.Message);
}
SetToolstripTheme();
}