mrDarker
2025-08-15 c6e24163c3c852b4ac3e45d100b9253b3db0e182
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// MCpp_globalImpl.h - MULTICAM C++ API - GlobalsImpl
#if !defined(__MCPP_GLOBALIMPL_H__)
#define __MCPP_GLOBALIMPL_H__
 
#include "MCpp_global.h"
#include <cstdio>
 
// ****************************************************************************************************
// Global callback function
// ------------------------
 
inline void MCAPI GlobalCallbackFunction(PMCSIGNALINFO CbInfo)
{
  Euresys::MultiCam::MultiCamObjectWithSignaling *signaler = reinterpret_cast<Euresys::MultiCam::MultiCamObjectWithSignaling *>(CbInfo->Context);
  if (signaler != NULL)
    signaler->CbRoutine(CbInfo);
}
 
 
inline void ThrowMultiCamException(MCSTATUS reportedStatus, OperationType Type, const char *Name, const char *Value)
{
  int aStatus = -reportedStatus;
  char ErrorDesc[256];
 
  char Description[MCPP_MAX_EXCEPTION_DESCRIPTION_SIZE];
 
  if (McGetParamStr(MC_CONFIGURATION, MC_ErrorDesc+aStatus, ErrorDesc, 256) != MC_OK)
    sprintf(ErrorDesc, "Unknown error");
 
  if (Type == TYPE_NO_OP)
    sprintf(Description, "%s", ErrorDesc);
 
  else if (Type == TYPE_SET)
    sprintf(Description, "%s '%s' to value '%s': %s", OperationStr[Type], Name? Name:"Unknown parameter", Value? Value:"", ErrorDesc);
 
  else if (Type == TYPE_GET)
    sprintf(Description, "%s '%s': %s", OperationStr[Type], Name? Name:"unknown parameter", ErrorDesc);
 
  else if (Type == TYPE_CREATE || Type == TYPE_DELETE)
    sprintf(Description, "%s %s: %s", OperationStr[Type], Name? Name:"", ErrorDesc);
 
  else
    sprintf(Description, "%s: %s", OperationStr[Type], ErrorDesc);
 
  Euresys::MultiCam::Exception e(reportedStatus, Description);
  throw e;
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, MCHANDLE , MCPARAMID ParamId, const char *Value)
{
  char paramStr[64];
 
  sprintf(paramStr, "%i", ParamId);
  ThrowMultiCamException(reportedStatus, Type, paramStr, Value);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, const char *Name, int Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%d", Value);
  ThrowMultiCamException(reportedStatus, Type, Name, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, const char *Name, INT64 Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "0x%llx", Value);
  ThrowMultiCamException(reportedStatus, Type, Name, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, const char *Name, double Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%f", Value);
  ThrowMultiCamException(reportedStatus, Type, Name, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, const char *Name, void *Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%p", Value);
  ThrowMultiCamException(reportedStatus, Type, Name, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, MCHANDLE Instance, MCPARAMID ParamId, int Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%d", Value);
  ThrowMultiCamException(reportedStatus, Type, Instance, ParamId, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, MCHANDLE Instance, MCPARAMID ParamId, double Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%f", Value);
  ThrowMultiCamException(reportedStatus, Type, Instance, ParamId, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, MCHANDLE Instance, MCPARAMID ParamId, INT64 Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "0x%llx", Value);
  ThrowMultiCamException(reportedStatus, Type, Instance, ParamId, ValueStr);
}
 
inline void ThrowMultiCamException (MCSTATUS reportedStatus, OperationType Type, MCHANDLE Instance, MCPARAMID ParamId, void *Value)
{
  char ValueStr[64];
  sprintf(ValueStr, "%p", Value);
  ThrowMultiCamException(reportedStatus, Type, Instance, ParamId, ValueStr);
}
 
namespace Euresys
{
  namespace MultiCam
  {
    // ********************************************************************************************
    // MultiCam initialization and cleanup functions
    // ---------------------------------------------
    inline void Initialize()
    {
      MCSTATUS status;
      status = McOpenDriver(NULL);
      if (status != MC_OK)
        ThrowMultiCamException(status, TYPE_OPENDRIVER);
      Boards.Init();
    }
 
    inline void Terminate()
    {
      McCloseDriver();
    }
  }
}
 
#endif