From 846acaf57a1d207d12271274781a2feac34cc29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Tue, 9 Jul 2024 09:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E6=8B=8D=E4=BB=AA=E5=B7=B2=E6=94=B9?= =?UTF-8?q?=E6=88=90=E6=AF=8F=E6=AC=A1=E7=94=A8=E7=9A=84=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=8B=8D=E7=85=A7=E7=84=B6=E5=90=8E=E5=85=B3=E9=97=AD=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=B7=B2=E6=9B=B4=E6=96=B0=E5=88=B0234?= =?UTF-8?q?=EF=BC=8C=E8=AF=A5=E6=96=B9=E5=BC=8F=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E9=AB=98=E6=8B=8D=E4=BB=AA=E6=8B=8D?= =?UTF-8?q?=E7=85=A7=E7=9A=84=E6=97=B6=E5=80=99=E4=BC=9A=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=8B=8D=E7=85=A7=E8=BF=94=E5=9B=9E=E7=9A=84=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89=E6=8B=8D=E5=88=B0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/FrmMain.cs | 32 +++++------ CPF_Cef/MainModel.cs | 123 ++++++++++++++++++++++++++++--------------- CPF_Cef/Parame.cs | 2 +- 3 files changed, 97 insertions(+), 60 deletions(-) diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index bee33dd..4d829e2 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -81,8 +81,8 @@ namespace AksWebBrowser //浏览器大小 Parame.webBrowser.Width = w; Parame.webBrowser.Height = h; - Parame.webBrowser.Url = "http://143.169.62.3:8096/#/main-out";//天府新区 - //Parame.webBrowser.Url = "http://192.168.0.232:8848/html/index.html"; + //Parame.webBrowser.Url = "http://143.169.62.3:8096/#/main-out";//天府新区 + Parame.webBrowser.Url = "http://192.168.0.234:8096/#/main-out"; //Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //开发者工具暂时只能支持Windows @@ -109,21 +109,21 @@ namespace AksWebBrowser } //获取授权 GetSQObject(); - //获取设备 - MainModel.GetSnIndex(); - //打开高拍仪 - if (MainModel.OpenSn(Parame.gpydevIndex) == "200") - { - Parame.isGPY = true; - } - //开启/关闭纠偏显示 - MainModel.EnableDeskImage(1); + ////获取设备 + //MainModel.GetSnIndex(); + ////打开高拍仪 + //if (MainModel.OpenSn(Parame.gpydevIndex) == "200") + //{ + // Parame.isGPY = true; + //} + ////开启/关闭纠偏显示 + //MainModel.EnableDeskImage(1); - //开启定时 - System.Timers.Timer timer = new System.Timers.Timer(1000);//3秒钟的时间间隔 - timer.Elapsed += OnTimedEvent; - timer.AutoReset = true;//重复执行 - timer.Enabled = true;//启动定时器 + ////开启定时 + //System.Timers.Timer timer = new System.Timers.Timer(1000);//3秒钟的时间间隔 + //timer.Elapsed += OnTimedEvent; + //timer.AutoReset = true;//重复执行 + //timer.Enabled = true;//启动定时器 } //矫正授权 diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 51f1131..815b2ce 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -519,67 +519,104 @@ namespace AksWebBrowser { try { - if (Parame.isGPY) + //if (Parame.isGPY) + //{ + // //拍照 + // string param = getFrame(); + // //Log.Info("img2" + (param)); + // if (string.IsNullOrEmpty(param)) + // { + // //关闭 + // //StopSn("0"); + // string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "获取图片失败" + "\"}"; + // SubmitLogs(result, "openCamera"); + // return result; + // } + // else + // { + // param = Utils.ImagesByRotate(param, 90); + // //关闭 + // //StopSn("0"); + // string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}"; + // SubmitLogs(result, "openCamera"); + // return result; + // } + //} + //else + //{ + // //打开高拍仪 + // string param = OpenSn(Parame.gpydevIndex); + // if (string.IsNullOrEmpty(param)) + // { + // string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "扫描仪打开失败" + "\"}"; + // SubmitLogs(result, "openCamera"); + // return result; + // } + // else + // { + // Task.Delay(1000).Wait(); + // //拍照 + // param = getFrame(); + // //Log.Info("img2" + (param)); + // if (string.IsNullOrEmpty(param)) + // { + // //关闭 + // //StopSn("0"); + // string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "获取图片失败" + "\"}"; + // SubmitLogs(result, "openCamera"); + // return result; + // } + // else + // { + // string base64 = Utils.ImagesByRotate(param, 90); + // //关闭 + // //StopSn("0"); + // string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}"; + // SubmitLogs(result, "openCamera"); + // return result; + // } + + // } + + //} + + string devindex = GetSnIndex(); + if (string.IsNullOrEmpty(devindex)) { + devindex = Parame.gpydevIndex; + } + //打开高拍仪 + string param = OpenSn(devindex); + if (string.IsNullOrEmpty(param)) + { + string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "扫描仪打开失败" + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } + else { + //开启纠偏 + EnableDeskImage(1); //拍照 - string param = getFrame(); + param = getFrame(); //Log.Info("img2" + (param)); if (string.IsNullOrEmpty(param)) { //关闭 - //StopSn("0"); + StopSn(devindex); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "获取图片失败" + "\"}"; SubmitLogs(result, "openCamera"); return result; } else { - param = Utils.ImagesByRotate(param, 90); + string base64 = Utils.ImagesByRotate(param, 90); //关闭 - //StopSn("0"); + StopSn(devindex); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}"; SubmitLogs(result, "openCamera"); return result; } } - else - { - //打开高拍仪 - string param = OpenSn(Parame.gpydevIndex); - if (string.IsNullOrEmpty(param)) - { - string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "扫描仪打开失败" + "\"}"; - SubmitLogs(result, "openCamera"); - return result; - } - else - { - Task.Delay(1000).Wait(); - //拍照 - param = getFrame(); - //Log.Info("img2" + (param)); - if (string.IsNullOrEmpty(param)) - { - //关闭 - //StopSn("0"); - string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "获取图片失败" + "\"}"; - SubmitLogs(result, "openCamera"); - return result; - } - else - { - string base64 = Utils.ImagesByRotate(param, 90); - //关闭 - //StopSn("0"); - string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}"; - SubmitLogs(result, "openCamera"); - return result; - } - - } - - } - } catch (Exception ex) { diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index 900c677..08346f5 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -19,7 +19,7 @@ namespace AksWebBrowser public static Window frm { get; set; } public static List FuncObject { get; set; } //接口地址 - public static string apiUrl = "http://143.169.62.3:8098";//"http://192.168.0.34:92";// + public static string apiUrl = "http://192.168.0.234:8098";//"http://143.169.62.3:8098";// //授权key public static string key = "1"; //硬件Ip