Need help troubleshooting my plugin
Posted: Sun Oct 02, 2005 11:46 am
I am trying to troubleshoot an issue in my plugin and I could use some help from the more experienced developers (I'm not really strong in C++). When I turn on debugging on my interface plugin I occasionally see lines like this in the log:
Here is the code that generates the message:
Notice that the mode indexes into sec_text to get the text value. Here is the code that creates sec_text:
The odd part is that the value "Burglary" does not exist in sec_text but rather in alarm_text. As I said I'm not real strong in C++ (especially the memory management aspects) but if I were to guess I would imagine that those two arrays are being created right next to each other in memory and I'm getting a value for mode that's higher than I should. I think I'll add some code to log the full value of m_nEvent (a bitmapped value containing all the information about the event) but I figured I would also ask for advice from others.
-- Dave
Oct 01 2005,10:09:38PM,Omni (network),Debug,"Security Mode Burglary in area 12 by code 57 (start)"
Here is the code that generates the message:
Code: Select all
/////////////////////////////////////////////////////////////////////////////////
// CHAISecurityMode
/////////////////////////////////////////////////////////////////////////////////
BOOL CHAISecurityMode::ProcessEvent()
{
m_pInstance->TraceMessage( ttDebug, "Security Mode %s in area %d by code %d (%s)",
sec_text[(m_nEvent >> 12) & 0x0007],
(m_nEvent >> 8) & 0x000F,
m_nEvent & 0x00FF,
(m_nEvent & 0x8000) ? "start" : "end");
CDataPack Data;
Data.AddData( "Mode", sec_text[(m_nEvent >> 12) & 0x0007] );
m_pInstance->NotifySubscribedDevices( "HAI Security Mode", "", &Data );
return( TRUE );
}
Code: Select all
const char *sec_text[] = {"Off", "Day", "Night", "Away", "Vacation", "Day Instant", "Night Delayed"};
const char *alarm_text[] = {"Burglary", "Fire", "Gas", "Auxiliary", "Freeze", "Water", "Duress", "Temp"};
The odd part is that the value "Burglary" does not exist in sec_text but rather in alarm_text. As I said I'm not real strong in C++ (especially the memory management aspects) but if I were to guess I would imagine that those two arrays are being created right next to each other in memory and I'm getting a value for mode that's higher than I should. I think I'll add some code to log the full value of m_nEvent (a bitmapped value containing all the information about the event) but I figured I would also ask for advice from others.
-- Dave