This entry may be a little long and with lots of data/code but I am having some serious issues and I am going crazy trying to figure them out.
I am programming in Visual C++, Visual Studio 2013. I am using MapInfo Pro 15.0.2. I am using the MapInfo/MapBasic API calls to Do and Eval to run MapBasic commands. When I try to write to a MapInfo table and commit that table I am getting errors. They are not always the same error and don't always occur at the same "time" during the running of my program. Attached is a file (MIErrors.png) that show some of them. They include:
1) Access Violation in MapInfow.exe
2) Heap Corruption
3) The data stops being written to the MI Table , but no actual crash, and I see this as a reason: Out of disk space while editing table nnn_RSSI_CW_LTE_UpperC_22_0_Cha. Please revert your changes to avoid database corruption.
4) Internal Error: 34623
5) Internal Error: 34531
Below is the code that I have in my C++ code:
if (!TableExists(mappingInfo->m_cstrMITableName))
{
1) cstrCommand.Format("Create Table \"%s\" (%s) File \"%s\" TYPE NATIVE "
"Charset \"WindowsLatin1\"", mappingInfo->m_cstrMITableName,
mappingInfo->m_cstrTableQuery, pathMITable.m_strPath);
retVal = Do(cstrCommand);
}
if (retVal)
{
// Open the tables
2) mappingInfo->m_cstrMIAlias = OpenTable(pathMITable.m_strPath, "", true);
// Create the map for the output file
3) cstrCommand.Format("Create Map For %s", mappingInfo->m_cstrMITableName);
retVal = Do(cstrCommand);
if (retVal)
{
break;
}
}
**********************************************************************************
try
{
m_pMI->ShowProgressBars(false);
sCmd.Format("Insert Into %s (Index, RunNumber, X, Y %s, Obj) "
"Values (%d, %d, %.4f, %.4f %s, CreatePoint(%.4f, "
"%.4f))", m_LostConnData->m_cstrMIAlias, sCols,
iIndx, m_iCurrentRunNumber, X, Y, sVals, X, Y);
4) bWriteMITable = m_pMI->Do(sCmd);
system_clock::time_point tp = system_clock::now();
milliseconds t = duration_cast<milliseconds>(tp - m_SaveInterval);
if (t.count() > 3000) // 1000)
{
5) m_pMI->CommitTable(m_LostConnData->m_cstrMIAlias);
m_SaveInterval = tp;
}
m_pMI->ShowProgressBars(true);
}
catch (CString ex)
{
CString erMsg;
erMsg.Format("Trying to save data to MapInfo File. Error %s "
"in CMeasurementDevice::RecordMeasurements",
ex);
AfxMessageBox(erMsg);
}
catch (COleDispatchException* e)
{
CString erMsg;
erMsg.Format("Map Basic Command Error: %s. Error in "
"CMeasurementDevice::RecordMeasurements",
e->m_strDescription);
e->Delete();
AfxMessageBox(erMsg);
}
catch (...)
{
AfxMessageBox("Trying to save data to MapInfo File. Unknown Error in "
"CMeasurementDevice::RecordMeasurements");
}
1) An example of my create table command is:
Create Table "test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI" (Index Integer, RunNumber Integer, X Float, Y Float, Max_RSSI FLOAT, Max_Chan INTEGER, Chan_5220_RSSI FLOAT) File "D:\Application Testing\Spectra_Testing\test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI.TAB" TYPE NATIVE Charset "WindowsLatin1"
2) Open table is equally as simple and straight forward:
Open Table "D:\Application Testing\Spectra_Testing\test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI.TAB" Interactive
3) Finally I Create a map for the table:
Create Map For test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI
In a piece of code not shown here, I do a simple: "Map From test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI". Overall, these three commands are good and as I said simple.
4)This is the insert command I run. An example is:
Insert Into test_RSSI_CW_LTE_UpperC_22_0_Ch (Index, RunNumber, X, Y , Chan_5220_RSSI, Max_Chan, Max_RSSI, Obj) Values (1, 496, 51.9703, -73.2853 , -116.569999694824, 5220, -116.57, CreatePoint(51.9703, -73.2853))
This is again a very simple insert with the creation of a point object included. This "works". That is it writes the data to the file for several loops until there is one of the errors. When this Insert stops and I get the "Out of disk space ...." error it is very confusing.
5) The Commit Table command is also straight forward:
Commit Table "test_RSSI_CW_LTE_UpperC_22_0_Chan_5220_RSSI"
I have been running with and without this statement. The prescence of the statement changes where and when and sometimes what error I get. If it is in there, I tend to get an Access Violation on the very first attempt at a commit. With out it I get several data lines written to the MI table before I get an error.
What is frustrating is that these are all normal MapInfo/MapBasic commands and commands issued without problem in other areas of our program. We used to have a Linked, then a Live table that was linked to an Access database but were having trouble with that. So I decided to try and control writing to both the Access and MI table. This code is my attempt at that and therefore fairly new code. When the MI table was linked (Live or Linked) to the Access table, the updates to the MI Table were good (no errors) but they lagged. For example, when driving around and plotting data we would get to where the data being shown was several (10-20) minutes behind where the car actually was. So to try and fix this I did as I said. I am trying to write to the Access DB and then at the same time, the MI Table. Unfortunately I am getting these errors.
Errors that all point to some time of memory issue. But I cannot see what I am doing wrong or where I am having a memory issue. There is also another issue that I cannot fully explain here as it is a visual problem, but in the attached file is a screen shot of what our program looks like when displaying data (albeit an incomplete picture). The black dots that are data at X,Y points should be fully spread from Green to Red pin. They never get fully from Green to Red as I get the error(s) I have talked about. But also, sometimes, the dots are printing then the screen "flickers" and some of them are gone, overwritten by a white block, erased, or I don't know what.
Any help, ideas, tests, what ever anyone can think of to help me would be greatly appreciated.