Added icsneo_isOpen() functionality
parent
f1e0625429
commit
903615dadd
|
|
@ -143,6 +143,15 @@ bool icsneo_closeDevice(const neodevice_t* device) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool icsneo_isOpen(const neodevice_t* device) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device->device->isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
bool icsneo_goOnline(const neodevice_t* device) {
|
bool icsneo_goOnline(const neodevice_t* device) {
|
||||||
if(!icsneo_isValidNeoDevice(device)) {
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,10 @@ void Device::enforcePollingMessageLimit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::open() {
|
bool Device::open() {
|
||||||
|
if(opened) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!com) {
|
if(!com) {
|
||||||
err(APIError::Unknown);
|
err(APIError::Unknown);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -170,10 +174,15 @@ bool Device::open() {
|
||||||
handleInternalMessage(message);
|
handleInternalMessage(message);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
opened = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::close() {
|
bool Device::close() {
|
||||||
|
if(!opened) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!com) {
|
if(!com) {
|
||||||
err(APIError::Unknown);
|
err(APIError::Unknown);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -183,7 +192,8 @@ bool Device::close() {
|
||||||
com->removeMessageCallback(internalHandlerCallbackID);
|
com->removeMessageCallback(internalHandlerCallbackID);
|
||||||
|
|
||||||
goOffline();
|
goOffline();
|
||||||
return com->close();
|
opened = !com->close();
|
||||||
|
return !opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::goOnline() {
|
bool Device::goOnline() {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
virtual bool close();
|
virtual bool close();
|
||||||
virtual bool isOnline() const { return online; }
|
virtual bool isOnline() const { return online; }
|
||||||
|
virtual bool isOpen() const { return opened; }
|
||||||
virtual bool goOnline();
|
virtual bool goOnline();
|
||||||
virtual bool goOffline();
|
virtual bool goOffline();
|
||||||
|
|
||||||
|
|
@ -83,6 +84,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
uint16_t productId = 0;
|
uint16_t productId = 0;
|
||||||
bool online = false;
|
bool online = false;
|
||||||
|
bool opened = false;
|
||||||
int messagePollingCallbackID = 0;
|
int messagePollingCallbackID = 0;
|
||||||
int internalHandlerCallbackID = 0;
|
int internalHandlerCallbackID = 0;
|
||||||
device_errorhandler_t err;
|
device_errorhandler_t err;
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,17 @@ extern bool DLLExport icsneo_openDevice(const neodevice_t* device);
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_closeDevice(const neodevice_t* device);
|
extern bool DLLExport icsneo_closeDevice(const neodevice_t* device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Verify network connection for the specified hardware
|
||||||
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
|
* \returns True if the device is connected.
|
||||||
|
*
|
||||||
|
* This function does not modify the working state of the device at all.
|
||||||
|
*
|
||||||
|
* See icsneo_openDevice() for an explanation about the concept of being "open".
|
||||||
|
*/
|
||||||
|
extern bool DLLExport icsneo_isOpen(const neodevice_t* device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Enable network communication for the specified hardware
|
* \brief Enable network communication for the specified hardware
|
||||||
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
|
|
@ -135,7 +146,7 @@ extern bool DLLExport icsneo_goOnline(const neodevice_t* device);
|
||||||
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
* \returns True if communication could be disabled.
|
* \returns True if communication could be disabled.
|
||||||
*
|
*
|
||||||
* See icsneo_goOnline() for an explaination about the concept of being "online".
|
* See icsneo_goOnline() for an explanation about the concept of being "online".
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_goOffline(const neodevice_t* device);
|
extern bool DLLExport icsneo_goOffline(const neodevice_t* device);
|
||||||
|
|
||||||
|
|
@ -146,7 +157,7 @@ extern bool DLLExport icsneo_goOffline(const neodevice_t* device);
|
||||||
*
|
*
|
||||||
* This function does not modify the working state of the device at all.
|
* This function does not modify the working state of the device at all.
|
||||||
*
|
*
|
||||||
* See icsneo_goOnline() for an explaination about the concept of being "online".
|
* See icsneo_goOnline() for an explanation about the concept of being "online".
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_isOnline(const neodevice_t* device);
|
extern bool DLLExport icsneo_isOnline(const neodevice_t* device);
|
||||||
|
|
||||||
|
|
@ -667,6 +678,9 @@ fn_icsneo_openDevice icsneo_openDevice;
|
||||||
typedef bool(*fn_icsneo_closeDevice)(const neodevice_t* device);
|
typedef bool(*fn_icsneo_closeDevice)(const neodevice_t* device);
|
||||||
fn_icsneo_closeDevice icsneo_closeDevice;
|
fn_icsneo_closeDevice icsneo_closeDevice;
|
||||||
|
|
||||||
|
typedef bool(*fn_icsneo_isOpen)(const neodevice_t* device);
|
||||||
|
fn_icsneo_isOpen icsneo_isOpen;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_goOnline)(const neodevice_t* device);
|
typedef bool(*fn_icsneo_goOnline)(const neodevice_t* device);
|
||||||
fn_icsneo_goOnline icsneo_goOnline;
|
fn_icsneo_goOnline icsneo_goOnline;
|
||||||
|
|
||||||
|
|
@ -784,6 +798,7 @@ int icsneo_init() {
|
||||||
ICSNEO_IMPORTASSERT(icsneo_isValidNeoDevice);
|
ICSNEO_IMPORTASSERT(icsneo_isValidNeoDevice);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_openDevice);
|
ICSNEO_IMPORTASSERT(icsneo_openDevice);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_closeDevice);
|
ICSNEO_IMPORTASSERT(icsneo_closeDevice);
|
||||||
|
ICSNEO_IMPORTASSERT(icsneo_isOpen);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_goOnline);
|
ICSNEO_IMPORTASSERT(icsneo_goOnline);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_goOffline);
|
ICSNEO_IMPORTASSERT(icsneo_goOffline);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_isOnline);
|
ICSNEO_IMPORTASSERT(icsneo_isOnline);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue