mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-21 03:38:15 +00:00
tunnel component & update vehicle abstraction example (#8)
This commit is contained in:
@@ -55,7 +55,7 @@ CChannelConnector::~CChannelConnector()
|
||||
sdv::ipc::IConnect* pConnection = m_ptrChannelEndpoint.GetInterface<sdv::ipc::IConnect>();
|
||||
if (pConnection)
|
||||
{
|
||||
if (m_uiConnectionStatusCookie) pConnection->UnregisterStatusEventCallback(m_uiConnectionStatusCookie);
|
||||
if (m_uiConnectStateCookie) pConnection->UnregisterStateEventCallback(m_uiConnectStateCookie);
|
||||
pConnection->Disconnect();
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ bool CChannelConnector::ServerConnect(sdv::IInterfaceAccess* pObject, bool bAllo
|
||||
// Establish connection...
|
||||
sdv::ipc::IConnect* pConnection = m_ptrChannelEndpoint.GetInterface<sdv::ipc::IConnect>();
|
||||
if (!pConnection) return false;
|
||||
m_uiConnectionStatusCookie = pConnection->RegisterStatusEventCallback(this);
|
||||
return m_uiConnectionStatusCookie != 0 && pConnection->AsyncConnect(this);
|
||||
m_uiConnectStateCookie = pConnection->RegisterStateEventCallback(this);
|
||||
return m_uiConnectStateCookie != 0 && pConnection->AsyncConnect(this);
|
||||
}
|
||||
|
||||
sdv::IInterfaceAccess* CChannelConnector::ClientConnect(uint32_t uiTimeoutMs)
|
||||
@@ -99,8 +99,8 @@ sdv::IInterfaceAccess* CChannelConnector::ClientConnect(uint32_t uiTimeoutMs)
|
||||
|
||||
// Establish connection...
|
||||
sdv::ipc::IConnect* pConnection = m_ptrChannelEndpoint.GetInterface<sdv::ipc::IConnect>();
|
||||
if (pConnection) m_uiConnectionStatusCookie = pConnection->RegisterStatusEventCallback(this);
|
||||
if (!pConnection || m_uiConnectionStatusCookie == 0 || !pConnection->AsyncConnect(this) ||
|
||||
if (pConnection) m_uiConnectStateCookie = pConnection->RegisterStateEventCallback(this);
|
||||
if (!pConnection || m_uiConnectStateCookie == 0 || !pConnection->AsyncConnect(this) ||
|
||||
!pConnection->WaitForConnection(uiTimeoutMs))
|
||||
{
|
||||
SDV_LOG_ERROR("Could not establish a connection!");
|
||||
@@ -113,17 +113,17 @@ sdv::IInterfaceAccess* CChannelConnector::ClientConnect(uint32_t uiTimeoutMs)
|
||||
|
||||
bool CChannelConnector::IsConnected() const
|
||||
{
|
||||
return m_eConnectStatus == sdv::ipc::EConnectStatus::connected;
|
||||
return m_eConnectState == sdv::ipc::EConnectState::connected;
|
||||
}
|
||||
|
||||
void CChannelConnector::SetStatus(/*in*/ sdv::ipc::EConnectStatus eConnectStatus)
|
||||
void CChannelConnector::SetConnectState(/*in*/ sdv::ipc::EConnectState eConnectState)
|
||||
{
|
||||
auto eConnectStatusTemp = m_eConnectStatus;
|
||||
m_eConnectStatus = eConnectStatus;
|
||||
switch (m_eConnectStatus)
|
||||
auto eConnectStateTemp = m_eConnectState;
|
||||
m_eConnectState = eConnectState;
|
||||
switch (m_eConnectState)
|
||||
{
|
||||
case sdv::ipc::EConnectStatus::disconnected:
|
||||
case sdv::ipc::EConnectStatus::disconnected_forced:
|
||||
case sdv::ipc::EConnectState::disconnected:
|
||||
case sdv::ipc::EConnectState::disconnected_forced:
|
||||
// Invalidate the proxy objects.
|
||||
for (auto& rvtProxyObject : m_mapProxyObjects)
|
||||
rvtProxyObject.second.reset();
|
||||
@@ -131,7 +131,7 @@ void CChannelConnector::SetStatus(/*in*/ sdv::ipc::EConnectStatus eConnectStatus
|
||||
if (m_eEndpointType == EEndpointType::server)
|
||||
{
|
||||
// Report information (but only once)
|
||||
if (sdv::app::ConsoleIsVerbose() && eConnectStatusTemp != sdv::ipc::EConnectStatus::disconnected)
|
||||
if (sdv::app::ConsoleIsVerbose() && eConnectStateTemp != sdv::ipc::EConnectState::disconnected)
|
||||
std::cout << "Client disconnected (ID#" << m_tConnectionID.uiIdent << ")" << std::endl;
|
||||
|
||||
// Remove the connection if reconnection is not enabled (normal case).
|
||||
@@ -139,7 +139,7 @@ void CChannelConnector::SetStatus(/*in*/ sdv::ipc::EConnectStatus eConnectStatus
|
||||
m_rcontrol.RemoveConnection(m_tConnectionID);
|
||||
}
|
||||
break;
|
||||
case sdv::ipc::EConnectStatus::connected:
|
||||
case sdv::ipc::EConnectState::connected:
|
||||
if (m_eEndpointType == EEndpointType::server)
|
||||
{
|
||||
// Report information
|
||||
|
||||
@@ -71,10 +71,10 @@ public:
|
||||
bool IsConnected() const;
|
||||
|
||||
/**
|
||||
* @brief Set the current status. Overload of sdv::ipc::IConnectEventCallback::SetStatus.
|
||||
* @param[in] eConnectStatus The connection status.
|
||||
* @brief Set the current connect statue. Overload of sdv::ipc::IConnectEventCallback::SetConnectState.
|
||||
* @param[in] eConnectState The connection state.
|
||||
*/
|
||||
virtual void SetStatus(/*in*/ sdv::ipc::EConnectStatus eConnectStatus) override;
|
||||
virtual void SetConnectState(/*in*/ sdv::ipc::EConnectState eConnectState) override;
|
||||
|
||||
/**
|
||||
* @brief Callback to be called by the IPC connection when receiving a data packet. Overload of
|
||||
@@ -139,14 +139,14 @@ private:
|
||||
} eState = EState::initialized; ///< Data processing state.
|
||||
sdv::sequence<sdv::pointer<uint8_t>> seqResult; ///< The result data.
|
||||
std::mutex mtxWaitForResult; ///< Mutex to protect result processing.
|
||||
std::condition_variable cvWaitForResult; ///< Condition variable to trigger result processing.
|
||||
std::condition_variable cvWaitForResult; ///< Condition var to trigger result processing.
|
||||
};
|
||||
|
||||
CCommunicationControl& m_rcontrol; ///< Reference to the communication control class.
|
||||
sdv::TObjectPtr m_ptrChannelEndpoint; ///< Managed pointer to the channel endpoint.
|
||||
uint64_t m_uiConnectionStatusCookie = 0; ///< Connection status cookie (received after registration).
|
||||
uint64_t m_uiConnectStateCookie = 0; ///< Connection state cookie (received after registration).
|
||||
std::shared_ptr<CMarshallObject> m_ptrInitialMarshallObject; ///< Initial marshall object used after a connect event.
|
||||
sdv::ipc::EConnectStatus m_eConnectStatus = sdv::ipc::EConnectStatus::uninitialized; ///< Current connection status.
|
||||
sdv::ipc::EConnectState m_eConnectState = sdv::ipc::EConnectState::uninitialized; ///< Current connection state.
|
||||
bool m_bAllowReconnect = false; ///< When set, allow reconnection of the server.
|
||||
EEndpointType m_eEndpointType = EEndpointType::client; ///< Endpoint type of this connector.
|
||||
std::recursive_mutex m_mtxMarshallObjects; ///< Synchronize access to the marshall object vector.
|
||||
|
||||
Reference in New Issue
Block a user