Developer Application Interface (ARC API) v3.6.2
ARC, Inc. GenII/III Application Interface
CArcSystem.h
Go to the documentation of this file.
1// +------------------------------------------------------------------------------------------------------------------+
2// | FILE: CArcSystem.h |
3// +------------------------------------------------------------------------------------------------------------------+
4// | PURPOSE: This file defines the standard ARC operating system class and definitions. |
5// | |
6// | AUTHOR: Scott Streit DATE: ? |
7// | |
8// | Copyright Astronomical Research Cameras, Inc. All rights reserved. |
9// +------------------------------------------------------------------------------------------------------------------+
12#pragma once
13
14
15#ifdef _WINDOWS
16
17 #include <windows.h>
18
19#elif defined( __APPLE__ )
20
21 #include <IOKit/IOKitLib.h>
22 #include <ApplicationServices/ApplicationServices.h>
23 #include <IOKit/usb/IOUSBLib.h>
24
25#elif defined( __linux )
26
27 #include <sys/mman.h>
28 #include <sys/ioctl.h>
29
30#endif
31
32#include <memory>
33
34#include <CArcDeviceDllMain.h>
35#include <CArcBase.h>
36
37
38
39namespace arc
40{
41 namespace gen3
42 {
43
44 // +=========================================================================================================+
45 // | WINDOWS DEFINITIONS |
46 // +=========================================================================================================+
47 #ifdef _WINDOWS
48
49 // +-----------------------------------------------------------------------------------------------------+
50 // | Data Types |
51 // +-----------------------------------------------------------------------------------------------------+
52 using arcDevHandle_t = HANDLE;
53
54
55 // +-----------------------------------------------------------------------------------------------------+
56 // | Constants |
57 // +-----------------------------------------------------------------------------------------------------+
58 constexpr auto ARC_CTRL_ID = 33000; // Used as part of DeviceIoCtrl
59 constexpr auto MAP_FAILED = ( uint8_t* )0;
60 constexpr auto ARC_MAX_PATH = _MAX_PATH;
61
62
63 // +=========================================================================================================+
64 // | MAC OS X DEFINITIONS |
65 // +=========================================================================================================+
66 #elif defined( __APPLE__ )
67
68 // +-----------------------------------------------------------------------------------------------------+
69 // | Data Types |
70 // +-----------------------------------------------------------------------------------------------------+
71 using arcDevHandle_t = io_connect_t;
72
73
74 // +-----------------------------------------------------------------------------------------------------+
75 // | Constants |
76 // +-----------------------------------------------------------------------------------------------------+
77 constexpr auto INVALID_HANDLE_VALUE = IO_OBJECT_NULL;
78 constexpr auto MAX_IOCTL_IN_COUNT = 4;
79 constexpr auto MAX_IOCTL_OUT_COUNT = 2;
80 constexpr auto ARC_MAX_PATH = 512;
81
83 enum
84 {
85 kArcOpenUserClient,
86 kArcCloseUserClient,
87 kArcIOCtlUserClient,
88 kArcNumberOfMethods // Must be last
89 };
90
91
92 // +-----------------------------------------------------------------------------------------------------+
93 // | Macros |
94 // +-----------------------------------------------------------------------------------------------------+
95 auto constexpr MKCMD( std::uint32_t uiCmd ) { return ( 0x41524300 | uiCmd ); }
96
97
98 // +=========================================================================================================+
99 // | LINUX DEFINITIONS |
100 // +=========================================================================================================+
101 #else
102
103 // +-----------------------------------------------------------------------------------------------------+
104 // | Data Types |
105 // +-----------------------------------------------------------------------------------------------------+
106 using arcDevHandle_t = int;
107
108
109 // +-----------------------------------------------------------------------------------------------------+
110 // | Constants |
111 // +-----------------------------------------------------------------------------------------------------+
112 constexpr auto INVALID_HANDLE_VALUE = int( -1 );
113 constexpr auto ARC_MAX_PATH = 512;
114
115
116 // +-----------------------------------------------------------------------------------------------------+
117 // | Macros |
118 // +-----------------------------------------------------------------------------------------------------+
119 auto constexpr MKCMD( std::uint32_t uiCmd ) { return ( 0x41524300 | uiCmd ); }
120
121 #endif
122
123
124 // +----------------------------------------------------------------------------------------------------------+
125 // | Device Entry Type |
126 // +----------------------------------------------------------------------------------------------------------+
130 typedef struct ArcDevType
131 {
132 std::string sName;
134 #ifdef __APPLE__
135 io_service_t tService;
136 #endif
137 } arcDev_t;
138
139
140 // +-------------------------------------------------------------------------------------------------------+
141 // | CArcSystem Class |
142 // +-------------------------------------------------------------------------------------------------------+
143
150 class GEN3_CARCDEVICE_API CArcSystem : public CArcBase
151 {
152 public:
153
160 static bool open( arc::gen3::arcDevHandle_t& hDevice, const arcDev_t& tDevice, const std::uint64_t uiFlags = 0 ) noexcept;
161
166 static bool close( arc::gen3::arcDevHandle_t& hDevice ) noexcept;
167
177 static bool ioctl( const arcDevHandle_t hDevice, const std::uint32_t uiCommand, void* pIn, const std::uint32_t uiInSize, void* pOut = nullptr, const std::uint32_t uiOutSize = 0 ) noexcept;
178
185 static void* mmap( const arcDevHandle_t hDevice, const std::int32_t iMapCommand, const std::uint32_t uiSize ) noexcept;
186
193 static bool munmap( const arcDevHandle_t hDevice, const std::int32_t iMapCommand, void* pAddress, const std::size_t uiSize ) noexcept;
194
195 protected:
196
199 CArcSystem( void ) = default;
200
203 ~CArcSystem( void ) = default;
204 };
205
206
207 } // end gen3
208} // end arc
Definition: CArcBase.h:67
Definition: CArcSystem.h:151
CArcSystem(void)=default
~CArcSystem(void)=default
Definition: CArcSystem.h:131
std::string sName
Definition: CArcSystem.h:132