private void SaveDataIncludingSyncOption(string fileName, string varName, int address, int length, byte[] data, bool useNote, string note)
{
Tools.Instance.savedatatobinary(address, length, data, fileName, useNote, note, Tools.Instance.m_currentFileType);
if (m_appSettings.CodeBlockSyncActive)
{
// check for other symbols with the same length and the same END address
if (fileName == Tools.Instance.m_currentfile)
{
int codeBlockOffset = -1;
foreach (SymbolHelper sh in Tools.Instance.m_symbols)
{
if (sh.Flash_start_address == address && sh.Length == length)
{
if (sh.CodeBlock > 0)
{
foreach (CodeBlock cb in Tools.Instance.codeBlockList)
{
if (cb.CodeID == sh.CodeBlock)
{
codeBlockOffset = address - cb.StartAddress;
break;
}
}
}
break;
}
}
foreach (SymbolHelper sh in Tools.Instance.m_symbols)
{
bool shSaved = false;
if (sh.Length == length)
{
if (sh.Flash_start_address != address)
{
if ((sh.Flash_start_address & 0x0FFFF) == (address & 0x0FFFF))
{
//
// if (MessageBox.Show("Do you want to save " + sh.Varname + " at address " + sh.Flash_start_address.ToString("X8") + " as well?", "Codeblock synchronizer", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Tools.Instance.savedatatobinary((int)sh.Flash_start_address, length, data, fileName, useNote, note, Tools.Instance.m_currentFileType);
shSaved = true;
}
}
// also check wether codeblock start + offset is equal
}
}
if (!shSaved && codeBlockOffset >= 0)
{
if (sh.Length == length)
{
if (sh.Flash_start_address != address)
{
// determine codeblock offset for this symbol
if (sh.CodeBlock > 0)
{
foreach (CodeBlock cb in Tools.Instance.codeBlockList)
{
if (cb.CodeID == sh.CodeBlock)
{
int thiscodeBlockOffset = (int)sh.Flash_start_address - cb.StartAddress;
if (thiscodeBlockOffset == codeBlockOffset)
{
// save this as well
Tools.Instance.savedatatobinary((int)sh.Flash_start_address, length, data, fileName, useNote, note, Tools.Instance.m_currentFileType);
}
break;
}
}
}
}
}
}
}
}
}
UpdateRollbackForwardControls();
VerifyChecksum(fileName, false, false);
}