void CConnectDlg::RevertConnectState()
{
    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::RevertConnectState : (TargetId: %s) \n"), 
                m_pTarget->GetId());

    if(m_bExclusive)
    {
        CTargetOnl* pTarg = dynamic_cast<CTargetOnl*> (m_pTarget);
        if(pTarg)
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::RevertConnectState : (TargetId: %s) DisconnectExclusive\n"), 
                        m_pTarget->GetId());
            pTarg->DisconnectExclusive();

            if(!m_bWasConnected)
            {
                TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::RevertConnectState : (TargetId: %s) Disconnect\n"), 
                        m_pTarget->GetId());
                m_pTarget->Disconnect();
            }
        }
    }
    else
    {
        TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::RevertConnectState : (TargetId: %s) Disconnect\n"), 
                        m_pTarget->GetId());
        m_pTarget->Disconnect();
    }
}
BOOL CSC_ReverseLookupTask(long taskid, CString &name)
{
    CCsvParse parser;
    CString filename = GetConfigPath() + pszTasksFileName;
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return FALSE;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CString task, str_taskid,loaded;

	  if (CConnection::GetFirmware() >= 20900 && CConnection::GetFirmware() < 21000)
	  {
		  // 04.04.06 SIS: do not check for end of line here (only for OSAI V2.09)
	  }
	  else
	  {
		  if (!parser.IsEndOfLine()) {
			syntax = FALSE;
			break;
		  }
	  }
	  
      BOOL ok = parser.ParseNextField(task);
      if (!ok)
          break;
      task.MakeLower();
      syntax = parser.ParseNextField(str_taskid);
      if (!syntax)
          break;

	  if (CConnection::GetFirmware() >= 20700)
	  {
		  // Skip loaded/unloaded flag
		  ok = parser.ParseNextField(loaded);
		  if (!ok)
			  break;
	  }

      if (taskid == _ttol(str_taskid)){
        name = task;
        return TRUE;
      }

	  if (CConnection::GetFirmware() >= 20900 && CConnection::GetFirmware() < 21000)
	  {
		parser.SkipLine();	// 04.04.06 SIS: skip rest of line
	  }
    }
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return FALSE;
}
BOOL CConnectDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
    CString strCaption,str;

    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnInitDialog : (TargetId: %s) Exclusive:%s \n"), 
        m_pTarget->GetId(), m_bExclusive?_T("TRUE"):_T("FALSE"));


    if(m_bExclusive)
    {
        CTargetOnl* pTarg = dynamic_cast<CTargetOnl*> (m_pTarget);
        if(pTarg)
        {
            if( ( m_bWaitForTargetConnection && pTarg->IsTargetConnectedExclusive()) ||
                (!m_bWaitForTargetConnection && pTarg->IsConnectedExclusive())       ||
                InitiateDebugConnection() != S_OK)
            {
                TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnInitDialog : (TargetId: %s) EndDialog (already connected or initiate error)\n"), 
                        m_pTarget->GetId());

                EndDialog(IDOK);
                return(TRUE);
            }
        }
    }
    else
    {
        if(( m_bWaitForTargetConnection && m_pTarget->IsTargetConnected()) ||
           (!m_bWaitForTargetConnection && m_pTarget->IsConnected()) ||
            InitiateMonitoringConnection() != S_OK)
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnInitDialog : (TargetId: %s) EndDialog (already connected or initiate error)\n"), 
                        m_pTarget->GetId());

            EndDialog(IDOK);
            return(TRUE);
        }
    }

    m_ProgrCtrl.SetRange(0, m_iConnectTimeOut);
    m_ProgrCtrl.SetPos(0);
    m_ProgrCtrl.SetStep(1);
    m_TimerId = SetTimer(1, 1000, NULL);
    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnInitDialog : (TargetId: %s) Timer started\n"), 
                        m_pTarget->GetId());

    if(m_pTarget)
    {
        str.Format(TARGET_NAME_ADDR,m_pTarget->GetId(),m_pTarget->GetControlAddress());
        strCaption.Format(IDS_CONNECT_TO_CONTROL,str );
        SetWindowText(strCaption);
    }

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}
//----------------------------- FUNCTION -------------------------------------*
int
    TrcWin32Error(WORD wLevel, LPCTSTR pszText)
/*>>>>
trace Win32 system error messages

I   wLevel:     trace level
I   pszText     additional text to display

Result
  E_TRC_OK
  E_TRC_NOT_INITIALIZED
  E_TRC_BAD_LEVEL
  E_TRC_NO_RESOURCE
<<<<*/
{
    if (!s_bInitialized) {
        return E_TRC_NOT_INITIALIZED;
    }

    if (s_traceMode == noTrace) {
        // trace mode is disabled
        return E_TRC_OK;
    }

    if ((wLevel & s_wLevel) == 0) {
        // this level is not activated
        return E_TRC_OK;
    }

    TCHAR msg[MAX_PATH];
    EnterCriticalSection(&s_csTrcFile);
    DWORD   dwErr = ::GetLastError();
    // show error code...
    if (pszText == NULL) {
        pszText = _T("");
    }
    TrcPrint(wLevel, _T("%s Win32 Error: code = 0x%08lX\n"), pszText, dwErr);
    s_bNewLine = FALSE;
    if ((dwErr & 0x20000000) == 0) {
        // system error, get message text:
        msg[0] = _T('\0');
        ::FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
            NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
            msg, MAX_PATH, NULL); 
        TrcPrint(wLevel, _T("****  %s"), msg);
    }
    else {
        TrcPrint(wLevel, _T("****  Custom Error Code!!"));
    }
    if (!s_bNewLine) {
        TrcPrint(wLevel, _T("\n"));
    }
    LeaveCriticalSection(&s_csTrcFile);

    return E_TRC_OK;
}
/**
 * CSC_LookupBreakpointList
 *
 * @return     CBreakpointList*
 * @exception    -
 * @see        
 */
CBreakpointList *CSC_LookupBreakpointList(LPCTSTR clsName)
{
    CObject *val;
    if (s_MapBreakpoints.Lookup(clsName, val)) {
        return (CBreakpointList*)val;
    }

    CBreakpointList *retval = new CBreakpointList;
    s_MapBreakpoints.SetAt(clsName, retval);

    CCsvParse parser;
    CString filename = GetConfigPath() + clsName + _T(".dbp");
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return retval;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CSC_BREAKPOINT line;
      CString str;
      if (!parser.IsEndOfLine()) {
        syntax = FALSE;
        break;
      }
      BOOL ok = parser.ParseNextField(str);
      if (!ok)
          break;
      line.bpnr = _ttol(str);
      syntax = parser.ParseNextField(str);
      if (!syntax)
          break;
      line.offset = _ttol(str);
      syntax = parser.ParseNextField(str); // 'I' | 'N'
      if (!syntax)
          break;

      if (str.CompareNoCase(_T("I")) && str.CompareNoCase(_T("N")) )
          continue;

      if (str.CompareNoCase(_T("N")) == 0)
          line.type = 1; // NATIVE CODE
      else
          line.type = 0; // INTERPRETER

      retval->AddTail(line);
    }
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return retval;

}
/**
 * CSC_ParseDomainList
 *
 * @return     CDomainList*
 * @exception    -
 * @see        
 */
CDomainList *CSC_ParseDomainList(BOOL fullDownload)
{
    CDomainList *retval = new CDomainList;

    CCsvParse parser;
    CString filename = GetConfigPath() + (fullDownload?pszDomainFileName:pszOnlineDomainName);
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return retval;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CSC_DOMAINENTRY domain;
      CString strType, strFile;
      if (!parser.IsEndOfLine()) {
        syntax = FALSE;
        break;
      }
      BOOL ok = parser.ParseNextField(strType);
      if (!ok)
          break;
      strType.MakeLower();
      if (strType == _T("code"))
          domain.type = CSC_DOMAINTYPE_CODE;
      else if (strType == _T("init"))
          domain.type = CSC_DOMAINTYPE_INITIAL;
      else if (strType == _T("config"))
          domain.type = CSC_DOMAINTYPE_CONFIG;
      else if (strType == _T("custom"))
          domain.type = CSC_DOMAINTYPE_CUSTOM;
      else if (strType == _T("debug"))
          domain.type = CSC_DOMAINTYPE_DEBUG;
      else
          domain.type = CSC_DOMAINTYPE_UNKNOWN;
      syntax = parser.ParseNextField(strFile);
      if (!syntax)
          break;
      domain.file = GetConfigPath() + strFile;
      retval->AddTail(domain);
      while (!parser.IsEndOfLine() && parser.ParseNextField(strFile))
          ;
    }
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return retval;
}
HRESULT CConnectDlg::InitiateDebugConnection()
{
    HRESULT hr;
    CString strMessage;

    ASSERT(m_pTarget != NULL);
    if(m_pTarget == NULL)
        return(E_FAIL);

    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateDebugConnection : (TargetId: %s) \n"), 
                        m_pTarget->GetId());

    m_bWasConnected = m_pTarget->IsConnected();

    if(!m_bWasConnected)
    {
        hr = m_pTarget->Connect();
        if(hr != S_OK)
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateDebugConnection : (TargetId: %s) Target->Connect returned hr=0x%08X!\n"), 
                m_pTarget->GetId(), hr);
            return(hr);
        }
    }

    CTargetOnl* pTarg = dynamic_cast<CTargetOnl*> (m_pTarget);
    if(pTarg)
    {
        hr = pTarg->ConnectExclusive();
        if(hr != S_OK)
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateDebugConnection : (TargetId: %s) Target->ConnectExclusive returned hr=0x%08X!\n"), 
                m_pTarget->GetId(), hr);
            if(!m_bWasConnected)
            {
                m_pTarget->Disconnect();
            }

            return(hr);
        }
    }
    else
    {
        TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateDebugConnection : (TargetId: %s) GetTargetOnl failed.\n"), 
                m_pTarget->GetId());
        return(E_FAIL);
    }

    return(S_OK);
}
BOOL CSC_GetFileType(const CString& strFileName, CString& strFileType)
{
    CCsvParse parser;
	int found = 0;
	CString strFile;
	CString filename = GetConfigPath() + pszDomainFileName;

	HRESULT hr = parser.Open(filename);
	if (FAILED(hr)) {
		FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
		TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
	}
	else {
		while(1)
		{
			BOOL ok = parser.ParseNextField(strFileType);
			if (!ok)
				break;
			ok = parser.ParseNextField(strFile);
			if (!ok)
				break;
			if(strFileName.CompareNoCase(strFile) == 0)
			{
				found = 1;
				break;
			}
		}
		parser.Close();
	}

	if(!found) 
		strFileType = _T("unknown");

	return found;
}
/* SendInfoBlock
 * ----------------------------------------------------------------------------
 */
ECommError CLogBlock::SendInfoBlock (USHORT uBlock, BYTE byType)
{
	ASSERT(m_pPhys);

	if (m_pInfoFrame == NULL)
	{
		m_pInfoFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen];
	}

	memset (m_pInfoFrame, 0x00, HD_FRAME);

	m_pInfoFrame->byType		= byType;
	m_pInfoFrame->BLK.uBlock	= uBlock;

	BuildCRC(m_pInfoFrame);

	// Convert Little -> Big Endian
	HtoT(m_pInfoFrame);
	
	switch (byType)
	{
		case BT_ACK:
		{
			TRACE (_T(">>> %-8s %3d %3d     "), _T("ACK"), uBlock, 0);
			TrcPrint(TRC_INTERFACE, _T(">>> %-8s %3d %3d     "), _T("ACK"), uBlock, 0);
			break;
		}

		case BT_NACK:
		{
			TRACE (_T(">>> %-8s %3d %3d     "), _T("NACK"), uBlock, 0);
			TrcPrint(TRC_INTERFACE, _T(">>> %-8s %3d %3d     "), _T("NACK"), uBlock, 0);
			break;
		}

		case BT_REQ:
		{
			TRACE (_T(">>> %-8s %3d %3d     "), _T("REQ"), uBlock, 0);
			TrcPrint(TRC_INTERFACE, _T(">>> %-8s %3d %3d     "), _T("REQ"), uBlock, 0);
			break;
		}
	}

	return m_pPhys->Send((BYTE *)m_pInfoFrame, HD_FRAME);
}
Example #10
0
// Created by Joshua on 18-Sep-2006
void TrcPrintAreaName(void)
{
	int i;

	TrcPrint("all");
	for ( i=0;i<AREA_COUNT;i++)
	{
		TrcPrintF(" | %s",arrAreaList[i].szAreaName);
	}
}
//------------------------------------------------------------------*
HRESULT CFCMessageSessionThread::DoConnect()
{
    HRESULT hr;

    if (m_pMessage != NULL)
        return S_OK;

    TrcPrint(TRC_INTERFACE, _T("MsgSession: DoConnect(%s)\n"),(LPCTSTR) m_pRawMsgSession->m_strMachineName);

    hr = ConnectToOnlineServer(&m_pMessage);
    if (FAILED(hr))
        return hr;

    if (m_pMessage == NULL)
        return E_FAIL;

    hr = m_pMessage->QueryInterface(IID_IConnection,(void**)&m_pCheckConnection); 
    if (FAILED(hr))
        return hr;

    hr = Login();
    if (FAILED(hr)) {
        DoDisconnect();
        return hr;
    }

    hr = AtlAdvise(m_pMessage, GetUnknown(), IID__ICERemoteMessageEvent, &m_dwMsgNotifyCookie);
    if (FAILED(hr)) {
        DoDisconnect();
        return hr;
    }
    hr = m_pMessage->Connect(m_lKey);
    if (FAILED(hr)) {
        TRACE(_T("MsgSession::Connected callback: error while trying to connect to message source; 0x%08X\n"), hr);
        TrcPrint(TRC_ERROR, _T("MsgSession::Connected callback: error while trying to connect to message source; 0x%08X\n"), hr);
        DoDisconnect();
        return hr;
    }

    return hr;
}
HRESULT CConnectDlg::InitiateMonitoringConnection()
{
    HRESULT hr;
    
    ASSERT(m_pTarget != NULL);
    if(m_pTarget == NULL)
        return(E_FAIL);

    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateMonitoringConnection : (TargetId: %s) \n"), 
                        m_pTarget->GetId());

    hr = m_pTarget->Connect();
    if(hr != S_OK)
    {
        TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::InitiateMonitoringConnection : (TargetId: %s) Target->Connect returned hr=0x%08X!\n"), 
            m_pTarget->GetId(), hr);
        return(hr);
    }

    return(S_OK);
}
Example #13
0
void TrcDumpAreaStatus(void)
{
    char buffer[100];
    int i;

    TrcPrint("=============================================\n");
    sprintf(buffer, "TRACE_LEVEL : %d\n", PrvConvertAreaLevel(TRACELEVEL));
    TrcPrint( buffer );
    
    for ( i = 0 ;i < AREA_COUNT ; i++ )
    {
		sprintf(buffer, "%10s : ", arrAreaList[i].szAreaName);
		TrcPrint(buffer);
		if ( TRACESELECT & arrAreaList[i].szAreaSelect ) {
			sprintf(buffer, "on  [Lv: %d]\n",
					   ((arrAreaList[i].szAreaLevel == 0) ?
						PrvConvertAreaLevel(TRACELEVEL) : PrvConvertAreaLevel(arrAreaList[i].szAreaLevel)));
			TrcPrint(buffer);
		}
		else {
			TrcPrint("off\n");
		}
    }
    TrcPrint("=============================================\n");
}
Example #14
0
void TrcPrintHdr(unsigned int area, unsigned int level)
{
    int i;
    TrcPrint("[");

    for ( i = 0 ;i < AREA_COUNT ; i++ ) {
        if (arrAreaList[i].szAreaSelect == area) {
            TrcPrintF("%s:", arrAreaList[i].szAreaName);
            break;
        }
    }

    switch (level) {
    case TR_LEVEL1 : TrcPrint("1]");
        break;
    case TR_LEVEL2 : TrcPrint("2]");
        break;
    case TR_LEVEL3 : TrcPrint("3]");
        break;
    case TR_LEVEL4 : TrcPrint("4]");
        break;
    }
}
Example #15
0
/** 
 *	@brief	Dump memory through TrcPrint API
 *	@if HISTORY
 *			18-Sep-2006	Joshua	created
 *	@endif
 */
void TrcDumpMemory(void *Ptr,int DumpSize,int NumColumn)
{
#ifndef F_REXY_ENV_PHONE
	unsigned char *data;
	int i = 0;
	int offset = 0;
	int	RealColumnNum;
	char	Buffer[2]={0,0};
	/*
    * Heading
    */
	TrcPrint("                    "); /* skip address area */
	for ( i = 0; i < NumColumn ; ++i )
	{
		TrcPrintF("+%lX     ", (long unsigned)i);
	}
	TrcPrint("Text\n");
	/*
    * Body
    */
	do
	{
		data = (char *)((unsigned int)Ptr+offset);
		
		/* Print the base address. */
		TrcPrintF("%08lX: ", (long unsigned)data);

		RealColumnNum = ( offset + NumColumn > DumpSize ) ? DumpSize-offset : NumColumn;

		/* Print the characters' hex values. */
		for ( i = 0; i < RealColumnNum; ++i )
		{
			TrcPrintF("0x%02X ", data[i]);
		}
		/* Pad the hex values area if necessary. */
		for ( ++i; i <= NumColumn; ++i )
		{
			TrcPrint("         ");
		}
		/* Print the characters. */
		for ( i = 0; i < RealColumnNum; i++ )
		{
			if ( isprint(data[i]) )
			{
				Buffer[0] = data[i];
				TrcPrint(Buffer);
			}
			else
				TrcPrint(".");
		}
		TrcPrint("\n");

		offset += NumColumn;
		
	} while ( offset < DumpSize ); /* break on partial buffer */
#endif
}
Example #16
0
//----------------------------- FUNCTION -------------------------------------*
int
    TrcHexDump(WORD wLevel, BYTE* pby, int nBytes, int nShowBytes /*= -1*/)
/*>>>>
print hex dump of <pby>

I   wLevel:     trace level
I   pby:        ptr to byte array to dump
I   nBytes:     number of bytes in byte array
I   nShowBytes: show up to <nShowBytes> bytes;
                if -1, use default max length <s_nMaxDumpWidth>

Result
  E_TRC_OK
  E_TRC_NOT_INITIALIZED
  E_TRC_BAD_LEVEL
  E_TRC_NO_RESOURCE
<<<<*/
{
    if (!s_bInitialized) {
        return E_TRC_NOT_INITIALIZED;
    }

    if (s_traceMode == noTrace) {
        // trace mode is disabled
        return E_TRC_OK;
    }

    if ((wLevel & s_wLevel) == 0) {
        // this level is not activated
        return E_TRC_OK;
    }

    if (pby == NULL) {
        return E_TRC_NO_RESOURCE;
    }

    EnterCriticalSection(&s_csTrcFile);
    TrcPrint(wLevel, _T("HexDump: "));
    if (nShowBytes < 0) {
        nShowBytes = s_nMaxDumpWidth;
    }
    hexDump(pby, nBytes, nShowBytes);
    LeaveCriticalSection(&s_csTrcFile);
    return E_TRC_OK;
}
//------------------------------------------------------------------*
STDMETHODIMP
    CFCMessageSession::Disconnect()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState())
    TrcPrint(TRC_INTERFACE, _T("MsgSession: Disconnect(%s)\n"),(LPCTSTR) m_strMachineName);
    HRESULT hr = S_OK;

    if (m_pSessionThread != NULL) {
        m_cookieThread++;
        m_state = regular_shutdown;
        FireStateChangeHelper(regular_shutdown);
        hr = m_pSessionThread->StopThread();
        m_pSessionThread->Release();
        m_pSessionThread = NULL;
        m_state = not_connected;
        m_sUser.Empty();
        FireStateChangeHelper(not_connected);
    }

	return hr;
}
CConnectDlg::CConnectDlg( CTargetOnlBase* pTarget, int iConnectTimeOut, BOOL bExclusive, CWnd* pParent /*=NULL*/)
	: CDialog(CConnectDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CConnectDlg)
		// HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein
	//}}AFX_DATA_INIT
    ASSERT(pTarget != NULL);

    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::CConnectDlg : (TargetId: %s) Exclusive:%s : iConnectTimeOut:%i \n"), 
        pTarget->GetId(), bExclusive?_T("TRUE"):_T("FALSE"), iConnectTimeOut);

    m_TimerId = 0;
    m_pTarget = pTarget;
    m_bExclusive = bExclusive;
    m_bForced = FALSE;
    m_iConnectTimeOut = max(iConnectTimeOut, CE_MIN_CONN_TIMEOUT);
    m_strStateText.LoadString(IDS_CONNECT_CONNECT);
    m_bWasConnected = false;
    m_bWaitForTargetConnection = TRUE;
    m_bWaitForTargetConnection = m_pTarget->GetWaitForTargetConnection();
}
void CConnectDlg::OnCancel() 
{
    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnCancel : (TargetId: %s) \n"), 
                        m_pTarget->GetId());

    if(m_TimerId > 0)
    {
        if(m_pTarget)
        {
            // user aborted connection before timeout
            CString strTargetName = m_pTarget->GetId();
            m_strStateText.Format(IDS_CONNECT_ABORTED, strTargetName);
            UpdateData(FALSE);
        }

        KillTimer(m_TimerId);
    }

    RevertConnectState();

	CDialog::OnCancel();
}
Example #20
0
/**
* @brief		Send the message to the window.
* @param[in]	panel	Window handle.
* @param[in]	Msg		Message type.
* @param[in]	wParam	Message dependent data.
* @param[in]	lParam	Message dependent data.
* @return		Depends on the message and window procedure.
* @remarks		Gets blocked until sent message is processed. Process message by calling window procedure directly.
*			
* @if HISTORY
*				11-Jan-2006 madholic Initiated 
*				09-Jan-2008 joshua	 update warning message
* @endif
*/
int MsgSendMessage(WND panel, int Msg, int wParam, int lParam)
{
	ASSERT( panel );

    if ( panel )
	{
		if ( panel->WndProc )
		{
			TRACE(TR_SystemEvent, TR_LEVEL1, ("MsgSendMessage Sending %x msg to %lx\n", Msg, panel));
			return panel->WndProc(panel, Msg, wParam, lParam);
		}
		else
		{
			TrcPrintF("[Warning] Message %x has been vaporized since window panel %d has no event handler\n", Msg, panel);
		}
	}
	else
	{
		// Should not reach here
		TrcPrint( "[Error] Message %d sent to invalid window\n" );
	}
    return -1;
}
//=======================================================================
//      interface   IMessageSession
//=======================================================================
//------------------------------------------------------------------*
STDMETHODIMP
    CFCMessageSession::Connect(/*[in, string]*/BSTR sUserName,/*[in, string]*/BSTR sPassword)
{
    HRESULT hr = S_OK;

    AFX_MANAGE_STATE(AfxGetStaticModuleState())
    TrcPrint(TRC_INTERFACE, _T("MsgSession: Connect(%s)\n"),(LPCTSTR) m_strMachineName);
    
    FC_PCHECK_HR(sUserName,E_POINTER);
    m_sUser = sUserName;
    m_sPassword = sPassword;
    if (m_pSessionThread == NULL) {
        CComObject<CFCMessageSessionThread> *pSessionThread;
        hr = CComObject<CFCMessageSessionThread>::CreateInstance(&pSessionThread);
        pSessionThread->AddRef();
        m_pSessionThread = pSessionThread;
        m_state = waiting_for_connect;
        FireStateChangeHelper(waiting_for_connect);
        hr = m_pSessionThread->StartThread(this, m_cookieThread);
    }
    
	return hr;
}
//------------------------------------------------------------------*
HRESULT CFCMessageSessionThread::DoDisconnect()
{
    HRESULT hr;

    if (m_pMessage != NULL) {

        TrcPrint(TRC_INTERFACE, _T("MsgSession: DoDisconnect(%s)\n"),(LPCTSTR) m_pRawMsgSession->m_strMachineName);

        hr = m_pMessage->Disconnect(m_lKey);

        if (m_dwMsgNotifyCookie != 0UL) {
            hr = AtlUnadvise(m_pMessage, IID__ICERemoteMessageEvent, m_dwMsgNotifyCookie);
        }
        m_dwMsgNotifyCookie = 0;

        Logout();

        FC_RELEASE_PTR(m_pCheckConnection);
        FC_RELEASE_PTR(m_pMessage);
        CoDisconnectObject(this, 0);
    }
    return S_OK;
}
/* Send
 * ----------------------------------------------------------------------------
 */
ECommError CLogBlock::Send (BYTE byCommand, BYTE *pData, UINT uLen)
{
	ASSERT(m_pPhys);

	// Build block frame
	if (m_pDataFrame == NULL)
	{
		m_pDataFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen];
	}

	memset (m_pDataFrame, 0x00, HD_FRAME);

	m_pDataFrame->BLK.CMD.byCommand	= byCommand;

	USHORT	uBlock		= 0;
	UINT	uBlockLen	= 0;
	UINT	uDataLen	= 0;
	BOOL	bLast		= FALSE;
	BYTE	byType		= BT_DATA;

	UINT	uProgMax	= uLen / m_Para.uBlockLen + ((uLen % m_Para.uBlockLen) > 0 ? 1 : 0);
	UINT	uProgCur	= 0;

	while (! bLast)
	{
		PROGRESS(uProgCur, uProgMax);
		
		// Block count starts with 1!
		uBlock++;
		
		m_pDataFrame->byType = byType;

		// Build data length
		uDataLen = (uLen - (uBlock - 1) * m_Para.uBlockLen) <= m_Para.uBlockLen ? 
				   (uLen - (uBlock - 1) * m_Para.uBlockLen) : m_Para.uBlockLen;
		
		// Build block length
		uBlockLen	= uDataLen + HD_FRAME;
		bLast		= (uBlock * m_Para.uBlockLen >= uLen);

		m_pDataFrame->BLK.byLast	= (uBlock * m_Para.uBlockLen >= uLen);
		m_pDataFrame->BLK.uBlock	= uBlock;			
		m_pDataFrame->BLK.uLen		= (USHORT)uDataLen;

		if (pData != NULL)
		{
			memcpy(m_pDataFrame->BLK.CMD.pData, pData + m_Para.uBlockLen * (uBlock - 1), uDataLen);
		}

		BuildCRC(m_pDataFrame);

		// Convert Little -> Big Endian
		HtoT(m_pDataFrame);

		ECommError eError = ceError;

		for (UINT i = 0; (i < m_uRepeatOnError && eError != ceAck) || i == 0; i++)
		{

			TRACE(_T(">>> %-8s %3d %3d     "), byCommand <= LAST_CMD_VALUE ? szCommandText[byCommand] : _T("Invalid"), uBlock, uDataLen);
			TrcPrint(TRC_INTERFACE, _T(">>> %-8s %3d %3d     "), byCommand <= LAST_CMD_VALUE ? szCommandText[byCommand] : _T("Invalid"), uBlock, uDataLen);

			// Send block
			eError = m_pPhys->Send((BYTE *)m_pDataFrame, HD_FRAME + uDataLen);

			if (eError != ceOK)
			{
				// Communication error sending data block.
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();
				
				continue;
			}

			// Wait for acknowledge
			eError = RecvAck (uBlock);

			if (eError != ceAck && eError != ceNAck)
			{
				// Communication Error receiving ACK / NACK.
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();
				
				continue;
			}
		
		} // end for 

		if (eError != ceAck)
		{
			// A block could not be transmitted correctly. 
			PROGRESS_LAST(uProgMax);
			return eError;
		}
	
		uProgCur++;
		
	} // end while

	PROGRESS(uProgCur, uProgMax);

	return ceOK;
}
/**
 * CSC_LookupStructDef
 *
 * @param      name
 * @return     CMapVarDef*
 * @exception    -
 * @see        
 */
CMapVarDef *CSC_LookupStructDef(LPCTSTR name)
{
	CObject *val;
	if (s_MapStruct.Lookup(name, val)) 
	{
		return (CMapVarDef*)val;
	}
	
	CMapVarDef *pStructDef = new CMapVarDef;
	s_MapStruct.SetAt(name, pStructDef);
	
	CCsvParse parser;
	CString filename = GetConfigPath() + name + DEF_FILE_EXT;
	HRESULT hr = parser.Open(filename);
	if (FAILED(hr)) 
	{
		FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
		TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
		return pStructDef;
	}
	
	CString strName, strDeclSpec, strType, strSegment;
	CString strOffset, strBitOffset, strBitSize, strStrLen;
	
	BOOL syntax = TRUE;
	for (;;) 
	{
		CSC_VARDEF vardef;
		
		if (!parser.IsEndOfLine()) 
		{
			syntax = FALSE;
			break;
		}
		
		/* CSV_IDX_NAME: Instance name
		 */
		BOOL ok = parser.ParseNextField(strName);
		if (!ok)
			break;
		strName.MakeLower();
		
		/* CSV_IDX_DECL_SPEC: Declaration Specification
		 */
		syntax = parser.ParseNextField(strDeclSpec);
		if (!syntax)
			break;
		strDeclSpec.MakeUpper();
		
		/* CSV_IDX_SEGMENT: Segment Information
		 */
		syntax = parser.ParseNextField(strSegment);
		if (!syntax)
			break;
		
		/* CSV_IDX_TYPE: Data Type
		 */
		syntax = parser.ParseNextField(strType);
		if (!syntax)
			break;
		
		/* CSV_IDX_BYTE_OFFSET: Byte Offset
		 */
		syntax = parser.ParseNextField(strOffset);
		if (!syntax)
			break;
		
		/* CSV_IDX_BIT_OFFSET: Bit Offset
		 */
		syntax = parser.ParseNextField(strBitOffset);
		if (!syntax)
			break;
		
		/* CSV_IDX_BIT_SIZE: Bit Size
		 */
		syntax = parser.ParseNextField(strBitSize);
		if (!syntax)
			break;
		
		/* CSV_IDX_STRLEN: String Length
		 */
		syntax = parser.ParseNextField(strStrLen);
		if (!syntax)
			break;
		
		if (strDeclSpec[0] == _T('S')) 
		{
			strType.MakeLower();
			
			vardef.vardefType	= CSC_VARDEF_STRUCT;
			vardef.iecType		= BL_ANY;
			vardef.segment		= 0;
			vardef.offset		= 0;
			vardef.bitnr		= 0;
			vardef.strlen		= 0;
			vardef.structType	= strType;
			
		} 
		else if (strDeclSpec[0] == _T('G')) 
		{
			vardef.vardefType	= CSC_VARDEF_GLOBAL;
			
			strType.MakeUpper();
			if (strType == _T("WSTRING"))
			{
				strType = _T("STRING");
			}	
			
			DWORD dummy;
			hr = BL_TypenameToDatatype(CComBSTR(strType), &vardef.iecType, &dummy);
			if (FAILED(hr)) 
			{
				syntax = FALSE;
				break;
			}
			
			vardef.segment	= _ttol(strSegment);
			vardef.offset	= _ttol(strOffset);
			vardef.bitnr	= 0;
			vardef.strlen	= 0;
			
			if (vardef.iecType == BL_BOOL) 
			{
				vardef.bitnr = _ttoi(strBitOffset);
			}
			if (vardef.iecType == BL_STRING) 
			{
				vardef.strlen = _ttoi(strStrLen);
			}
		}
		else if (strDeclSpec[0] == _T('N') || strDeclSpec[0] == _T('R')) 
		{
			vardef.vardefType = strDeclSpec[0] == _T('N') ? CSC_VARDEF_NORMAL : CSC_VARDEF_RETAIN;

			strType.MakeUpper();
			if (strType == _T("WSTRING"))
			{
				strType = _T("STRING");
			}	

			DWORD dummy;
			hr = BL_TypenameToDatatype(CComBSTR(strType), &vardef.iecType, &dummy);
			if (FAILED(hr)) 
			{
				syntax = FALSE;
				break;
			}

			vardef.segment	= 0;
			vardef.offset	= _ttol(strOffset);
			vardef.bitnr	= 0;
			vardef.strlen	= 0;

			if (vardef.iecType == BL_BOOL) 
			{
				vardef.bitnr = _ttoi(strBitOffset);
			}
			if (vardef.iecType == BL_STRING) 
			{
				vardef.strlen = _ttoi(strStrLen);
			}
		}
		else 
		{
			syntax = FALSE;
			break;
		}
		
		pStructDef->SetAt(strName, vardef);
		
	} /* for (;;) */
	
	if (!syntax) {
		FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
		TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
	}
	return pStructDef;
}
/* RecvAck
 * ----------------------------------------------------------------------------
 */
ECommError CLogBlock::RecvAck (USHORT uBlock)
{
	ASSERT(m_pPhys);

	if (m_pInfoFrame == NULL)
	{
		m_pInfoFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen];
	}

	memset (m_pInfoFrame, 0x00, HD_FRAME);

	UINT uLen = HD_FRAME + m_Para.uBlockLen;

	ECommError eError = m_pPhys->Receive((BYTE *)m_pInfoFrame, &uLen);

	// Error receiving BLK
	if (eError != ceOK)
	{
		return eError;
	}

	// Check data length
	if (uLen != HD_FRAME)
	{
		TrcPrint(TRC_ERROR, _T("[CLogBlock][RecvAck] Invalid data length.\n"));
		return ceError;
	}

	// Convert Big -> Little Endian
	TtoH(m_pInfoFrame);

    if (HD_FRAME + m_pInfoFrame->BLK.uLen != uLen)
    {
		TrcPrint(TRC_ERROR, _T("[CLogBlock][RecvAck] CRC frame data length check failed.\n"));
		return ceCRC;
    }

	if (CheckCRC (m_pInfoFrame) != ceOK)
	{
		TrcPrint(TRC_ERROR, _T("[CLogBlock][RecvAck] CRC check failed.\n"));
		return ceCRC;
	}

	// Check block number
	if (uBlock != m_pInfoFrame->BLK.uBlock)
	{
		TrcPrint(TRC_ERROR, _T("[CLogBlock][RecvAck] Invalid block number.\n"));
		return ceError;
	}

	// Get ACK / NACK
	if (m_pInfoFrame->byType == BT_ACK)
	{
		TRACE(_T("<<<  %-8s %3d %3d\n"), _T("ACK"), uBlock, m_pInfoFrame->BLK.uLen);
		TrcPrint(TRC_INTERFACE, _T("<<<  %-8s %3d %4d\n"), _T("ACK"), uBlock, m_pInfoFrame->BLK.uLen);

		return ceAck;
	}

	if (m_pInfoFrame->byType == BT_NACK)
	{
		TRACE(_T("<<<  %-8s %3d %3d\n"), _T("NACK"), uBlock, m_pInfoFrame->BLK.uLen);
		TrcPrint(TRC_INTERFACE, _T("<<<  %-8s %3d %4d\n"), _T("NACK"), uBlock, m_pInfoFrame->BLK.uLen);

		return ceNAck;
	}

	return ceError;
}
/* Receive
 * ----------------------------------------------------------------------------
 */
ECommError CLogBlock::Receive (BYTE *bypCommand, BYTE **ppData, UINT *upLen)
{
	HEAP_FREE(*ppData, *upLen);

	// Build block frame
	if (m_pDataFrame == NULL)
	{
		m_pDataFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen];
	}

	memset (m_pDataFrame, 0x00, HD_FRAME);

	*upLen	= 0;

	USHORT	uBlock		= 0;
	UINT	uBlockLen	= 0;
	UINT	uDataLen	= 0;
	BOOL	bLast		= FALSE;

	ECommError eError;

	UINT	uProgMax	= m_uMaxRecvProg;
	UINT	uProgCur	= 0;

	while (! bLast)
	{
		PROGRESS(uProgCur,uProgMax);
		
		// Block count starts with 1!
		uBlock++;

		eError = ceError;

		for (UINT i = 0; (i < m_uRepeatOnError && eError != ceOK) || i == 0; i++)
		{
			bLast = FALSE;

			// Send request for response block
			eError = SendInfoBlock (uBlock, BT_REQ);

			if (eError != ceOK)
			{
				// Communication error sending block
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();
	
				continue;			
			}

			uBlockLen = m_Para.uBlockLen + HD_FRAME;

			// Receive block
			eError = m_pPhys->Receive((BYTE *)m_pDataFrame, &uBlockLen);

			if (eError != ceOK)
			{
				// Communication error or time out; try again
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();

				continue;
			}

			// Check block size
			if (uBlockLen < HD_FRAME)
			{
				// Received block could not be a valid block; try again
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();

				TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block length.\n"));

				eError = ceError;
				continue;
			}

			// Convert Big -> Little Endian
			TtoH(m_pDataFrame);

            if (HD_FRAME + m_pDataFrame->BLK.uLen != uBlockLen)
            {
		        TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] CRC frame data length check failed.\n"));
				PROGRESS_LAST(uProgMax);
		        return ceCRC;
            }

			// Check CRC
			if (CheckCRC (m_pDataFrame) != ceOK)
			{
				TRACE (_T("CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_\n"));
				TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] CRC check failed.\n"));

				// Wrong checksum; send NACK and try again
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();

				eError = ceCRC;
				continue;
			}

			// Check block type
			if (m_pDataFrame->byType != BT_DATA)
			{
				// Received block could not be a valid block; try again
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();

				TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block type (data expected).\n"));

				eError = ceError;
				continue;
			}

			bLast = m_pDataFrame->BLK.byLast;

			// Check block number
			if (m_pDataFrame->BLK.uBlock != uBlock)
			{
				// Received block number does not match
				SleepEx (m_uWaitResend, FALSE);
				m_pPhys->Flush();

				TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block number.\n"));

				eError = ceError;
				continue;
			}

			*bypCommand = m_pDataFrame->BLK.CMD.byCommand;
			uDataLen	= m_pDataFrame->BLK.uLen;

			// Create Command Buffer
			if (uBlock == 1)
			{
				HEAP_ALLOC(*ppData, uDataLen);
			}
			else
			{
				HEAP_RE_ALLOC(*ppData, *upLen + uDataLen);
			}

			if (*ppData == NULL)
			{
				TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Alloc Memory.\n"));

				eError = ceError;
				continue;
			}

			// Copy data
			memcpy(*ppData + *upLen, m_pDataFrame->BLK.CMD.pData, uDataLen);
			*upLen += uDataLen;

			if (m_pDataFrame->BLK.CMD.byCommand > 0x80u)
			{
				// Error Message from VMM
				TRACE(_T("<<<  %-8s %3d %4d  \n"), _T("FAILED"), uBlock, m_pDataFrame->BLK.uLen);
				TrcPrint(TRC_INTERFACE, _T("<<<  %-8s %3d %4d  \n"), _T("FAILED"), uBlock, m_pDataFrame->BLK.uLen);

				PROGRESS_LAST(uProgMax);

				return ceOK;
			}
			else
			{
				TRACE(_T("<<<  %-8s %3d %3d  \n"), m_pDataFrame->BLK.CMD.byCommand <= LAST_CMD_VALUE ? szCommandText[m_pDataFrame->BLK.CMD.byCommand] : _T("Invalid"), uBlock, m_pDataFrame->BLK.uLen);
				TrcPrint(TRC_INTERFACE, _T("<<<  %-8s %3d %4d  \n"), m_pDataFrame->BLK.CMD.byCommand <= LAST_CMD_VALUE ? szCommandText[m_pDataFrame->BLK.CMD.byCommand] : _T("Invalid"), uBlock, m_pDataFrame->BLK.uLen);
			}

		} // end for 

		if (eError != ceOK)
		{
			HEAP_FREE(*ppData, *upLen);

			PROGRESS_LAST(uProgMax);
			return eError;
		}

		if (++uProgCur == uProgMax)
		{
			uProgMax += uProgMax;
		}
		
	} // end while

	PROGRESS_LAST(uProgMax);
	
	return ceOK;
}
Example #27
0
/** 
 * @brief	Rexy's Main Event Handler
 * @if HISTORY
 *		26-Jul-2006	Joshua Revised to support capsulated event handling
 * @endif
 */
void Rexy_WinMain(void)
{
    msg		nMsg;
//    bool	bCheckStartTime = TRUE;
	MsgType	NullMessage = { 0, 0, 0};
	MsgType CreateMessage = { AWM_CREATE, 0, 0 };
	WND		hFocusedWindow;
	int		wmsg;
	
	// Initialize message queue
	MgqInitFreeStructures();	
	
	LckInit();
	
	// Initialize application
	AppInit();

	DiagInit();

	// Set default font
	FntSetFont(&FntGlobalContext, 0);

	// Execute application of which state id is 0
	StaGotoState( NULL, 0, NullMessage , CreateMessage );	
	
	while ( MsgGetMessage( hFocusedWindow = WinGetSelection(), &nMsg ) )
    {
		if ( DiagHandler() != DIAG_RET_OK )
		{
			TrcPrint("[FATAL ERROR] DiagHandler\n");
			break;
		}

        TRACE( TR_RexyCore, TR_LEVEL1, ("MsgDispatch in GetMessage Loop with Msg %x\n", nMsg.wmsg) );

		// Dispatch message to current state procedure first
		// in case of that we could have AWM_DESTROY or something
		// big event which can affect all open window
		if ( nMsg.window ) 
		{
			wmsg = AWM_CHILDMSG;
			MsgSetChildMsg( &nMsg );
		}
		else
		{
			wmsg = nMsg.wmsg;
		}
		if ( !StaGetCurrentProc()( (WND)nMsg.window, wmsg, nMsg.wparam, nMsg.lparam ) )
		{ 
			// Since current state proc didn't handle the message,
			// this message will be floating among its window & child windows, Joshua 
			//if ( !MsgRouteMessage( ( ((WND)nMsg.window)->parentwin != NULL ? ((WND)nMsg.window)->parentwin : (WND)nMsg.window ), &nMsg ) )
			if ( !MsgRouteMessage( PrvFindTopWindow((WND)nMsg.window), &nMsg ) )
			{
				// Since current window proc didn't handle the message,
				// we will hand this over to system event handler
				MsgDispatchSystemMessage( &nMsg );
			}
		}
    }

    DiagDeinit();

	TrcPrint("before sending AWM_DESTROY\n");
	StaGetCurrentProc() ((WND)nMsg.window, AWM_DESTROY, 0, 0);
	TrcPrint("after sending AWM_DESTROY\n");
    TRACE(TR_RexyCore, TR_LEVEL1, ("MsgGetMessage End\n"));

}
void CConnectDlg::OnTimer(UINT nIDEvent) 
{
    int iLower;
    int iUpper;
    int iPos;
    CSC_SESSION_STATE ConnectState;
    CSC_SESSION_STATE ExclusiveConnectState = not_connected;
    BOOL bStop = FALSE;
    BOOL bForced = FALSE;
    BOOL bUpdate = FALSE;
    CString strTargetName;
    BOOL bIsTargetConnected = FALSE;
    BOOL bIsTargetConnectedExclusive = FALSE;
    BOOL bIsConnected = FALSE;
    BOOL bIsConnectedExclusive = FALSE;

	CDialog::OnTimer(nIDEvent);

    TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s)\n"), 
                        m_pTarget->GetId());

    if(m_pTarget)
    {
        ConnectState        = m_pTarget->GetSessionState();
        bIsTargetConnected  = m_pTarget->IsTargetConnected();
        bIsConnected        = m_pTarget->IsConnected();
        
        // SIS 30.06.04 SUPER SPECIAL HACK FOR OSAI >>
        // even if target is not connected, end dialog
        // this is required if OSAI target is in emergency mode
        // download is possible since download can be done
        // from the OPC server by copying into the file system
        if(m_pTarget->GetType().Compare(_T("OSAI")) == 0)
        {
            bIsTargetConnected = TRUE;
        }
        // SIS 30.06.04 SUPER SPECIAL HACK FOR OSAI <<

        TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : SessionState:%s ; IsConnected: %s ; IsTargetConnected: %s\n"), 
                        m_pTarget->GetId(), m_pTarget->GetSessionStateText(ConnectState), 
                        bIsConnected?_T("TRUE"):_T("FALSE"),
                        bIsTargetConnected?_T("TRUE"):_T("FALSE"));

        CTargetOnl* pTarg = dynamic_cast<CTargetOnl*> (m_pTarget);
        if(pTarg)
        {
            ExclusiveConnectState       = pTarg->GetExclusiveSessionState();
            bIsTargetConnectedExclusive = pTarg->IsTargetConnectedExclusive();
            bIsConnectedExclusive       = pTarg->IsConnectedExclusive(); 
            
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : ExclusiveSessionState:%s ; IsConnectedExclusive: %s ; IsTargetConnectedExclusive: %s\n"), 
                        m_pTarget->GetId(), m_pTarget->GetSessionStateText(ExclusiveConnectState),
                        bIsConnectedExclusive?_T("TRUE"):_T("FALSE"),
                        bIsTargetConnectedExclusive?_T("TRUE"):_T("FALSE"));
        }

        if( ( m_bWaitForTargetConnection && 
              bIsTargetConnected && 
             (!m_bExclusive || bIsTargetConnectedExclusive) 
            ) 
          ||
            ( !m_bWaitForTargetConnection &&
              bIsTargetConnected && bIsConnected && 
             (!m_bExclusive || bIsConnectedExclusive) 
            ) 
          )
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : Target connected, close dialog.\n"), 
                        m_pTarget->GetId());
            OnOK();
        }

        strTargetName.Format(TARGET_NAME_ADDR,m_pTarget->GetId(),m_pTarget->GetControlAddress());
        m_ProgrCtrl.GetRange(iLower, iUpper);
        iPos = m_ProgrCtrl.GetPos();

        if(interrupted == ConnectState || interrupted == ExclusiveConnectState)
        {
            m_strStateText.Format(IDS_CONNECT_INTERRUPT, strTargetName);
            bUpdate = TRUE;
        }

        if(iPos >= iUpper)
        {
            TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : Timeout.\n"), 
                        m_pTarget->GetId());
            m_strStateText.Format(IDS_CONNECT_TIMEOUT, strTargetName);
            bUpdate = TRUE;
            bStop = TRUE;
        }

        if(!m_bForced && m_bExclusive
            && RW_established == ConnectState
            && waiting_for_exclusive == ExclusiveConnectState
            && E_CSC_TRANSFER_SINGLE_DOWNLOADER_ALLOWED == pTarg->GetExclusiveSessionHResult() )
        {
                TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : Force Logout Dialog.\n"), 
                        m_pTarget->GetId());

                m_bForced = TRUE;
                CConnErrDlg* pDlg = new CConnErrDlg(this);
                if(pDlg->DoModal() == IDOK) {
                    if(pTarg) {
                        TrcPrint(TRC_COMM_EVENT, _T("CConnectDlg::OnTimer : (TargetId: %s) : User forced Logout.\n"), 
                                m_pTarget->GetId());
                        // user forced connection abort
                        pTarg->DisconnectExclusive(TRUE);
                    }
                }
                delete pDlg;
        }

        if(bUpdate) {
            UpdateData(FALSE);
        }

        if(bStop)
        {
            KillTimer(m_TimerId);
            m_TimerId = 0;
//            RevertConnectState();
            return;
        }

    }

    m_ProgrCtrl.StepIt();
}
/**
 * Helper to call Fire_OnStateChanged().
 *
 * @param   newState - new session (connection) state.
 * @param   hError - possible error code.
 * @see     CSC_SESSION_STATE.
*/
void CFCMessageSession::FireStateChangeHelper(CSC_SESSION_STATE newState, HRESULT hError /*= S_OK*/)
{
    TrcPrint(TRC_INTERFACE, _T("MsgSession: OnStateChanged(%s) state='%s'\n"),
        (LPCTSTR) m_strMachineName,GetSessionStateString(newState));
    Fire_OnStateChanged(GetUnknown(), newState, hError);
}
/**
 * CSC_InitHashTables initializes the hash tables.
 *
 * @param      
 * @return     
 * @exception    -
 * @see        
 */
VOID CSC_InitHashTables()
{
    CSingleLock lock(CSC_GetConfigLock(), TRUE);
    CSC_CleanupHashTables();

    CCsvParse parser;
    CString filename = GetConfigPath() + _T("__objects.hash");
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CSC_INSTANCEDEF instancedef;
      CString strName, strParam;
      if (!parser.IsEndOfLine()) {
        syntax = FALSE;
        break;
      }
      BOOL ok = parser.ParseNextField(strName);
      if (!ok)
          break;
      strName.MakeLower();
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.task = _ttol(strParam);
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.obj = _ttol(strParam);
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.off = _ttol(strParam);
      syntax = parser.ParseNextField(strParam); // length: ignored...
      if (!syntax)
          break;
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.r_obj = _ttol(strParam);
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.r_off = _ttol(strParam);
      syntax = parser.ParseNextField(strParam); // length: ignored...
      if (!syntax)
          break;
      syntax = parser.ParseNextField(strParam);
      if (!syntax)
          break;
      instancedef.cls_id = _ttol(strParam);
      syntax = parser.ParseNextField(instancedef.strClassName);
      if (!syntax)
          break;
      s_MapInstances.SetAt(strName, instancedef);
    }
    
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return;
}