ilabs-flir 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/Flir.podspec +31 -31
  2. package/README.md +1271 -1271
  3. package/android/Flir/build.gradle.kts +85 -80
  4. package/android/Flir/src/main/AndroidManifest.xml +31 -31
  5. package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCodeException.java +14 -0
  6. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ImageBuffer.java +11 -0
  7. package/android/Flir/src/main/java/com/flir/thermalsdk/image/JavaImageBuffer.java +35 -0
  8. package/android/Flir/src/main/java/com/flir/thermalsdk/image/Palette.java +15 -0
  9. package/android/Flir/src/main/java/com/flir/thermalsdk/image/PaletteManager.java +16 -0
  10. package/android/Flir/src/main/java/com/flir/thermalsdk/image/Point.java +11 -0
  11. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalImage.java +23 -0
  12. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalValue.java +9 -0
  13. package/android/Flir/src/main/java/com/flir/thermalsdk/live/CameraType.java +8 -0
  14. package/android/Flir/src/main/java/com/flir/thermalsdk/live/CommunicationInterface.java +16 -0
  15. package/android/Flir/src/main/java/com/flir/thermalsdk/live/Identity.java +23 -0
  16. package/android/Flir/src/main/java/com/flir/thermalsdk/live/IpSettings.java +9 -0
  17. package/android/Flir/src/main/java/com/flir/thermalsdk/live/connectivity/ConnectionStatusListener.java +7 -0
  18. package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnReceived.java +5 -0
  19. package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnRemoteError.java +7 -0
  20. package/android/Flir/src/main/java/flir/android/CameraHandler.java +224 -194
  21. package/android/Flir/src/main/java/flir/android/FlirCommands.java +111 -0
  22. package/android/Flir/src/main/java/flir/android/FlirConnectionManager.java +354 -0
  23. package/android/Flir/src/main/java/flir/android/FlirController.kt +11 -11
  24. package/android/Flir/src/main/java/flir/android/FlirDiscoveryManager.java +236 -0
  25. package/android/Flir/src/main/java/flir/android/FlirDownloadManager.kt +75 -75
  26. package/android/Flir/src/main/java/flir/android/FlirDownloadPackage.kt +16 -16
  27. package/android/Flir/src/main/java/flir/android/FlirFrameCache.kt +6 -6
  28. package/android/Flir/src/main/java/flir/android/FlirManager.kt +254 -248
  29. package/android/Flir/src/main/java/flir/android/FlirModule.kt +74 -74
  30. package/android/Flir/src/main/java/flir/android/FlirPackage.kt +19 -19
  31. package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +195 -195
  32. package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +890 -0
  33. package/android/Flir/src/main/java/flir/android/FlirStatus.kt +12 -12
  34. package/android/Flir/src/main/java/flir/android/FlirView.kt +48 -48
  35. package/android/Flir/src/main/java/flir/android/FlirViewManager.kt +13 -13
  36. package/android/Flir/src/main/java/flir/android/FrameDataHolder.java +14 -14
  37. package/app.plugin.js +264 -264
  38. package/expo-module.config.json +5 -5
  39. package/ios/Flir/Framework/ThermalSDK/FLIRBattery.h +76 -76
  40. package/ios/Flir/Framework/ThermalSDK/FLIRCalibration.h +108 -108
  41. package/ios/Flir/Framework/ThermalSDK/FLIRCamera.h +156 -156
  42. package/ios/Flir/Framework/ThermalSDK/FLIRCameraDeviceInfo.h +53 -53
  43. package/ios/Flir/Framework/ThermalSDK/FLIRCameraEvent.h +132 -132
  44. package/ios/Flir/Framework/ThermalSDK/FLIRCameraImport.h +204 -204
  45. package/ios/Flir/Framework/ThermalSDK/FLIRColorDistributionSettings.h +204 -204
  46. package/ios/Flir/Framework/ThermalSDK/FLIRColorizer.h +82 -82
  47. package/ios/Flir/Framework/ThermalSDK/FLIRDiscoveredCamera.h +44 -44
  48. package/ios/Flir/Framework/ThermalSDK/FLIRDiscovery.h +132 -132
  49. package/ios/Flir/Framework/ThermalSDK/FLIRDisplaySettings.h +29 -29
  50. package/ios/Flir/Framework/ThermalSDK/FLIRFocus.h +70 -70
  51. package/ios/Flir/Framework/ThermalSDK/FLIRFusion.h +192 -192
  52. package/ios/Flir/Framework/ThermalSDK/FLIRFusionController.h +136 -136
  53. package/ios/Flir/Framework/ThermalSDK/FLIRFusionTransformation.h +35 -35
  54. package/ios/Flir/Framework/ThermalSDK/FLIRIdentity.h +264 -264
  55. package/ios/Flir/Framework/ThermalSDK/FLIRImageBase.h +196 -196
  56. package/ios/Flir/Framework/ThermalSDK/FLIRImageColorizer.h +26 -26
  57. package/ios/Flir/Framework/ThermalSDK/FLIRImageStatistics.h +61 -61
  58. package/ios/Flir/Framework/ThermalSDK/FLIRIsotherms.h +208 -208
  59. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementArea.h +38 -38
  60. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementCollection.h +147 -147
  61. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDelta.h +62 -62
  62. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDimensions.h +33 -33
  63. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementEllipse.h +49 -49
  64. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementLine.h +66 -66
  65. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementMarker.h +69 -69
  66. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementParameters.h +41 -41
  67. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementRectangle.h +36 -36
  68. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementReference.h +27 -27
  69. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementShape.h +46 -46
  70. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementSpot.h +33 -33
  71. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementsController.h +160 -160
  72. package/ios/Flir/Framework/ThermalSDK/FLIRMeterLinkSensorPoll.h +247 -247
  73. package/ios/Flir/Framework/ThermalSDK/FLIROverlayController.h +27 -27
  74. package/ios/Flir/Framework/ThermalSDK/FLIRPalette.h +60 -60
  75. package/ios/Flir/Framework/ThermalSDK/FLIRPaletteController.h +36 -36
  76. package/ios/Flir/Framework/ThermalSDK/FLIRPaletteManager.h +97 -97
  77. package/ios/Flir/Framework/ThermalSDK/FLIRQuantification.h +55 -55
  78. package/ios/Flir/Framework/ThermalSDK/FLIRRemoteControl.h +393 -393
  79. package/ios/Flir/Framework/ThermalSDK/FLIRRenderer.h +35 -35
  80. package/ios/Flir/Framework/ThermalSDK/FLIRRendererImpl.h +17 -17
  81. package/ios/Flir/Framework/ThermalSDK/FLIRScale.h +99 -99
  82. package/ios/Flir/Framework/ThermalSDK/FLIRScaleController.h +44 -44
  83. package/ios/Flir/Framework/ThermalSDK/FLIRStream.h +109 -109
  84. package/ios/Flir/Framework/ThermalSDK/FLIRStreamer.h +124 -124
  85. package/ios/Flir/Framework/ThermalSDK/FLIRSystem.h +40 -40
  86. package/ios/Flir/Framework/ThermalSDK/FLIRTemperatureRange.h +43 -43
  87. package/ios/Flir/Framework/ThermalSDK/FLIRThermalDelta.h +77 -77
  88. package/ios/Flir/Framework/ThermalSDK/FLIRThermalImage.h +331 -331
  89. package/ios/Flir/Framework/ThermalSDK/FLIRThermalImageFile.h +56 -56
  90. package/ios/Flir/Framework/ThermalSDK/FLIRThermalParameters.h +31 -31
  91. package/ios/Flir/Framework/ThermalSDK/FLIRThermalValue.h +92 -92
  92. package/ios/Flir/Framework/ThermalSDK/FLIRWirelessCameraDetails.h +88 -88
  93. package/ios/Flir/Framework/ThermalSDK/ThermalSDK.h +73 -73
  94. package/ios/Flir/SDKLoader/FlirSDKLoader.m +13 -13
  95. package/ios/Flir/SDKLoader/FlirSDKLoader.swift +175 -175
  96. package/ios/Flir/src/FlirEventEmitter.h +12 -12
  97. package/ios/Flir/src/FlirEventEmitter.m +33 -33
  98. package/ios/Flir/src/FlirModule.h +10 -10
  99. package/ios/Flir/src/FlirModule.m +381 -381
  100. package/ios/Flir/src/FlirPreviewView.h +13 -13
  101. package/ios/Flir/src/FlirPreviewView.m +24 -24
  102. package/ios/Flir/src/FlirState.h +20 -20
  103. package/ios/Flir/src/FlirState.m +79 -79
  104. package/ios/Flir/src/FlirViewManager.h +9 -9
  105. package/ios/Flir/src/FlirViewManager.m +16 -16
  106. package/package.json +60 -60
  107. package/react-native.config.js +14 -14
  108. package/scripts/copy_ios_libs.sh +32 -32
  109. package/scripts/create_stubs.py +174 -174
  110. package/scripts/download-sdk.js +62 -62
  111. package/scripts/prepare-binaries.sh +171 -171
  112. package/sdk-manifest.json +30 -30
  113. package/src/FlirDownload.ts +78 -78
  114. package/src/index.d.ts +17 -17
  115. package/src/index.js +7 -7
  116. package/src/index.ts +7 -7
@@ -1,194 +1,224 @@
1
- package flir.android;
2
-
3
- import android.graphics.Bitmap;
4
- import android.util.Log;
5
-
6
- import com.flir.thermalsdk.androidsdk.image.BitmapAndroid;
7
- import com.flir.thermalsdk.image.ThermalImage;
8
- import com.flir.thermalsdk.live.Camera;
9
- import com.flir.thermalsdk.live.CommunicationInterface;
10
- import com.flir.thermalsdk.live.ConnectParameters;
11
- import com.flir.thermalsdk.live.Identity;
12
- import com.flir.thermalsdk.live.connectivity.ConnectionStatusListener;
13
- import com.flir.thermalsdk.live.discovery.DiscoveryEventListener;
14
- import com.flir.thermalsdk.live.discovery.DiscoveryFactory;
15
- import com.flir.thermalsdk.live.streaming.Stream;
16
- import com.flir.thermalsdk.live.streaming.ThermalStreamer;
17
-
18
- import java.io.IOException;
19
- import java.util.LinkedList;
20
- import java.util.Objects;
21
-
22
- public class CameraHandler {
23
-
24
- private static final String TAG = "CameraHandler";
25
-
26
- private StreamDataListener streamDataListener;
27
-
28
- public interface StreamDataListener {
29
- void images(FrameDataHolder dataHolder);
30
- void images(Bitmap msxBitmap, Bitmap dcBitmap);
31
- }
32
-
33
- LinkedList<Identity> foundCameraIdentities = new LinkedList<>();
34
-
35
- private Camera camera;
36
-
37
- private Stream connectedStream;
38
- private ThermalStreamer streamer;
39
- // Cache the latest ThermalImage delivered by the streamer
40
- private ThermalImage latestThermalImage;
41
-
42
- public CameraHandler() {
43
- Log.d(TAG, "CameraHandler constr");
44
- }
45
-
46
- public void startDiscovery(DiscoveryEventListener cameraDiscoveryListener, DiscoveryStatus discoveryStatus) {
47
- DiscoveryFactory.getInstance().scan(cameraDiscoveryListener, CommunicationInterface.EMULATOR, CommunicationInterface.USB);
48
- discoveryStatus.started();
49
- }
50
-
51
- public void stopDiscovery(DiscoveryStatus discoveryStatus) {
52
- DiscoveryFactory.getInstance().stop(CommunicationInterface.EMULATOR, CommunicationInterface.USB);
53
- discoveryStatus.stopped();
54
- }
55
-
56
- public synchronized void connect(Identity identity, ConnectionStatusListener connectionStatusListener) throws IOException {
57
- Log.d(TAG, "connect identity: " + identity);
58
- camera = new Camera();
59
- camera.connect(identity, connectionStatusListener, new ConnectParameters());
60
- }
61
-
62
- public synchronized void disconnect() {
63
- Log.d(TAG, "disconnect");
64
- if (camera == null) {
65
- return;
66
- }
67
- if (connectedStream == null) {
68
- return;
69
- }
70
-
71
- if (connectedStream.isStreaming()) {
72
- connectedStream.stop();
73
- }
74
- camera.disconnect();
75
- camera = null;
76
- }
77
-
78
- public synchronized void startStream(StreamDataListener listener) {
79
- this.streamDataListener = listener;
80
- if (camera == null || !camera.isConnected()) {
81
- Log.e(TAG, "startStream, failed, camera was null or not connected");
82
- return;
83
- }
84
- connectedStream = camera.getStreams().get(0);
85
- if (connectedStream.isThermal()) {
86
- streamer = new ThermalStreamer(connectedStream);
87
- } else {
88
- Log.e(TAG, "startStream, failed, no thermal stream available for the camera");
89
- return;
90
- }
91
- connectedStream.start(
92
- unused -> {
93
- streamer.update();
94
- final Bitmap[] dcBitmap = new Bitmap[1];
95
- streamer.withThermalImage(thermalImage -> {
96
- try {
97
- // Cache the latest ThermalImage for sampling
98
- latestThermalImage = thermalImage;
99
- if (thermalImage.getFusion() != null && thermalImage.getFusion().getPhoto() != null) {
100
- dcBitmap[0] = BitmapAndroid.createBitmap(thermalImage.getFusion().getPhoto()).getBitMap();
101
- }
102
- // The streamer.getImage() returns the ImageBuffer expected by BitmapAndroid
103
- final Bitmap thermalPixels = BitmapAndroid.createBitmap(streamer.getImage()).getBitMap();
104
- if (streamDataListener != null) streamDataListener.images(thermalPixels, dcBitmap[0]);
105
- } catch (Exception e) {
106
- Log.e(TAG, "thermal bitmap creation error", e);
107
- }
108
- });
109
- },
110
- error -> Log.e(TAG, "Streaming error: " + error));
111
- }
112
-
113
- public synchronized Double getTemperatureAt(int x, int y) {
114
- try {
115
- if (streamer == null) return null;
116
- ThermalImage img = latestThermalImage;
117
- if (img == null) return null;
118
-
119
- java.lang.reflect.Method[] methods = img.getClass().getMethods();
120
- for (java.lang.reflect.Method m : methods) {
121
- String name = m.getName().toLowerCase();
122
- Class<?>[] params = m.getParameterTypes();
123
-
124
- if ((name.contains("get") || name.contains("value") || name.contains("temperature")) && params.length == 2
125
- && (params[0] == int.class || params[0] == Integer.class || params[0] == double.class || params[0] == float.class)
126
- && (params[1] == int.class || params[1] == Integer.class || params[1] == double.class || params[1] == float.class)) {
127
- try {
128
- Object res = null;
129
- if (params[0] == int.class && params[1] == int.class) {
130
- res = m.invoke(img, x, y);
131
- } else if (params[0] == double.class && params[1] == double.class) {
132
- res = m.invoke(img, (double) x, (double) y);
133
- } else if (params[0] == float.class && params[1] == float.class) {
134
- res = m.invoke(img, (float) x, (float) y);
135
- } else {
136
- res = m.invoke(img, Integer.valueOf(x), Integer.valueOf(y));
137
- }
138
- if (res instanceof Number) {
139
- return ((Number) res).doubleValue();
140
- }
141
- } catch (Exception e) {
142
- }
143
- }
144
- }
145
- } catch (Exception e) {
146
- Log.e(TAG, "getTemperatureAt error", e);
147
- }
148
- return null;
149
- }
150
-
151
- public void add(Identity identity) {
152
- foundCameraIdentities.add(identity);
153
- }
154
-
155
- public Identity getCppEmulator() {
156
- for (Identity foundCameraIdentity : foundCameraIdentities) {
157
- if (foundCameraIdentity.deviceId.contains("C++ Emulator")) {
158
- return foundCameraIdentity;
159
- }
160
- }
161
- return null;
162
- }
163
-
164
- public Identity getFlirOneEmulator() {
165
- for (Identity foundCameraIdentity : foundCameraIdentities) {
166
- if (foundCameraIdentity.deviceId.contains("EMULATED FLIR ONE")) {
167
- return foundCameraIdentity;
168
- }
169
- }
170
- return null;
171
- }
172
-
173
- public Identity getFlirOne() {
174
- for (Identity foundCameraIdentity : foundCameraIdentities) {
175
- if (foundCameraIdentity.communicationInterface == CommunicationInterface.USB) return foundCameraIdentity;
176
- }
177
- return null;
178
- }
179
-
180
- public String getDeviceInfo() {
181
- if (camera == null) return "N/A";
182
- try {
183
- if (camera.getRemoteControl() == null) return "N/A";
184
- return camera.getRemoteControl().cameraInformation().getSync().displayName;
185
- } catch (Exception e) {
186
- return "N/A";
187
- }
188
- }
189
-
190
- public interface DiscoveryStatus {
191
- void started();
192
- void stopped();
193
- }
194
- }
1
+ package flir.android;
2
+
3
+ import android.graphics.Bitmap;
4
+ import android.util.Log;
5
+
6
+ import com.flir.thermalsdk.androidsdk.image.BitmapAndroid;
7
+ import com.flir.thermalsdk.image.ThermalImage;
8
+ import com.flir.thermalsdk.live.Camera;
9
+ import com.flir.thermalsdk.live.CommunicationInterface;
10
+ import com.flir.thermalsdk.live.ConnectParameters;
11
+ import com.flir.thermalsdk.live.Identity;
12
+ import com.flir.thermalsdk.live.connectivity.ConnectionStatusListener;
13
+ import com.flir.thermalsdk.live.discovery.DiscoveryEventListener;
14
+ import com.flir.thermalsdk.live.discovery.DiscoveryFactory;
15
+ import com.flir.thermalsdk.live.streaming.Stream;
16
+ import com.flir.thermalsdk.live.streaming.ThermalStreamer;
17
+
18
+ import java.io.IOException;
19
+ import java.util.LinkedList;
20
+ import java.util.Objects;
21
+
22
+ public class CameraHandler {
23
+
24
+ private static final String TAG = "CameraHandler";
25
+
26
+ private StreamDataListener streamDataListener;
27
+
28
+ public interface StreamDataListener {
29
+ void images(FrameDataHolder dataHolder);
30
+
31
+ void images(Bitmap msxBitmap, Bitmap dcBitmap);
32
+ }
33
+
34
+ LinkedList<Identity> foundCameraIdentities = new LinkedList<>();
35
+
36
+ private Camera camera;
37
+
38
+ private Stream connectedStream;
39
+ private ThermalStreamer streamer;
40
+ // Cache the latest ThermalImage delivered by the streamer
41
+ private ThermalImage latestThermalImage;
42
+
43
+ public CameraHandler() {
44
+ Log.d(TAG, "CameraHandler constr");
45
+ }
46
+
47
+ public void startDiscovery(DiscoveryEventListener cameraDiscoveryListener, DiscoveryStatus discoveryStatus) {
48
+ DiscoveryFactory.getInstance().scan(cameraDiscoveryListener, CommunicationInterface.EMULATOR,
49
+ CommunicationInterface.USB);
50
+ discoveryStatus.started();
51
+ }
52
+
53
+ public void stopDiscovery(DiscoveryStatus discoveryStatus) {
54
+ DiscoveryFactory.getInstance().stop(CommunicationInterface.EMULATOR, CommunicationInterface.USB);
55
+ discoveryStatus.stopped();
56
+ }
57
+
58
+ public synchronized void connect(Identity identity, ConnectionStatusListener connectionStatusListener)
59
+ throws IOException {
60
+ Log.d(TAG, "connect identity: " + identity);
61
+ camera = new Camera();
62
+ camera.connect(identity, connectionStatusListener, new ConnectParameters());
63
+ }
64
+
65
+ public synchronized void disconnect() {
66
+ Log.d(TAG, "disconnect");
67
+ if (camera == null) {
68
+ return;
69
+ }
70
+ if (connectedStream == null) {
71
+ return;
72
+ }
73
+
74
+ if (connectedStream.isStreaming()) {
75
+ connectedStream.stop();
76
+ }
77
+ camera.disconnect();
78
+ camera = null;
79
+ }
80
+
81
+ public synchronized void startStream(StreamDataListener listener) {
82
+ this.streamDataListener = listener;
83
+ if (camera == null || !camera.isConnected()) {
84
+ Log.e(TAG, "startStream, failed, camera was null or not connected");
85
+ return;
86
+ }
87
+ connectedStream = camera.getStreams().get(0);
88
+ if (connectedStream.isThermal()) {
89
+ streamer = new ThermalStreamer(connectedStream);
90
+ } else {
91
+ Log.e(TAG, "startStream, failed, no thermal stream available for the camera");
92
+ return;
93
+ }
94
+ connectedStream.start(
95
+ unused -> {
96
+ streamer.update();
97
+ final Bitmap[] dcBitmap = new Bitmap[1];
98
+ streamer.withThermalImage(thermalImage -> {
99
+ try {
100
+ // Cache the latest ThermalImage for sampling
101
+ latestThermalImage = thermalImage;
102
+ // TODO: Re-enable fusion when SDK is available at runtime
103
+ // if (thermalImage.getFusion() != null && thermalImage.getFusion().getPhoto()
104
+ // != null) {
105
+ // dcBitmap[0] = BitmapAndroid.createBitmap(thermalImage.getFusion().getPhoto())
106
+ // .getBitMap();
107
+ // }
108
+ // The streamer.getImage() returns the ImageBuffer expected by BitmapAndroid
109
+ // final Bitmap thermalPixels =
110
+ // BitmapAndroid.createBitmap(streamer.getImage()).getBitMap();
111
+ // if (streamDataListener != null) streamDataListener.images(thermalPixels,
112
+ // dcBitmap[0]);
113
+ } catch (Exception e) {
114
+ Log.e(TAG, "thermal bitmap creation error", e);
115
+ }
116
+ });
117
+ },
118
+ error -> Log.e(TAG, "Streaming error: " + error));
119
+ }
120
+
121
+ public synchronized Double getTemperatureAt(int x, int y) {
122
+ try {
123
+ if (streamer == null)
124
+ return null;
125
+ ThermalImage img = latestThermalImage;
126
+ if (img == null)
127
+ return null;
128
+
129
+ java.lang.reflect.Method[] methods = img.getClass().getMethods();
130
+ for (java.lang.reflect.Method m : methods) {
131
+ String name = m.getName().toLowerCase();
132
+ Class<?>[] params = m.getParameterTypes();
133
+
134
+ if ((name.contains("get") || name.contains("value") || name.contains("temperature"))
135
+ && params.length == 2
136
+ && (params[0] == int.class || params[0] == Integer.class || params[0] == double.class
137
+ || params[0] == float.class)
138
+ && (params[1] == int.class || params[1] == Integer.class || params[1] == double.class
139
+ || params[1] == float.class)) {
140
+ try {
141
+ Object res = null;
142
+ if (params[0] == int.class && params[1] == int.class) {
143
+ res = m.invoke(img, x, y);
144
+ } else if (params[0] == double.class && params[1] == double.class) {
145
+ res = m.invoke(img, (double) x, (double) y);
146
+ } else if (params[0] == float.class && params[1] == float.class) {
147
+ res = m.invoke(img, (float) x, (float) y);
148
+ } else {
149
+ res = m.invoke(img, Integer.valueOf(x), Integer.valueOf(y));
150
+ }
151
+ if (res instanceof Number) {
152
+ return ((Number) res).doubleValue();
153
+ }
154
+ } catch (Exception e) {
155
+ }
156
+ }
157
+ }
158
+ } catch (Exception e) {
159
+ Log.e(TAG, "getTemperatureAt error", e);
160
+ }
161
+ return null;
162
+ }
163
+
164
+ public void add(Identity identity) {
165
+ foundCameraIdentities.add(identity);
166
+ }
167
+
168
+ public Identity getCppEmulator() {
169
+ for (Identity foundCameraIdentity : foundCameraIdentities) {
170
+ if (foundCameraIdentity.deviceId.contains("C++ Emulator")) {
171
+ return foundCameraIdentity;
172
+ }
173
+ }
174
+ return null;
175
+ }
176
+
177
+ public Identity getFlirOneEmulator() {
178
+ for (Identity foundCameraIdentity : foundCameraIdentities) {
179
+ if (foundCameraIdentity.deviceId.contains("EMULATED FLIR ONE")) {
180
+ return foundCameraIdentity;
181
+ }
182
+ }
183
+ return null;
184
+ }
185
+
186
+ public Identity getFlirOne() {
187
+ for (Identity foundCameraIdentity : foundCameraIdentities) {
188
+ if (foundCameraIdentity.communicationInterface == CommunicationInterface.USB)
189
+ return foundCameraIdentity;
190
+ }
191
+ return null;
192
+ }
193
+
194
+ public String getDeviceInfo() {
195
+ if (camera == null)
196
+ return "N/A";
197
+ try {
198
+ if (camera.getRemoteControl() == null)
199
+ return "N/A";
200
+ return camera.getRemoteControl().cameraInformation().getSync().displayName;
201
+ } catch (Exception e) {
202
+ return "N/A";
203
+ }
204
+ }
205
+
206
+ public void setPalette(String name) {
207
+ if (latestThermalImage != null) {
208
+ java.util.List<com.flir.thermalsdk.image.Palette> palettes = com.flir.thermalsdk.image.PaletteManager
209
+ .getDefaultPalettes();
210
+ for (com.flir.thermalsdk.image.Palette p : palettes) {
211
+ if (p.name.equalsIgnoreCase(name)) {
212
+ latestThermalImage.setPalette(p);
213
+ break;
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ public interface DiscoveryStatus {
220
+ void started();
221
+
222
+ void stopped();
223
+ }
224
+ }
@@ -0,0 +1,111 @@
1
+ package flir.android;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.facebook.react.bridge.ReadableArray;
5
+ import com.facebook.react.bridge.WritableMap;
6
+ // import com.otaliastudios.cameraview.CameraView; // Removed dependency
7
+ // import ilabs.libs.io.data.Var; // Removed dependency
8
+
9
+ public final class FlirCommands {
10
+
11
+ private FlirCommands() {
12
+ // No instances
13
+ }
14
+
15
+ /**
16
+ * Command 59: selectFlirDevice - Select FLIR device by ID
17
+ * Args: [deviceId: string]
18
+ */
19
+ public static void handleSelectFlirDevice(Object root, WritableMap resp, @Nullable ReadableArray args) {
20
+ try {
21
+ if (args == null || args.size() < 1) {
22
+ resp.putString("status", "error");
23
+ resp.putString("message", "deviceId required");
24
+ return;
25
+ }
26
+
27
+ String deviceId = args.getString(0);
28
+ android.util.Log.i("CameraCommand", "[FLIR] Selecting device: " + deviceId);
29
+
30
+ // Get device from discovery manager
31
+ FlirDiscoveryManager discoveryMgr = FlirDiscoveryManager.getInstance();
32
+
33
+ com.flir.thermalsdk.live.Identity identity = discoveryMgr.getDeviceById(deviceId);
34
+
35
+ if (identity == null) {
36
+ resp.putString("status", "error");
37
+ resp.putString("message", "Device not found: " + deviceId);
38
+ return;
39
+ }
40
+
41
+ // Select and connect to device
42
+ FlirConnectionManager.getInstance().selectDevice(identity);
43
+
44
+ resp.putString("status", "ok");
45
+ resp.putString("message", "Device selected");
46
+ resp.putString("deviceId", deviceId);
47
+ } catch (Exception e) {
48
+ android.util.Log.w("CameraCommand", "[FLIR] Device selection failed", e);
49
+ resp.putString("status", "error");
50
+ resp.putString("message", e.getMessage());
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Command 60: setFlirEmulatorType - Set FLIR emulator type
56
+ * Args: [type: "FLIR_ONE" | "FLIR_ONE_EDGE"]
57
+ */
58
+ public static void handleSetFlirEmulatorType(Object root, WritableMap resp, @Nullable ReadableArray args) {
59
+ try {
60
+ if (args == null || args.size() < 1) {
61
+ resp.putString("status", "error");
62
+ resp.putString("message", "emulator type required");
63
+ return;
64
+ }
65
+
66
+ String type = args.getString(0);
67
+
68
+ if (!"FLIR_ONE".equals(type) && !"FLIR_ONE_EDGE".equals(type)) {
69
+ resp.putString("status", "error");
70
+ resp.putString("message", "Invalid type. Use FLIR_ONE or FLIR_ONE_EDGE");
71
+ return;
72
+ }
73
+
74
+ // Set type in discovery manager
75
+ FlirDiscoveryManager.getInstance().setEmulatorType(type);
76
+
77
+ android.util.Log.i("CameraCommand", "[FLIR] Emulator type set to: " + type);
78
+
79
+ resp.putString("status", "ok");
80
+ resp.putString("message", "Emulator type set");
81
+ resp.putString("emulatorType", type);
82
+ } catch (Exception e) {
83
+ android.util.Log.w("CameraCommand", "[FLIR] Set emulator type failed", e);
84
+ resp.putString("status", "error");
85
+ resp.putString("message", e.getMessage());
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Command 61: setFlirPalette - Set FLIR thermal palette
91
+ * Args: [acol: number] - palette index
92
+ */
93
+ public static void handleSetFlirPalette(Object root, WritableMap resp, @Nullable ReadableArray args) {
94
+ try {
95
+ int acol = args != null && args.size() > 0 ? (int) args.getDouble(0) : 1;
96
+
97
+ android.util.Log.i("CameraCommand", "[FLIR] Setting palette acol=" + acol);
98
+
99
+ // Set palette via FlirConnectionManager
100
+ FlirConnectionManager.getInstance().setPalette(acol);
101
+
102
+ resp.putString("status", "ok");
103
+ resp.putString("message", "Palette set");
104
+ resp.putInt("acol", acol);
105
+ } catch (Exception e) {
106
+ android.util.Log.w("CameraCommand", "[FLIR] Set palette failed", e);
107
+ resp.putString("status", "error");
108
+ resp.putString("message", e.getMessage());
109
+ }
110
+ }
111
+ }