本文整理汇总了C++中CNodeConManager类的典型用法代码示例。如果您正苦于以下问题:C++ CNodeConManager类的具体用法?C++ CNodeConManager怎么用?C++ CNodeConManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CNodeConManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DILJ_ManageMsgBuf
/**
* \brief Manages the target client buffer list. Call this function to open a data channel to receive messages.
* \req RSI_26_004 - DILJ1939_ManageMsgBuf
* \param[in] bAction When MSGBUF_ADD, adds pBufObj to the target message buffer list. Removes when MSGBUF_CLEAR.
* \param[in] ClientID Client ID
* \param[in] pBufObj Interface to message buffer object.
* \return S_OK if successful, else S_FALSE.
* \note At present maximum number of entries in the list is kept as 8.
*
* Manages the target client buffer list. Call this function to open a data channel to receive messages.
*/
USAGEMODE HRESULT DILJ_ManageMsgBuf(BYTE bAction, DWORD dwClientID,
CBaseMsgBufVSE* pBufObj)
{
HRESULT hResult = INVALID_PARAM;
if (pBufObj != NULL)
{
CNodeConManager* pConManager =
CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClientID);
if (pConManager != NULL)
{
if (bAction == MSGBUF_ADD)
{
pConManager->lAddMsgBuffer(pBufObj);
}
else if (bAction == MSGBUF_CLEAR)
{
pConManager->vClearMsgBuffer(pBufObj);
}
hResult = S_OK;
}
else
{
hResult = ERROR_NOCLIENT;
}
}
return hResult;
}
示例2: vRetrieveDataFromBuffer
void CReadCanMsg::vRetrieveDataFromBuffer(BYTE byIndex)
{
//Get the node manager and indicate to read data
CNodeConManager* pouNodeManager =
CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(byIndex);
if (pouNodeManager != NULL)
{
pouNodeManager->vReadCANdataBuffer();
}
}
示例3: pouGetConMagrObj
void CNetworkMgmt::vReinitAdresClaimProc(DWORD dwClient)
{
CNodeConManager* pNodConMgr = pouGetConMagrObj(dwClient);
if (pNodConMgr != NULL)
{
BYTE byPreferedAdres = byGetUnclaimedAddress();
pNodConMgr->StartAdresClaimProc(byPreferedAdres);
}
}
示例4: vInitializeAllNodes
void CNetworkMgmt::vInitializeAllNodes(void)
{
for (int i = 0; i < m_nConMgrCnt; i++)
{
CNodeConManager* pNodConMgr = m_ConMgrArr[i];
if (pNodConMgr != NULL)
{
pNodConMgr->vActivate();
}
}
}
示例5: vUnInitializeAllNodes
void CNetworkMgmt::vUnInitializeAllNodes(void)
{
for (int i = 0; i < m_nConMgrCnt; i++)
{
CNodeConManager* pNodConMgr = m_ConMgrArr[i];
if (pNodConMgr != NULL)
{
pNodConMgr->vDeactivate();
}
}
m_odClaimedAdresMap.RemoveAll();
}
示例6: DILJ_NM_ClaimAddress
/**
* \brief Claim address
* \req RSI_26_013 - DILJ_NM_ClaimAddress
* \param[in] dwClientId Already register node's client Id
* \param[in] unChannel Channel number
* \param[in] byAddress New address to be claimed
* \param[in] byPriority Priority (0 - 7)
* \return S_OK if successful, else S_FALSE.
*
* Node tries to claim a new address by sending Address Claim message into the network.
*/
USAGEMODE HRESULT DILJ_NM_ClaimAddress (DWORD dwClientId, UINT unChannel, BYTE byAddress, BYTE byPriority)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = NULL;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClientId);
if (NULL != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(byAddress);
}
pManager->vSendMessage(unChannel, MSG_TYPE_NM_ACL, byAddress, 0, NULL, byPriority, ADDRESS_ALL);
}
return hResult;
}
示例7: vGetNodeName
void CNetworkMgmt::vGetNodeName(BYTE byAddress, char* acNodeName)
{
for (int i = 0; i < m_nConMgrCnt; i++)
{
CNodeConManager* pNodConMgr = m_ConMgrArr[i];
if (pNodConMgr != NULL)
{
if (pNodConMgr->byGetNodeAddress() == byAddress)
{
i = m_nConMgrCnt; //break the loop
_tcscpy(acNodeName, pNodConMgr->m_acNodeName);
}
}
}
}
示例8: DILJ_RequestPGN
/**
* \brief Requests a PGN from a node
* \req RSI_26_007 - DILJ_RequestPGN
* \param[in] dwClient Client Id
* \param[in] unChannel Channel number
* \param[in] unPGN Parameter group number to be requested
* \param[in] byPriority Priority (0-7)
* \param[in] byDesrAdress Destination address.
* \return S_OK if successful, else S_FALSE.
*
* Requests a PGN from the node.
*/
USAGEMODE HRESULT DILJ_RequestPGN(DWORD dwClient, UINT unChannel, UINT32 unPGN,
BYTE byPriority, BYTE bySrc, BYTE byDestAddress)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = NULL;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
if (NULL != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(bySrc);
}
pManager->vSendMessage(unChannel, MSG_TYPE_REQUEST, unPGN, 0, 0, byPriority, byDestAddress);
}
return hResult;
}
示例9: DILJ_NM_RequestAddress
/**
* \brief Requests address from the node.
* \req RSI_26_014 - DILJ_NM_RequestAddress
* \param[in] dwClientId Already register node's client Id
* \param[in] unChannel Channel number
* \param[in] byDestAddress Destination Address
* \param[in] byPriority Priority (0 - 7).
* \return S_OK if successful, else S_FALSE.
*
* A node requests address from an another node.
*/
USAGEMODE HRESULT DILJ_NM_RequestAddress(DWORD dwClient, UINT unChannel, BYTE byPriority,
BYTE bySrc, BYTE byDestAddress)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = nullptr;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
if (nullptr != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(bySrc);
}
pManager->vSendMessage(unChannel, MSG_TYPE_NM_RQST_ACL, 0, nullptr, 0, byPriority, byDestAddress);
}
return hResult;
}
示例10: DILJ_SendJ1939Msg
/**
* \brief Sends a J1939 message.
* \req RSI_26_005 - DILJ_SendJ1939Msg
* \param[in] dwClient Client Id
* \param[in] unChannel Channel number
* \param[in] eMsgType COMMAND, BROADCAST, REQUEST, RESPONSE
* \param[in] unPGN Parameter group number
* \param[in] pbyData Data bytes
* \param[in] unDLC Data length in number of bytes.
* \param[in] byPriority Priority (0-7) byDesrAdress = Destination address.
* \return S_OK if successful, else S_FALSE.
*
* Sends a J1939 message.
*/
USAGEMODE HRESULT DILJ_SendJ1939Msg (DWORD dwClientId, UINT unChannel, EJ1939_MSG_TYPE eMsgType, UINT32 unPGN,
BYTE* pbyData, UINT unDLC, BYTE byPriority, BYTE bySrc, BYTE byDestAdres)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = NULL;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClientId);
if (NULL != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(bySrc);
}
pManager->vSendMessage(unChannel, eMsgType, unPGN, pbyData, unDLC, byPriority, byDestAdres);
}
return hResult;
}
示例11: byGetNodeAddress
BYTE CNetworkMgmt::byGetNodeAddress(DWORD dwClient)
{
BYTE byAddress = ADDRESS_NULL;
for (int i = 0; i < m_nConMgrCnt; i++)
{
CNodeConManager* pNodConMgr = m_ConMgrArr[i];
if (pNodConMgr != NULL)
{
if (pNodConMgr->m_dwClientID == dwClient)
{
i = m_nConMgrCnt; //break the loop
byAddress = pNodConMgr->byGetNodeAddress();
}
}
}
return byAddress;
}
示例12: DILJ_SendAckMsg
/**
* \brief Sends a acknowledgement message.
* \req RSI_26_006 - DILJ_SendAckMsg
* \param[in] dwClientId Already register node's client Id
* \param[in] unChannel Channel number
* \param[in] eAckType Acknowledge type (ACK_POS, ACK_NEG)
* \param[in] unPGN PGN to be sent.
* \param[in] pbyData PGN data.
* \param[in] byAddresAck Destination address.
* \return S_OK if successful, else S_FALSE.
*
* Sends Positive/Negative acknowledgement msg.
*/
USAGEMODE HRESULT DILJ_SendAckMsg(DWORD dwClient, UINT unChannel, ETYPE_ACK eAckType, UINT32 unPGN, BYTE bySrc, BYTE byAddresAck)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = NULL;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
if (NULL != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(bySrc);
}
BYTE abyFrame[MAX_FRAME_DATA_SIZE];
switch (eAckType)
{
case ACK_POS:
{
abyFrame[0] = CB_ACK_POS;
abyFrame[4] = byAddresAck;
}
break;
case ACK_NEG:
{
abyFrame[0] = CB_ACK_NEG;
abyFrame[4] = ADDRESS_NULL;
}
break;
}
abyFrame[1] = 0xFF;
abyFrame[2] = 0xFF;
abyFrame[3] = 0xFF;
abyFrame[5] = (BYTE)unPGN;
abyFrame[6] = (BYTE)(unPGN >> 8);
abyFrame[7] = (BYTE)(unPGN >> 16);
pManager->vSendMessage(unChannel, MSG_TYPE_ACKNOWLEDGEMENT,
unPGN, abyFrame, 0, DEFAULT_PRIORITY, byAddresAck);
}
示例13: DILJ_NM_CommandAddress
/**
* \brief Commands a node with perticular NAME to assume a address.
* \req RSI_26_015 - DILJ_NM_CommandAddress
* \param[in] dwClientId Already register node's client Id
* \param[in] unChannel Channel number
* \param[in] unECU_NAME 64 bit ECU NAME of the destination node
* \param[in] byDestAddress Destination Address
* \param[in] byPriority Priority (0 - 7)
* \return S_OK if successful, else S_FALSE.
*
* A node commands another node to assume an address.
*/
USAGEMODE HRESULT DILJ_NM_CommandAddress(DWORD dwClient, UINT unChannel, UINT64 unECU_NAME,
BYTE byNewAddress, BYTE byPriority, BYTE bySrc, BYTE byDestAddress)
{
HRESULT hResult = S_FALSE;
CNodeConManager* pManager = NULL;
pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
if (NULL != pManager && pManager->bIsActive())
{
hResult = S_OK;
if (pManager->bIsMonitorNode())
{
pManager->vSetNodeAddress(bySrc);
}
BYTE abyFrame[DATA_LEN_CMD_ADDRESS] = {0xFF};
memcpy(abyFrame, &unECU_NAME, MAX_FRAME_DATA_SIZE);
abyFrame[DATA_LEN_CMD_ADDRESS - 1] = byNewAddress;
pManager->vSendMessage(unChannel, MSG_TYPE_NM_CMD_ADDRESS, 0, abyFrame, DATA_LEN_CMD_ADDRESS, byPriority, byDestAddress);
}
return hResult;
}
示例14: rand
HRESULT CNetworkMgmt::StartAdresClaimProc(void)
{
//Give a random delay to start
HRESULT hResult = S_OK;
UINT unRandomWait = rand() % sg_unTO_RESPONSE;
Sleep(unRandomWait);
static BYTE byPreferedAdres = 0;
for (int i = 0; i < m_nConMgrCnt; i++)
{
CNodeConManager* pNodConMgr = m_ConMgrArr[i];
if (pNodConMgr != NULL)
{
byPreferedAdres = pNodConMgr->m_byPrefAddress;
if (bIsAddressClaimed(byPreferedAdres) == TRUE)
{
byPreferedAdres = byGetUnclaimedAddress(i);
}
hResult |= pNodConMgr->StartAdresClaimProc(byPreferedAdres);
}
}
return hResult;
}
示例15: VALIDATE_POINTER_RETURN_VAL
LONG CNetworkMgmt::lCreateNodeConManager(char* pacNodeName,
UINT64 un64ECUName,
BYTE byPrefAdres,
DWORD& dwClientId)
{
VALIDATE_POINTER_RETURN_VAL(m_pIDIL_CAN, S_FALSE);
LONG lResult = S_OK;
CNodeConManager* pNodeConMgr = NULL;
//Search the array if node is already present
pNodeConMgr = pouGetConMagrObj(pacNodeName);
if (pNodeConMgr != NULL)
{
lResult = ERR_CLIENT_EXISTS;
dwClientId = pNodeConMgr->m_dwClientID;
}
//If no. of node reached limit
else if(m_nConMgrCnt == DEF_MAX_SIMULATED_NODE)
{
lResult = ALLOWED_NOMORE;
}
//Create new node
if (lResult == S_OK)
{
//Find the first available position in the Array. There will
//be empty places in beween due to deletion
int nEmptyPos = 0;
for (int i = 0; i < DEF_MAX_SIMULATED_NODE; i++)
{
if (m_ConMgrArr[i] == NULL)
{
nEmptyPos = i;
break;
}
}
if ( _tcscmp(pacNodeName, J1939_MONITOR_NODE) == 0 )
{
pNodeConMgr = new CMonitorNode(nEmptyPos, pacNodeName, un64ECUName, byPrefAdres);
}
else
{
//Provide its position in array and its PGN
pNodeConMgr = new CNodeConManager(nEmptyPos, pacNodeName, un64ECUName, byPrefAdres);
}
if (pNodeConMgr != NULL)
{
m_ConMgrArr[nEmptyPos] = pNodeConMgr;
m_nConMgrCnt++;
HRESULT hResult = S_FALSE;
// Connection manager is created. Proceed with rest of the procedures
if ( _tcscmp(pacNodeName, J1939_MONITOR_NODE) == 0 )
{
hResult = m_pIDIL_CAN->DILC_RegisterClient(TRUE, dwClientId,
CAN_MONITOR_NODE);
m_dwCANMonitorNodeClientId = dwClientId;
if (hResult == ERR_CLIENT_EXISTS)
{
hResult = S_OK;
}
}
else
{
hResult = m_pIDIL_CAN->DILC_RegisterClient(TRUE, dwClientId,
pacNodeName);
}
//ASSERT(hResult == S_OK);
if ((hResult == S_OK) || (hResult == ERR_CLIENT_EXISTS))
{
CBaseCANBufFSE* pouBuffer = pNodeConMgr->pouGetBuf();
hResult = m_pIDIL_CAN->DILC_ManageMsgBuf(MSGBUF_ADD, dwClientId, pouBuffer);
ASSERT(hResult == S_OK);
if (hResult == S_OK)
{
pNodeConMgr->m_dwClientID = dwClientId;
m_ouReadCANMsg.AddEventHandle(pouBuffer->hGetNotifyingEvent(), (BYTE)nEmptyPos);
}
//Join this node to network if started.
if (m_bOnline == TRUE)
{
pNodeConMgr->vActivate();
BYTE byPrefAddress = pNodeConMgr->m_byPrefAddress;
if ((byPrefAddress >= ADDRESS_NULL) || (bIsAddressClaimed(byPrefAddress) == TRUE))
{
byPrefAddress = byGetUnclaimedAddress();
}
pNodeConMgr->StartAdresClaimProc(byPrefAddress);
}
}
}
else
{
ASSERT(FALSE);
}
}
return lResult;
}