SapAcqDevice.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. #ifndef _SAPACQDEVICE_H_
  2. #define _SAPACQDEVICE_H_
  3. // SapAcqDevice.h : header file
  4. //
  5. #include "SapClassBasicDef.h"
  6. class SAPCLASSBASIC_CLASS SapBuffer;
  7. class SAPCLASSBASIC_CLASS SapFeature;
  8. class SAPCLASSBASIC_CLASS SapAcqDeviceCallbackInfo;
  9. typedef void (*SapAcqDeviceCallback)(SapAcqDeviceCallbackInfo*);
  10. //
  11. // SapAcqDevice class declaration
  12. //
  13. class SAPCLASSBASIC_CLASS SapAcqDevice : public SapXferNode
  14. {
  15. public:
  16. // Enumerations
  17. enum UpdateFeatureMode
  18. {
  19. UpdateFeatureAuto = CORACQDEVICE_VAL_UPDATE_FEATURE_MODE_AUTO,
  20. UpdateFeatureManual = CORACQDEVICE_VAL_UPDATE_FEATURE_MODE_MANUAL
  21. };
  22. enum FileProperty
  23. {
  24. FilePropertyAccessMode = CORACQDEVICE_FILE_PROPERTY_ACCESS_MODE,
  25. FilePropertySize = CORACQDEVICE_FILE_PROPERTY_FILE_SIZE
  26. };
  27. enum FilePropertyValues
  28. {
  29. FileAccessModeNone = CORACQDEVICE_VAL_FILE_ACCESS_MODE_NONE,
  30. FileAccessModeReadOnly = CORACQDEVICE_VAL_FILE_ACCESS_MODE_READ_ONLY,
  31. FileAccessModeWriteOnly = CORACQDEVICE_VAL_FILE_ACCESS_MODE_WRITE_ONLY,
  32. FileAccessModeReadWrite = CORACQDEVICE_VAL_FILE_ACCESS_MODE_READ_WRITE
  33. };
  34. // Various values
  35. enum MiscValues
  36. {
  37. MaxConfigNameSize = 64,
  38. MaxModeNameSize = 64,
  39. };
  40. public:
  41. // Constructor/Destructor
  42. SapAcqDevice(SapLocation location = SapLocation::ServerSystem, BOOL readOnly = FALSE);
  43. SapAcqDevice(SapLocation location, const char *configFile);
  44. SapAcqDevice(const SapAcqDevice &acqDevice);
  45. virtual ~SapAcqDevice();
  46. SapAcqDevice &operator= (const SapAcqDevice &acqDevice);
  47. // Creation/destruction
  48. virtual BOOL Create();
  49. virtual BOOL Destroy();
  50. // SapXferNode type information
  51. XferNodeType GetXferNodeType() { return NodeTypeAcqDevice; }
  52. // General Parameters
  53. const char *GetConfigFile() const { return m_ConfigFile; }
  54. BOOL GetReadOnly() const { return m_ReadOnly ; }
  55. UpdateFeatureMode GetUpdateFeatureMode() const { return m_UpdateFeatureMode; }
  56. const char *GetLabel() const { return m_Label; }
  57. const char *GetConfigName() const { return m_ConfigName; }
  58. const char *GetModeName() const { return m_ModeName; }
  59. BOOL SetConfigFile(const char *configFile);
  60. BOOL SetReadOnly(BOOL readOnly);
  61. BOOL SetUpdateFeatureMode(UpdateFeatureMode mode);
  62. BOOL SetConfigName(const char *configName);
  63. BOOL SetModeName(const char *modeName);
  64. // Direct capability/parameter access
  65. BOOL IsCapabilityValid(int cap);
  66. BOOL IsParameterValid(int param);
  67. BOOL GetCapability(int cap, void *pValue);
  68. BOOL GetParameter(int param, void *pValue);
  69. BOOL SetParameter(int param, int value);
  70. BOOL SetParameter(int param, void *pValue);
  71. // Feature Access Functions
  72. BOOL GetFeatureCount(int *featureCount);
  73. BOOL GetFeatureNameByIndex(int featureIndex, char *featureName, int featureNameSize);
  74. BOOL GetFeatureIndexByName(const char *featureName, int *featureIndex);
  75. BOOL IsFeatureAvailable(const char *featureName, BOOL *isAvailable);
  76. BOOL GetFeatureInfo(const char *featureName, SapFeature *feature);
  77. BOOL GetFeatureInfo(int featureIndex, SapFeature *feature);
  78. // There is no prototype with INT32 type because it is essentially the same as BOOL
  79. BOOL GetFeatureValue(const char *featureName, UINT32 *featureValue);
  80. BOOL GetFeatureValue(const char *featureName, INT64 *featureValue);
  81. BOOL GetFeatureValue(const char *featureName, UINT64 *featureValue);
  82. BOOL GetFeatureValue(const char *featureName, float *featureValue);
  83. BOOL GetFeatureValue(const char *featureName, double *featureValue);
  84. BOOL GetFeatureValue(const char *featureName, BOOL *featureValue);
  85. BOOL GetFeatureValue(const char *featureName, char *featureString, int featureStringSize);
  86. BOOL GetFeatureValue(const char *featureName, SapBuffer *featureBuffer);
  87. BOOL GetFeatureValue(const char *featureName, SapLut *featureLut);
  88. BOOL GetFeatureValue(int featureIndex, UINT32 *featureValue);
  89. BOOL GetFeatureValue(int featureIndex, INT64 *featureValue);
  90. BOOL GetFeatureValue(int featureIndex, UINT64 *featureValue);
  91. BOOL GetFeatureValue(int featureIndex, float *featureValue);
  92. BOOL GetFeatureValue(int featureIndex, double *featureValue);
  93. BOOL GetFeatureValue(int featureIndex, BOOL *featureValue);
  94. BOOL GetFeatureValue(int featureIndex, char *featureString, int featureStringSize);
  95. BOOL GetFeatureValue(int featureIndex, SapBuffer *featureBuffer);
  96. BOOL GetFeatureValue(int featureIndex, SapLut *featureLut);
  97. BOOL SetFeatureValue(const char *featureName, UINT32 featureValue);
  98. BOOL SetFeatureValue(const char *featureName, INT64 featureValue);
  99. BOOL SetFeatureValue(const char *featureName, UINT64 featureValue);
  100. BOOL SetFeatureValue(const char *featureName, float featureValue);
  101. BOOL SetFeatureValue(const char *featureName, double featureValue);
  102. BOOL SetFeatureValue(const char *featureName, BOOL featureValue);
  103. BOOL SetFeatureValue(const char *featureName, const char *featureString);
  104. BOOL SetFeatureValue(const char *featureName, SapBuffer *featureBuffer);
  105. BOOL SetFeatureValue(const char *featureName, SapLut *featureLut);
  106. BOOL SetFeatureValue(int featureIndex, UINT32 featureValue);
  107. BOOL SetFeatureValue(int featureIndex, INT64 featureValue);
  108. BOOL SetFeatureValue(int featureIndex, UINT64 featureValue);
  109. BOOL SetFeatureValue(int featureIndex, float featureValue);
  110. BOOL SetFeatureValue(int featureIndex, double featureValue);
  111. BOOL SetFeatureValue(int featureIndex, BOOL featureValue);
  112. BOOL SetFeatureValue(int featureIndex, const char *featureString);
  113. BOOL SetFeatureValue(int featureIndex, SapBuffer *featureBuffer);
  114. BOOL SetFeatureValue(int featureIndex, SapLut *featureLut);
  115. BOOL UpdateFeaturesFromDevice();
  116. BOOL UpdateFeaturesToDevice();
  117. BOOL UpdateLabel();
  118. BOOL LoadFeatures(const char *configFile);
  119. BOOL SaveFeatures(const char *configFile);
  120. // Event Management Functions
  121. BOOL GetEventCount(int *eventCount);
  122. BOOL GetEventNameByIndex(int eventIndex, char *eventName, int eventNameSize);
  123. BOOL GetEventIndexByName(const char *eventName, int *eventIndex);
  124. BOOL IsEventAvailable(const char *eventName, BOOL *isAvailable);
  125. BOOL RegisterCallback(const char *eventName, SapAcqDeviceCallback callback, void *context);
  126. BOOL RegisterCallback(int eventIndex, SapAcqDeviceCallback callback, void *context);
  127. BOOL UnregisterCallback(const char *eventName);
  128. BOOL UnregisterCallback(int eventIndex);
  129. BOOL IsCallbackRegistered(const char *eventName, BOOL *isRegistered);
  130. BOOL IsCallbackRegistered(int eventIndex, BOOL *isRegistered);
  131. // Command Management Functions
  132. BOOL GetCommandCount(int *commandCount);
  133. BOOL GetCommandNameByIndex(int commandIndex, char *commandName, int commandNameSize);
  134. BOOL GetCommandIndexByName(const char *commandName, int *commandIndex);
  135. BOOL IsCommandAvailable(const char *commandName, BOOL *isAvailable);
  136. BOOL SendCommand(const char *commandName, void *inData, int inDataSize, void *outData, int outDataSize);
  137. BOOL SendCommand(int commandIndex, void *inData, int inDataSize, void *outData, int outDataSize);
  138. // Flat field correction management
  139. BOOL IsFlatFieldAvailable();
  140. // Bayer management
  141. BOOL IsRawBayerOutput();
  142. // File access Functions
  143. BOOL GetFileCount(int *fileCount);
  144. BOOL GetFileNameByIndex(int fileIndex, char *fileName, int fileNameSize);
  145. BOOL GetFileIndexByName(const char *fileName, int *fileIndex);
  146. BOOL IsFileAccessAvailable();
  147. BOOL GetFileProperty(int fileIndex, FileProperty propertyType, UINT64 *filePropertyValue);
  148. BOOL GetFileProperty(char *fileName, FileProperty propertyType, UINT64 *filePropertyValue);
  149. BOOL WriteFile(const char *localFilePath, const char *deviceFileName);
  150. BOOL WriteFile(const char *localFilePath, int deviceFileIndex);
  151. BOOL ReadFile(const char *deviceFileName, const char *localFilePath);
  152. BOOL ReadFile(int deviceFileIndex, const char *localFilePath);
  153. BOOL DeleteDeviceFile(const char *deviceFileName);
  154. BOOL DeleteDeviceFile(int deviceFileIndex);
  155. // Category Functions
  156. BOOL GetCategoryCount(int *categoryCount);
  157. BOOL GetCategoryPath(int categoryIndex, char *path, int pathSize);
  158. protected:
  159. // Utility methods
  160. void Construct(const char *configFile, BOOL readOnly, UpdateFeatureMode featureMode);
  161. BOOL SetLabel(BOOL refreshResourceName);
  162. BOOL SetXferParams();
  163. BOOL GetFeatureValue(const char *featureName, void *featureValue, int featureValueSize);
  164. BOOL GetFeatureValue(int featureIndex, void *featureValue, int featureValueSize);
  165. BOOL SetFeatureValue(const char *featureName, const void *featureValue, int featureValueSize);
  166. BOOL SetFeatureValue(int featureIndex, const void *featureValue, int featureValueSize);
  167. BOOL IsTransferFeature(const char *featureName);
  168. BOOL IsTransferFeature(int featureIndex);
  169. BOOL IsTransferModifyingFeature(const char *featureName);
  170. BOOL IsTransferModifyingFeature(int featureIndex);
  171. static SAPSTATUS CCONV OnCallback(void *context, COREVENTINFO eventInfo);
  172. protected:
  173. // Parameters
  174. char m_ConfigFile[MAX_PATH]; // Configuration (.ccf) file name
  175. BOOL m_ReadOnly; // Read-only usage flag (only feature retrieval allowed)
  176. UpdateFeatureMode m_UpdateFeatureMode; // Auto vs. manual update mode when writing feature values
  177. char m_Label[MaxLabelSize]; // Name of the acquisition resource
  178. char m_ConfigName[MaxConfigNameSize]; // Configuration name saved to CCF file (as 'Vic Name')
  179. char m_ModeName[MaxModeNameSize]; // Mode name saved to CCF file (as 'Camera Name')
  180. UINT32 m_NumPorts; // Number of available streaming ports
  181. // Feature management
  182. int m_FeatureCount; // Number of available features
  183. static char *m_ValueChangeEventName; // Name of event for feature value change
  184. static char *m_InfoChangeEventName; // Name of event for feature info change
  185. int m_ValueChangeEventIndex; // Index of event for feature value change
  186. int m_InfoChangeEventIndex;
  187. // Event management
  188. int m_EventCount; // Number of available events
  189. SapAcqDeviceCallback *m_Callback; // Application callback functions
  190. void **m_Context; // Application context for each callback function
  191. // Command management
  192. int m_CommandCount; // Number of available commands
  193. // Feature names needed to set transfer parameters, and their indexes
  194. static const char *m_WidthFeatureName;
  195. static const char *m_HeightFeatureName;
  196. static const char *m_LowLevelFormatFeatureName;
  197. static const char *m_SaperaFormatFeatureName;
  198. static const char *m_BitsPerPixelFeatureName;
  199. int m_WidthFeatureIndex;
  200. int m_HeightFeatureIndex;
  201. int m_LowLevelFormatFeatureIndex;
  202. int m_SaperaFormatFeatureIndex;
  203. int m_BitsPerPixelFeatureIndex;
  204. BOOL m_IsGenie;
  205. // Feature corresponding to user name of acquisition device, and its index
  206. static const char *m_UserNameFeature;
  207. int m_UserNameIndex;
  208. // Feature corresponding to loading of camera configuration, and its index
  209. static const char *m_LoadConfigFeatureName;
  210. BOOL m_LoadConfigAvailable;
  211. int m_LoadConfigFeatureIndex;
  212. // Flat field correction management
  213. static const char *m_FlatFieldEnableFeatureName;
  214. BOOL m_FlatFieldAvailable;
  215. static const char *m_FlatFieldCalibEnableFeatureName;
  216. BOOL m_FlatFieldCalibAvailable;
  217. int m_FlatFieldCalibEnableFeatureIndex;
  218. static const char *m_BinningHorizontalFeatureName;
  219. BOOL m_BinningHorizontalAvailable;
  220. int m_BinningHorizontalFeatureIndex;
  221. static const char *m_BinningVerticalFeatureName;
  222. BOOL m_BinningVerticalAvailable;
  223. int m_BinningVerticalFeatureIndex;
  224. // File access management
  225. BOOL m_FileAccessAvailable;
  226. };
  227. //
  228. // SapAcqDeviceCallbackInfo class declaration
  229. //
  230. class SAPCLASSBASIC_CLASS SapAcqDeviceCallbackInfo
  231. {
  232. public:
  233. SapAcqDeviceCallbackInfo(SapAcqDevice *acqDevice, void *context, COREVENTINFO eventInfo);
  234. ~SapAcqDeviceCallbackInfo();
  235. // Attributes
  236. SapAcqDevice *GetAcqDevice() const { return m_AcqDevice; }
  237. void *GetContext() const { return m_Context; }
  238. COREVENTINFO GetEventInfo() const { return m_EventInfo; } // Direct Access (internal)
  239. // Common Parameters
  240. BOOL GetEventCount(int *eventCount);
  241. BOOL GetEventIndex(int *eventIndex);
  242. BOOL GetHostTimeStamp(UINT64 *hostTimeStamp);
  243. BOOL GetAuxiliaryTimeStamp(UINT64 *auxTimeStamp);
  244. // Custom Parameters
  245. BOOL GetCustomData(void **customData);
  246. BOOL GetCustomSize(int *customSize);
  247. // Unnamed Parameters
  248. BOOL GetGenericParam0(int *paramValue);
  249. BOOL GetGenericParam1(int *paramValue);
  250. BOOL GetGenericParam2(int *paramValue);
  251. BOOL GetGenericParam3(int *paramValue);
  252. // Event-specific Parameters
  253. BOOL GetFeatureIndex(int *featureIndex); // Used by "FeatureChanged" event
  254. protected:
  255. SapAcqDevice* m_AcqDevice;
  256. void *m_Context;
  257. COREVENTINFO m_EventInfo;
  258. };
  259. #endif // _SAPACQDEVICE_H_