-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added "real" version of API (clone of stub for now) and infrastructur…
…e to build both extension versions
- Loading branch information
1 parent
bb2fb5d
commit 81ce18d
Showing
16 changed files
with
607 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
plugins/excalibur/fem_api_extension/api_stub/ExcaliburFemClient.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
|
||
#include "ExcaliburFemClient.h" | ||
|
||
ExcaliburFemClient::ExcaliburFemClient(void* aCtlHandle, const CtlCallbacks* aCallbacks, | ||
const CtlConfig* aConfig, unsigned int aTimeoutInMsecs) : | ||
id_(aConfig->femNumber) | ||
{ | ||
// Dummy exception thrown by negative ID | ||
if (id_ < 0) { | ||
throw FemClientException((FemClientErrorCode)30000, "Illegal ID specified"); | ||
} | ||
//std::cout << "ExcaliburFemClient constructor with id=" << id_ << std::endl; | ||
} | ||
|
||
ExcaliburFemClient::~ExcaliburFemClient() | ||
{ | ||
//std::cout << "ExcaliburFemClient destructor for id=" << id_ << std::endl; | ||
} | ||
|
||
int ExcaliburFemClient::get_id() { | ||
return id_; | ||
} |
61 changes: 61 additions & 0 deletions
61
plugins/excalibur/fem_api_extension/api_stub/ExcaliburFemClient.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "femApi.h" | ||
#include "FemException.h" | ||
|
||
typedef enum | ||
{ | ||
femClientOK = 0, ///< OK | ||
femClientDisconnected = 10000, ///< Client disconnected by peer | ||
femClientTimeout, ///< Timeout occurred on a socket operation | ||
femClientResponseMismatch, ///< Mismatch between requested command and response | ||
femClientMissingAck, ///< Transaction command was not acknowledged in reponse | ||
femClientSendMismatch, ///< Mismatch in length of send operation | ||
femClientReadMismatch, ///< Mismatch in requested versus received access in read transaction | ||
femClientWriteMismatch, ///< Mismatch in requested versus acknowledged access in write transaction | ||
femClientIllegalSensor, ///< Illegal sensor specified in tempSensorRead call | ||
femClientNextEnumRange = 20000 ///< Next enum range to use for derived class exceptions | ||
} FemClientErrorCode; | ||
|
||
class FemClientException: public FemException | ||
{ | ||
public: | ||
FemClientException(const std::string aExText): FemException(aExText) { }; | ||
FemClientException(const FemClientErrorCode aExCode, const std::string aExText) : | ||
FemException((FemErrorCode)aExCode, aExText) { }; | ||
}; | ||
|
||
typedef enum | ||
{ | ||
excaliburFemClientIllegalDacId = femClientNextEnumRange, | ||
excaliburFemClientIllegalConfigId, | ||
excaliburFemClientIllegalChipId, | ||
excaliburFemClientIllegalConfigSize, | ||
excaliburFemClientIllegalCounterDepth, | ||
excaliburFemClientOmrTransactionTimeout, | ||
excaliburFemClientUdpSetupFailed, | ||
excaliburFemClientDataReceviverSetupFailed, | ||
excaliburFemClientIllegalOperationMode, | ||
excaliburFemClientIllegalCounterSelect, | ||
excaliburFemClientBufferAllocateFailed, | ||
excaliburFemClientPersonalityStatusError, | ||
excaliburFemClientBadDacScanParameters, | ||
excaliburFemClientMissingScanFunction, | ||
excaliburFemClientIllegalTriggerMode, | ||
excaliburFemClientIllegalTriggerPolarity, | ||
excaliburFemClientIllegalReadWriteMode, | ||
|
||
} ExcaliburFemClientErrorCode; | ||
|
||
|
||
class ExcaliburFemClient{ | ||
public: | ||
|
||
ExcaliburFemClient(void* aCtlHandle, const CtlCallbacks* aCallbacks, | ||
const CtlConfig* aConfig, unsigned int aTimeoutInMsecs = 0); | ||
~ExcaliburFemClient(); | ||
|
||
int get_id(); | ||
|
||
private: | ||
int id_; | ||
|
||
}; |
29 changes: 29 additions & 0 deletions
29
plugins/excalibur/fem_api_extension/api_stub/FemApiError.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "FemApiError.h" | ||
|
||
FemApiError::FemApiError() { | ||
|
||
} | ||
|
||
FemApiError::~FemApiError() { | ||
error_string_ = os.str(); | ||
} | ||
|
||
std::ostringstream& FemApiError::Set() { | ||
return os; | ||
} | ||
|
||
std::ostringstream& FemApiError::Set(const int error_code) { | ||
error_code_ = error_code; | ||
return os; | ||
} | ||
|
||
const char* FemApiError::get_string(void) { | ||
return error_string_.c_str(); | ||
} | ||
|
||
const int FemApiError::get_code(void) { | ||
return error_code_; | ||
} | ||
|
||
std::string FemApiError::error_string_ = ""; | ||
int FemApiError::error_code_ = 0; |
24 changes: 24 additions & 0 deletions
24
plugins/excalibur/fem_api_extension/api_stub/FemApiError.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
|
||
class FemApiError | ||
{ | ||
public: | ||
FemApiError(); | ||
virtual ~FemApiError(); | ||
std::ostringstream& Set(); | ||
std::ostringstream& Set(const int error_code); | ||
static const char* get_string(void); | ||
static const int get_code(void); | ||
|
||
protected: | ||
std::ostringstream os; | ||
|
||
private: | ||
FemApiError(const FemApiError&); | ||
FemApiError& operator =(const FemApiError&); | ||
static std::string error_string_; | ||
static int error_code_; | ||
|
||
}; |
77 changes: 77 additions & 0 deletions
77
plugins/excalibur/fem_api_extension/api_stub/FemException.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* FemException.h | ||
* | ||
* Created on: Nov 22, 2011 | ||
* Author: tcn45 | ||
*/ | ||
|
||
#ifndef FEMEXCEPTION_H_ | ||
#define FEMEXCEPTION_H_ | ||
|
||
#include <exception> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
|
||
#define FEM_EXCEPTION_LOCATION __FUNCTION__,__FILE__,__LINE__ | ||
|
||
typedef int FemErrorCode; | ||
|
||
class FemException: public std::exception | ||
{ | ||
|
||
public: | ||
|
||
FemException(const std::string aExText) throw() : | ||
mExCode(-1), | ||
mExText(aExText), | ||
mExFunc("unknown"), | ||
mExFile("unknown"), | ||
mExLine(-1) | ||
{ }; | ||
|
||
FemException(const FemErrorCode aExCode, const std::string aExText) throw() : | ||
mExCode(aExCode), | ||
mExText(aExText), | ||
mExFunc("unknown"), | ||
mExFile("unknown"), | ||
mExLine(-1) | ||
{ }; | ||
|
||
FemException(const FemErrorCode aExCode, const std::string aExText, const std::string aExFunc, | ||
const std::string aExFile, const int aExLine) throw() : | ||
mExCode(aExCode), | ||
mExText(aExText), | ||
mExFunc(aExFunc), | ||
mExFile(aExFile), | ||
mExLine(aExLine) | ||
{ }; | ||
|
||
virtual ~FemException(void) throw() { }; | ||
|
||
virtual const char * what() const throw() { | ||
return mExText.c_str(); | ||
}; | ||
|
||
virtual const char * where() const throw() { | ||
std::ostringstream ostr; | ||
ostr << "function: " << mExFunc << " file: " << mExFile << " line: " << mExLine; | ||
return (ostr.str()).c_str(); | ||
}; | ||
|
||
virtual FemErrorCode which() const throw() | ||
{ | ||
return mExCode; | ||
}; | ||
|
||
private: | ||
|
||
const FemErrorCode mExCode; | ||
const std::string mExText; | ||
const std::string mExFunc; | ||
const std::string mExFile; | ||
const int mExLine; | ||
|
||
}; | ||
|
||
#endif /* FEMEXCEPTION_H_ */ |
103 changes: 103 additions & 0 deletions
103
plugins/excalibur/fem_api_extension/api_stub/femApi.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#include <iostream> | ||
#include <map> | ||
#include <vector> | ||
|
||
#include "femApi.h" | ||
#include "FemApiError.h" | ||
#include "ExcaliburFemClient.h" | ||
|
||
std::map<int, std::vector<int> > int_params; | ||
|
||
const unsigned int kClientTimeoutMsecs = 10000; | ||
|
||
const char* femErrorMsg(void) | ||
{ | ||
return FemApiError::get_string(); | ||
} | ||
|
||
int femErrorCode(void) | ||
{ | ||
return FemApiError::get_code(); | ||
} | ||
|
||
void* femInitialise(void* ctlHandle, const CtlCallbacks* callbacks, const CtlConfig* config) | ||
{ | ||
ExcaliburFemClient* theFem = NULL; | ||
try { | ||
theFem = new ExcaliburFemClient(ctlHandle, callbacks, config, kClientTimeoutMsecs); | ||
} | ||
catch (FemClientException& e) | ||
{ | ||
FemApiError().Set(e.which()) << "Error trying to initialise FEM id " << config->femNumber << ": " << e.what(); | ||
} | ||
|
||
return (void*)theFem; | ||
} | ||
|
||
int femGetInt(void* femHandle, int chipId, int id, size_t size, int* value) | ||
{ | ||
int rc = FEM_RTN_OK; | ||
|
||
//ExcaliburFemClient* theFem = reinterpret_cast<ExcaliburFemClient*>(femHandle); | ||
|
||
if (int_params.count(id) > 0) { | ||
for (size_t i = 0; i < size; i++) { | ||
value[i] = int_params[id][i]; | ||
} | ||
} else { | ||
for (size_t i = 0; i < size; i++) { | ||
value[i] = id + i; | ||
} | ||
} | ||
|
||
return rc; | ||
} | ||
|
||
int femSetInt(void* femHandle, int chipId, int id, size_t size, int* value) | ||
{ | ||
int rc = FEM_RTN_OK; | ||
|
||
int_params[id] = std::vector<int>(value, value + size); | ||
|
||
return rc; | ||
} | ||
|
||
int femCmd(void* femHandle, int chipId, int id) | ||
{ | ||
int rc = FEM_RTN_OK; | ||
|
||
//ExcaliburFemClient* theFem = reinterpret_cast<ExcaliburFemClient*>(femHandle); | ||
|
||
switch (id) | ||
{ | ||
case FEM_OP_STARTACQUISITION: | ||
case FEM_OP_STOPACQUISITION: | ||
case FEM_OP_LOADPIXELCONFIG: | ||
case FEM_OP_FREEALLFRAMES: | ||
case FEM_OP_LOADDACCONFIG: | ||
case FEM_OP_FEINIT: | ||
case FEM_OP_REBOOT: | ||
// Do nothing for now | ||
break; | ||
|
||
default: | ||
rc = FEM_RTN_UNKNOWNOPID; | ||
FemApiError().Set() << "femCmd: illegal command ID: " << id; | ||
} | ||
|
||
return rc; | ||
} | ||
|
||
int femGetId(void* femHandle) | ||
{ | ||
ExcaliburFemClient* theFem = reinterpret_cast<ExcaliburFemClient*>(femHandle); | ||
|
||
return theFem->get_id(); | ||
} | ||
|
||
void femClose(void* femHandle) | ||
{ | ||
ExcaliburFemClient* theFem = reinterpret_cast<ExcaliburFemClient*>(femHandle); | ||
|
||
delete theFem; | ||
} |
Oops, something went wrong.