Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
BadPixelHandler.h
Go to the documentation of this file.
1 #ifndef BADPIXELHANDLER_H
2 #define BADPIXELHANDLER_H
3 
4 #include "AbstractHandler.h"
5 
6 namespace SocCamera {
7 
8 template <typename BprCoreProvider>
10 {
11 public:
12  tcBadPixelHandler(BprCoreProvider *apSensor,
13  tcAbstractHandler *apNextHandler = NULL, std::map<std::string, tcAbstractHandler*> *apMap = NULL)
14  : tcAbstractHandler(nullptr, apNextHandler)
15  , mpBpr(apSensor)
16  {
17  if(apMap) {
18  (*apMap)["SBPR"] = this;
19  (*apMap)["GBPR"] = this;
20  (*apMap)["SBPRM"] = this;
21  (*apMap)["GBPRM"] = this;
22  }
23  }
24 
25  enum teOperation {
30  };
31 
38  virtual std::string execute(std::string& arCommandString,
39  std::string& arParameters) {
40  std::string retVal;
41  teOperation type;
42  int32 value;
43  teNackCode rv = eeNoError;
44 
45  if (arCommandString == "SBPR") {
46  type = eeSet;
47  } else if (arCommandString == "GBPR") {
48  type = eeGet;
49  } else if (arCommandString == "SBPRM") {
50  type = eeSetM;
51  } else if (arCommandString == "GBPRM") {
52  type = eeGetM;
53  } else {
54  return tcAbstractHandler::execute(arCommandString, arParameters);
55  }
56 
57  tcStringTokenizer strtok(arParameters);
58  switch (type) {
59  case eeSet:
60  case eeSetM:
61  if (strtok.hasNext()) {
62  if (!strtok.nextInt(&value)) {
64  }
65  } else {
66  rv = eeArgumentMissing;
67  }
68  break;
69  default:
70  break;
71  }
72 
73  // Execute the operation if there wasn't a problem parsing input.
74  rv = (rv == eeNoError ? this->execute(type, value) : rv);
75  std::string str = carrotNumber(value);
76  if (rv == eeNoError) {
77  switch (type) {
78  case eeGet:
79  case eeGetM:
80  retVal = ack(&str);
81  break;
82  default:
83  retVal = ack();
84  break;
85  }
86  } else {
87  retVal = nack(rv);
88  }
89 
90  return retVal;
91  }
92 
99  virtual teNackCode execute(teOperation aeOp, int32 &arValue) {
100  switch(aeOp) {
101  case eeGetM:
102  arValue = mpBpr->mapState();
103  break;
104  case eeSetM:
105  mpBpr->setMapState(arValue);
106  break;
107  case eeGet:
108  arValue = mpBpr->onState();
109  break;
110  case eeSet:
111  if(!arValue) {
112  mpBpr->setData("");
113  } else {
114  mpBpr->setData(mpBpr->defaultData());
115  }
116  break;
117  }
118 
119  return eeNoError;
120  }
121 
122  void update(tsUpdate asMessage) {
123  tcRegUpdateMsg* pmsg = (tcRegUpdateMsg*) asMessage.mpMessage;
124  tcRegUpdateUint32Msg* pu32msg = (pmsg->m_regtype == eeRegUint32) ? (tcRegUpdateUint32Msg*) pmsg : NULL;
125  teNackCode ncode = eeNoError;
126 
127  if (pu32msg != NULL)
128  {
129  switch (pmsg->m_address)
130  {
131  default:
132  return;
133 
135  mpBpr->setMapState(pu32msg->m_newval);
136  break;
137  case BAD_PIXEL_CTRL_ADDR:
138  if(!pu32msg->m_newval) {
139  mpBpr->setData("");
140  } else {
141  mpBpr->setData(mpBpr->defaultData());
142  }
143  break;
144  }
145 
146  switch (ncode)
147  {
148  case eeNoError:
149  break;
150 
152  pu32msg->m_status = GEV_STATUS_NOT_IMPLEMENTED;
153  pu32msg->m_fixval = pu32msg->m_oldval;
154  break;
155 
157  pu32msg->m_status = GEV_STATUS_INVALID_PARAMETER;
158  pu32msg->m_fixval = pu32msg->m_oldval;
159  break;
160 
161  case eeCaptureInProgress:
162  pu32msg->m_status = GEV_STATUS_BUSY;
163  pu32msg->m_fixval = pu32msg->m_oldval;
164  break;
165 
166  default:
167  pu32msg->m_status = GEV_STATUS_ERROR;
168  pu32msg->m_fixval = pu32msg->m_oldval;
169  break;
170  }
171  pmsg->m_handled = true;
172  }
173  }
174 
175 private:
176  BprCoreProvider* mpBpr;
177 
178 };
179 
180 }
181 
182 #endif // BADPIXELHANDLER_H
tsUpdate
Definition: Observer.h:6
SocCamera::tcBadPixelHandler::eeGetM
@ eeGetM
Definition: BadPixelHandler.h:26
int32
int32_t int32
Definition: Types.h:8
SocCamera::tcRegUpdateMsg::m_regtype
teRegType m_regtype
Definition: RegisterFile.h:364
SocCamera::tcBadPixelHandler::update
void update(tsUpdate asMessage)
Definition: BadPixelHandler.h:122
SocCamera::tcBadPixelHandler::eeSet
@ eeSet
Definition: BadPixelHandler.h:29
BAD_PIXEL_CTRL_ADDR
const uint32_t BAD_PIXEL_CTRL_ADDR
Definition: RegisterFile.h:648
SocCamera::tcAbstractHandler::carrotNumber
static std::string carrotNumber(float anNum)
Definition: AbstractHandler.cpp:79
GEV_STATUS_BUSY
const GEV_STATUS GEV_STATUS_BUSY
A required resource to service the request isn't currently available. The request may be retried.
Definition: GigE.h:32
SocCamera::tcRegUpdateMsg::m_handled
bool m_handled
Definition: RegisterFile.h:366
SocCamera::tcRegUpdateMsg::m_address
uint32_t m_address
Definition: RegisterFile.h:365
SocCamera::tcBadPixelHandler::execute
virtual std::string execute(std::string &arCommandString, std::string &arParameters)
Definition: BadPixelHandler.h:38
GEV_STATUS_INVALID_PARAMETER
const GEV_STATUS GEV_STATUS_INVALID_PARAMETER
At least one parameter provided in the command is invalid (or out of range) for the device.
Definition: GigE.h:27
tsUpdate::mpMessage
void * mpMessage
Definition: Observer.h:9
SocCamera::eeArgumentOutOfRange
@ eeArgumentOutOfRange
!< Command arguments missing
Definition: CameraTypes.h:67
SocCamera::tcBadPixelHandler
Definition: BadPixelHandler.h:9
SocCamera::tcAbstractHandler
Definition: AbstractHandler.h:24
SocCamera::tcBadPixelHandler::teOperation
teOperation
Definition: BadPixelHandler.h:25
tcStringTokenizer::hasNext
bool hasNext()
Definition: StringTokenizer.cpp:13
SocCamera::teNackCode
teNackCode
Definition: CameraTypes.h:62
SocCamera::eeCaptureInProgress
@ eeCaptureInProgress
!< Internal configuration error... typically an incorrect sensor/handler combination
Definition: CameraTypes.h:69
SocCamera::tcRegUpdateTypeMsg
Definition: RegisterFile.h:372
tcStringTokenizer
Definition: StringTokenizer.h:14
SocCamera::eeRegUint32
@ eeRegUint32
Generic 32-bit unsigned integer interface (for endian management)
Definition: RegisterFile.h:112
GEV_STATUS_ERROR
const GEV_STATUS GEV_STATUS_ERROR
Generic error. Try to avoid and use a more descriptive status code from list above.
Definition: GigE.h:37
SocCamera::eeOperationNotSupported
@ eeOperationNotSupported
!< Indicates a communication error (typically with the sensor)
Definition: CameraTypes.h:71
SocCamera::tcBadPixelHandler::tcBadPixelHandler
tcBadPixelHandler(BprCoreProvider *apSensor, tcAbstractHandler *apNextHandler=NULL, std::map< std::string, tcAbstractHandler * > *apMap=NULL)
Definition: BadPixelHandler.h:12
SocCamera
Definition: CameraTypes.h:7
BAD_PIXEL_CTRL_MAP_ADDR
const uint32_t BAD_PIXEL_CTRL_MAP_ADDR
Set whether to display bad pixel map (as 1s/0s) for debugging.
Definition: RegisterFile.h:649
SocCamera::tcBadPixelHandler::execute
virtual teNackCode execute(teOperation aeOp, int32 &arValue)
Definition: BadPixelHandler.h:99
tcStringTokenizer::nextInt
bool nextInt(int32 *apRet)
Definition: StringTokenizer.cpp:60
AbstractHandler.h
SocCamera::eeNoError
@ eeNoError
Definition: CameraTypes.h:64
SocCamera::tcBadPixelHandler::eeSetM
@ eeSetM
Definition: BadPixelHandler.h:27
SocCamera::tcAbstractHandler::ack
static std::string ack(std::string *apValue=NULL)
Definition: AbstractHandler.cpp:68
SocCamera::eeArgumentMissing
@ eeArgumentMissing
!< No command handler exists for command
Definition: CameraTypes.h:66
GEV_STATUS_NOT_IMPLEMENTED
const GEV_STATUS GEV_STATUS_NOT_IMPLEMENTED
The request isn't supported by the device.
Definition: GigE.h:26
SocCamera::tcAbstractHandler::execute
virtual std::string execute(std::string &arCommandString, std::string &arParameters)
Definition: AbstractHandler.cpp:35
SocCamera::tcBadPixelHandler::eeGet
@ eeGet
Definition: BadPixelHandler.h:28
SocCamera::tcRegUpdateMsg
Definition: RegisterFile.h:351
SocCamera::tcAbstractHandler::nack
static std::string nack(int32 anNack)
Definition: AbstractHandler.cpp:50