ITxFormView::ITxFormView() : CFormView(ITxFormView::IDD) { m_bInitDone = FALSE; /*m_bValidTxWndSize = false;*/ m_pouTxDataStore = new CTxDataStore(); m_pouIBMNetwork = nullptr; m_pouTransmitter = nullptr; m_eBusStatus = BUS_DISCONNECTED; SetDefaultWindowPos(); }
CTxFlexRayDataStore::CTxFlexRayDataStore(void) { m_bTransmissionON = false; m_bAutoUpdate = false; InitializeCriticalSection(&m_MsgBlockCriticalSection); m_nChannelsConfigured = 0; m_bValidTxWndSize = false; m_eBusStatus = BUS_DISCONNECTED; m_bHexMode = false; SetDefaultWindowPos(); }
CTxEthernetDataStore::CTxEthernetDataStore(void) { m_bTransmissionON = false; m_bAutoUpdate = false; m_nChannelsConfigured = 1; m_bValidTxWndSize = false; m_eBusStatus = BUS_DISCONNECTED; m_bHexMode = false; //m_ouClusterConfig = NULL; SetDefaultWindowPos(); m_ouTransmitThread.m_pBuffer = this; m_ouTransmitThread.m_hActionEvent = CreateEvent(NULL, FALSE, FALSE, NULL); InitializeCriticalSection(&m_ouCSMsgList); InitializeCriticalSection(&m_ouCSKeyMap); m_pouDIL_Ethernet_Interface = NULL; m_ouMapIndexToKey.clear(); }
int ITxFormView::SetConfigData(xmlDocPtr pDoc) { int hResult = S_FALSE; if (nullptr != m_pouTxDataStore) { m_pouTxDataStore->DeleteAllMsgItems(); } if (pDoc == nullptr) { SetDefaultWindowPos(); return hResult; } std::string strConfigTag = ""; GetConfigTag(strConfigTag); strConfigTag += "/" + std::string(DEF_WND_POS); xmlChar* pXpath = (xmlChar*)(strConfigTag.c_str()); xmlXPathObjectPtr pObjectPath = xmlUtils::pGetNodes(pDoc, pXpath); if (pObjectPath != nullptr) { xmlNodeSetPtr pNodeSet = pObjectPath->nodesetval; if (nullptr != pNodeSet) { xmlNodePtr pNode = pNodeSet->nodeTab[0]; //Take First One only WINDOWPLACEMENT WndPlacement; xmlUtils::ParseWindowsPlacement(pNode, WndPlacement); SetTxData(TX_WINDOW_PLACEMENT, &WndPlacement); } } strConfigTag = ""; GetConfigTag(strConfigTag); strConfigTag += "/" + std::string(DEF_MSG_LIST); xmlChar* pXpathChannel = (xmlChar*)strConfigTag.c_str(); pObjectPath = xmlUtils::pGetNodes(pDoc, pXpathChannel); if (pObjectPath != nullptr) { xmlNodeSetPtr pNodeSet = pObjectPath->nodesetval; if (nullptr != pNodeSet) { xmlChar* pchPathMsg = (xmlChar*)DEF_MESSAGE; xmlXPathObjectPtr pObjectPath = xmlUtils::pGetChildNodes(pNodeSet->nodeTab[0], pchPathMsg); if (nullptr != pObjectPath) { hResult = S_OK; xmlNodeSetPtr pNodeMsg = pObjectPath->nodesetval; if (nullptr != pNodeMsg) { if (S_OK == AddNewMsgItemsToDataStore(pNodeMsg->nodeNr) && nullptr != m_pouTxDataStore) { m_pouTxDataStore->SetMsgItemsConfigData(pNodeSet->nodeTab[0]); } } } } } //Support for older .cfx for CAN where Message Blocks were used and LIN used Channel_Msg_List Tag. else { hResult = SetOldFormatConfigData(pDoc); } return hResult; }
USAGEMODE HRESULT TXFlexRay_vShowConfigureMsgWindow(void* pParentWnd) { //Place this code at the beginning of the export function. //Save previous resource handle and switch to current one. HINSTANCE hInst = AfxGetResourceHandle(); AfxSetResourceHandle(TXFlexRayWindowDLL.hResource); //AFX_MANAGE_STATE(AfxGetStaticModuleState()); if( g_pomTxMsgFlexChildWindow == NULL ) { // Create New Instance g_pomTxMsgFlexChildWindow = new CTxMsgFlexChildFrame; if( g_pomTxMsgFlexChildWindow != NULL ) { //// Register Window Class LPCTSTR strMDIClass = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, LoadCursor(NULL, IDC_CROSS), 0, ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICO_SEND_MSG)) ); // Set the size got from configuration module WINDOWPLACEMENT sTxWndPlacement; SetDefaultWindowPos(sTxWndPlacement); WINDOWPLACEMENT* psTxWndPlacement = &sTxWndPlacement; CTxFlexRayDataStore::ouGetTxFlexRayDataStoreObj().bGetTxData(TX_WINDOW_PLACEMENT, (void**)&psTxWndPlacement); if (sTxWndPlacement.rcNormalPosition.top == -1 || sTxWndPlacement.length == 0)//Load default configuration { CRect omRect; CWnd* pWnd = (CWnd*)pParentWnd; pWnd->GetClientRect(&omRect); omRect.NormalizeRect(); // // Reduce the size propotionally omRect.bottom -= (LONG)(omRect.Height() * defTX_MSG_WND_BOTTOM_MARGIN); omRect.right -= (LONG)(omRect.Width() * defTX_MSG_WND_RIGHT_MARGIN); // // Update the size //sTxWndPlacement.rcNormalPosition = omRect; sTxWndPlacement.flags = 1; sTxWndPlacement.length = 44; sTxWndPlacement.ptMaxPosition.x = 0; sTxWndPlacement.ptMaxPosition.x = 0; sTxWndPlacement.ptMinPosition.x = 0; sTxWndPlacement.ptMinPosition.y = 0; sTxWndPlacement.rcNormalPosition.top = 1; sTxWndPlacement.rcNormalPosition.bottom = 661; sTxWndPlacement.rcNormalPosition.left = 4; sTxWndPlacement.rcNormalPosition.right = 864; sTxWndPlacement.showCmd = 1; } CRect omRect(&(sTxWndPlacement.rcNormalPosition)); // Create Tx Message Configuration window //CRect omRect(0,0,200,200); if( g_pomTxMsgFlexChildWindow->Create( strMDIClass, "Configure Transmission Messages - FLEXRAY", WS_CHILD | WS_OVERLAPPEDWINDOW, omRect, (CMDIFrameWnd*)pParentWnd ) == TRUE ) { // Show window and set focus g_pomTxMsgFlexChildWindow->ShowWindow( SW_SHOW); g_pomTxMsgFlexChildWindow->SetFocus(); if (sTxWndPlacement.rcNormalPosition.top != -1 && sTxWndPlacement.length != 0) { g_pomTxMsgFlexChildWindow->SetWindowPlacement(&sTxWndPlacement); } } } else { return S_FALSE; } } // If already exist then activate and set the focus else { g_pomTxMsgFlexChildWindow->ShowWindow( SW_RESTORE ); g_pomTxMsgFlexChildWindow->MDIActivate(); g_pomTxMsgFlexChildWindow->SetActiveWindow(); } //Place this at the end of the export function. //switch back to previous resource handle. // CWnd objParent; //objParent.Attach(((CWnd*)pParentWnd)->m_hWnd); //objParent.Detach(); AfxSetResourceHandle(hInst); return S_OK; }
int nShowTxWindow( void* pParentWnd, ETYPE_BUS eBUS ) { CTxMsgChildFrame* pFrameWindow = NULL; string strTitle = ""; //Used for Title. bool bValidBus = false; if ( eBUS == FLEXRAY ) { pFrameWindow = g_pomTxMsgFlexChildWindow; strTitle = "Configure Transmission Messages - FLEXRAY"; bValidBus = true; } else if ( eBUS == LIN ) { pFrameWindow = g_pomTxMsgLinChildWindow; strTitle = "Configure Transmission Messages - LIN"; bValidBus = true; } if ( bValidBus == false ) { return S_FALSE; } if( pFrameWindow == NULL ) { pFrameWindow = new CTxMsgChildFrame(eBUS); if( pFrameWindow != NULL ) { //// Register Window Class LPCTSTR strMDIClass = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, LoadCursor(NULL, IDC_CROSS), 0, ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICO_SEND_MSG)) ); // Set the size got from configuration module WINDOWPLACEMENT sTxWndPlacement; SetDefaultWindowPos(sTxWndPlacement); WINDOWPLACEMENT* psTxWndPlacement = &sTxWndPlacement; bool bRetVal = false; if ( eBUS == FLEXRAY ) { bRetVal = CTxFlexRayDataStore::ouGetTxFlexRayDataStoreObj().bGetTxData(TX_WINDOW_PLACEMENT, (void**)&psTxWndPlacement); } else if ( eBUS == LIN ) { bRetVal = CTxLINDataStore::ouGetTxLINDataStoreObj().bGetTxData(TX_WINDOW_PLACEMENT, (void**)&psTxWndPlacement); } if ( bRetVal == false)//Load default configuration { CRect omRect; CWnd* pWnd = (CWnd*)pParentWnd; pWnd->GetClientRect(&omRect); omRect.NormalizeRect(); // // Reduce the size propotionally omRect.bottom -= (LONG)(omRect.Height() * defTX_MSG_WND_BOTTOM_MARGIN); omRect.right -= (LONG)(omRect.Width() * defTX_MSG_WND_RIGHT_MARGIN); // // Update the size //sTxWndPlacement.rcNormalPosition = omRect; sTxWndPlacement.flags = 1; sTxWndPlacement.length = 44; sTxWndPlacement.ptMaxPosition.x = 0; sTxWndPlacement.ptMaxPosition.x = 0; sTxWndPlacement.ptMinPosition.x = 0; sTxWndPlacement.ptMinPosition.y = 0; sTxWndPlacement.rcNormalPosition.top = 1; sTxWndPlacement.rcNormalPosition.bottom = 661; sTxWndPlacement.rcNormalPosition.left = 4; sTxWndPlacement.rcNormalPosition.right = 864; sTxWndPlacement.showCmd = 1; } CRect omRect(&(sTxWndPlacement.rcNormalPosition)); // Create Tx Message Configuration window //CRect omRect(0,0,200,200); if( pFrameWindow->Create( strMDIClass, strTitle.c_str(), WS_CHILD | WS_OVERLAPPEDWINDOW, omRect, (CMDIFrameWnd*)pParentWnd ) == TRUE ) { // Show window and set focus pFrameWindow->ShowWindow( SW_SHOW); pFrameWindow->SetFocus(); if (sTxWndPlacement.rcNormalPosition.top != -1 && sTxWndPlacement.length != 0) { pFrameWindow->SetWindowPlacement(&sTxWndPlacement); } } if ( eBUS == FLEXRAY ) { g_pomTxMsgFlexChildWindow = pFrameWindow; } else if ( eBUS == LIN ) { g_pomTxMsgLinChildWindow = pFrameWindow; } } else { return S_FALSE; } } else { pFrameWindow->ShowWindow( SW_RESTORE ); pFrameWindow->MDIActivate(); pFrameWindow->SetActiveWindow(); } }