Browse Source

Afe read and software meta data are added

master
Arash Aletayeb 4 years ago
parent
commit
994a4384dd
  1. 2
      developHw.pro.user
  2. 50
      include/config/Configuration.h
  3. BIN
      include/lib/CL/OpenCL.lib
  4. 1235
      include/lib/CL/cl.h
  5. 12906
      include/lib/CL/cl.hpp
  6. 10465
      include/lib/CL/cl2.hpp
  7. 126
      include/lib/CL/cl_d3d10.h
  8. 122
      include/lib/CL/cl_d3d10_ext.h
  9. 126
      include/lib/CL/cl_d3d11.h
  10. 122
      include/lib/CL/cl_d3d11_ext.h
  11. 143
      include/lib/CL/cl_d3d9_ext.h
  12. 127
      include/lib/CL/cl_dx9_media_sharing.h
  13. 133
      include/lib/CL/cl_egl.h
  14. 334
      include/lib/CL/cl_ext.h
  15. 162
      include/lib/CL/cl_gl.h
  16. 69
      include/lib/CL/cl_gl_ext.h
  17. 1278
      include/lib/CL/cl_platform.h
  18. 54
      include/lib/CL/opencl.h
  19. 53
      include/model/backendImageProcessor/Bip.h
  20. 52
      include/model/backendImageProcessor/core/BaseStrategy.h
  21. 90
      include/model/backendImageProcessor/core/BipCore.h
  22. 50
      include/model/backendImageProcessor/core/algorithm/ScanConversionAlg.h
  23. 14
      include/model/backendImageProcessor/core/algorithm/ScanConversionOutput.h
  24. 36
      include/model/backendImageProcessor/core/kernelHelper/B/Cri.h
  25. 40
      include/model/backendImageProcessor/core/kernelHelper/B/DynamicContrastB.h
  26. 47
      include/model/backendImageProcessor/core/kernelHelper/B/EnhanceB.h
  27. 44
      include/model/backendImageProcessor/core/kernelHelper/B/FrameFilter.h
  28. 41
      include/model/backendImageProcessor/core/kernelHelper/B/GrayMapB.h
  29. 44
      include/model/backendImageProcessor/core/kernelHelper/B/Persist.h
  30. 41
      include/model/backendImageProcessor/core/kernelHelper/B/RejectionB.h
  31. 46
      include/model/backendImageProcessor/core/kernelHelper/B/ScanConversionB.h
  32. 41
      include/model/backendImageProcessor/core/kernelHelper/B/TintMapB.h
  33. 13
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/CriDto.h
  34. 13
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/DynamicContrastKernelDto.h
  35. 14
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/EnhanceKernelDto.h
  36. 12
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/GrayMapKernelDto.h
  37. 12
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/PersistKernelDto.h
  38. 11
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/RejectionKernelDto.h
  39. 15
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/ScanConversionKernelDto.h
  40. 16
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/SriKernelDto.h
  41. 12
      include/model/backendImageProcessor/core/kernelHelper/kernelDto/TintMapKernelDto.h
  42. 38
      include/model/backendImageProcessor/core/kernelHelper/misc/PreProcess.h
  43. 42
      include/model/backendImageProcessor/core/kernelHelper/misc/Sri.h
  44. 20
      include/model/backendImageProcessor/core/process/ProcessConfig.h
  45. 62
      include/model/backendImageProcessor/core/process/ProcessQueue.h
  46. 26
      include/model/backendImageProcessor/core/process/ProcessQueueFactory.h
  47. 33
      include/model/backendImageProcessor/core/process/twoD/TwoDProcessQueue.h
  48. 19
      include/model/backendImageProcessor/core/process/twoD/TwoDProcessQueueFactory.h
  49. 18
      include/model/backendImageProcessor/core/scenario/ScenarioConfig.h
  50. 18
      include/model/backendImageProcessor/core/strategy/StrategyConfig.h
  51. 44
      include/model/backendImageProcessor/core/strategy/StrategyQueue.h
  52. 19
      include/model/backendImageProcessor/dto/BipImage.h
  53. 11
      include/model/backendImageProcessor/dto/BipProbeProperties.h
  54. 120
      include/model/backendImageProcessor/dtoInternal/BipInput.h
  55. 79
      include/model/backendImageProcessor/dtoInternal/BipScanConversionConfig.h
  56. 55
      include/model/backendImageProcessor/dtoInternal/KernelInput.h
  57. 92
      include/model/backendImageProcessor/type/EImageMode.h
  58. 80
      include/model/backendImageProcessor/utils/KernelInputFetcher.h
  59. 654
      include/model/backendImageProcessor/utils/OpenClHelper.h
  60. 38
      include/model/bipTester/BipTester.h
  61. 105
      include/model/bipTester/core/BipTesterCore.h
  62. 21
      include/model/bipTester/core/BipTesterMetadata.h
  63. 19
      include/model/bipTester/utils/FileHelper.h
  64. 44
      include/model/csm/Csm.h
  65. 78
      include/model/csm/core/ConsoleCore.h
  66. 43
      include/model/csm/core/EMenuTab.h
  67. 79
      include/model/csm/core/Hid.h
  68. 125
      include/model/csm/core/TrackballCore.h
  69. 63
      include/model/csm/core/consoleComponent/Button.h
  70. 83
      include/model/csm/core/consoleComponent/ConsoleButton.h
  71. 129
      include/model/csm/core/consoleComponent/ControlAbstract.h
  72. 23
      include/model/csm/core/consoleComponent/Led.h
  73. 23
      include/model/csm/core/consoleComponent/Rotary.h
  74. 29
      include/model/csm/core/trackballComponent/CenterBall.h
  75. 42
      include/model/csm/core/trackballComponent/HidButton.h
  76. 23
      include/model/csm/core/trackballComponent/MiceButton.h
  77. 51
      include/model/csm/core/trackballComponent/TrackballItem.h
  78. 24
      include/model/csm/dto/CommandControl.h
  79. 18
      include/model/csm/dto/HidPacket.h
  80. 17
      include/model/csm/dto/ItemValue.h
  81. 24
      include/model/csm/dto/TrackballConfig.h
  82. 53
      include/model/csm/exception/CsmException.h
  83. 43
      include/model/csm/exception/CsmExceptionDef.h
  84. 133
      include/model/csm/type/EConsole.h
  85. 77
      include/model/csm/type/Graph.h
  86. 35
      include/model/csm/type/Node.h
  87. 17
      include/model/csm/type/Transition.h
  88. 27
      include/model/csm/utils/MouseEventFilter.h
  89. 43
      include/model/csm/utils/XCursorSetter.h
  90. 63
      include/model/csm/utils/XmlConsoleConfigReader.h
  91. 49
      include/model/csm/utils/XmlGraphStateReader.h
  92. 49
      include/model/csm/utils/XmlTrackballConfigReader.h
  93. 35
      include/model/databaseManager/DatabaseManager.h
  94. 66
      include/model/databaseManager/core/DatabaseManagerCore.h
  95. 11
      include/model/databaseManager/core/DatabaseManagerNames.h
  96. 55
      include/model/databaseManager/dto/Hardware/DbmApodizationLut.h
  97. 73
      include/model/databaseManager/dto/Hardware/DbmLineFilter.h
  98. 58
      include/model/databaseManager/dto/Hardware/DbmLpf.h
  99. 66
      include/model/databaseManager/dto/ProbeProperties/DbmApplicatoin.h
  100. 138
      include/model/databaseManager/dto/ProbeProperties/DbmLastConfig.h

2
developHw.pro.user

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2021-05-16T15:18:03. -->
<!-- Written by QtCreator 4.10.0, 2021-05-22T16:16:54. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

50
include/config/Configuration.h

@ -0,0 +1,50 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <QVector>
#include <QString>
//#define USE_DBL
//timeout for which event coordinator waits for events responders
#define EVENT_COORD_TIMEOUT 5000
#define US_HOME_PATH "US_HOME"
#define SCENARIO_EXT ".scn"
//config file path
#if defined(_WIN32)
#define CONFIGURATION_PATH QString("D:\\config\\")
#elif defined(__linux__)
#define CONFIGURATION_PATH QString("/home/hasis/Desktop/config/")
#else
#define CONFIGURATION_PATH QString("D:\\config\\")
#endif
//module names
#define VIEWMODEL_NAME QString("MainViewModel")
#define HARDWARE_NAME QString("Hardware")
#define SCEN_GEN_NAME QString("ScenarioGenerator")
#define LOGGER_NAME QString("Logger")
#define CONF_MAN_NAME QString("ConfigurationManager")
#define CSM_NAME QString("Csm")
#define SSM_NAME QString("Ssm")
#define BIP_NAME QString("Bip")
#define CINE_NAME QString("Evocator")
#define PLAYER_NAME QString("Player")
#define DB_MAN_NAME QString("DatabaseManager")
#define BIP_TESTER_NAME QString("BipTester")
#define HID_NAME QString("Hid")
#define EVOCATOR_NAME QString("Evocator")
#define B_SET_VM_NAME QString("BModeSettingViewModel")
#define B_DISP_VM_NAME QString("BModeDisplayViewModel")
#define IMAGE_VM_NAME QString("ImageViewModel")
#define USER_VM_NAME QString("UserViewModel")
#define PROBE_VM_NAME QString("ProbeViewModel")
#define SIM_VM_NAME QString("SimulationViewModel")
#define TGC_VM_NAME QString("TgcViewModel")
#define USER_NAME QString("sonographer")
#endif //CONFIGURATION_H

BIN
include/lib/CL/OpenCL.lib

Binary file not shown.

1235
include/lib/CL/cl.h

File diff suppressed because it is too large

12906
include/lib/CL/cl.hpp

File diff suppressed because it is too large

10465
include/lib/CL/cl2.hpp

File diff suppressed because it is too large

126
include/lib/CL/cl_d3d10.h

@ -0,0 +1,126 @@
/**********************************************************************************
* Copyright (c) 2008-2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
#ifndef __OPENCL_CL_D3D10_H
#define __OPENCL_CL_D3D10_H
#include <d3d10.h>
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* cl_khr_d3d10_sharing */
#define cl_khr_d3d10_sharing 1
typedef cl_uint cl_d3d10_device_source_khr;
typedef cl_uint cl_d3d10_device_set_khr;
/******************************************************************************/
/* Error Codes */
#define CL_INVALID_D3D10_DEVICE_KHR -1002
#define CL_INVALID_D3D10_RESOURCE_KHR -1003
#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004
#define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005
/* cl_d3d10_device_source_nv */
#define CL_D3D10_DEVICE_KHR 0x4010
#define CL_D3D10_DXGI_ADAPTER_KHR 0x4011
/* cl_d3d10_device_set_nv */
#define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012
#define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013
/* cl_context_info */
#define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014
#define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C
/* cl_mem_info */
#define CL_MEM_D3D10_RESOURCE_KHR 0x4015
/* cl_image_info */
#define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016
/* cl_command_type */
#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017
#define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)(
cl_platform_id platform,
cl_d3d10_device_source_khr d3d_device_source,
void * d3d_object,
cl_d3d10_device_set_khr d3d_device_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Buffer * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Texture2D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Texture3D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_D3D10_H */

122
include/lib/CL/cl_d3d10_ext.h

@ -0,0 +1,122 @@
/**********************************************************************************
* Copyright (c) 2008-2009 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
#ifndef __OPENCL_CL_D3D10_EXT_H
#define __OPENCL_CL_D3D10_EXT_H
#include <d3d10.h>
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* cl_nv_d3d10_sharing */
typedef cl_uint cl_d3d10_device_source_nv;
typedef cl_uint cl_d3d10_device_set_nv;
/******************************************************************************/
// Error Codes
#define CL_INVALID_D3D10_DEVICE_NV -1002
#define CL_INVALID_D3D10_RESOURCE_NV -1003
#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_NV -1004
#define CL_D3D10_RESOURCE_NOT_ACQUIRED_NV -1005
// cl_d3d10_device_source_nv
#define CL_D3D10_DEVICE_NV 0x4010
#define CL_D3D10_DXGI_ADAPTER_NV 0x4011
// cl_d3d10_device_set_nv
#define CL_PREFERRED_DEVICES_FOR_D3D10_NV 0x4012
#define CL_ALL_DEVICES_FOR_D3D10_NV 0x4013
// cl_context_info
#define CL_CONTEXT_D3D10_DEVICE_NV 0x4014
// cl_mem_info
#define CL_MEM_D3D10_RESOURCE_NV 0x4015
// cl_image_info
#define CL_IMAGE_D3D10_SUBRESOURCE_NV 0x4016
// cl_command_type
#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_NV 0x4017
#define CL_COMMAND_RELEASE_D3D10_OBJECTS_NV 0x4018
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10NV_fn)(
cl_platform_id platform,
cl_d3d10_device_source_nv d3d_device_source,
void * d3d_object,
cl_d3d10_device_set_nv d3d_device_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Buffer * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Texture2D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D10Texture3D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
#ifdef __cplusplus
}
#endif
#endif // __OPENCL_CL_D3D10_H

126
include/lib/CL/cl_d3d11.h

@ -0,0 +1,126 @@
/**********************************************************************************
* Copyright (c) 2008-2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
#ifndef __OPENCL_CL_D3D11_H
#define __OPENCL_CL_D3D11_H
#include <d3d11.h>
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* cl_khr_d3d11_sharing */
#define cl_khr_d3d11_sharing 1
typedef cl_uint cl_d3d11_device_source_khr;
typedef cl_uint cl_d3d11_device_set_khr;
/******************************************************************************/
/* Error Codes */
#define CL_INVALID_D3D11_DEVICE_KHR -1006
#define CL_INVALID_D3D11_RESOURCE_KHR -1007
#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008
#define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009
/* cl_d3d11_device_source */
#define CL_D3D11_DEVICE_KHR 0x4019
#define CL_D3D11_DXGI_ADAPTER_KHR 0x401A
/* cl_d3d11_device_set */
#define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B
#define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C
/* cl_context_info */
#define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D
#define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D
/* cl_mem_info */
#define CL_MEM_D3D11_RESOURCE_KHR 0x401E
/* cl_image_info */
#define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F
/* cl_command_type */
#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020
#define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)(
cl_platform_id platform,
cl_d3d11_device_source_khr d3d_device_source,
void * d3d_object,
cl_d3d11_device_set_khr d3d_device_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Buffer * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Texture2D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Texture3D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_D3D11_H */

122
include/lib/CL/cl_d3d11_ext.h

@ -0,0 +1,122 @@
/**********************************************************************************
* Copyright (c) 2008-2009 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
#ifndef __OPENCL_CL_D3D11_EXT_H
#define __OPENCL_CL_D3D11_EXT_H
#include <d3d11.h>
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* cl_nv_d3d11_sharing */
typedef cl_uint cl_d3d11_device_source_nv;
typedef cl_uint cl_d3d11_device_set_nv;
/******************************************************************************/
// Error Codes
#define CL_INVALID_D3D11_DEVICE_NV -1006
#define CL_INVALID_D3D11_RESOURCE_NV -1007
#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_NV -1008
#define CL_D3D11_RESOURCE_NOT_ACQUIRED_NV -1009
// cl_d3d11_device_source_nv
#define CL_D3D11_DEVICE_NV 0x4019
#define CL_D3D11_DXGI_ADAPTER_NV 0x401A
// cl_d3d11_device_set_nv
#define CL_PREFERRED_DEVICES_FOR_D3D11_NV 0x401B
#define CL_ALL_DEVICES_FOR_D3D11_NV 0x401C
// cl_context_info
#define CL_CONTEXT_D3D11_DEVICE_NV 0x401D
// cl_mem_info
#define CL_MEM_D3D11_RESOURCE_NV 0x401E
// cl_image_info
#define CL_IMAGE_D3D11_SUBRESOURCE_NV 0x401F
// cl_command_type
#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_NV 0x4020
#define CL_COMMAND_RELEASE_D3D11_OBJECTS_NV 0x4021
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11NV_fn)(
cl_platform_id platform,
cl_d3d11_device_source_nv d3d_device_source,
void * d3d_object,
cl_d3d11_device_set_nv d3d_device_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Buffer * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Texture2D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DNV_fn)(
cl_context context,
cl_mem_flags flags,
ID3D11Texture3D * resource,
UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
#ifdef __cplusplus
}
#endif
#endif // __OPENCL_CL_D3D11_H

143
include/lib/CL/cl_d3d9_ext.h

@ -0,0 +1,143 @@
/**********************************************************************************
* Copyright (c) 2008-2009 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
#ifndef __OPENCL_CL_D3D9_EXT_H
#define __OPENCL_CL_D3D9_EXT_H
#include <d3d9.h>
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* cl_nv_d3d9_sharing */
typedef cl_uint cl_d3d9_device_source_nv;
typedef cl_uint cl_d3d9_device_set_nv;
/******************************************************************************/
// Error Codes
#define CL_INVALID_D3D9_DEVICE_NV -1010
#define CL_INVALID_D3D9_RESOURCE_NV -1011
#define CL_D3D9_RESOURCE_ALREADY_ACQUIRED_NV -1012
#define CL_D3D9_RESOURCE_NOT_ACQUIRED_NV -1013
// cl_d3d9_device_source_nv
#define CL_D3D9_DEVICE_NV 0x4022
#define CL_D3D9_ADAPTER_NAME_NV 0x4023
// cl_d3d9_device_set_nv
#define CL_PREFERRED_DEVICES_FOR_D3D9_NV 0x4024
#define CL_ALL_DEVICES_FOR_D3D9_NV 0x4025
// cl_context_info
#define CL_CONTEXT_D3D9_DEVICE_NV 0x4026
// cl_mem_info
#define CL_MEM_D3D9_RESOURCE_NV 0x4027
// cl_image_info
#define CL_IMAGE_D3D9_FACE_NV 0x4028
#define CL_IMAGE_D3D9_LEVEL_NV 0x4029
// cl_command_type
#define CL_COMMAND_ACQUIRE_D3D9_OBJECTS_NV 0x402A
#define CL_COMMAND_RELEASE_D3D9_OBJECTS_NV 0x402B
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D9NV_fn)(
cl_platform_id platform,
cl_d3d9_device_source_nv d3d_device_source,
void * d3d_object,
cl_d3d9_device_set_nv d3d_device_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9VertexBufferNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DVertexBuffer9 * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9IndexBufferNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DIndexBuffer9 * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9SurfaceNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DSurface9 * resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9TextureNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DTexture9 *resource,
UINT miplevel,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9CubeTextureNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DCubeTexture9 * resource,
D3DCUBEMAP_FACES facetype,
UINT miplevel,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D9VolumeTextureNV_fn)(
cl_context context,
cl_mem_flags flags,
IDirect3DVolumeTexture9 * resource,
UINT miplevel,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D9ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem *mem_objects,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D9ObjectsNV_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
cl_mem *mem_objects,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event) CL_API_SUFFIX__VERSION_1_0;
#ifdef __cplusplus
}
#endif
#endif // __OPENCL_CL_D3D9_H

127
include/lib/CL/cl_dx9_media_sharing.h

@ -0,0 +1,127 @@
/**********************************************************************************
* Copyright (c) 2008-2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
#ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H
#define __OPENCL_CL_DX9_MEDIA_SHARING_H
#include <CL/cl.h>
#include <CL/cl_platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
/* cl_khr_dx9_media_sharing */
#define cl_khr_dx9_media_sharing 1
typedef cl_uint cl_dx9_media_adapter_type_khr;
typedef cl_uint cl_dx9_media_adapter_set_khr;
#if defined(_WIN32)
#include <d3d9.h>
typedef struct _cl_dx9_surface_info_khr
{
IDirect3DSurface9 *resource;
HANDLE shared_handle;
} cl_dx9_surface_info_khr;
#endif
/******************************************************************************/
/* Error Codes */
#define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010
#define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011
#define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012
#define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013
/* cl_media_adapter_type_khr */
#define CL_ADAPTER_D3D9_KHR 0x2020
#define CL_ADAPTER_D3D9EX_KHR 0x2021
#define CL_ADAPTER_DXVA_KHR 0x2022
/* cl_media_adapter_set_khr */
#define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023
#define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024
/* cl_context_info */
#define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025
#define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026
#define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027
/* cl_mem_info */
#define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028
#define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029
/* cl_image_info */
#define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A
/* cl_command_type */
#define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B
#define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C
/******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)(
cl_platform_id platform,
cl_uint num_media_adapters,
cl_dx9_media_adapter_type_khr * media_adapter_type,
void * media_adapters,
cl_dx9_media_adapter_set_khr media_adapter_set,
cl_uint num_entries,
cl_device_id * devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)(
cl_context context,
cl_mem_flags flags,
cl_dx9_media_adapter_type_khr adapter_type,
void * surface_info,
cl_uint plane,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */

133
include/lib/CL/cl_egl.h

@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2008-2010 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
******************************************************************************/
#ifndef __OPENCL_CL_EGL_H
#define __OPENCL_CL_EGL_H
#ifdef __APPLE__
#else
#include <CL/cl.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Command type for events created with clEnqueueAcquireEGLObjectsKHR */
#define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F
#define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D
#define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E
/* Error type for clCreateFromEGLImageKHR */
#define CL_INVALID_EGL_OBJECT_KHR -1093
#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092
/* CLeglImageKHR is an opaque handle to an EGLImage */
typedef void* CLeglImageKHR;
/* CLeglDisplayKHR is an opaque handle to an EGLDisplay */
typedef void* CLeglDisplayKHR;
/* CLeglSyncKHR is an opaque handle to an EGLSync object */
typedef void* CLeglSyncKHR;
/* properties passed to clCreateFromEGLImageKHR */
typedef intptr_t cl_egl_image_properties_khr;
#define cl_khr_egl_image 1
extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromEGLImageKHR(cl_context /* context */,
CLeglDisplayKHR /* egldisplay */,
CLeglImageKHR /* eglimage */,
cl_mem_flags /* flags */,
const cl_egl_image_properties_khr * /* properties */,
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)(
cl_context context,
CLeglDisplayKHR egldisplay,
CLeglImageKHR eglimage,
cl_mem_flags flags,
const cl_egl_image_properties_khr * properties,
cl_int * errcode_ret);
extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireEGLObjectsKHR(cl_command_queue /* command_queue */,
cl_uint /* num_objects */,
const cl_mem * /* mem_objects */,
cl_uint /* num_events_in_wait_list */,
const cl_event * /* event_wait_list */,
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event);
extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseEGLObjectsKHR(cl_command_queue /* command_queue */,
cl_uint /* num_objects */,
const cl_mem * /* mem_objects */,
cl_uint /* num_events_in_wait_list */,
const cl_event * /* event_wait_list */,
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)(
cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem * mem_objects,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event);
#define cl_khr_egl_event 1
extern CL_API_ENTRY cl_event CL_API_CALL
clCreateEventFromEGLSyncKHR(cl_context /* context */,
CLeglSyncKHR /* sync */,
CLeglDisplayKHR /* display */,
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)(
cl_context context,
CLeglSyncKHR sync,
CLeglDisplayKHR display,
cl_int * errcode_ret);
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_EGL_H */

334
include/lib/CL/cl_ext.h

@ -0,0 +1,334 @@
/*******************************************************************************
* Copyright (c) 2008-2013 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
******************************************************************************/
/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
/* cl_ext.h contains OpenCL extensions which don't have external */
/* (OpenGL, D3D) dependencies. */
#ifndef __CL_EXT_H
#define __CL_EXT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __APPLE__
#include <OpenCL/cl.h>
#include <AvailabilityMacros.h>
#else
#include <CL/cl.h>
#endif
/* cl_khr_fp16 extension - no extension #define since it has no functions */
#define CL_DEVICE_HALF_FP_CONFIG 0x1033
/* Memory object destruction
*
* Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
*
* Registers a user callback function that will be called when the memory object is deleted and its resources
* freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
* stack associated with memobj. The registered user callback functions are called in the reverse order in
* which they were registered. The user callback functions are called and then the memory object is deleted
* and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
* notified when the memory referenced by host_ptr, specified when the memory object is created and used as
* the storage bits for the memory object, can be reused or freed.
*
* The application may not call CL api's with the cl_mem object passed to the pfn_notify.
*
* Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
* before using.
*/
#define cl_APPLE_SetMemObjectDestructor 1
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
/* Context Logging Functions
*
* The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
* Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
* before using.
*
* clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
*/
#define cl_APPLE_ContextLoggingFunctions 1
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
const void * /* private_info */,
size_t /* cb */,
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
const void * /* private_info */,
size_t /* cb */,
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
const void * /* private_info */,
size_t /* cb */,
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
/************************
* cl_khr_icd extension *
************************/
#define cl_khr_icd 1
/* cl_platform_info */
#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
/* Additional Error Codes */
#define CL_PLATFORM_NOT_FOUND_KHR -1001
extern CL_API_ENTRY cl_int CL_API_CALL
clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
cl_platform_id * /* platforms */,
cl_uint * /* num_platforms */);
typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
cl_uint /* num_entries */,
cl_platform_id * /* platforms */,
cl_uint * /* num_platforms */);
/* Extension: cl_khr_image2D_buffer
*
* This extension allows a 2D image to be created from a cl_mem buffer without a copy.
* The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t.
* Both the sampler and sampler-less read_image built-in functions are supported for 2D images
* and 2D images created from a buffer. Similarly, the write_image built-ins are also supported
* for 2D images created from a buffer.
*
* When the 2D image from buffer is created, the client must specify the width,
* height, image format (i.e. channel order and channel data type) and optionally the row pitch
*
* The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels.
* The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels.
*/
/*************************************
* cl_khr_initalize_memory extension *
*************************************/
#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x200E
/**************************************
* cl_khr_terminate_context extension *
**************************************/
#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x200F
#define CL_CONTEXT_TERMINATE_KHR 0x2010
#define cl_khr_terminate_context 1
extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
/*
* Extension: cl_khr_spir
*
* This extension adds support to create an OpenCL program object from a
* Standard Portable Intermediate Representation (SPIR) instance
*/
#define CL_DEVICE_SPIR_VERSIONS 0x40E0
#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1
/******************************************
* cl_nv_device_attribute_query extension *
******************************************/
/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
#define CL_DEVICE_WARP_SIZE_NV 0x4003
#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
#define CL_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT_NV 0x4007
#define CL_DEVICE_PCI_BUS_ID_NV 0x4008
#define CL_DEVICE_PCI_SLOT_ID_NV 0x4009
/******************************************
* cl_nv_create_buffer extension *
******************************************/
typedef cl_bitfield cl_mem_flags_NV;
CL_API_ENTRY cl_mem CL_API_CALL
clCreateBufferNV(cl_context context,
cl_mem_flags flags,
cl_mem_flags_NV flags_NV,
size_t size,
void *host_ptr,
cl_int *errcode_ret);
#define CL_MEM_LOCATION_HOST_NV (1 << 0)
#define CL_MEM_PINNED_NV (1 << 1)
/*********************************
* cl_amd_device_attribute_query *
*********************************/
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
/*********************************
* cl_arm_printf extension
*********************************/
#define CL_PRINTF_CALLBACK_ARM 0x40B0
#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
#ifdef CL_VERSION_1_1
/***********************************
* cl_ext_device_fission extension *
***********************************/
#define cl_ext_device_fission 1
extern CL_API_ENTRY cl_int CL_API_CALL
clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int
(CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
extern CL_API_ENTRY cl_int CL_API_CALL
clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int
(CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
typedef cl_ulong cl_device_partition_property_ext;
extern CL_API_ENTRY cl_int CL_API_CALL
clCreateSubDevicesEXT( cl_device_id /*in_device*/,
const cl_device_partition_property_ext * /* properties */,
cl_uint /*num_entries*/,
cl_device_id * /*out_devices*/,
cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int
( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
const cl_device_partition_property_ext * /* properties */,
cl_uint /*num_entries*/,
cl_device_id * /*out_devices*/,
cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
/* cl_device_partition_property_ext */
#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
#define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
#define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
/* clDeviceGetInfo selectors */
#define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
#define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
#define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
#define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
#define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
/* error codes */
#define CL_DEVICE_PARTITION_FAILED_EXT -1057
#define CL_INVALID_PARTITION_COUNT_EXT -1058
#define CL_INVALID_PARTITION_NAME_EXT -1059
/* CL_AFFINITY_DOMAINs */
#define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
#define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
#define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
#define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
#define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
#define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
/* cl_device_partition_property_ext list terminators */
#define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
#define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
#define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
/*********************************
* cl_qcom_ext_host_ptr extension
*********************************/
#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
#define CL_MEM_HOST_UNCACHED_QCOM 0x40A4
#define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5
#define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6
#define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7
typedef cl_uint cl_image_pitch_info_qcom;
extern CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceImageInfoQCOM(cl_device_id device,
size_t image_width,
size_t image_height,
const cl_image_format *image_format,
cl_image_pitch_info_qcom param_name,
size_t param_value_size,
void *param_value,
size_t *param_value_size_ret);
typedef struct _cl_mem_ext_host_ptr
{
/* Type of external memory allocation. */
/* Legal values will be defined in layered extensions. */
cl_uint allocation_type;
/* Host cache policy for this external memory allocation. */
cl_uint host_cache_policy;
} cl_mem_ext_host_ptr;
/*********************************
* cl_qcom_ion_host_ptr extension
*********************************/
#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
typedef struct _cl_mem_ion_host_ptr
{
/* Type of external memory allocation. */
/* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
cl_mem_ext_host_ptr ext_host_ptr;
/* ION file descriptor */
int ion_filedesc;
/* Host pointer to the ION allocated memory */
void* ion_hostptr;
} cl_mem_ion_host_ptr;
#endif /* CL_VERSION_1_1 */
#ifdef __cplusplus
}
#endif
#endif /* __CL_EXT_H */

162
include/lib/CL/cl_gl.h

@ -0,0 +1,162 @@
/**********************************************************************************
* Copyright (c) 2008 - 2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
#ifndef __OPENCL_CL_GL_H
#define __OPENCL_CL_GL_H
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef cl_uint cl_gl_object_type;
typedef cl_uint cl_gl_texture_info;
typedef cl_uint cl_gl_platform_info;
typedef struct __GLsync *cl_GLsync;
/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */
#define CL_GL_OBJECT_BUFFER 0x2000
#define CL_GL_OBJECT_TEXTURE2D 0x2001
#define CL_GL_OBJECT_TEXTURE3D 0x2002
#define CL_GL_OBJECT_RENDERBUFFER 0x2003
#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E
#define CL_GL_OBJECT_TEXTURE1D 0x200F
#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010
#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011
/* cl_gl_texture_info */
#define CL_GL_TEXTURE_TARGET 0x2004
#define CL_GL_MIPMAP_LEVEL 0x2005
#define CL_GL_NUM_SAMPLES 0x2012
extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLBuffer(cl_context /* context */,
cl_mem_flags /* flags */,
cl_GLuint /* bufobj */,
int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLTexture(cl_context /* context */,
cl_mem_flags /* flags */,
cl_GLenum /* target */,
cl_GLint /* miplevel */,
cl_GLuint /* texture */,
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLRenderbuffer(cl_context /* context */,
cl_mem_flags /* flags */,
cl_GLuint /* renderbuffer */,
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLObjectInfo(cl_mem /* memobj */,
cl_gl_object_type * /* gl_object_type */,
cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLTextureInfo(cl_mem /* memobj */,
cl_gl_texture_info /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
cl_uint /* num_objects */,
const cl_mem * /* mem_objects */,
cl_uint /* num_events_in_wait_list */,
const cl_event * /* event_wait_list */,
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
cl_uint /* num_objects */,
const cl_mem * /* mem_objects */,
cl_uint /* num_events_in_wait_list */,
const cl_event * /* event_wait_list */,
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
/* Deprecated OpenCL 1.1 APIs */
extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
clCreateFromGLTexture2D(cl_context /* context */,
cl_mem_flags /* flags */,
cl_GLenum /* target */,
cl_GLint /* miplevel */,
cl_GLuint /* texture */,
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
clCreateFromGLTexture3D(cl_context /* context */,
cl_mem_flags /* flags */,
cl_GLenum /* target */,
cl_GLint /* miplevel */,
cl_GLuint /* texture */,
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
/* cl_khr_gl_sharing extension */
#define cl_khr_gl_sharing 1
typedef cl_uint cl_gl_context_info;
/* Additional Error Codes */
#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
/* cl_gl_context_info */
#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
/* Additional cl_context_properties */
#define CL_GL_CONTEXT_KHR 0x2008
#define CL_EGL_DISPLAY_KHR 0x2009
#define CL_GLX_DISPLAY_KHR 0x200A
#define CL_WGL_HDC_KHR 0x200B
#define CL_CGL_SHAREGROUP_KHR 0x200C
extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
cl_gl_context_info /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
const cl_context_properties * properties,
cl_gl_context_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret);
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_GL_H */

69
include/lib/CL/cl_gl_ext.h

@ -0,0 +1,69 @@
/**********************************************************************************
* Copyright (c) 2008-2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
/* OpenGL dependencies. */
#ifndef __OPENCL_CL_GL_EXT_H
#define __OPENCL_CL_GL_EXT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __APPLE__
#include <OpenCL/cl_gl.h>
#else
#include <CL/cl_gl.h>
#endif
/*
* For each extension, follow this template
* cl_VEN_extname extension */
/* #define cl_VEN_extname 1
* ... define new types, if any
* ... define new tokens, if any
* ... define new APIs, if any
*
* If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
* This allows us to avoid having to decide whether to include GL headers or GLES here.
*/
/*
* cl_khr_gl_event extension
* See section 9.9 in the OpenCL 1.1 spec for more information
*/
#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
extern CL_API_ENTRY cl_event CL_API_CALL
clCreateEventFromGLsyncKHR(cl_context /* context */,
cl_GLsync /* cl_GLsync */,
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_CL_GL_EXT_H */

1278
include/lib/CL/cl_platform.h

File diff suppressed because it is too large

54
include/lib/CL/opencl.h

@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2008-2012 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
******************************************************************************/
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
#ifndef __OPENCL_H
#define __OPENCL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __APPLE__
#include <OpenCL/cl.h>
#include <OpenCL/cl_gl.h>
#include <OpenCL/cl_gl_ext.h>
#include <OpenCL/cl_ext.h>
#else
#include <CL/cl.h>
#include <CL/cl_gl.h>
#include <CL/cl_gl_ext.h>
#include <CL/cl_ext.h>
#endif
#ifdef __cplusplus
}
#endif
#endif /* __OPENCL_H */

53
include/model/backendImageProcessor/Bip.h

@ -0,0 +1,53 @@
#ifndef BIP_H
#define BIP_H
#include <QMutex>
#include "model/ultrasoundModule/UsModule.h"
#include "model/backendImageProcessor/core/BipCore.h"
#include "model/scenarioGenerator/dto/software/SoftwareOutput.h"
#include "model/backendImageProcessor/dto/BipImage.h"
#include "model/databaseManager/type/EDatabaseRequest.h"
#include "model/backendImageProcessor/utils/KernelInputFetcher.h"
#include "model/backendImageProcessor/dtoInternal/BipInput.h"
/*************************************************************************************************/
/**
* @brief The class is responsible for processing frames with GPU's aid
* @author Mohsen Emami - revised by h-4nd-h
* @date 2019/8/5(1398/5/14)
*/
/*************************************************************************************************/
class Bip : public UsModule
{
Q_OBJECT
US_MODULE
SINGLETON(Bip)
private:
BipCore* _core;
KernelInputFetcher* _kernelInput;
Bip();
void sendDataToEvocator(const UsPacket& packet);
void sendDataToViewModel(const BipImage_t& outputImage);
public:
~Bip() override
{
}
signals:
void sendOutputImageToViewModel(QVariant outputImage);
//uncrustify off
public slots:
//uncrustify on
void newOuput(const UsPacket& evocData, const BipImage_t& outputImage);
void requestDataFromDatabase(EDatabaseRequest::eDatabaseRequest request,
const QList<QVariant> args);
};
#endif //BIP_H

52
include/model/backendImageProcessor/core/BaseStrategy.h

@ -0,0 +1,52 @@
#ifndef BASESTRATEGY_H
#define BASESTRATEGY_H
#include <QObject>
#include "model/backendImageProcessor/utils/OpenClHelper.h"
#include "model/ultrasoundModule/metadata/UsMetadataBag.h"
#include "model/backendImageProcessor/dtoInternal/KernelInput.h"
class BaseStrategy : public QObject
{
Q_OBJECT
private:
void saveOuput(cl::Image* inputFrame, UsMetadataBag& metadata);
protected:
cl::Kernel _clKernel;
cl::Context _clContext;
cl::CommandQueue _clQueue;
OpenClHelper _openClHelper;
cl::Device getDefaultDevice(const cl::Context& context);
virtual cl::Image* gpuProcess(cl::Image* inputFrame,
UsMetadataBag& metadata,
cl::Buffer* scrathPad) = 0;
virtual void finalize() = 0;
public:
BaseStrategy(const cl::Context context,
const cl::CommandQueue queue,
const QString kernelPath,
const QString kernelName);
virtual void cpuProcess(KernelInput_t parameters) = 0;
signals:
void gpuDataReady(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* scrathPad);
//uncrustify off
public slots:
//uncrustify on
void newGpuData(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* scrathPad);
void newCpuData(KernelInput_t parameters);
};
#endif //BASESTRATEGY_H

90
include/model/backendImageProcessor/core/BipCore.h

@ -0,0 +1,90 @@
#ifndef BIPCORE_H
#define BIPCORE_H
#include <QObject>
#include "model/backendImageProcessor/core/process/ProcessQueue.h"
#include "model/backendImageProcessor/core/process/ProcessQueueFactory.h"
#include "model/backendImageProcessor/type/EImageMode.h"
#include "model/backendImageProcessor/dtoInternal/BipInput.h"
#include "model/backendImageProcessor/utils/OpenClHelper.h"
#include "config/Configuration.h"
#include "model/hardware/Hardware.h"
#include "model/backendImageProcessor/dto/BipImage.h"
#include "model/ultrasoundModule/metadata/HardwareMetadata.h"
#include "model/ultrasoundModule/metadata/BMetadata.h"
//helper macros
#define REGISTER_STRATEGY(c) qRegisterMetaType<c*>(#c)
//defines
#define SCRATCH_PAD_SIZE 2000
#define KERNEL_PATH_POSTFIX "/lib/Kernels"
#define SCENARIO_PATH_POSTFIX "/config/Scenarios"
/*************************************************************************************************/
/**
* @brief Does the actual work of BIP module
* @author Hessamoddin Hediyehloo(H-4nd-H)
* @date 2020/08/22(1399/6/1)
*/
/*************************************************************************************************/
class BipCore : public QObject
{
Q_OBJECT
private:
QList<ProcessQueue*> _queues;
cl::CommandQueue _clQueue;
cl::Context _clContext;
cl::Buffer* _scratchPad;
OpenClHelper _openCLHelper;
QString _kernelsFolder;
QString _scenariosFolder;
UsPacket _dataStorage;
BipImage_t _outputImage;
QString getApplicationHomePath();
QString getStrategyPath(EImageMode::eImageMode imageMode);
void createStrategyQueues(ProcessQueueFactory* queueFactory, QString inputPath);
QStringList getQueueDestinations(QString line);
bool queueIsNull(ProcessQueue* queue);
bool shouldSendImageToOutside(QString destination);
void process(cl::Image* clFrames, const UsMetadataBag& metaData, cl::Buffer* _scratchPad);
void dispatcher(cl::Image* frame, UsMetadataBag metadata, EDataType::eDataType dataType);
void connectQueuesStrategyParam(ProcessQueue* queue);
void connectQueuesTransientData(ProcessQueue* queue);
ProcessQueue* selectQueueByName(QString name);
void connectQueueOutputToAnotherQueue(ProcessQueue* source, QString destinationName);
void connectQueueOutputToCore(ProcessQueue* source);
void registerStrategies();
public:
BipCore();
~BipCore();
void init();
void changeMode(const EImageMode::eImageMode& imageMode);
void changeStrategyParam(KernelInput_t scenarioParams);
void newData(const UsPacket& data);
signals:
void strategyParamReady(KernelInput_t parameters);
void outputReady(const UsPacket cineData, const BipImage_t outputImage);
//uncrustify off
public slots:
//uncrustify on
void newQueueTransientData(const QByteArray transienData, UsMetadataBag& metadata);
void newQueueOutputData(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* _scratchPad);
};
#endif //BIPCORE_H

50
include/model/backendImageProcessor/core/algorithm/ScanConversionAlg.h

@ -0,0 +1,50 @@
#ifndef SCANCONVERSIONALG_H
#define SCANCONVERSIONALG_H
#include "model/backendImageProcessor/dtoInternal/KernelInput.h"
#include "model/backendImageProcessor/core/algorithm/ScanConversionOutput.h"
/*************************************************************************************************/
/**
* @brief utils class for scan conversion method, as this method will be used at least in two
* places having them here is a good choice
*/
/*************************************************************************************************/
class ScanConversionAlg
{
private:
static ScanConversionOutput_t linear(BipScanConversionConfig_t params, QVector<float> pixelXPos,
QVector<float> pixelZPos);
static ScanConversionOutput_t virtualConvex(BipScanConversionConfig_t params,
QVector<float> pixelXPos,
QVector<float> pixelZPos);
static ScanConversionOutput_t convex(BipScanConversionConfig_t params, QVector<float> pixelXPos,
QVector<float> pixelZPos);
public:
static QPair<QVector<float>, QVector<float> > makeGrid(BipScanConversionConfig_t params);
static ScanConversionOutput_t scanConversion(BipScanConversionConfig_t params);
static QPair<QVector<float>, QVector<float> > virtualScanConversion(QVector<float> pixelXPos,
QVector<float> pixelZPos,
float steering,
float virtualOriginalZ,
float startDepth,
float depth,
float vcMaxTheta);
static QPair<QVector<float>, QVector<float> > convexScanConversion(
QVector<float> pixelXPos,
QVector<float> pixelZPos,
float steering,
float angle,
float fieldOfView,
float probeRadius,
float startDepth,
float depth);
};
#endif //SCANCONVERSIONALG_H

14
include/model/backendImageProcessor/core/algorithm/ScanConversionOutput.h

@ -0,0 +1,14 @@
#ifndef SCANCONVERSIONOUTPUT_H
#define SCANCONVERSIONOUTPUT_H
#include <QObject>
struct ScanConversionOutput_t
{
QVector<float> scanAzPos;
QVector<float> scanAxPos;
QVector<float> gridAzPos;
QVector<float> gridAxPos;
};
#endif //SCANCONVERSIONOUTPUT_H

36
include/model/backendImageProcessor/core/kernelHelper/B/Cri.h

@ -0,0 +1,36 @@
#ifndef CRI_H
#define CRI_H
#include <QObject>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/CriDto.h"
#define CRI_MAX_BUFFER_SIZE 11
class Cri : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE Cri(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D,
cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D,
Cri_t> _kernelFunctor;
Cri_t _kernelParameters;
QList<cl::Image*> _criBuffer;
int counter = 0;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //CRI_H

40
include/model/backendImageProcessor/core/kernelHelper/B/DynamicContrastB.h

@ -0,0 +1,40 @@
#ifndef DYNAMICCONTRASTB_H
#define DYNAMICCONTRASTB_H
#include <QObject>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/DynamicContrastKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with dynamic contrast opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/19(1399/7/28)
*/
/*************************************************************************************************/
class DynamicContrastB : public BaseStrategy
{
Q_OBJECT
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer, DynamicContrast_t> _kernelFunctor;
DynamicContrast_t _kernelParameters;
virtual cl::Image* gpuProcess(cl::Image* frames, UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
protected:
virtual void finalize() override;
public:
Q_INVOKABLE DynamicContrastB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
~DynamicContrastB();
virtual void cpuProcess(KernelInput_t parameters) override;
};
#endif //DYNAMICCONTRASTB_H

47
include/model/backendImageProcessor/core/kernelHelper/B/EnhanceB.h

@ -0,0 +1,47 @@
#ifndef ENHANCEB_H
#define ENHANCEB_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/EnhanceKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with enhance opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/21(1399/7/30)
*/
/*************************************************************************************************/
class EnhanceB : public BaseStrategy
{
Q_OBJECT
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer, Enhance_t> _kernelFunctor;
Enhance_t _kernelParameters;
bool _run;
cl::Buffer* _filter;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
protected:
virtual void finalize() override;
public:
Q_INVOKABLE EnhanceB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
~EnhanceB();
virtual void cpuProcess(KernelInput_t parameters) override;
};
#endif //ENHANCEB_H

44
include/model/backendImageProcessor/core/kernelHelper/B/FrameFilter.h

@ -0,0 +1,44 @@
#ifndef FRAMEFILTER_H
#define FRAMEFILTER_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/PersistKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with FrameFilter opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/11/11(1399/8/20)
*/
/*************************************************************************************************/
class FrameFilter : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE FrameFilter(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D,
Persist_t> _kernelFunctor;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
Persist_t _kernelParameters;
QList<cl::Image*> _sum;
QList<QList<cl::Image*> > _last;
QList<int> _counter;
int _fifoLength;
};
#endif //FRAMEFILTER_H

41
include/model/backendImageProcessor/core/kernelHelper/B/GrayMapB.h

@ -0,0 +1,41 @@
#ifndef GRAYMAPB_H
#define GRAYMAPB_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/GrayMapKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with graymap opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/26(1399/8/5)
*/
/*************************************************************************************************/
class GrayMapB : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE GrayMapB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer> _kernelFunctor;
GrayMap_t _kernelParameters;
cl::Buffer* _grayMap;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //GRAYMAPB_H

44
include/model/backendImageProcessor/core/kernelHelper/B/Persist.h

@ -0,0 +1,44 @@
#ifndef PERSIST_H
#define PERSIST_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/PersistKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with Persist opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/11/11(1399/8/20)
*/
/*************************************************************************************************/
class Persist : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE Persist(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D, cl::Image2D,
Persist_t> _kernelFunctor;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
Persist_t _kernelParameters;
cl::Image* _sum;
QList<cl::Image*> _last;
int _counter;
int _fifoLength;
};
#endif //PERSIST_H

41
include/model/backendImageProcessor/core/kernelHelper/B/RejectionB.h

@ -0,0 +1,41 @@
#ifndef REJECTIONB_H
#define REJECTIONB_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/RejectionKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with Reject opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/24(1399/8/3)
*/
/*************************************************************************************************/
class RejectionB : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE RejectionB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, Rejection_t> _kernelFunctor;
Rejection_t _kernelParameters;
float _rejectionThr;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //REJECTIONB_H

46
include/model/backendImageProcessor/core/kernelHelper/B/ScanConversionB.h

@ -0,0 +1,46 @@
#ifndef SCANCONVERSION_H
#define SCANCONVERSION_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/ScanConversionKernelDto.h"
class ScanConversionB : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE ScanConversionB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer, cl::Buffer, cl::Buffer, cl::Buffer,
ScanConversion_t> _kernelFunctor;
ScanConversion_t _kernelParameters;
void calcParams(int frameNumber);
QList<BipScanConversionConfig_t> _configs;
quint64 _width;
quint64 _height;
quint8 lastFrameCounter;
cl::Buffer* _gridX;
cl::Buffer* _gridZ;
cl::Buffer* _queryX;
cl::Buffer* _queryZ;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //SCANCONVERSION_H

41
include/model/backendImageProcessor/core/kernelHelper/B/TintMapB.h

@ -0,0 +1,41 @@
#ifndef TINTMAP_H
#define TINTMAP_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/TintMapKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with tinemap opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/26(1399/8/5)
*/
/*************************************************************************************************/
class TintMapB : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE TintMapB(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer> _kernelFunctor;
TintMap_t _kernelParameters;
cl::Buffer* _tintMap;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //TINTMAP_H

13
include/model/backendImageProcessor/core/kernelHelper/kernelDto/CriDto.h

@ -0,0 +1,13 @@
#ifndef CRIDTO_H
#define CRIDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct Cri_t
{
cl_int criFilterMode;
cl_int frameCntr;
cl_int scenarioFrameNumber;
cl_float zeroSteeringFrameWeight;
cl_float nonZeroSteeringFrameWeight;
}Cri_t;
#endif //CRIDTO_H

13
include/model/backendImageProcessor/core/kernelHelper/kernelDto/DynamicContrastKernelDto.h

@ -0,0 +1,13 @@
#ifndef DYNAMICCONTRASTKERNELDTO_H
#define DYNAMICCONTRASTKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct DynamicContrast_t
{
cl_int gain;
cl_int transformType; //0 : log, 1 : power
cl_float gamma;
}DynamicContrast_t;
#endif //DYNAMICCONTRASTKERNELDTO_H

14
include/model/backendImageProcessor/core/kernelHelper/kernelDto/EnhanceKernelDto.h

@ -0,0 +1,14 @@
#ifndef ENHANCEKERNELDTO_H
#define ENHANCEKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct Enhance_t
{
cl_int filterWidth;
cl_int filterHeight;
cl_int width;
cl_int height;
}Enhance_t;
#endif //ENHANCEKERNELDTO_H

12
include/model/backendImageProcessor/core/kernelHelper/kernelDto/GrayMapKernelDto.h

@ -0,0 +1,12 @@
#ifndef GRAYMAPKERNELDTO_H
#define GRAYMAPKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct GrayMap_t
{
}
GrayMap_t;
#endif //GRAYMAPKERNELDTO_H

12
include/model/backendImageProcessor/core/kernelHelper/kernelDto/PersistKernelDto.h

@ -0,0 +1,12 @@
#ifndef PERSISTKERNELDTO_H
#define PERSISTKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct Persist_t
{
cl_int fifoLength;
cl_int mode;
}Persist_t;
#endif //PERSISTKERNELDTO_H

11
include/model/backendImageProcessor/core/kernelHelper/kernelDto/RejectionKernelDto.h

@ -0,0 +1,11 @@
#ifndef REJECTIONKERNELDTO_H
#define REJECTIONKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct Rejection_t
{
cl_int rejectThr;
}Rejection_t;
#endif //REJECTIONKERNELDTO_H

15
include/model/backendImageProcessor/core/kernelHelper/kernelDto/ScanConversionKernelDto.h

@ -0,0 +1,15 @@
#ifndef SCANCONVERSIONKERNELDTO_H
#define SCANCONVERSIONKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct ScanConversion_t
{
cl_int width;
cl_int gridXSize;
cl_int gridZSize;
cl_float dx;
cl_float dz;
}ScanConversion_t;
#endif //SCANCONVERSIONKERNELDTO_H

16
include/model/backendImageProcessor/core/kernelHelper/kernelDto/SriKernelDto.h

@ -0,0 +1,16 @@
#ifndef SRIKERNELDTO_H
#define SRIKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct Sri_t
{
cl_int state;
cl_int windowSize;
cl_float alpha;
cl_int algorithmSelector;
cl_int width;
cl_int height;
}Sri_t;
#endif //SRIKERNELDTO_H

12
include/model/backendImageProcessor/core/kernelHelper/kernelDto/TintMapKernelDto.h

@ -0,0 +1,12 @@
#ifndef TINTMAPKERNELDTO_H
#define TINTMAPKERNELDTO_H
#include "model/backendImageProcessor/utils/OpenClHelper.h"
typedef struct TintMap_t
{
}
TintMap_t;
#endif //TINTMAPKERNELDTO_H

38
include/model/backendImageProcessor/core/kernelHelper/misc/PreProcess.h

@ -0,0 +1,38 @@
#ifndef PREPROCESS_H
#define PREPROCESS_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with PreProcess opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/11/07(1399/8/17)
*/
/*************************************************************************************************/
class PreProcess : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE PreProcess(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t parameters) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::Buffer> _kernelFunctor;
bool run;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadataBag,
cl::Buffer* scrathPad) override;
};
#endif //PREPROCESS_H

42
include/model/backendImageProcessor/core/kernelHelper/misc/Sri.h

@ -0,0 +1,42 @@
#ifndef SRI_H
#define SRI_H
#include <QObject>
#include <QMetaType>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/kernelHelper/kernelDto/SriKernelDto.h"
/*************************************************************************************************/
/**
* @brief The class is responsible interfacing with Sri opencl kernel
* @author Hessamoddin Hediyehloo(h-4nd-h)
* @date 2020/10/24(1399/8/3)
*/
/*************************************************************************************************/
class Sri : public BaseStrategy
{
Q_OBJECT
public:
Q_INVOKABLE Sri(const cl::Context& context,
const cl::CommandQueue& queue,
const QString kernelPath);
virtual void cpuProcess(KernelInput_t input) override;
virtual void finalize() override;
private:
cl::KernelFunctor<cl::Image2D, cl::Image2D, cl::LocalSpaceArg, cl::Buffer,
Sri_t> _kernelFunctor;
Sri_t _kernelParameters;
bool _run;
virtual cl::Image* gpuProcess(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* scrathPad) override;
};
#endif //SRI_H

20
include/model/backendImageProcessor/core/process/ProcessConfig.h

@ -0,0 +1,20 @@
#ifndef PROCESSCONFIG_H
#define PROCESSCONFIG_H
#include <QObject>
#include "model/backendImageProcessor/core/strategy/StrategyConfig.h"
class ProcessConfig
{
private:
QString _connection;
public:
ProcessConfig(QString connection);
bool isEmpty();
QList<StrategyConfig> getFields();
};
#endif //PROCESSCONFIG_H

62
include/model/backendImageProcessor/core/process/ProcessQueue.h

@ -0,0 +1,62 @@
#ifndef PROCESSQUEUE_H
#define PROCESSQUEUE_H
#include <QObject>
#include "model/backendImageProcessor/core/strategy/StrategyQueue.h"
#include "model/ultrasoundModule/metadata/UsMetadataBag.h"
#include "model/ultrasoundModule/metadata/UsBaseMetadata.h"
#include "model/ultrasoundModule/metadata/BipMetadata.h"
class ProcessQueue : public QObject
{
Q_OBJECT
protected:
QString _name;
StrategyQueue _queue;
cl::CommandQueue _clQueue;
public:
ProcessQueue()
{
}
virtual bool create(const QString name, const QString connection) = 0;
void init(const cl::Context& clContext,
const cl::CommandQueue& clQueue,
const QString kernelsFolder)
{
_clQueue = clQueue;
_queue.init(clContext, clQueue, kernelsFolder);
}
QString getName()
{
return _name;
}
signals:
void strategyParamReady(KernelInput_t parameters);
void transientOutputReady(QByteArray transient, UsMetadataBag& metadata);
void processedOutputReady(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* _scratchPad);
//uncrustify off
public slots:
//uncrustify on
virtual void process(cl::Image* clFrames, UsMetadataBag& metadata, cl::Buffer* _scratchPad) = 0;
virtual void newStrategyParam(KernelInput_t parameters) = 0;
virtual void newProcessedData(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* _scratchPad) = 0;
virtual void newTransientData(cl::Image* frames,
UsMetadataBag& metadata,
cl::Buffer* _scratchPad) = 0;
};
#endif //PROCESSQUEUE_H

26
include/model/backendImageProcessor/core/process/ProcessQueueFactory.h

@ -0,0 +1,26 @@
#ifndef STRATEGYQUEUEFACTORY_H
#define STRATEGYQUEUEFACTORY_H
#include <QObject>
#include "model/backendImageProcessor/core/process/ProcessQueue.h"
#include "model/backendImageProcessor/core/scenario/ScenarioConfig.h"
class ProcessQueueFactory
{
public:
ProcessQueueFactory()
{
}
virtual ~ProcessQueueFactory()
{
}
virtual ProcessQueue* createStrategyQueue(const ScenarioConfig& config,
cl::Context clContext,
cl::CommandQueue clQueue,
QString kernelsFolder) = 0;
};
#endif //STRATEGYQUEUEFACTORY_H

33
include/model/backendImageProcessor/core/process/twoD/TwoDProcessQueue.h

@ -0,0 +1,33 @@
#ifndef TWODSTRATEGYQUEUE_H
#define TWODSTRATEGYQUEUE_H
#include <QObject>
#include <QByteArray>
#include "model/backendImageProcessor/core/process/ProcessQueue.h"
class TwoDProcessQueue : public ProcessQueue
{
Q_OBJECT
private:
QByteArray readProcessedImageFromGpu(cl::Image* frame, UsMetadataBag& metadataBag);
void registerStrategies();
public:
bool create(const QString name, const QString connection) override;
void process(cl::Image* inputFrame, UsMetadataBag& metadataBag,
cl::Buffer* scratchPad) override;
//uncrustify off
public slots:
void newStrategyParam(KernelInput_t parameters) override;
void newProcessedData(cl::Image* frame, UsMetadataBag& metadataBag,
cl::Buffer* scratchPad) override;
void newTransientData(cl::Image* frame, UsMetadataBag& metadataBag,
cl::Buffer* scratchPad) override;
//uncrustify on
};
#endif //STRATEGYQUEUE_H

19
include/model/backendImageProcessor/core/process/twoD/TwoDProcessQueueFactory.h

@ -0,0 +1,19 @@
#ifndef TWODSTRATEGYQUEUEFACTORY_H
#define TWODSTRATEGYQUEUEFACTORY_H
#include "model/backendImageProcessor/core/process/ProcessQueueFactory.h"
#include "model/backendImageProcessor/core/process/twoD/TwoDProcessQueue.h"
class TwoDProcessQueueFactory : public ProcessQueueFactory
{
public:
TwoDProcessQueueFactory();
~TwoDProcessQueueFactory() override;
ProcessQueue* createStrategyQueue(const ScenarioConfig& config,
cl::Context clContext,
cl::CommandQueue clQueue,
QString kernelsFolder) override;
};
#endif //TWODSTRATEGYQUEUEFACTORY_H

18
include/model/backendImageProcessor/core/scenario/ScenarioConfig.h

@ -0,0 +1,18 @@
#ifndef SCENARIOCONFIG_H
#define SCENARIOCONFIG_H
#include <QObject>
class ScenarioConfig
{
QString _connection;
public:
ScenarioConfig(QString connection);
QString getQueueName() const;
QString getQueueFunctionality() const;
QStringList getQueueDestinations() const;
};
#endif //SCENARIOCONFIG_H

18
include/model/backendImageProcessor/core/strategy/StrategyConfig.h

@ -0,0 +1,18 @@
#ifndef STRATEGYCONFIG_H
#define STRATEGYCONFIG_H
#include <QObject>
class StrategyConfig
{
private:
QString _connection;
public:
StrategyConfig(QString connection);
QString getStrategyName() const;
bool hasTransientProbe() const;
};
#endif //STRATEGYCONFIG_H

44
include/model/backendImageProcessor/core/strategy/StrategyQueue.h

@ -0,0 +1,44 @@
#ifndef STRATEGYQUEUE_H
#define STRATEGYQUEUE_H
#include <QObject>
#include "model/backendImageProcessor/core/BaseStrategy.h"
#include "model/backendImageProcessor/core/process/ProcessConfig.h"
class ProcessQueue;
class StrategyQueue : public QObject
{
private:
QList<BaseStrategy*> _queue;
cl::Context _clContext;
cl::CommandQueue _clQueue;
QString _kernelsFolder;
bool queueHasMoreThanOneStrategy();
void connectLastStrategyToPreviousStrategy();
BaseStrategy* createStrategy(QString name);
void appendStrategy(BaseStrategy* strategy);
void connectStrategyTransientOutput(BaseStrategy* strategy, ProcessQueue* owner);
void connectLastStrategyOutput(BaseStrategy* strategy, ProcessQueue* owner);
void connectStrategyParameterPath(BaseStrategy* strategy, ProcessQueue* owner);
void disconnectSignals();
public:
StrategyQueue();
~StrategyQueue();
void init(const cl::Context& clContext,
const cl::CommandQueue& clQueue,
const QString kernelsFolder);
void create(ProcessConfig processConfig, ProcessQueue* parent);
void process(cl::Image* inputFrame, UsMetadataBag& metadataBag,
cl::Buffer* scratchPad);
};
#endif //STRATEGYQUEUE_H

19
include/model/backendImageProcessor/dto/BipImage.h

@ -0,0 +1,19 @@
#ifndef BIPIMAGE_H
#define BIPIMAGE_H
#include <QImage>
#include "model/ultrasoundModule/metadata/UsMetadataBag.h"
typedef struct BipImage_t
{
QImage bImage;
QImage mImage;
QImage cImage;
QImage cmImage;
UsMetadataBag metaData;
}BipImage_t;
Q_DECLARE_METATYPE(BipImage_t)
#endif //BIPIMAGE_H

11
include/model/backendImageProcessor/dto/BipProbeProperties.h

@ -0,0 +1,11 @@
#ifndef BIPPROBEPROPERTIES_H
#define BIPPROBEPROPERTIES_H
typedef struct BipProbeProperties_t
{
bool linear;
float radius;
float fieldOfView;
}BipProbeProperties_t;
#endif // BIPPROBEPROPERTIES_H

120
include/model/backendImageProcessor/dtoInternal/BipInput.h

@ -0,0 +1,120 @@
#ifndef BIPINPUT_H
#define BIPINPUT_H
#include <QObject>
#include "model/backendImageProcessor/dto/BipProbeProperties.h"
#include "model/backendImageProcessor/dtoInternal/BipScanConversionConfig.h"
struct BipInput_t
{
//scan conv
QList<BipScanConversionConfig_t> scanConversionConfig;
uint outputWidth;
uint outputHeight;
//reject
int rejectBThreshold;
int rejectMThreshold;
//enhance
int enhanceBSelector;
int enhanceMSelector;
//dynamic contrast
int dynamicContrastBSelector;
int dynamicContrastMSelector;
int dynamicContrastBGain;
int dynamicContrastMGain;
//sri
int sri;
//cri
int cri;
int criFilterMode;
//grayMap
QList<int> grayMapB;
QList<int> grayMapM;
//tintmap
int tintMapBSelector;
int tintMapMSelector;
//persist
int persist;
//frame filter
int frameFilterMode;
BipInput_t()
{
}
BipInput_t(ScenGenSoftwareOutput_t scenParams)
{
for(auto i = 0; i < scenParams.scanConversionProps.length(); i++)
{
scanConversionConfig.append(BipScanConversionConfig_t(scenParams.scanConversionProps[i]));
}
outputWidth = scenParams.outputWidth;
outputHeight = scenParams.outputHeight;
//reject
rejectBThreshold = scenParams.rejectB;
//sri
sri = scenParams.sri;
//enhance
enhanceBSelector = scenParams.enhanceB;
//dynamic contrast
dynamicContrastBSelector = scenParams.dynamicContrastBSelector;
dynamicContrastBGain = scenParams.gainB;
//graymap
grayMapB = scenParams.grayMapB;
grayMapM = scenParams.grayMapM;
//tintmap
tintMapBSelector = scenParams.tintMapBSelector;
tintMapMSelector = scenParams.tintMapMSelector;
cri = scenParams.cri;
criFilterMode = scenParams.criFilterMode;
persist = scenParams.persist;
frameFilterMode = scenParams.frameFilterMode;
}
void operator= (const BipInput_t& b)
{
scanConversionConfig.append(b.scanConversionConfig);
for(auto i = 0; i < b.grayMapB.length(); i++)
{
grayMapB.push_back(b.grayMapB[i]);
}
grayMapM.append(b.grayMapM);
outputWidth = b.outputWidth;
outputHeight = b.outputHeight;
rejectBThreshold = b.rejectBThreshold;
rejectMThreshold = b.rejectMThreshold;
enhanceBSelector = b.enhanceBSelector;
enhanceMSelector = b.enhanceMSelector;
dynamicContrastBSelector = b.dynamicContrastBSelector;
dynamicContrastMSelector = b.dynamicContrastMSelector;
dynamicContrastBGain = b.dynamicContrastBGain;
dynamicContrastMGain = b.dynamicContrastMGain;
sri = b.sri;
cri = b.cri;
criFilterMode = b.criFilterMode;
tintMapBSelector = b.tintMapBSelector;
tintMapMSelector = b.tintMapMSelector;
persist = b.persist;
frameFilterMode = b.frameFilterMode;
}
};
#endif //BIPINPUT_H

79
include/model/backendImageProcessor/dtoInternal/BipScanConversionConfig.h

@ -0,0 +1,79 @@
#ifndef BIPSCANCONVERSIONCONFIG_H
#define BIPSCANCONVERSIONCONFIG_H
#include "model/scenarioGenerator/dto/software/SoftwareOutput.h"
struct BipScanConversionConfig_t {
bool linear;
float probeRadius;
float fieldOfView;
float probeFieldOfView;
float virtualOriginalZ;
float bMinScanAx;
float bMinScanAz;
float bMaxScanAx;
float bMaxScanAz;
float minScanAx;
float minScanAz;
float maxScanAx;
float steering;
quint32 rxLineNo;
quint32 rxFocusPointNo;
float rxLineDaz;
float rxPointDax;
bool virtualConvex;
float vcMaxTheta;
float angle;
Pixel_t pixel;
BipScanConversionConfig_t(ScenGenScanConversionConfig_t config)
{
this->linear = config.linear;
this->probeRadius = config.probeRadius;
this->fieldOfView = config.fieldOfView;
this->probeFieldOfView = config.probeFieldOfView;
this->virtualOriginalZ = config.virtualOriginalZ;
this->bMinScanAx = config.bMinScanAx;
this->bMinScanAz = config.bMinScanAz;
this->bMaxScanAx = config.bMaxScanAx;
this->bMaxScanAz = config.bMaxScanAz;
this->minScanAx = config.minScanAx;
this->minScanAz = config.minScanAz;
this->maxScanAx = config.maxScanAx;
this->steering = config.steering;
this->rxLineNo = config.rxLineNo;
this->rxFocusPointNo = config.rxFocusPointNo;
this->rxLineDaz = config.rxLineDaz;
this->rxPointDax = config.rxPointDax;
this->virtualConvex = config.virtualConvex;
this->vcMaxTheta = config.vcMaxTheta;
this->angle = config.angle;
this->pixel = config.pixel;
}
BipScanConversionConfig_t()
{
this->linear = 0;
this->probeRadius = 0;
this->fieldOfView = 0;
this->probeFieldOfView = 0;
this->virtualOriginalZ = 0;
this->bMinScanAx = 0;
this->bMinScanAz = 0;
this->bMaxScanAx = 0;
this->bMaxScanAz = 0;
this->minScanAx = 0;
this->minScanAz = 0;
this->maxScanAx = 0;
this->steering = 0;
this->rxLineNo = 0;
this->rxFocusPointNo = 0;
this->rxLineDaz = 0;
this->rxPointDax = 0;
this->virtualConvex = 0;
this->vcMaxTheta = 0;
this->angle = 0;
}
};
#endif //BIPSCANCONVERSIONCONFIG_H

55
include/model/backendImageProcessor/dtoInternal/KernelInput.h

@ -0,0 +1,55 @@
#ifndef KERNELINPUT_H
#define KERNELINPUT_H
#include <QObject>
#include "model/backendImageProcessor/dto/BipProbeProperties.h"
#include "model/backendImageProcessor/dtoInternal/BipScanConversionConfig.h"
#include "model/databaseManager/type/EAlgorithmType.h"
typedef struct KernelInput_t
{
//scan conversion
QList<BipScanConversionConfig_t> scanConvConfig;
quint64 outputWidth;
quint64 outputHeight;
//reject
int rejectBThreshold;
int rejectMThreshold;
//enhance
int enhanceBSelector;
int enhanceMSelector;
EAlgorithmType::eEnhanceAlgorithmType enhanceAlgorithm;
int enhanceLoGFilterSize;
QList<float> enhanceAlpha;
QList<float> enhanceSigma;
//dynamic contrast
int compressionType;
int dynamicContrastBGain;
int dynamicContrastMGain;
int dynamicContrastBSelector;
int dynamicContrastMSelector;
QList<float> dynamicContrastGamma;
//sri
int sriSelector;
EAlgorithmType::eSriAlgorithmType sriAlgorithm;
QList<float> sriAlpha;
QList<int> sriWindowSize;
//cri
int cri;
int criFilterMode;
QList<int> criFilterZeroSteeringWeight;
//grayMap
QList<int> grayMapMList;
QList<int> grayMapBList;
//tintmap
QList<QList<int> > tintMapMList;
QList<QList<int> > tintMapBList;
bool tintMapMEnable;
//persist
int persist;
//frame filter
int frameFilterMode;
}KernelInput_t;
#endif //KERNELINPUT_H

92
include/model/backendImageProcessor/type/EImageMode.h

@ -0,0 +1,92 @@
#ifndef EIMAGEMODE_H
#define EIMAGEMODE_H
#include <QtCore>
/*************************************************************************************************/
/**
* @brief The EImageMode enumeration class
* @author Mohsen Emami
* @date 14 Oct 2019
*/
/*************************************************************************************************/
class EImageMode : public QObject
{
Q_OBJECT
private:
//Private constructor prevent the enumeration class from being instantiated
explicit EImageMode(QObject* parent = nullptr);
public:
/*************************************************************************************************/
/**
* @brief Image Mode Enumerator
*
* Contains the reference enumerator for
* identificaiton of image modes.
*/
/*************************************************************************************************/
enum eImageMode : quint8
{
B,
BM,
BCri,
CineB,
CineBM,
CineBCri,
Test
};
Q_ENUM(eImageMode)
/*************************************************************************************************/
/**
* @brief enum to string converter
* @param qtEnum Enumerator to be converted to the relevant string
* @return String relevant to the input eImageMode enumerator
*/
/*************************************************************************************************/
static QString qtEnumToQString(const eImageMode qtEnum)
{
return QVariant::fromValue(qtEnum).toString();
}
/*************************************************************************************************/
/**
* @brief string to enum converter
* @param qtEnum Enumerator to be converted to the relevant string
* @return String relevant to the input eImageMode enumerator
*/
/*************************************************************************************************/
static eImageMode qtQStringToEnum(const QString qtEnum)
{
return QVariant(qtEnum).value<eImageMode>();
}
/*************************************************************************************************/
/**
* @brief enum to <int>value converter
* @param qtEnum Enumerator to be converted to the relevant value
* @return Identification value relevant to the input eImageMode enumerator
*/
/*************************************************************************************************/
static int qtEnumToInt(const eImageMode qtEnum)
{
return QMetaEnum::fromType<eImageMode>().value(qtEnum);
}
/*************************************************************************************************/
/**
* @brief int to enaum value converter
* @param int Enumerator to be converted to the relevant value
* @return int value relevant to the input eImageMode enumerator
*/
/*************************************************************************************************/
static eImageMode intToEnum(const quint8 intEnum)
{
return static_cast<eImageMode>(intEnum);
}
};
#endif //EIMAGEMODE_H

80
include/model/backendImageProcessor/utils/KernelInputFetcher.h

@ -0,0 +1,80 @@
#ifndef KERNELINPUTFETCHER_H
#define KERNELINPUTFETCHER_H
#include <QObject>
#include "model/backendImageProcessor/dtoInternal/BipInput.h"
#include "model/backendImageProcessor/dtoInternal/KernelInput.h"
#include "model/databaseManager/type/EDatabaseRequest.h"
class KernelInputFetcher : public QObject
{
Q_OBJECT
private:
KernelInput_t _kernelInput;
BipInput_t _bipInput;
bool _success;
QList<QVariant> _valueList;
void getKernelsConstantData();
void getKernelsInputRelatedData(BipInput_t input);
void updateGrayMapBParameters(BipInput_t input);
void updateGrayMapMParameters(BipInput_t input);
void updateTintMapBParameters(BipInput_t input);
bool tintMapBSelectorHasChanged(BipInput_t input);
void updateTintMapMParameters(BipInput_t input);
bool tintMapMSelectorHasChanged(BipInput_t input);
void updateDynamicContrastBParameters(BipInput_t input);
void updateDynamicContrastMParameters(BipInput_t input);
void updateEnhanceBParameters(BipInput_t input);
void updateEnhanceMParameters(BipInput_t input);
void updateRejectBParameters(BipInput_t input);
void updateRejectMParameters(BipInput_t input);
void updateSriParameters(BipInput_t input);
void updatePersistParameters(BipInput_t input);
void updateFrameFilterParameters(BipInput_t input);
void updateScanConvParameters(BipInput_t input);
void updateCriParameters(BipInput_t input);
void updateImageSizeParameters(BipInput_t input);
void getSriAlgorithmConstantData();
QList<int> getGrayMapAlgorithmData(int grayMapSelector);
QList<QList<int> > getTintMapAlgorithmData(int tintMapSelector);
void getEnhanceAlgorithmConstantData();
void getCriFilterAlgorithmConstantData();
void getDynamicContrastAlgorithmConstantData();
void getSysParamsData();
template<typename T>
T translateDatabaseData(const QList<QVariant> result);
public:
KernelInputFetcher();
void newBipInput(BipInput_t input);
KernelInput_t getKernelInput();
void init();
void setRequestResult(bool success, QList<QVariant> valueList);
signals:
void requestDataFromDatabase(EDatabaseRequest::eDatabaseRequest request,
const QList<QVariant> args);
};
#endif //KERNELINPUTFETCHER_H

654
include/model/backendImageProcessor/utils/OpenClHelper.h

@ -0,0 +1,654 @@
#ifndef OPENCLHELPER_H
#define OPENCLHELPER_H
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#define CL_HPP_TARGET_OPENCL_VERSION 120
#include <QObject>
#include <QFile>
#include "logger/Logger.h"
#include "lib/CL/cl2.hpp"
#define caseReturnString(x) case x: \
return #x
/*************************************************************************************************/
/**
* @brief The OpenCLHelper class
* @note This class can not be broken to .h and .cpp files, because of the way opencl works,
* if we include it in 2 places it complains about duplicated defenition
* @author Mohsen Emami revised by Hessamoddin Hediyehloo(H-4nd-H)
* @date 2019/8/5(1398/5/14)
*/
/*************************************************************************************************/
class OpenClHelper : public QObject
{
Q_OBJECT
private:
inline std::vector<cl::Platform> getAllAvailablePlatform();
inline std::vector<cl::Platform> getAmdAndNvidiaPlatforms();
inline std::vector<cl::Platform> filterNoneAmdAndNoneNvidiaPlatforms(
std::vector<cl::Platform> platforms);
inline void ThrowIfNoPlatformAvailable(const std::vector<cl::Platform>& platforms);
inline std::vector<cl::Device> getAllAvailableDevicesForValidPlatforms(
const std::vector<cl::Platform>& platforms);
inline std::vector<cl::Device> getAllAvailableDevicesForGivenPlatforms(
const cl::Platform& platform);
inline void ThrowIfNoDeviceAvailable(const std::vector<cl::Device>& devices);
inline QString getErrorString(int error);
inline QString getKernelFullPath(QString kernelPath, QString kernelName);
inline std::string readKernelSourceCode(QString kernelPath);
inline cl::Program createProgramFromKernelCode(const cl::Context& context,
std::string kernelSource);
inline cl::Kernel createKernelFromProgram(const cl::Program& program, QString kernelName);
public:
inline cl::Context& getContext();
inline cl::Device getFirstDeviceByContext(const cl::Context& context);
inline cl::Kernel createKernel(const cl::Context& context,
const QString kernelPath,
const QString KernelName);
inline cl::Buffer* allocateClBuffer(const cl::Context& context,
quint64 size,
bool read);
inline cl::Image* allocateClImage(const cl::Context& context,
cl::ImageFormat clFrameFormat,
QList<quint64> dimensions, bool read);
inline cl::CommandQueue createCommandQueue(const cl::Context& context,
const cl_command_queue_properties properties);
template<typename ... Ts>
inline cl::KernelFunctor<Ts...> createKernelFunctor(const cl::Kernel& kernel);
template<typename ... Ts>
inline void runKernelFunctor(cl::KernelFunctor<Ts...>& kernelFunctor,
cl::EnqueueArgs args,
Ts... ts);
};
/*************************************************************************************************/
/**
* @brief Returns the name of error
* @param error The error to get th ename of
* @return The error name
*/
/*************************************************************************************************/
QString OpenClHelper::getErrorString(int error)
{
switch(error)
{
caseReturnString(CL_SUCCESS);
caseReturnString(CL_DEVICE_NOT_FOUND);
caseReturnString(CL_DEVICE_NOT_AVAILABLE);
caseReturnString(CL_COMPILER_NOT_AVAILABLE);
caseReturnString(CL_MEM_OBJECT_ALLOCATION_FAILURE);
caseReturnString(CL_OUT_OF_RESOURCES);
caseReturnString(CL_OUT_OF_HOST_MEMORY);
caseReturnString(CL_PROFILING_INFO_NOT_AVAILABLE);
caseReturnString(CL_MEM_COPY_OVERLAP);
caseReturnString(CL_IMAGE_FORMAT_MISMATCH);
caseReturnString(CL_IMAGE_FORMAT_NOT_SUPPORTED);
caseReturnString(CL_BUILD_PROGRAM_FAILURE);
caseReturnString(CL_MAP_FAILURE);
caseReturnString(CL_MISALIGNED_SUB_BUFFER_OFFSET);
caseReturnString(CL_COMPILE_PROGRAM_FAILURE);
caseReturnString(CL_LINKER_NOT_AVAILABLE);
caseReturnString(CL_LINK_PROGRAM_FAILURE);
caseReturnString(CL_DEVICE_PARTITION_FAILED);
caseReturnString(CL_KERNEL_ARG_INFO_NOT_AVAILABLE);
caseReturnString(CL_INVALID_VALUE);
caseReturnString(CL_INVALID_DEVICE_TYPE);
caseReturnString(CL_INVALID_PLATFORM);
caseReturnString(CL_INVALID_DEVICE);
caseReturnString(CL_INVALID_CONTEXT);
caseReturnString(CL_INVALID_QUEUE_PROPERTIES);
caseReturnString(CL_INVALID_COMMAND_QUEUE);
caseReturnString(CL_INVALID_HOST_PTR);
caseReturnString(CL_INVALID_MEM_OBJECT);
caseReturnString(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
caseReturnString(CL_INVALID_IMAGE_SIZE);
caseReturnString(CL_INVALID_SAMPLER);
caseReturnString(CL_INVALID_BINARY);
caseReturnString(CL_INVALID_BUILD_OPTIONS);
caseReturnString(CL_INVALID_PROGRAM);
caseReturnString(CL_INVALID_PROGRAM_EXECUTABLE);
caseReturnString(CL_INVALID_KERNEL_NAME);
caseReturnString(CL_INVALID_KERNEL_DEFINITION);
caseReturnString(CL_INVALID_KERNEL);
caseReturnString(CL_INVALID_ARG_INDEX);
caseReturnString(CL_INVALID_ARG_VALUE);
caseReturnString(CL_INVALID_ARG_SIZE);
caseReturnString(CL_INVALID_KERNEL_ARGS);
caseReturnString(CL_INVALID_WORK_DIMENSION);
caseReturnString(CL_INVALID_WORK_GROUP_SIZE);
caseReturnString(CL_INVALID_WORK_ITEM_SIZE);
caseReturnString(CL_INVALID_GLOBAL_OFFSET);
caseReturnString(CL_INVALID_EVENT_WAIT_LIST);
caseReturnString(CL_INVALID_EVENT);
caseReturnString(CL_INVALID_OPERATION);
caseReturnString(CL_INVALID_GL_OBJECT);
caseReturnString(CL_INVALID_BUFFER_SIZE);
caseReturnString(CL_INVALID_MIP_LEVEL);
caseReturnString(CL_INVALID_GLOBAL_WORK_SIZE);
caseReturnString(CL_INVALID_PROPERTY);
caseReturnString(CL_INVALID_IMAGE_DESCRIPTOR);
caseReturnString(CL_INVALID_COMPILER_OPTIONS);
caseReturnString(CL_INVALID_LINKER_OPTIONS);
caseReturnString(CL_INVALID_DEVICE_PARTITION_COUNT);
default:
return "Unknown OpenCL error code";
}
}
/*************************************************************************************************/
/**
* @brief Return the full file path for the kernel
* @param kernelPath Directory of kernel
* @param kernelName Kernel name
* @return Full kernel path
*/
/*************************************************************************************************/
QString OpenClHelper::getKernelFullPath(QString kernelPath, QString kernelName)
{
return QDir(kernelPath).filePath(kernelName + ".cl");
}
/*************************************************************************************************/
/**
* @brief Read kernel source file from the given path
* @param kernelPath Kernel file path
* @return Kernel source code
*/
/*************************************************************************************************/
std::string OpenClHelper::readKernelSourceCode(QString kernelPath)
{
QFile kernelFile(kernelPath);
if(!kernelFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLKernelError,
"Can not open kernel file @ " + kernelPath,
this->metaObject()->className());
}
auto kernelSource = kernelFile.readAll().toStdString();
kernelFile.close();
return kernelSource;
}
/*************************************************************************************************/
/**
* @brief Compile the rkernel code and create a ne wprogram object
* @param context OpenCL object
* @param kernelSource Kernel source code
* @return Created program object
*/
/*************************************************************************************************/
cl::Program OpenClHelper::createProgramFromKernelCode(const cl::Context& context,
std::string kernelSource)
{
cl_int err = 0;
cl::Program program(context, kernelSource, true, &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLKernelError,
getErrorString(err),
this->metaObject()->className());
}
return program;
}
/*************************************************************************************************/
/**
* @brief Create kernel object from openCl program object
* @param program OpenCL program object
* @param kernelName Name of the kernel
* @return OpenCl kernel
*/
/*************************************************************************************************/
cl::Kernel OpenClHelper::createKernelFromProgram(const cl::Program& program, QString kernelName)
{
cl_int err;
cl::Kernel kernel(program, kernelName.toStdString().c_str(), &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLKernelError,
getErrorString(err),
this->metaObject()->className());
}
return kernel;
}
/*************************************************************************************************/
/**
* @brief Checks to see if platform list is empty or not, throws exception if empty
* @param platforms List of platforms
*/
/*************************************************************************************************/
void OpenClHelper::ThrowIfNoPlatformAvailable(const std::vector<cl::Platform>& platforms)
{
if(platforms.size() > 0)
{
return;
}
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLPlatformError,
"No valid platform was found",
this->metaObject()->className());
}
/*************************************************************************************************/
/**
* @brief Checks to see if device list is empty or not, throws exception if empty
* @param devices List of devices
*/
/*************************************************************************************************/
void OpenClHelper::ThrowIfNoDeviceAvailable(const std::vector<cl::Device>& devices)
{
if(devices.size() > 0)
{
return;
}
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLDeviceError,
"No valid device was found",
this->metaObject()->className());
}
/*************************************************************************************************/
/**
* @brief Return all available opencl platforms
* @return Availaable opencl platforms
*/
/*************************************************************************************************/
std::vector<cl::Platform> OpenClHelper::getAllAvailablePlatform()
{
std::vector<cl::Platform> availablePlatforms;
cl_int err = cl::Platform::get(&availablePlatforms);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLPlatformError,
getErrorString(err),
this->metaObject()->className());
}
return availablePlatforms;
}
/*************************************************************************************************/
/**
* @brief Remove none amd and none nvidia paltforsm from a given list of platforms
* @param platforms List of available platforms
* @return Platform list containing only nvidia and amd
*/
/*************************************************************************************************/
std::vector<cl::Platform> OpenClHelper::filterNoneAmdAndNoneNvidiaPlatforms(
std::vector<cl::Platform> platforms)
{
std::vector<cl::Platform> AmdNvidiaPlatforms;
for(auto it = platforms.begin(); it != platforms.end(); it++)
{
cl::string currentPlatformName = it->getInfo<CL_PLATFORM_NAME>();
Logger::log(ESeverityLevel::Debug, ELogID::CLPlatformInfo,
"Platform Name: " + QString::fromStdString(currentPlatformName),
this->metaObject()->className());
if(!(it->getInfo<CL_PLATFORM_NAME>().find("NVIDIA") == cl::string::npos) ||
!(it->getInfo<CL_PLATFORM_NAME>().find("AMD") == cl::string::npos))
{
AmdNvidiaPlatforms.push_back(*it);
}
}
return AmdNvidiaPlatforms;
}
/*************************************************************************************************/
/**
* @brief gets available nvidia or amd platforms on host machine
* @return platforms The list of available nvidia nd amd platforms
*/
/*************************************************************************************************/
std::vector<cl::Platform> OpenClHelper::getAmdAndNvidiaPlatforms()
{
auto availablePlatform = getAllAvailablePlatform();
availablePlatform = filterNoneAmdAndNoneNvidiaPlatforms(availablePlatform);
ThrowIfNoPlatformAvailable(availablePlatform);
return availablePlatform;
}
/*************************************************************************************************/
/**
* @brief get the opencl devices for all provided platforms
* @param platforms The list of nvidia and amd platforms \sa getPlatforms
* @return devices List of available devices for provided platforms
*/
/*************************************************************************************************/
std::vector<cl::Device> OpenClHelper::getAllAvailableDevicesForValidPlatforms(
const std::vector<cl::Platform>& platforms)
{
std::vector<cl::Device> availableDevices;
for(auto platform = platforms.begin(); platform != platforms.end(); platform++)
{
auto temp = getAllAvailableDevicesForGivenPlatforms(*platform);
for(auto device = temp.begin(); device != temp.end(); device++)
{
availableDevices.push_back(*device);
cl::string currentDeviceName = device->getInfo<CL_DEVICE_NAME>();
Logger::log(ESeverityLevel::Debug, ELogID::CLDeviceInfo,
"Device Name: " + QString::fromStdString(currentDeviceName),
this->metaObject()->className());
}
}
return availableDevices;
}
std::vector<cl::Device> OpenClHelper::getAllAvailableDevicesForGivenPlatforms(
const cl::Platform& platform)
{
std::vector<cl::Device> availableDevices;
cl_int err = platform.getDevices(CL_DEVICE_TYPE_GPU, &availableDevices);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLDeviceError,
getErrorString(err),
this->metaObject()->className());
}
return availableDevices;
}
/*************************************************************************************************/
/**
* @brief get context of opencl
* @return context Actual opencl context
*/
/*************************************************************************************************/
cl::Context& OpenClHelper::getContext()
{
static cl::Context* internalContext = nullptr;
if(internalContext)
{
return *internalContext;
}
auto platforms = getAmdAndNvidiaPlatforms();
auto devices = getAllAvailableDevicesForValidPlatforms(platforms);
cl_int err;
internalContext = new cl::Context(devices, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLContextError,
getErrorString(err),
this->metaObject()->className());
}
return *internalContext;
}
/*************************************************************************************************/
/**
* @brief Creates and compiles the given kernel
* @param context OpenCl contex \sa getContext
* @param kernelPath The folder directory for kernel
* @param kernelName The kernel file name without .cl extension
* @return kernel The newly created kernel instance
*/
/*************************************************************************************************/
cl::Kernel OpenClHelper::createKernel(const cl::Context& context,
const QString kernelPath,
const QString kernelName)
{
auto kernelFullPath = getKernelFullPath(kernelPath, kernelName);
auto kernelSource = readKernelSourceCode(kernelFullPath);
auto program = createProgramFromKernelCode(context, kernelSource);
return createKernelFromProgram(program, kernelName);
}
/*************************************************************************************************/
/**
* @brief allocate a cl buffer
* @param context OpenCL context \sa getContext
* @param size Number of bytes to allocate
* @param read Should the buffer be allocated with read access or write access
* @return buffer The allocated buffer pointer
*/
/*************************************************************************************************/
cl::Buffer* OpenClHelper::allocateClBuffer(const cl::Context& context,
quint64 size, bool read = true)
{
cl_mem_flags clMemFlags = read ? CL_MEM_READ_ONLY : CL_MEM_WRITE_ONLY;
cl_int err;
auto buffer = new cl::Buffer(context, clMemFlags, size, Q_NULLPTR, &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLBufferError,
getErrorString(err),
this->metaObject()->className());
}
return buffer;
}
/*************************************************************************************************/
/**
* @brief Allocate proper CL image based on input
* @param context OpenCL context \sa getContext
* @param clFrameFormat Frame format for image
* @param dimensions List containing size for each image dimension, can be 1D, 2D or 3D
* @return image Actual allocated image
*/
/*************************************************************************************************/
cl::Image* OpenClHelper::allocateClImage(const cl::Context& context,
cl::ImageFormat clFrameFormat,
QList<quint64> dimensions,
bool read)
{
cl_mem_flags clMemFlags = CL_MEM_READ_WRITE;
cl::Image* image = Q_NULLPTR;
cl_int err = 0;
switch(dimensions.size())
{
case 1:
image = new cl::Image1D(context,
clMemFlags,
clFrameFormat,
dimensions[0],
&err);
break;
case 2:
image = new cl::Image2D(context,
clMemFlags,
clFrameFormat,
dimensions[0],
dimensions[1],
0,
&err);
break;
case 3:
image = new cl::Image3D(context,
clMemFlags,
clFrameFormat,
dimensions[0],
dimensions[1],
dimensions[2],
0,
0,
&err);
break;
default:
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLFrameError,
"Invalid dimension size",
this->metaObject()->className());
}
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLFrameError,
getErrorString(err),
this->metaObject()->className());
}
return image;
}
/*************************************************************************************************/
/**
* @brief Creates a functor for given kernel
* @param kernel The kernel to build functor for
* @return functor The created functor
*/
/*************************************************************************************************/
template<typename ... Ts>
cl::KernelFunctor<Ts...> OpenClHelper::createKernelFunctor(const cl::Kernel& kernel)
{
auto kernelName = QString::fromStdString(kernel.getInfo<CL_KERNEL_FUNCTION_NAME>());
cl_int err;
cl::KernelFunctor<Ts...> functor(kernel.getInfo<CL_KERNEL_PROGRAM>(), kernelName, &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLKernelFunctorError,
getErrorString(err),
this->metaObject()->className());
}
return functor;
}
/*************************************************************************************************/
/**
* @brief Create an OpenCl commandQueue
* @param context OpenCL context \sa getContext
* @param properties Properties to build queue upon them
* @return queue The newly created queue
*/
/*************************************************************************************************/
cl::CommandQueue OpenClHelper::createCommandQueue(const cl::Context& context,
const cl_command_queue_properties properties)
{
cl_int err;
cl::CommandQueue commandQueue(context, properties, &err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLCommandQueueCreationError,
getErrorString(err),
this->metaObject()->className());
}
return commandQueue;
}
/*************************************************************************************************/
/**
* @brief Returns the first device of context
* @param context OpenCl context \sa getContext
* @param device First device of context
* @return success or failure
*/
/*************************************************************************************************/
cl::Device OpenClHelper::getFirstDeviceByContext(const cl::Context& context)
{
std::vector<cl::Device> devices;
auto err = context.getInfo<std::vector<cl::Device> >(CL_CONTEXT_DEVICES, &devices);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLDeviceError,
getErrorString(err),
this->metaObject()->className());
}
return devices[0];
}
/*************************************************************************************************/
/**
* @brief Run the kernel functor \sa createKernelFunctor
* @param kernelFunctor Functor to run
* @param args Arg structure for functor
* @param ts actual arg for functor
* @return success or failure
*/
/*************************************************************************************************/
template<typename ... Ts>
void OpenClHelper::runKernelFunctor(cl::KernelFunctor<Ts...>& kernelFunctor,
cl::EnqueueArgs args,
Ts... ts)
{
cl_int err;
kernelFunctor(args, ts ..., err);
if(err != CL_SUCCESS)
{
throw LoggerException(ESeverityLevel::Alert,
ELogID::CLKernelRunError,
getErrorString(err),
this->metaObject()->className());
}
}
#endif

38
include/model/bipTester/BipTester.h

@ -0,0 +1,38 @@
#ifndef BIPTESTER_H
#define BIPTESTER_H
#include <QMutex>
#include <QObject>
#include <QMetaType>
#include "model/ultrasoundModule/UsModule.h"
#include "core/BipTesterCore.h"
class BipTester : public UsModule
{
Q_OBJECT
US_MODULE
private:
static BipTester* _instance;
static QMutex _mutex;
bool _run;
BipTesterCore* _core;
BipTester();
~BipTester() override;
public:
static BipTester* getInstance();
//uncrustify off
public slots:
//uncrustify on
void dataReady(const UsPacket& data);
void paramsReady(QVariant output);
void newSimulationState(bool run);
};
#endif //BIPTESTER_H

105
include/model/bipTester/core/BipTesterCore.h

@ -0,0 +1,105 @@
#ifndef CORE_H
#define CORE_H
#include <QObject>
#include <QFile>
#include "model/scenarioGenerator/dto/software/SoftwareOutput.h"
#include "model/ultrasoundModule/UsPacket.h"
#include "model/bipTester/core/BipTesterMetadata.h"
#include "model/hardware/service/HardwarePacketEngine.h"
#define HEX2FLT(x) *(reinterpret_cast<float*>(&x))
#define PARSE toUInt(Q_NULLPTR, 16)
#define READ_INP2(NAME) \
if(sl[0] == #NAME) \
{ \
auto temp = sl[1].PARSE; \
_output.NAME = HEX2FLT(temp); \
}
#define READ_INP(NAME) \
if(sl[0] == #NAME) \
{ \
auto temp = sl[1].PARSE; \
_output.NAME = HEX2FLT(temp); \
}
#define READ_INP_BOOL(NAME) \
if(sl[0] == #NAME) \
{ \
auto temp = sl[1].PARSE; \
_output.NAME = HEX2FLT(temp) == 1; \
}
typedef struct input_t {
QString workingDir;
}input_t;
typedef struct simState_t {
quint32 currentScenarioNumber;
bool rxTesterMode;
bool oneshot;
bool autoIncrement;
quint32 maxFileNumber;
quint32 maxCriNumber;
quint32 maxPersistNumber;
}simState_t;
class BipTesterCore : public QObject
{
Q_OBJECT
private:
input_t _input;
simState_t _simState;
ScenGenSoftwareOutput_t _output;
bool _run;
int _frameCounter;
QList<int> _cri = {1, 3, 3, 3, 3, 5, 7, 9, 11};
void loadParams();
QString makeInputFolderPath();
QString makeOutputFolderPath();
QString makeParamsFolderPath();
QString makeFileNameString();
QString makeFileNameString(int scenNum);
QString makeFileNameString(int scenNum, int persist, int cri);
HardwarePacketEngine _engine;
public:
BipTesterCore();
QList<QList<int> > grayMap;
void changeWorkingDir(QString path);
void changeMode(bool rxMode);
void changeOneshot(bool oneshot);
void changeAutoInc(bool autoInc);
void start();
void stop();
void feedData();
void flowManager();
void frameProcessed(const UsPacket& packet);
signals:
void newParams(QVariant params);
void newData(const UsPacket& packet);
void simulationChanged(bool run);
void quit();
//uncrustify off
public slots:
//uncrustify on
void newPacket(const UsPacket& packet);
};
#endif //CORE_H

21
include/model/bipTester/core/BipTesterMetadata.h

@ -0,0 +1,21 @@
#ifndef BIPTESTERMETADAYA_H
#define BIPTESTERMETADAYA_H
#include <QObject>
#include "model/ultrasoundModule/metadata/UsBaseMetadata.h"
class BipTesterMetadata : public UsBaseMetadata
{
public:
bool isLast;
int persist;
int cri;
int scenNum;
QString logPath;
BipTesterMetadata();
};
Q_DECLARE_METATYPE(BipTesterMetadata)
#endif //BIPTESTERMETADAYA_H

19
include/model/bipTester/utils/FileHelper.h

@ -0,0 +1,19 @@
#ifndef FILE_HELPER_H
#define FILE_HELPER_H
#include <QByteArray>
#include <QStringList>
class FileHelper
{
public:
FileHelper()
{
}
static bool ReadInputFile(QByteArray& arr, QString path, quint64* width, quint64* height);
static bool ReadInputFile(QByteArray& arr, QString path);
static bool WriteOutputFile(char* arr, QString path, quint64 width, quint64 height);
};
#endif //FILE_HELPER_H

44
include/model/csm/Csm.h

@ -0,0 +1,44 @@
#ifndef CSM_H
#define CSM_H
#include <QMutex>
#include <QObject>
#include <chrono>
#include <thread>
#include "model/ultrasoundModule/UsModule.h"
#include "viewModel/factory/ApplicationStarter.h"
#include "model/csm/core/ConsoleCore.h"
#include "model/scenarioGenerator/ScenarioGenerator.h"
#include "model/ultrasoundModule/UsHelper.h"
#include "model/csm/dto/TrackballConfig.h"
class Csm : public UsModule
{
Q_OBJECT
US_MODULE
private:
static Csm* _instance;
static QMutex _mutex;
ConsoleCore* _consoleCore;
TrackballCore* _trackballCore;
Csm();
~Csm() override;
int mCursorX;
int mCursorY;
public:
static Csm* getInstance();
//uncrustify off
public slots:
//uncrustify on
void recieveCommandFromCore(const CommandControl_t command);
void recieveTrackballConfigFromCore(TrackballConfig_t config);
};
#endif //CSM_H

78
include/model/csm/core/ConsoleCore.h

@ -0,0 +1,78 @@
#ifndef CSMCORE_H
#define CSMCORE_H
#include <QObject>
#include <QtXml>
#include <QMouseEvent>
#include "model/csm/utils/XmlConsoleConfigReader.h"
#include "model/csm/utils/XmlGraphStateReader.h"
#include "model/csm/core/consoleComponent/ConsoleButton.h"
//#include "model/csm/dto/CommandTuple.h"
#include "config/Configuration.h"
#include "model/csm/core/Hid.h"
/*****************************************************************************/
/**
* @brief this is the core of console management system. this class mange aonsole and trackball as
* a part of user interface.
* @author Mohammad Mohsen Talaie
* @details
* @date 12 jan 20214
*/
/*****************************************************************************/
class ConsoleCore : public QObject
{
Q_OBJECT
private:
QString _configPath;
QList<ConsoleButton*> _btnList;
QString _probType;
EConsole::eConsoleState _currentState;
XmlConsoleConfigReader* _consoleConfigReader;
XmlGraphStateReader* _graphStateReader;
Graph _consoleStateGraph;
Hid* _hidHandler;
Graph getConsoleStateGraph() const;
void readConfigFile();
void setConsoleStateGraph(const Graph& csmStateGraph);
void connectToConsoleButton(const ConsoleButton* consoleButton);
void checkMicro();
void blink();
public:
ConsoleCore();
void setCurrentConsoleState(const EConsole::eConsoleState& csmState, const QString& probType);
void init();
void newInterrupt(const EConsole::eCsmInterruptType& interrupt, const QString& value);
void setProbType(const QString& prbType);
QString getProbType() const;
EConsole::eConsoleState getCurrentState() const;
void selfTest();
signals:
void sendChangeStateToButton(const EConsole::eConsoleState& csmState, const QString& probType);
void sendCommandToCsmModule(const CommandControl_t& commands);
void sendInterruptToTrackball(const EConsole::eCsmInterruptType& interrupt,
const QString& value);
//uncrustify off
public slots:
//uncrustify on
void recieveButtonCommand(const QList<CommandControl_t>& commands,
const quint8& fCode);
void recieveButtonLongPressCommand(const QList<CommandControl_t>& commands,
const quint8& fCode);
};
#endif //CSMCORE_H

43
include/model/csm/core/EMenuTab.h

@ -0,0 +1,43 @@
#ifndef EMENUTAB_H
#define EMENUTAB_H
#include <QtCore>
#include <QMetaType>
class EMenuTab : public QObject
{
Q_OBJECT
private:
//Private constructor prevent the enumeration class from being instantiated
explicit EMenuTab(QObject* parent = nullptr);
public:
enum eMenuTab : quint8
{
EMPTY_TAB,
B_TAB,
M_TAB,
C_TAB,
PW_TAB,
PD_TAB,
CINE_TAB,
TGC_TAB
};
Q_ENUM(eMenuTab)
static int qtEnumToInt(const eMenuTab qtEnum)
{
return QMetaEnum::fromType<eMenuTab>().value(qtEnum);
}
static QString qtEnumToString(const eMenuTab qtEnum)
{
return QString(QMetaEnum::fromType<eMenuTab>().valueToKey(qtEnum));
}
};
Q_DECLARE_METATYPE(EMenuTab::eMenuTab);
#endif //EMENUTAB_H

79
include/model/csm/core/Hid.h

@ -0,0 +1,79 @@
#ifndef HID_H
#define HID_H
#include <QObject>
#include <QMutex>
#include <QMap>
#include <QMetaType>
#include "model/ultrasoundModule/UsHelper.h"
#include "model/csm/core/consoleComponent/ConsoleButton.h"
#include "model/ultrasoundModule/type/ECommandType.h"
#include "model/csm/core/TrackballCore.h"
#include "model/csm/dto/HidPacket.h"
#include "hidapi/hidapi.h"
class SglContainer : public QObject
{
Q_OBJECT
signals:
void sendHitButton(HidPacket_t);
};
class TrackballCore;
/*****************************************************************************/
/**
* @brief this is a handler for hid interface.
* @author Mohammad Mohsen Talaie
* @details
* @date 21 sep 2020
*/
/*****************************************************************************/
class Hid : public QObject
{
Q_OBJECT
SINGLETON(Hid)
private:
Hid();
QFuture<void> readThreadFuture;
QFuture<void> writeThreadFuture;
QFuture<void> processThreadFuture;
void readThread();
void writeThread();
void processThread();
QList<HidPacket_t> _readFifo;
QMutex _readFifoLocker;
QList<HidPacket_t> _writeFifo;
QMutex _writeFifoLocker;
QMutex _readHidLocker;
QMap<quint8, SglContainer*> _signalFuctionCodeTable;
bool _run = true;
hid_device* _handle;
public:
~Hid();
void start();
void initConsoleButtons(const QList<ConsoleButton*>& consoleButtons);
void initTracballButtons(const QList<quint8>& trackballButtons);
bool exist();
bool sendEcho();
bool turnOnAllLeds();
bool turnOffAllLeds();
//uncrustify off
public slots:
//uncrustify on
void recieveLedStatus(const QMap<quint8, quint8>& ledStatus);
};
#endif //HID_H

125
include/model/csm/core/TrackballCore.h

@ -0,0 +1,125 @@
#ifndef TRACKBALLCORE_H
#define TRACKBALLCORE_H
#include <QObject>
#include <QMutex>
#include <QtXml>
#include <QMouseEvent>
#include <QPoint>
#include <QCursor>
#include "model/csm/utils/XmlGraphStateReader.h"
#include "model/csm/utils/XmlTrackballConfigReader.h"
#include "model/csm/core/trackballComponent/HidButton.h"
#include "model/csm/core/trackballComponent/MiceButton.h"
#include "model/csm/core/trackballComponent/CenterBall.h"
#include "model/csm/dto/TrackballConfig.h"
#include "model/csm/type/EConsole.h"
#include "config/Configuration.h"
#include "model/csm/dto/HidPacket.h"
#include "model/ultrasoundModule/UsHelper.h"
#include "model/csm/core/Hid.h"
class Hid;
class TrackballCore : public QObject
{
Q_OBJECT
SINGLETON(TrackballCore)
private:
Hid* _hidHandler;
XmlGraphStateReader* _graphStateReader;
XmlTrackballConfigReader* _trackballConfigReader;
QString _configPath;
TrackballConfig_t _currentConfig;
//mice button
MiceButton* _middleTop;
MiceButton* _left;
MiceButton* _right;
//hid button
HidButton* _topLeft;
HidButton* _topRight;
HidButton* _bottomLeft;
HidButton* _bottomRight;
HidButton* _middleBottom;
//center ball
CenterBall* _centerBall;
QMap<quint8, HidButton*> hidFucitonMap;
//state
EConsole::eTrackballState _currentState;
//mode
EConsole::eTrackballMode _currentMode;
//Pointer temp Memory
QPoint _pointerMemory;
QPoint _currentTrackballPos;
QPoint _trackballPosTemp;
QPoint _trackballPosDifference;
Graph _trackballStateGraph;
TrackballCore();
void sendCommandForMicePushButton(MiceButton* miceButton, const QMouseEvent* mouseEvent);
void trackballModeMiceEventHandler(QEvent* ev);
void mouseModeEventHandler(QEvent* ev);
void trackballMoveEventHandler(QEvent* ev);
void miceButtonPushHandler(MiceButton* miceButton,
const QMouseEvent* mouseEvent,
const QString interruptValue);
void newInterrupt(EConsole::eCsmInterruptType interrupt, QString value);
void readConfigFile();
void changeMiceToTrackball();
void changeMiceToMouse();
QPoint getCursorPosiotion();
protected:
bool event(QEvent*) override;
public:
//virtual bool eventFilter(QObject* object, QEvent* ev) override;
void init();
TrackballConfig_t getCurrentConfig();
void loadConfig(const EConsole::eTrackballState tracballState);
void refreshAndSendConfig();
void clearConfig();
void configFiller(const EConsole::eTrackballItem item,
const QString text,
const bool enable = true,
const bool active = true);
void setTrackballState(EConsole::eTrackballState state);
void swapMode();
signals:
void sendConfigToCsmModule(TrackballConfig_t config);
void sendCommandToCsmModule(CommandControl_t command);
//uncrustify off
public slots:
//uncrustify on
void reciveEvents(QMouseEvent* ev);
void recievePush(HidPacket_t data);
void recieveChangeTrackballState(EConsole::eCsmInterruptType interruptType, QString value);
};
#endif //TRACKBALLCORE_H

63
include/model/csm/core/consoleComponent/Button.h

@ -0,0 +1,63 @@
#ifndef BUTTON_H
#define BUTTON_H
#include <QObject>
#include <QElapsedTimer>
#include <QMutex>
#include "model/csm/core/consoleComponent/ControlAbstract.h"
/*****************************************************************************/
/**
* @brief Button Class, this class is a part of console button
* @author Mohammad Mohsen Talaie
* @details
* @date 12 Jan 2021
*/
/*****************************************************************************/
class Button : public ControlAbstract
{
private:
bool _down;
QMutex _downLoker;
QElapsedTimer _timer;
QList<CommandControl_t> _currentCommandList;
QList<CommandControl_t> _longPressCommands;
QList<CommandControl_t> _commonLongPressCommands;
QMap<EConsole::eConsoleState, QList<CommandControl_t> > _longPressCommandListBasedOnState;
bool _longPressEnable;
public:
Button()
{
}
QList<CommandControl_t> getCommandList(const EConsole::eConsoleState& consoleState) override;
QList<CommandControl_t> getLongPressCommandList(const EConsole::eConsoleState& consoleState);
EConsole::eControlType getType() const override;
void loadLongPressCommands(const EConsole::eConsoleState& consoleState);
void enable() override;
void disable() override;
void appendCommonLongPressCommandList(const CommandControl_t& commandControl);
void appendLongPressCommandListBasedOnConsoleState(const QString& consoleState,
const CommandControl_t& commandControl);
//start timer
void keyDown();
//calculate timer between down and up
long keyUp();
bool isDown() const;
bool hasLongPress() const;
bool hasTimeOutExpired(const long& timeOut);
};
#endif //BUTTON_H

83
include/model/csm/core/consoleComponent/ConsoleButton.h

@ -0,0 +1,83 @@
#ifndef ConsoleButton_H
#define ConsoleButton_H
#include <QObject>
#include <QtXml>
#include <QMap>
#include <QMutex>
#include <QtConcurrent/QtConcurrent>
#include <QMetaType>
#include "model/csm/core/consoleComponent/ControlAbstract.h"
#include "model/csm/core/consoleComponent/Button.h"
#include "model/csm/core/consoleComponent/Rotary.h"
#include "model/csm/core/consoleComponent/Led.h"
#include "model/csm/dto/HidPacket.h"
#include "model/csm/utils/XmlConsoleConfigReader.h"
#define LONG_PRESS_TIME_MS 1000
/*****************************************************************************/
/**
* @brief this class is a code vision of each console's item in real
* @author Mohammad Mohsen Talaie
* @details this class modifing the leds, rotary and buttons of each item
* @date 12 jan 2021
*/
/*****************************************************************************/
class ConsoleButton : public QObject
{
Q_OBJECT
private:
QString _name;
Button _push;
Button _up;
Button _down;
Rotary _rotary;
QMutex _longPressLocker;
QList<quint8> _functionCodes; //init inside ctor
QList<Led_t> _ledList;
//this list contain fuction code and corespond commands information.
QMap<quint8, QList<CommandControl_t> > _controlCommandList;
QMap<quint8, QList<CommandControl_t> > _controlLongPressCommandList;
EConsole::eConsoleButtonType _ConsolebuttonType;
void pushDownCheck(Button* btn, const HidPacket_t& data);
void checkPushUp(Button& btn, const HidPacket_t& data);
void longPressThread(Button* btn, const HidPacket_t& data);
int updateControlsEnablity(const Led_t& led);
public:
//ctor
ConsoleButton(const QDomElement& btnElement);
EConsole::eConsoleButtonType getConsoleButtonType() const;
QList<quint8> getFunctionCodes();
QString getName() const;
void prepareControlComandList(ControlAbstract* control,
const EConsole::eConsoleState& consoleState);
signals:
void sendLedStatusToHID(const QMap<quint8, quint8>& ledStatus);
void sendControlCommandToConsoleCore(const QList<CommandControl_t>& commands,
const quint8& functionCode);
void sendControlLongPressCommandToConsoleCore(const QList<CommandControl_t>& commands,
const quint8& functionCode);
//uncrustify off
public slots:
//uncrustify on
void recievePush(const HidPacket_t& data);
void recieveConsoleState(const EConsole::eConsoleState& consoleState, const QString& probType);
};
#endif //ConsoleButton_H

129
include/model/csm/core/consoleComponent/ControlAbstract.h

@ -0,0 +1,129 @@
#ifndef ICONTROL_H
#define ICONTROL_H
#include <QObject>
#include <QMap>
#include "model/ultrasoundModule/type/ECommandType.h"
#include "model/csm/type/EConsole.h"
#include "model/csm/dto/CommandControl.h"
/*****************************************************************************/
/**
* @brief this is an abtract of controls, like buttons and rotaries
* @author Mohammad Mohsen Talaie
* @details
* @date 12 jan 2021
*/
/*****************************************************************************/
class ControlAbstract : public QObject
{
Q_OBJECT
protected:
bool _exist = false;
bool _enable;
quint8 _functionCode = 0;
quint8 _ledFunctionCode;
//This dictionary that store commands depend on csm state
QMap<EConsole::eConsoleState, QList<CommandControl_t> > _commandList;
/*****************************************************************************/
/**
* @brief Dtor
*/
/*****************************************************************************/
virtual ~ControlAbstract()
{
}
public:
/*****************************************************************************/
/**
* @brief this fuction return existance of an ControlAbstract.
* @details in detaile this fuction is use full for console button to check its chield is exist
* or not.
* @return existance of ControlAbstract
*/
/*****************************************************************************/
bool isExist() const
{
return _exist;
}
/*****************************************************************************/
/**
* @brief this fuction return enable situation of an ControlAbstract.
* @details in detaile this fuction is use full for console button to check its chield is enable
* or not.
* @return enable situation of ControlAbstract
*/
/*****************************************************************************/
bool isEnable() const
{
return _enable;
}
/*****************************************************************************/
/**
* @brief this function append command to command list of object.
*/
/*****************************************************************************/
void appendCommandList(const QString& csmState, const CommandControl_t& commandControl)
{
QList<CommandControl_t> temp;
if(!_commandList.contains(EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)))
{
temp.append(commandControl);
_commandList.insert(EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState),
temp);
}
else
{
temp = _commandList[EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)];
temp.append(commandControl);
_commandList[EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)] = temp;
}
}
/*****************************************************************************/
/**
* @brief this fuction sets the function code and led function code of Icontrol.
*/
/*****************************************************************************/
void setFunctionCodes(const quint8& functionCode, const quint8& ledFunctionCode)
{
_functionCode = functionCode;
_ledFunctionCode = ledFunctionCode;
_exist = true;
}
/*****************************************************************************/
/**
* @brief return the function code of ControlAbstract
*/
/*****************************************************************************/
quint8 getFunctionCode() const
{
return _functionCode;
}
/*****************************************************************************/
/**
* @brief return the led's function code of ControlAbstract
*/
/*****************************************************************************/
quint8 getLedFunctionCode()
{
return _ledFunctionCode;
}
virtual QList<CommandControl_t> getCommandList(const EConsole::eConsoleState& csmState) = 0;
virtual void enable() = 0;
virtual void disable() = 0;
virtual EConsole::eControlType getType() const = 0;
};
#endif //ICONTROL_H

23
include/model/csm/core/consoleComponent/Led.h

@ -0,0 +1,23 @@
#ifndef LED_H
#define LED_H
#include <QObject>
#include <QMap>
#include "model/csm/type/EConsole.h"
typedef struct LedStatus_T
{
EConsole::eConsoleState csmState;
QString probType;
quint8 value;
}LedStatus_T;
typedef struct Led_t
{
QString name;
quint8 functionCode;
QList<LedStatus_T> ledStatus;
}Led_t;
#endif //LED_H

23
include/model/csm/core/consoleComponent/Rotary.h

@ -0,0 +1,23 @@
#ifndef ROTARY_H
#define ROTARY_H
#include "model/csm/core/consoleComponent/ControlAbstract.h"
/*****************************************************************************/
/**
* @brief Rotary class
* @author Mohammad Mohsen Talaie
* @details
* @date 12 Jan 2020
*/
/*****************************************************************************/
class Rotary : public ControlAbstract
{
public:
QList<CommandControl_t> getCommandList(const EConsole::eConsoleState& consoleState) override;
EConsole::eControlType getType()const override;
void enable() override;
void disable() override;
};
#endif //ROTARY_H

29
include/model/csm/core/trackballComponent/CenterBall.h

@ -0,0 +1,29 @@
#ifndef CENTERBALL_H
#define CENTERBALL_H
#include "model/csm/core/trackballComponent/TrackballItem.h"
/*****************************************************************************/
/**
* @brief this is a code vision of center ball of trackball
* @author Mohammad Mohsen Talaie
* @details
* @date 12 jan 2021
*/
/*****************************************************************************/
class CenterBall : public TrackballItem
{
public:
/*****************************************************************************/
/**
* @brief ctor. this funciton set type of trackball item
*/
/*****************************************************************************/
inline CenterBall(const QString& name) : TrackballItem(EConsole::eTrackballItemType::centerBall,
name)
{
_type = EConsole::eTrackballItemType::centerBall;
}
};
#endif //CENTERBALL_H

42
include/model/csm/core/trackballComponent/HidButton.h

@ -0,0 +1,42 @@
#ifndef HIDBUTTON_H
#define HIDBUTTON_H
#include "model/csm/core/trackballComponent/TrackballItem.h"
/*****************************************************************************/
/**
* @brief class of trackball's hid button
* @author Mohammad Mohsen Talaie
* @details
* @date 21 sep 2021
*/
/*****************************************************************************/
class HidButton : public TrackballItem
{
private:
quint8 _functionCode;
public:
/*****************************************************************************/
/**
* @brief ctor. set type of control
*/
/*****************************************************************************/
HidButton(QString name) : TrackballItem(EConsole::eTrackballItemType::hidButton, name)
{
_type = EConsole::eTrackballItemType::hidButton;
_functionCode = 0;
}
quint8 getFucitonCode() const
{
return _functionCode;
}
void setFunctionCode(const quint8 fCode)
{
this->_functionCode = fCode;
}
};
#endif //HIDBUTTON_H

23
include/model/csm/core/trackballComponent/MiceButton.h

@ -0,0 +1,23 @@
#ifndef MICEBUTTON_H
#define MICEBUTTON_H
#include "model/csm/core/trackballComponent/TrackballItem.h"
/*****************************************************************************/
/**
* @brief class of mice button of trackball
* @author Mohammad Mohsen Talaie
* @details
* @date 12 jan 2021
*/
/*****************************************************************************/
class MiceButton : public TrackballItem
{
public:
MiceButton(QString name) : TrackballItem(EConsole::eTrackballItemType::miceButton, name)
{
_type = EConsole::eTrackballItemType::miceButton;
}
};
#endif //MICEBUTTON_H

51
include/model/csm/core/trackballComponent/TrackballItem.h

@ -0,0 +1,51 @@
#ifndef ITRACKBALLITEM_H
#define ITRACKBALLITEM_H
#include <QObject>
#include "model/csm/type/EConsole.h"
#include "model/csm/dto/ItemValue.h"
#include "model/csm/dto/CommandControl.h"
/*****************************************************************************/
/**
* @brief trackball item class. this class is the father of mice button, hid button and center ball.
* @author Mohammad Mohsen Talaie
* @details
* @date 12 jan 2021
*/
/*****************************************************************************/
class TrackballItem
{
protected:
EConsole::eTrackballItemType _type;
QMap<EConsole::eTrackballState, QList<CommandControl_t> > _commandContainer;
QMap<EConsole::eTrackballState, QList<ItemValue_t> > _configContainer;
QString _name;
public:
TrackballItem(const EConsole::eTrackballItemType& type, const QString& name);
~TrackballItem()
{
}
EConsole::eTrackballItemType getType();
void appendCommandContainer(const EConsole::eTrackballState& trackballState,
const QList<CommandControl_t>& commandList);
void appendConfigContainer(const EConsole::eTrackballState& trackballState,
const QList<ItemValue_t>& configList);
void appendConfigContainer(const EConsole::eTrackballState& trackballState,
const ItemValue_t& config);
void appendCommandContainer(const QString& trackballStateName,
const CommandControl_t& command);
QString getName()const;
QList<CommandControl_t> getCommand(const EConsole::eTrackballState& state)const;
QList<ItemValue_t> getConfig(const EConsole::eTrackballState& state)const;
};
#endif //ITRACKBALLITEM_H

24
include/model/csm/dto/CommandControl.h

@ -0,0 +1,24 @@
#ifndef COMMANDCONTROL_H
#define COMMANDCONTROL_H
#include <QObject>
#include "model/ultrasoundModule/type/ECommandType.h"
typedef struct RecieverContent_t
{
QString reciever;
QList<QVariant> content;
}RecieverContent_t;
typedef struct CommandControl_t
{
ECommandType::eCommandType commandType;
RecieverContent_t recieverInfo;
int value;
int timeTag;
}CommandControl_t;
Q_DECLARE_METATYPE(CommandControl_t)
Q_DECLARE_METATYPE(QList<CommandControl_t>)
#endif //COMMANDCONTROL_H

18
include/model/csm/dto/HidPacket.h

@ -0,0 +1,18 @@
#ifndef PACKET_H
#define PACKET_H
#include <QObject>
typedef struct HidPacket_t
{
quint8 header;
quint8 dataLength;
quint8 type;
quint8 functionCode;
quint16 data;
quint16 timeTag;
}HidPacket_t;
Q_DECLARE_METATYPE(HidPacket_t)
#endif //PACKET_H

17
include/model/csm/dto/ItemValue.h

@ -0,0 +1,17 @@
#ifndef ITEMVALUE_H
#define ITEMVALUE_H
#include <QMetaType>
#include <QtCore>
typedef struct ItemValue_t
{
QString value;
bool enable;
bool active;
}ItemValue_t;
Q_DECLARE_METATYPE(ItemValue_t)
Q_DECLARE_METATYPE(QList<ItemValue_t>)
#endif // ITEMVALUE_H

24
include/model/csm/dto/TrackballConfig.h

@ -0,0 +1,24 @@
#ifndef TRACKBALLCONFIG_H
#define TRACKBALLCONFIG_H
#include <QtCore>
#include <QMetaType>
#include "model/csm/dto/ItemValue.h"
typedef struct TrackballConfig_t
{
QList<ItemValue_t> middleTop;
QList<ItemValue_t> topLeft;
QList<ItemValue_t> topRight;
QList<ItemValue_t> left;
QList<ItemValue_t> right;
QList<ItemValue_t> bottomRight;
QList<ItemValue_t> bottomLeft;
QList<ItemValue_t> middleBottom;
QList<ItemValue_t> centerBall;
}TrackballConfig_t;
Q_DECLARE_METATYPE(TrackballConfig_t)
#endif //TRACKBALLCONFIG_H

53
include/model/csm/exception/CsmException.h

@ -0,0 +1,53 @@
#ifndef CSMEXCEPTION_H
#define CSMEXCEPTION_H
#include <exception>
#include "logger/ESeverityLevel.h"
#include "model/csm/exception/CsmExceptionDef.h"
class CsmException : public std::exception
{
private:
quint32 _errId;
QString _innerMessage;
public:
explicit CsmException(quint32 errId)
{
_errId = errId;
}
explicit CsmException(quint32 errId, QString innerMessage)
{
_errId = errId;
_innerMessage = innerMessage;
}
const char* what() const noexcept override
{
return HwErrors::getErrorMessage(_errId).toStdString().c_str();
}
ESeverityLevel::eSeverityLevel getSeverityLevel() const
{
return HwErrors::getSeverityLevel(_errId);
}
quint32 errId() const
{
return _errId;
}
QString getInnerMessage() const
{
return _innerMessage;
}
QString getMessage() const
{
return HwErrors::getErrorMessage(_errId);
}
};
#endif //CSMEXCEPTION_H

43
include/model/csm/exception/CsmExceptionDef.h

@ -0,0 +1,43 @@
#ifndef CSMEXCEPTIONDEF_H
#define CSMEXCEPTIONDEF_H
#include <QString>
#include "logger/ESeverityLevel.h"
#define ECHO_FAILED 0
#define WRITE_ERROR 1
#define HID_NOT_FOUND 2
struct HwErrors
{
static QString getErrorMessage(quint32 id)
{
switch(id)
{
case ECHO_FAILED:
return
"The panel micro did not responsed within time limit. Restart the device and contact the service if problem still persists";
case WRITE_ERROR:
return "Could not send HID data to the panel";
case HID_NOT_FOUND:
return
"HID device not found, make sure the usb cable is connected and device is powered on";
}
}
static ESeverityLevel::eSeverityLevel getSeverityLevel(quint32 id)
{
switch(id)
{
case ECHO_FAILED:
case WRITE_ERROR:
case HID_NOT_FOUND:
return ESeverityLevel::Error;
}
}
};
#endif //CSMEXCEPTIONDEF_H

133
include/model/csm/type/EConsole.h

@ -0,0 +1,133 @@
#ifndef ECONSOLE_H
#define ECONSOLE_H
#include <QtCore>
#include <QObject>
class EConsole : public QObject
{
Q_OBJECT
private:
//Private constructor prevent the enumeration class from being instantiated
explicit EConsole(QObject* parent = nullptr);
public:
enum eControlType
{
button,
rotary
};
enum eConsoleButtonType : int
{
pushButton = 1,
rotaryButton = 2,
rotaryPushButton = 3,
rotaryPushButtonUpDown = 5
};
enum eCsmInterruptType : quint8
{
push,
longPress,
tabChanged,
touchPanel,
deviceInterrupt,
mouseMove
};
Q_ENUM(eCsmInterruptType)
enum eConsoleState : quint8
{
BMode,
BMode_Freeze,
BMode_Freeze_CineTab,
BMode_Freeze_Pointer,
BMode_Pointer,
Test
};
Q_ENUM(eConsoleState)
enum eTrackballMode : quint8
{
trackball,
mouse
};
Q_ENUM(eTrackballMode)
enum eTrackballState : quint8
{
tBMode,
tBMode_Freeze,
tTest,
tCine,
tHDZoom
};
Q_ENUM(eTrackballState)
enum eTrackballItemType : quint8
{
miceButton,
hidButton,
centerBall
};
Q_ENUM(eTrackballItemType)
enum eTrackballItem : quint8
{
left,
right,
top,
bottom,
topLeft,
topRight,
bottomLeft,
bottomRight,
center
};
Q_ENUM(eTrackballItem)
template<typename EnumType>
static QString eConsoleEnumToString(const EnumType inputEnum)
{
return QString(QMetaEnum::fromType<EnumType>().valueToKey(inputEnum));
}
template<typename EnumType>
static EnumType stringToEConsoleEnum(QString name)
{
auto&& metaEnum = QMetaEnum::fromType<EnumType>();
auto data = name.toUtf8().constData();
auto ret = static_cast<EnumType>(metaEnum.keyToValue(data));
return ret;
}
template<typename EnumType>
static quint8 consoleEnumToQuint(const EnumType qtEnum)
{
return QMetaEnum::fromType<EnumType>().value(qtEnum);
}
template<typename EnumType>
static EnumType consoleQuintToEnum(const quint8 intEnum)
{
auto&& metaEnum = QMetaEnum::fromType<EnumType>();
return static_cast<EnumType>(intEnum);
}
};
template EConsole::eConsoleState EConsole::consoleQuintToEnum<EConsole::eConsoleState>(
const quint8 intEnum);
template EConsole::eTrackballState EConsole::consoleQuintToEnum<EConsole::eTrackballState>(
const quint8 intEnum);
#endif //ECONSOLE_H

77
include/model/csm/type/Graph.h

@ -0,0 +1,77 @@
#ifndef GRAPH_H
#define GRAPH_H
#include <QtCore>
#include <QtConcurrent/QtConcurrent>
#include "Node.h"
#include "EConsole.h"
class GraphException : public QException
{
private:
QString message;
public:
GraphException(QString const& text = " ") noexcept
: message(text)
{
}
GraphException(const GraphException& re)
{
this->message = re.message;
}
~GraphException() override
{
}
void raise() const override {
throw*this;
}
GraphException* clone() const override {
return new GraphException(*this);
}
const char* what() const noexcept override {
return this->message.toStdString().c_str();
}
};
/*****************************************************************************/
/**
* @brief class for processing graph
* @author Mohammad Mohsen Talaie
* @details
* @date 13 JAN 2021
*/
/*****************************************************************************/
class Graph
{
QList<Node*> _nodeList;
public:
Graph();
bool existNode(QString nodeName);
bool existNode(Node* node);
QList<Node*> getNodeChildren(QString nodeName);
Node* getNodeByName(QString name);
template<typename EnumType>
Node* getNode(EnumType state);
bool insertEdge(Node* source,
Node* destination,
EConsole::eCsmInterruptType interrupt,
QString vaule);
bool insertEdge(QString sourceName,
QString destinationName,
EConsole::eCsmInterruptType interrupt,
QString value);
};
#endif //GRAPH_H

35
include/model/csm/type/Node.h

@ -0,0 +1,35 @@
#ifndef NODE_H
#define NODE_H
#include <QObject>
#include "model/csm/type/Transition.h"
#include "model/csm/type/EConsole.h"
/*****************************************************************************/
/**
* @brief the class for node processing
* @author Mohammad Mohsen Talaie
* @details
* @date 13 JAN 2021
*/
/*****************************************************************************/
class Node
{
private:
QList<Transition_t> _transitionList;
QString _name;
quint8 _state;
QList<Node*> _childList;
public:
Node(QString name);
QString getName();
QList<Node*> getChildren();
Node* getDestination(EConsole::eCsmInterruptType interrupt, QString value);
bool hasTransiton(Transition_t inputTransition);
bool appendTransition(Node* destiantion, EConsole::eCsmInterruptType interrupt, QString value);
quint8 getState();
};
#endif //NODE_H

17
include/model/csm/type/Transition.h

@ -0,0 +1,17 @@
#ifndef TRANSITION_H
#define TRANSITION_H
#include <QtCore>
#include "model/csm/type/EConsole.h"
class Node;
typedef struct Transition_t
{
Node* source;
Node* Destination;
EConsole::eCsmInterruptType interruptType;
QString value;
}Transition_t;
#endif //TRANSITION_H

27
include/model/csm/utils/MouseEventFilter.h

@ -0,0 +1,27 @@
#ifndef MOUSEEVENTFILTER_H
#define MOUSEEVENTFILTER_H
#include <QObject>
#include <QtEvents>
#include "model/csm/core/TrackballCore.h"
class MouseEventFilter : public QObject
{
Q_OBJECT
public:
bool eventFilter(QObject* obj, QEvent* event) override;
MouseEventFilter();
};
class TrackballMouseEventFilter : public QObject
{
Q_OBJECT
public:
bool eventFilter(QObject* obj, QEvent* event) override;
TrackballMouseEventFilter();
};
#endif //MOUSEEVENTFILTER_H

43
include/model/csm/utils/XCursorSetter.h

@ -0,0 +1,43 @@
#ifndef XCURSORSETTER_H
#define XCURSORSETTER_H
#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/extensions/XInput2.h>
#include <assert.h>
using namespace std;
class XCursorSetter
{
Display* dpy;
int screen;
Window win;
int ptrid;
char *shape_name;
int shape;
int size;
char *theme;
XcursorImage *image;
Cursor cursor;
// ./xicursorset 2 right_ptr whiteglass
void hide()
{
ptrid = std::atoi("19");
shape_name = "right_ptr";
shape = XcursorLibraryShape(shape_name);
if (shape < 0)
{
fprintf(stderr, "Invalid shape name.\n");
return;
}
}
};
#endif // XCURSORSETTER_H

63
include/model/csm/utils/XmlConsoleConfigReader.h

@ -0,0 +1,63 @@
#ifndef XMLCONFIGREADER_H
#define XMLCONFIGREADER_H
#include <QObject>
#include <QtXml>
#include "model/csm/core/consoleComponent/Button.h"
#include "model/csm/core/consoleComponent/Rotary.h"
#include "model/csm/core/consoleComponent/Led.h"
#include "model/csm/dto/CommandControl.h"
#include "logger/Logger.h"
#include "model/csm/type/Node.h"
#include "model/csm/type/Graph.h"
class XmlConsoleConfigReader
{
private:
inline void handleError(ESeverityLevel::eSeverityLevel severityLevel,
ELogID::eLogID logID,
QString logText,
bool emitThrow = true) const;
QDomDocument _xmlDoc;
QString _xmlAddress;
QDomElement _root;
QDomElement _console;
QList<QDomElement> _consoleButtons;
public:
XmlConsoleConfigReader(QString address);
QDomElement getConsole();
QList<QDomElement> getConsoleButtons();
//Console Button
static QList<QDomElement> getAllControls(QDomElement consoleButton);
static QDomElement getRotary(QDomElement consoleButton);
static QList<QDomElement> getPushButton(QDomElement consoleButton);
static QList<QDomElement> getLeds(QDomElement console);
static void initControl(QDomElement controlElement, Button* btn);
static void initControl(QDomElement controlElement, Rotary* rotary);
static void initControls(QList<QDomElement> controlsElement,
Button* push,
Button* up,
Button* down,
Rotary* rotary);
static void initLeds(QList<QDomElement> ledsElements, QList<Led_t>* leds);
static QString initConsoleButton(QDomElement consoleButtonElement,
Button* push,
Button* up,
Button* down,
Rotary* rotary,
QList<Led_t>* leds);
static void getControlCommonLongPressCommands(QDomElement controlElement, Button* btn);
static void getButtonStateCommands(QDomElement controlElement, Button* btn);
static void getButtonLongPressCommandBasedOnConsoleState(QDomNode consoleState, Button* btn);
static void getButtonShortPressCommands(QDomNode consoleState, Button* btn);
};
#endif //XMLCONFIGREADER_H

49
include/model/csm/utils/XmlGraphStateReader.h

@ -0,0 +1,49 @@
#ifndef XMLGRAPHSTATEREADER_H
#define XMLGRAPHSTATEREADER_H
#include <QObject>
#include <QtXml>
#include "model/csm/dto/CommandControl.h"
#include "logger/Logger.h"
#include "model/csm/type/Node.h"
#include "model/csm/type/Graph.h"
class XmlGraphStateReader
{
private:
QDomDocument _xmlDoc;
QString _xmlAddress;
QDomElement _root;
//gragh nodes
QDomElement _state;
QList<QDomElement> _commonDestinations;
QList<QDomElement> _specificStates;
inline void handleError(ESeverityLevel::eSeverityLevel severityLevel,
ELogID::eLogID logID,
QString logText,
bool emitThrow = true) const;
public:
XmlGraphStateReader(QString address);
//Graph
QDomElement getState();
QList<QDomElement> getCommonDestinations();
QList<QDomElement> getSpeciticStates();
static QList<QDomElement> getStateDestination(QDomElement state);
static void addEdge(QDomElement state,
QList<QDomElement> commonDestinations,
Graph* stateGraph);
static void initGraph(Graph* stateGraph,
QList<QDomElement> states,
QList<QDomElement> commonDestinations);
static void addSpeciticEdge(QDomElement state, QList<QDomElement> desinations,
Graph* stateGraph);
static void addCommonEdge(QDomElement state,
QList<QDomElement> commonDestinations,
Graph* stateGraph);
};
#endif //XMLGRAPHSTATEREADER_H

49
include/model/csm/utils/XmlTrackballConfigReader.h

@ -0,0 +1,49 @@
#ifndef XMLTRACKBALLCONFIGREADER_H
#define XMLTRACKBALLCONFIGREADER_H
#include <QObject>
#include <QtXml>
#include "logger/Logger.h"
#include "model/csm/core/trackballComponent/TrackballItem.h"
/*****************************************************************************/
/**
* @brief
* @author Mohammad Mohsen Talaie
* @details
* @date 13 JAN 2021
*/
/*****************************************************************************/
class XmlTrackballConfigReader
{
private:
inline void handleError(ESeverityLevel::eSeverityLevel severityLevel,
ELogID::eLogID logID,
QString logText,
bool emitThrow = true) const;
QDomDocument _xmlDoc;
QString _xmlAddress;
QDomElement _root;
QDomElement _trackball;
QList<QDomElement> _trackballItems;
public:
XmlTrackballConfigReader(QString address);
QDomElement getTrackball();
QList<QDomElement> getTrackballItems();
static QDomElement getChildElement(const QDomElement fatherElement, const QString elementName);
static QList<QDomElement> getChildrenElemets(const QDomElement fatherElement,
const QString elementsName);
static QString getElementAttribute(const QDomElement element, const QString attributeName);
static bool getElementBooleanAttribute(QDomElement element, QString bollAttrName);
static void initTrackballItem(TrackballItem* tbItem, const QDomElement itemElement);
static void initTrackballItems(QList<TrackballItem*> trackballItems,
const QDomElement trackballElement);
static TrackballItem* findItem(const QList<TrackballItem*> trackballItems, const QString name);
};
#endif //XMLTRACKBALLCONFIGREADER_H

35
include/model/databaseManager/DatabaseManager.h

@ -0,0 +1,35 @@
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include <QtSql>
#include <QMutex>
#include "model/ultrasoundModule/UsModule.h"
#include "config/Configuration.h"
#include "model/databaseManager/core/DatabaseManagerCore.h"
/*************************************************************************************************/
/**
* @brief Is responsible for database management i.e. CRUD operations on tables
* @details This module will take commands from other classes and does the database stuff, for
* example it will read requested data or writes new ones, at the first run it also creates the DB
* scheme with provided files
* @author Mohammad Mohsen Talaie
* @date 20 sep 2020
*/
/*************************************************************************************************/
class DatabaseManager : public UsModule
{
Q_OBJECT
US_MODULE
SINGLETON(DatabaseManager)
private:
DatabaseManagerCore* _core;
public:
DatabaseManager();
~DatabaseManager() override;
};
#endif //DATABASEMANAGER_H

66
include/model/databaseManager/core/DatabaseManagerCore.h

@ -0,0 +1,66 @@
#ifndef DATABASEMANAGERCORE_H
#define DATABASEMANAGERCORE_H
#include <QObject>
#include <QtSql>
#include "model/databaseManager/utils/XmlReader.h"
#include "model/databaseManager/type/EDatabaseRequest.h"
#include "model/databaseManager/dto/ProbeProperties/DbmProbeProperties.h"
#include "model/databaseManager/dto/ProbeProperties/DbmApplicatoin.h"
#include "model/databaseManager/dto/ProbeProperties/DbmPreset.h"
#include "model/databaseManager/dto/ProbeProperties/DbmPresetValue.h"
#include "model/databaseManager/dto/ProbeProperties/DbmLastConfig.h"
#include "model/databaseManager/dto/System/DbmSysParameters.h"
#include "model/databaseManager/dto/System/DbmGrayMap.h"
#include "model/databaseManager/dto/System/DbmTgc.h"
#include "model/databaseManager/dto/System/DbmTintMap.h"
#include "model/databaseManager/dto/System/DbmSri.h"
#include "model/databaseManager/dto/System/DbmDynamicContrast.h"
#include "model/databaseManager/dto/System/DbmCriFilter.h"
#include "model/databaseManager/dto/System/DbmEnhance.h"
#include "model/databaseManager/dto/Hardware/DbmLineFilter.h"
#include "model/databaseManager/dto/Hardware/DbmLpf.h"
#include "model/databaseManager/dto/Hardware/DbmApodizationLut.h"
#include "model/databaseManager/dto/User/DbmUser.h"
#include "model/databaseManager/dto/User/DbmUserGrayMap.h"
#include "model/databaseManager/dto/User/DbmUserTgc.h"
#include "model/databaseManager/core/DatabaseManagerNames.h"
/*************************************************************************************************/
/**
* @brief Database manager core class
* @author Mohammad Mohsen Talaie
* @details
* @date 20 sep 2020
*/
/*************************************************************************************************/
class DatabaseManagerCore : public QObject
{
Q_OBJECT
private:
static QMutex _locker;
XmlReader* _xmlReader;
XmlReader* _xmlDataReader;
QSqlDatabase _databaseDriver = QSqlDatabase::addDatabase("QSQLITE");
QString getDatabaseHomeDirectory();
QString createDbName(QString dbName);
DbmDtoGrayMap appendUserGrayMapToMainGrayMapList(const QVariant& userGrayVar,
QVariant& grayVar);
DbmDtoTgc appendUserTgcToMainTgcList(const QVariant& userTgcVar, QVariant& tgcVar);
public:
DatabaseManagerCore();
~DatabaseManagerCore();
void init();
QPair<bool, QVariant> read(EDatabaseRequest::eDatabaseRequest databaseRequest,
QList<QVariant> args);
bool write(EDatabaseRequest::eDatabaseRequest databaseRequest,
QList<QVariant> args);
};
#endif //DATABASEMANAGERCORE_H

11
include/model/databaseManager/core/DatabaseManagerNames.h

@ -0,0 +1,11 @@
#ifndef DATABASEMANAGERNAMES_H
#define DATABASEMANAGERNAMES_H
#define DB_FILE_EXT ".db"
#define PROBE_DB_NAME "ProbeProperties"
#define SYSTEM_DB_NAME "System"
#define HW_DB_NAME "Hardware"
#define USER_DB_NAME "UserData"
#endif //DATABASEMANAGERNAMES_H

55
include/model/databaseManager/dto/Hardware/DbmApodizationLut.h

@ -0,0 +1,55 @@
#ifndef DBMAPODIZATIONLUT_H
#define DBMAPODIZATIONLUT_H
#include <QMetaType>
#include <QString>
#include <QObject>
#include <QtSql>
#include "model/databaseManager/utils/initializationUtils.h"
/*************************************************************************************************/
/**
* @brief Database dto structure for ApodizationLut
* @author Mohammad Mohsen Talaie
* @details
* @date 07 feb 2021
*/
/*************************************************************************************************/
typedef struct DbmDtoApodizationLut
{
QList<int> case1;
QList<int> case2;
QList<int> case3;
QList<int> case4;
bool isActive;
}DbmDtoApodizationLut;
Q_DECLARE_METATYPE(DbmDtoApodizationLut)
/*************************************************************************************************/
/**
* @brief Database class for ApodizationLut
* @author Mohammad Mohsen Talaie
* @details
* @date 2021
*/
/*************************************************************************************************/
class DbmApodizationLut
{
public:
static bool getApodizationLut(QSqlTableModel* tableModel, DbmDtoApodizationLut& apodizationLut)
{
tableModel->setTable("ApodizationLut");
tableModel->setFilter(QString("isActive = 1"));
bool ret = tableModel->select();
INIT_LIST(apodizationLut, tableModel, case1, Int, 0);
INIT_LIST(apodizationLut, tableModel, case2, Int, 0);
INIT_LIST(apodizationLut, tableModel, case3, Int, 0);
INIT_LIST(apodizationLut, tableModel, case4, Int, 0);
return ret;
}
};
#endif //DBMAPODIZATIONLUT_H

73
include/model/databaseManager/dto/Hardware/DbmLineFilter.h

@ -0,0 +1,73 @@
#ifndef DBMLINEFILTER_H
#define DBMLINEFILTER_H
#include <QMetaType>
#include <QString>
#include <QObject>
#include <QtSql>
#include <QDebug>
#include "model/databaseManager/utils/initializationUtils.h"
/*************************************************************************************************/
/**
* @brief Database dto structu for Line filter
* @author MMT
* @details
* @date 06 feb 2021
*/
/*************************************************************************************************/
typedef struct DbmDtoLineFilter
{
QList<QList<double> > lineFilterData;
bool isActive;
}DbmDtoLineFilter;
Q_DECLARE_METATYPE(DbmDtoLineFilter)
class DbmLineFilter
{
public:
static bool getLineFilter(QSqlTableModel* tableModel, DbmDtoLineFilter& lineFilter)
{
tableModel->setTable("LineFilter");
tableModel->setFilter(QString("isActive = 1"));
bool ret = tableModel->select();
if(!ret)
{
return ret;
}
auto __off =
tableModel->record(0).value("off").toString().split(',', QString::SkipEmptyParts);
auto __low =
tableModel->record(0).value("low").toString().split(',', QString::SkipEmptyParts);
auto __hi =
tableModel->record(0).value("hi").toString().split(',', QString::SkipEmptyParts);
QList<double> temp;
for(int j = 0; j < __off.length(); ++j)
{
temp.append(__off[j].toDouble());
}
lineFilter.lineFilterData.append(temp);
temp.clear();
for(int j = 0; j < __low.length(); ++j)
{
temp.append(__low[j].toDouble());
}
lineFilter.lineFilterData.append(temp);
temp.clear();
for(int j = 0; j < __hi.length(); ++j)
{
temp.append(__hi[j].toDouble());
}
lineFilter.lineFilterData.append(temp);
return ret;
}
};
#endif //DBMLINEFILTER_H

58
include/model/databaseManager/dto/Hardware/DbmLpf.h

@ -0,0 +1,58 @@
#ifndef DBMLPF_H
#define DBMLPF_H
#include <QMetaType>
#include <QString>
#include <QObject>
#include <QtSql>
#include <QDebug>
#include "model/databaseManager/utils/initializationUtils.h"
#include "model/databaseManager/type/EAlgorithmType.h"
/*************************************************************************************************/
/**
* @brief Database dto structure for LPF data
* @author Mohammad Mohsen Talaie
* @details
* @date 06 feb 2021
*/
/*************************************************************************************************/
typedef struct DbmDtoLpf
{
public:
QList<double> lpf;
QList<double> lpfCoef;
QList<double> lpfKaiser;
QList<double> lpfKaiser2;
bool isActive;
}DbmDtoLpf;
Q_DECLARE_METATYPE(DbmDtoLpf)
/*************************************************************************************************/
/**
* @brief Database class for LPF data
* @author Mohammad Mohsen Talaie
* @details
* @date 06 feb 2021
*/
/*************************************************************************************************/
class DbmLpf
{
public:
static bool getLpfParams(QSqlTableModel* tableModel, DbmDtoLpf& lpfData)
{
tableModel->setTable("LPF");
tableModel->setFilter(QString("isActive = 1"));
bool ret = tableModel->select();
INIT_LIST(lpfData, tableModel, lpf, Double, 0);
INIT_LIST(lpfData, tableModel, lpfCoef, Double, 0);
INIT_LIST(lpfData, tableModel, lpfKaiser, Double, 0);
INIT_LIST(lpfData, tableModel, lpfKaiser2, Double, 0);
return ret;
}
};
#endif //DBMLPF_H

66
include/model/databaseManager/dto/ProbeProperties/DbmApplicatoin.h

@ -0,0 +1,66 @@
#ifndef DBMAPPLICATOIN_H
#define DBMAPPLICATOIN_H
#include <QMetaType>
#include <QString>
#include <QObject>
#include <QtSql>
#include "model/databaseManager/utils/initializationUtils.h"
/*************************************************************************************************/
/**
* @brief Database dto structur for Application
* @author MMT
* @details
* @date 20 sep 2020
*/
/*************************************************************************************************/
typedef struct DbmDtoApplication
{
int ID;
int Prob_id;
int orderNum;
int Owner_id;
QString name;
QString showText;
QString image;
}DbmDtoApplication;
Q_DECLARE_METATYPE(DbmDtoApplication)
/*************************************************************************************************/
/**
* @brief Database Class for Appliction
* @author Mohammad Mohsen Talaie
* @details
* @date 20 sep 2020
*/
/*************************************************************************************************/
class DbmApplication
{
public:
static bool getApplicationsByProbeId(QString ID, QSqlTableModel* tableModel,
QList<DbmDtoApplication>& applications)
{
tableModel->setTable("Application");
tableModel->setFilter(QString("Probe_id = '%1'").arg(ID));
bool ret = tableModel->select();
DbmDtoApplication applicationIns;
for(int i = 0; i < tableModel->record().count(); ++i)
{
INIT_SINGLE(applicationIns, tableModel, ID, Int, i);
INIT_SINGLE(applicationIns, tableModel, Prob_id, Int, i);
INIT_SINGLE(applicationIns, tableModel, Owner_id, Int, i);
INIT_SINGLE(applicationIns, tableModel, orderNum, Int, i);
INIT_SINGLE(applicationIns, tableModel, image, String, i);
INIT_SINGLE(applicationIns, tableModel, name, String, i);
INIT_SINGLE(applicationIns, tableModel, showText, String, i);
applications.append(applicationIns);
}
return ret;
}
};
#endif //DBMAPPLICATOIN_H

138
include/model/databaseManager/dto/ProbeProperties/DbmLastConfig.h

@ -0,0 +1,138 @@
#ifndef DBMLASTCONFIG_H
#define DBMLASTCONFIG_H
#include <QMetaType>
#include <QString>
#include <QObject>
#include <QtSql>
#include "model/databaseManager/utils/initializationUtils.h"
#define GET_MAX_ID_FILTER "ID = (SELECT max(ID) FROM LastConfig)"
/*************************************************************************************************/
/**
* @brief Database dto structur for LastConfig
* @author MMT
* @details
* @date 08 mar 2021
*/
/*************************************************************************************************/
typedef struct DbmDtoLastConfig
{
int ID;
int Probe_id;
int Application_id;
int Preset_id;
int ProbePortIndex;
int Owner_id;
}DbmDtoLastConfig;
Q_DECLARE_METATYPE(DbmDtoLastConfig)
/*************************************************************************************************/
/**
* @brief Database class for LastConfig
* @author Mohammad Mohsen Talaie
* @details
* @date 08 mar 2021
*/
/*************************************************************************************************/
class DbmLastConfig
{
public:
static bool getLastConfig(QSqlTableModel* tableModel,
DbmDtoLastConfig& lastConfig)
{
auto filter = GET_MAX_ID_FILTER;
bool ret = selectFromLastConfig(tableModel, filter);
DbmDtoLastConfig lastConfigIns;
if(tableModel->rowCount() > 0)
{
INIT_SINGLE(lastConfigIns, tableModel, ID, Int, 0);
INIT_SINGLE(lastConfigIns, tableModel, Application_id, Int, 0);
INIT_SINGLE(lastConfigIns, tableModel, Probe_id, Int, 0);
INIT_SINGLE(lastConfigIns, tableModel, Owner_id, Int, 0);
INIT_SINGLE(lastConfigIns, tableModel, Preset_id, Int, 0);
INIT_SINGLE(lastConfigIns, tableModel, ProbePortIndex, Int, 0);
}
lastConfig = lastConfigIns;
return ret;
}
static bool selectFromLastConfig(QSqlTableModel* tableModel, QString filter = "")
{
tableModel->clear();
tableModel->setTable("LastConfig");
if(!filter.isEmpty())
{
tableModel->setFilter(filter);
}
bool ret = tableModel->select();
return ret;
}
static bool updateExistLastConfig(QSqlTableModel* tableModel, DbmDtoLastConfig& lastConfig)
{
tableModel->setData(tableModel->index(0, 1), lastConfig.Probe_id);
tableModel->setData(tableModel->index(0, 2), lastConfig.Application_id);
tableModel->setData(tableModel->index(0, 3), lastConfig.Preset_id);
tableModel->setData(tableModel->index(0, 4), lastConfig.ProbePortIndex);
tableModel->setData(tableModel->index(0, 5), 1);
bool ret = tableModel->submit();
return ret;
}
static bool setLastConfig(QSqlTableModel* tableModel, DbmDtoLastConfig& lastConfig)
{
auto filter = GET_MAX_ID_FILTER;
bool ret = selectFromLastConfig(tableModel, filter);
if(tableModel->rowCount() > 0)
{
ret = updateExistLastConfig(tableModel, lastConfig);
}
else
{
QSqlRecord newRec = createLastConfigRecord(lastConfig);
ret = tableModel->insertRecord(-1, newRec);
}
return ret;
}
static QSqlRecord createLastConfigRecord(DbmDtoLastConfig& lastConfig)
{
QSqlRecord newRec;
QSqlField probeId("Probe_id", QVariant::Int);
probeId.setValue(lastConfig.Probe_id);
QSqlField applicationId("Application_id", QVariant::Int);
applicationId.setValue(lastConfig.Application_id);
QSqlField presetId("Preset_id", QVariant::Int);
presetId.setValue(lastConfig.Preset_id);
QSqlField probePortIndex("ProbePortIndex", QVariant::Int);
probePortIndex.setValue(lastConfig.ProbePortIndex);
QSqlField ownerId("Owner_id", QVariant::Int);
ownerId.setValue(lastConfig.Owner_id);
newRec.append(probeId);
newRec.append(applicationId);
newRec.append(presetId);
newRec.append(probePortIndex);
newRec.append(ownerId);
return newRec;
}
};
#endif //DBMLASTCONFIG_H

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save