ilabs-flir 2.3.7 → 2.3.10

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.
@@ -1,136 +1,136 @@
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
-
7
- public final class FlirCommands {
8
-
9
- private FlirCommands() {
10
- // No instances
11
- }
12
-
13
- /**
14
- * Command 59: selectFlirDevice - Select FLIR device by ID
15
- * Args: [deviceId: string]
16
- */
17
- public static void handleSelectFlirDevice(Object root, WritableMap resp, @Nullable ReadableArray args) {
18
- try {
19
- if (args == null || args.size() < 1) {
20
- resp.putString("status", "error");
21
- resp.putString("message", "deviceId required");
22
- return;
23
- }
24
-
25
- String deviceId = args.getString(0);
26
- android.util.Log.i("CameraCommand", "[FLIR] Selecting device: " + deviceId);
27
-
28
- // Get FlirManager instance and select device
29
- FlirManager flirManager = FlirManager.INSTANCE;
30
- if (flirManager == null) {
31
- resp.putString("status", "error");
32
- resp.putString("message", "FlirManager not initialized");
33
- return;
34
- }
35
-
36
- // Select device by ID (triggers connection)
37
- flirManager.switchToDevice(deviceId);
38
-
39
- resp.putString("status", "ok");
40
- resp.putString("message", "Device selected");
41
- resp.putString("deviceId", deviceId);
42
- } catch (Exception e) {
43
- android.util.Log.w("CameraCommand", "[FLIR] Device selection failed", e);
44
- resp.putString("status", "error");
45
- resp.putString("message", e.getMessage());
46
- }
47
- }
48
-
49
- /**
50
- * Command 60: setFlirEmulatorType - Set FLIR emulator type
51
- * Args: [type: "FLIR_ONE" | "FLIR_ONE_EDGE"]
52
- */
53
- public static void handleSetFlirEmulatorType(Object root, WritableMap resp, @Nullable ReadableArray args) {
54
- try {
55
- if (args == null || args.size() < 1) {
56
- resp.putString("status", "error");
57
- resp.putString("message", "emulator type required");
58
- return;
59
- }
60
-
61
- String type = args.getString(0);
62
-
63
- if (!"FLIR_ONE".equals(type) && !"FLIR_ONE_EDGE".equals(type)) {
64
- resp.putString("status", "error");
65
- resp.putString("message", "Invalid type. Use FLIR_ONE or FLIR_ONE_EDGE");
66
- return;
67
- }
68
-
69
- // Get FlirManager instance and set emulator type
70
- FlirManager flirManager = FlirManager.INSTANCE;
71
- if (flirManager == null) {
72
- resp.putString("status", "error");
73
- resp.putString("message", "FlirManager not initialized");
74
- return;
75
- }
76
-
77
- flirManager.setPreferredEmulatorType(type);
78
-
79
- android.util.Log.i("CameraCommand", "[FLIR] Emulator type set to: " + type);
80
-
81
- resp.putString("status", "ok");
82
- resp.putString("message", "Emulator type set");
83
- resp.putString("emulatorType", type);
84
- } catch (Exception e) {
85
- android.util.Log.w("CameraCommand", "[FLIR] Set emulator type failed", e);
86
- resp.putString("status", "error");
87
- resp.putString("message", e.getMessage());
88
- }
89
- }
90
-
91
- /**
92
- * Command 61: setFlirPalette - Set FLIR thermal palette
93
- * Args: [acol: number] - palette index
94
- */
95
- public static void handleSetFlirPalette(Object root, WritableMap resp, @Nullable ReadableArray args) {
96
- try {
97
- int acol = args != null && args.size() > 0 ? (int) args.getDouble(0) : 1;
98
-
99
- android.util.Log.i("CameraCommand", "[FLIR] Setting palette acol=" + acol);
100
-
101
- // Get FlirManager instance and set palette by index
102
- FlirManager flirManager = FlirManager.INSTANCE;
103
- if (flirManager == null) {
104
- resp.putString("status", "error");
105
- resp.putString("message", "FlirManager not initialized");
106
- return;
107
- }
108
-
109
- // Map acol index to palette name
110
- String paletteName = mapAcolToPaletteName(acol);
111
- flirManager.setPalette(paletteName);
112
-
113
- resp.putString("status", "ok");
114
- resp.putString("message", "Palette set");
115
- resp.putInt("acol", acol);
116
- } catch (Exception e) {
117
- android.util.Log.w("CameraCommand", "[FLIR] Set palette failed", e);
118
- resp.putString("status", "error");
119
- resp.putString("message", e.getMessage());
120
- }
121
- }
122
-
123
- private static String mapAcolToPaletteName(int acol) {
124
- switch (acol) {
125
- case 0: return "gray";
126
- case 1: return "iron";
127
- case 2: return "rainbow";
128
- case 3: return "lava";
129
- case 4: return "arctic";
130
- case 5: return "coldest";
131
- case 6: return "hottest";
132
- case 7: return "contrast";
133
- default: return "iron";
134
- }
135
- }
136
- }
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
+
7
+ public final class FlirCommands {
8
+
9
+ private FlirCommands() {
10
+ // No instances
11
+ }
12
+
13
+ /**
14
+ * Command 59: selectFlirDevice - Select FLIR device by ID
15
+ * Args: [deviceId: string]
16
+ */
17
+ public static void handleSelectFlirDevice(Object root, WritableMap resp, @Nullable ReadableArray args) {
18
+ try {
19
+ if (args == null || args.size() < 1) {
20
+ resp.putString("status", "error");
21
+ resp.putString("message", "deviceId required");
22
+ return;
23
+ }
24
+
25
+ String deviceId = args.getString(0);
26
+ android.util.Log.i("CameraCommand", "[FLIR] Selecting device: " + deviceId);
27
+
28
+ // Get FlirManager instance and select device
29
+ FlirManager flirManager = FlirManager.INSTANCE;
30
+ if (flirManager == null) {
31
+ resp.putString("status", "error");
32
+ resp.putString("message", "FlirManager not initialized");
33
+ return;
34
+ }
35
+
36
+ // Select device by ID (triggers connection)
37
+ flirManager.switchToDevice(deviceId);
38
+
39
+ resp.putString("status", "ok");
40
+ resp.putString("message", "Device selected");
41
+ resp.putString("deviceId", deviceId);
42
+ } catch (Exception e) {
43
+ android.util.Log.w("CameraCommand", "[FLIR] Device selection failed", e);
44
+ resp.putString("status", "error");
45
+ resp.putString("message", e.getMessage());
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Command 60: setFlirEmulatorType - Set FLIR emulator type
51
+ * Args: [type: "FLIR_ONE" | "FLIR_ONE_EDGE"]
52
+ */
53
+ public static void handleSetFlirEmulatorType(Object root, WritableMap resp, @Nullable ReadableArray args) {
54
+ try {
55
+ if (args == null || args.size() < 1) {
56
+ resp.putString("status", "error");
57
+ resp.putString("message", "emulator type required");
58
+ return;
59
+ }
60
+
61
+ String type = args.getString(0);
62
+
63
+ if (!"FLIR_ONE".equals(type) && !"FLIR_ONE_EDGE".equals(type)) {
64
+ resp.putString("status", "error");
65
+ resp.putString("message", "Invalid type. Use FLIR_ONE or FLIR_ONE_EDGE");
66
+ return;
67
+ }
68
+
69
+ // Get FlirManager instance and set emulator type
70
+ FlirManager flirManager = FlirManager.INSTANCE;
71
+ if (flirManager == null) {
72
+ resp.putString("status", "error");
73
+ resp.putString("message", "FlirManager not initialized");
74
+ return;
75
+ }
76
+
77
+ flirManager.setPreferredEmulatorType(type);
78
+
79
+ android.util.Log.i("CameraCommand", "[FLIR] Emulator type set to: " + type);
80
+
81
+ resp.putString("status", "ok");
82
+ resp.putString("message", "Emulator type set");
83
+ resp.putString("emulatorType", type);
84
+ } catch (Exception e) {
85
+ android.util.Log.w("CameraCommand", "[FLIR] Set emulator type failed", e);
86
+ resp.putString("status", "error");
87
+ resp.putString("message", e.getMessage());
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Command 61: setFlirPalette - Set FLIR thermal palette
93
+ * Args: [acol: number] - palette index
94
+ */
95
+ public static void handleSetFlirPalette(Object root, WritableMap resp, @Nullable ReadableArray args) {
96
+ try {
97
+ int acol = args != null && args.size() > 0 ? (int) args.getDouble(0) : 1;
98
+
99
+ android.util.Log.i("CameraCommand", "[FLIR] Setting palette acol=" + acol);
100
+
101
+ // Get FlirManager instance and set palette by index
102
+ FlirManager flirManager = FlirManager.INSTANCE;
103
+ if (flirManager == null) {
104
+ resp.putString("status", "error");
105
+ resp.putString("message", "FlirManager not initialized");
106
+ return;
107
+ }
108
+
109
+ // Map acol index to palette name
110
+ String paletteName = mapAcolToPaletteName(acol);
111
+ flirManager.setPalette(paletteName);
112
+
113
+ resp.putString("status", "ok");
114
+ resp.putString("message", "Palette set");
115
+ resp.putInt("acol", acol);
116
+ } catch (Exception e) {
117
+ android.util.Log.w("CameraCommand", "[FLIR] Set palette failed", e);
118
+ resp.putString("status", "error");
119
+ resp.putString("message", e.getMessage());
120
+ }
121
+ }
122
+
123
+ private static String mapAcolToPaletteName(int acol) {
124
+ switch (acol) {
125
+ case 0: return "WhiteHot";
126
+ case 1: return "Iron";
127
+ case 2: return "Rainbow";
128
+ case 3: return "Arctic";
129
+ case 4: return "Lava";
130
+ case 5: return "Coldest";
131
+ case 6: return "Hottest";
132
+ case 7: return "Wheel";
133
+ default: return "Iron";
134
+ }
135
+ }
136
+ }