|
|
@@ -18,25 +18,63 @@ let cameraProcess = null; // 子进程引用
|
|
|
let isProcessRunning = false; // 进程运行状态
|
|
|
const processEmitter = new EventEmitter(); // 进程事件发射器
|
|
|
|
|
|
-const exe = {
|
|
|
- "digiCamControl":"CameraControl.exe",
|
|
|
- "SmartShooter":"SmartShooter5.exe",
|
|
|
+// Smart Shooter 5 / 6 与 digiCamControl 并存。
|
|
|
+// 5 和 6 共用同一套 External API(54543 事件 / 54544 请求),不能同时开,按 controlType 只启动其中一个。
|
|
|
+const CONTROLLERS = {
|
|
|
+ digiCamControl: {
|
|
|
+ exe: "CameraControl.exe",
|
|
|
+ pathKey: "digiCamControlPath",
|
|
|
+ label: "digiCamControl",
|
|
|
+ },
|
|
|
+ SmartShooter: {
|
|
|
+ exe: "SmartShooter5.exe",
|
|
|
+ pathKey: "SmartShooterPath",
|
|
|
+ label: "Smart Shooter 5",
|
|
|
+ },
|
|
|
+ SmartShooter6: {
|
|
|
+ exe: "SmartShooter6.exe",
|
|
|
+ pathKey: "SmartShooter6Path",
|
|
|
+ label: "Smart Shooter 6",
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
+// 历史配置 controlType 仍是 SmartShooter,保持原行为
|
|
|
+function normalizeControlType(type) {
|
|
|
+ return CONTROLLERS[type] ? type : "SmartShooter"
|
|
|
+}
|
|
|
|
|
|
-function getExePath () {
|
|
|
- let exePath = ""
|
|
|
- if(readConfigFile().controlType === 'digiCamControl'){
|
|
|
- exePath = path.join( readConfigFile().controlPath || readConfigFile().digiCamControlPath, exe["digiCamControl"]);
|
|
|
- }else if(readConfigFile().controlType === 'SmartShooter'){
|
|
|
- exePath = path.join( readConfigFile().controlPath || readConfigFile().SmartShooterPath, exe["SmartShooter"]);
|
|
|
+function isSmartShooterType(type) {
|
|
|
+ return type === "SmartShooter" || type === "SmartShooter6"
|
|
|
+}
|
|
|
+
|
|
|
+function getController() {
|
|
|
+ const config = readConfigFile() || {}
|
|
|
+ const type = normalizeControlType(config.controlType)
|
|
|
+ const spec = CONTROLLERS[type]
|
|
|
+ return {
|
|
|
+ type,
|
|
|
+ ...spec,
|
|
|
+ dir: config.controlPath || config[spec.pathKey] || "",
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+function getExePath () {
|
|
|
+ const controller = getController()
|
|
|
+ const exePath = controller.dir ? path.join(controller.dir, controller.exe) : ""
|
|
|
|
|
|
console.log('ex============ePath');
|
|
|
console.log(exePath);
|
|
|
return exePath
|
|
|
}
|
|
|
|
|
|
+// 用户手动选安装目录时,按目录里实际存在的 exe 识别,5 和 6 互不覆盖
|
|
|
+function detectController(dir) {
|
|
|
+ if (fs.existsSync(path.join(dir, CONTROLLERS.SmartShooter6.exe))) return "SmartShooter6"
|
|
|
+ if (fs.existsSync(path.join(dir, CONTROLLERS.SmartShooter.exe))) return "SmartShooter"
|
|
|
+ if (fs.existsSync(path.join(dir, CONTROLLERS.digiCamControl.exe))) return "digiCamControl"
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -61,27 +99,29 @@ async function checkCameraControlCmdExists() {
|
|
|
if (!canceled && filePaths.length > 0) {
|
|
|
const selectedPath = filePaths[0];
|
|
|
|
|
|
- // Check if SmartShooter5.exe exists in the selected directory
|
|
|
- const hasExe = path.join(selectedPath, exe["SmartShooter"]);
|
|
|
-
|
|
|
- if (fs.existsSync(hasExe)) {
|
|
|
- writeConfigFile("controlType","SmartShooter")
|
|
|
- }else{
|
|
|
- writeConfigFile("controlType","digiCamControl")
|
|
|
+ const detected = detectController(selectedPath);
|
|
|
+ if (!detected) {
|
|
|
+ console.error('所选目录不是已知的相机控制软件');
|
|
|
+ return {
|
|
|
+ status:-1,
|
|
|
+ msg:"所选目录中未找到 SmartShooter6.exe、SmartShooter5.exe 或 CameraControl.exe",
|
|
|
+ }
|
|
|
}
|
|
|
- writeConfigFile("controlPath",selectedPath)
|
|
|
+ writeConfigFile("controlType", detected)
|
|
|
+ writeConfigFile("controlPath", selectedPath)
|
|
|
+ writeConfigFile(CONTROLLERS[detected].pathKey, selectedPath)
|
|
|
} else {
|
|
|
console.error('用户未选择文件夹');
|
|
|
return {
|
|
|
status:-1,
|
|
|
- msg:"无法找到 CameraControlCmd.exe 或者 SmartShooter5.exe",
|
|
|
+ msg:"无法找到 SmartShooter6.exe、SmartShooter5.exe 或 CameraControl.exe",
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
const res = await openCameraControlCmd();
|
|
|
|
|
|
- // 如果是SmartShooter,启动后最小化窗口
|
|
|
- if(readConfigFile().controlType === 'SmartShooter'){
|
|
|
+ // Smart Shooter 5 / 6 启动后最小化窗口;digiCamControl 走自己的最小化命令
|
|
|
+ if(isSmartShooterType(getController().type)){
|
|
|
// 等待软件启动完成
|
|
|
setTimeout(async () => {
|
|
|
try {
|
|
|
@@ -167,6 +207,9 @@ module.exports = {
|
|
|
checkCameraControlCmdExists,
|
|
|
closeCameraControlTips,
|
|
|
minimizeSmartShooter,
|
|
|
+ CONTROLLERS,
|
|
|
+ isSmartShooterType,
|
|
|
+ getController,
|
|
|
// 进程状态管理
|
|
|
isProcessRunning: () => isProcessRunning,
|
|
|
onProcessClosed: (callback) => processEmitter.on('camera-process-closed', callback),
|