fix:外部接口

master
handefeng 7 months ago
parent 11c7d74a30
commit ad27e6880f
  1. 12
      Language/en_US.xaml
  2. 11
      Language/zh_CN.xaml
  3. 5
      Model/Entity/ApiEntity/AlgorithmResultEntity.cs
  4. 6
      Model/Entity/ApiEntity/SocResultEntity.cs
  5. 9
      Model/Entity/ApiEntity/StatusCodes.cs
  6. 22
      Model/Services/AlgorithmServer.cs
  7. 75
      Model/Services/SOCClientService.cs
  8. 4
      SparkClient.sln.DotSettings.user
  9. BIN
      SparkDB.db
  10. 149
      ViewModel/Grading/DiamondSelectVM.cs
  11. 18
      Views/Dialog/MsgDialog.xaml
  12. 30
      Views/Dialog/MsgDialog.xaml.cs

@ -36,4 +36,16 @@
<!--算法配置 报表--> <!--算法配置 报表-->
<sys:String x:Key="Demo1">Button</sys:String> <sys:String x:Key="Demo1">Button</sys:String>
<!-- 外部接口MSG-->
<sys:String x:Key="InProgress">Drawing is in progress</sys:String>
<sys:String x:Key="CacheCleared">Cached images are cleared</sys:String>
<sys:String x:Key="CannotSendCommand">Unable to send instructions tNo the SOC</sys:String>
<sys:String x:Key="MicrocontrollerTimeout">Microcontroller access timeout</sys:String>
<sys:String x:Key="MicrocontrollerError">The microcontroller returns an error code</sys:String>
<sys:String x:Key="CameraNotConnected">Camera not connected</sys:String>
<sys:String x:Key="DeviceNotFound">Cutter not found</sys:String>
<sys:String x:Key="AlgorithmFailed">Algorithm call failed</sys:String>
<sys:String x:Key="ImageFileReadFailure">Failed to read the image file</sys:String>
<sys:String x:Key="JsonParseFailure">JSON parsing failed</sys:String>
</ResourceDictionary> </ResourceDictionary>

@ -177,5 +177,16 @@
<sys:String x:Key="DiamondResultGridSymLevel">SYM等级</sys:String> <sys:String x:Key="DiamondResultGridSymLevel">SYM等级</sys:String>
<sys:String x:Key="DiamondResultPopupFacet1">面1</sys:String> <sys:String x:Key="DiamondResultPopupFacet1">面1</sys:String>
<!-- 外部接口MSG-->
<sys:String x:Key="InProgress">采图正在进行中</sys:String>
<sys:String x:Key="CacheCleared">缓存图片被清理</sys:String>
<sys:String x:Key="CannotSendCommand">无法向单片机发送指令</sys:String>
<sys:String x:Key="MicrocontrollerTimeout">单片机访问超时</sys:String>
<sys:String x:Key="MicrocontrollerError">单片机返回错误码</sys:String>
<sys:String x:Key="CameraNotConnected">摄像头未连接</sys:String>
<sys:String x:Key="DeviceNotFound">未找到切工仪</sys:String>
<sys:String x:Key="AlgorithmFailed">算法调用失败</sys:String>
<sys:String x:Key="ImageFileReadFailure">图片文件读取失败</sys:String>
<sys:String x:Key="JsonParseFailure">JSON解析失败</sys:String>
</ResourceDictionary> </ResourceDictionary>

@ -86,5 +86,10 @@ namespace SparkClient.Model.Entity.ApiEntity
public string DiamondCode { get; set; } public string DiamondCode { get; set; }
public string error_msg { get; set; } public string error_msg { get; set; }
public string status { get; set; } public string status { get; set; }
/// <summary>
/// 机器号
/// </summary>
public string DeviceId { get; set; }
} }
} }

@ -12,4 +12,10 @@ public class SocResultEntity
/// 图片名称列表 /// 图片名称列表
/// </summary> /// </summary>
public List<string> Images { get; set; } public List<string> Images { get; set; }
/// <summary>
/// 机器号
/// </summary>
public string DeviceId { get; set; }
} }

@ -23,10 +23,19 @@
// 单片机返回错误码 // 单片机返回错误码
public const string MicrocontrollerError = "S005"; public const string MicrocontrollerError = "S005";
// 摄像头未连接
public const string CameraNotConnected = "S006";
// 未找到切工仪 // 未找到切工仪
public const string DeviceNotFound = "P001"; public const string DeviceNotFound = "P001";
// 算法调用失败 // 算法调用失败
public const string AlgorithmFailed = "P002"; public const string AlgorithmFailed = "P002";
// 图片文件读取失败
public const string ImageFileReadFailure = "P003";
// JSON解析失败
public const string JsonParseFailure = "P004";
} }
} }

@ -1,8 +1,10 @@
using System.Runtime.InteropServices; using System.Data;
using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using SparkClient.Model.Entity.ApiEntity; using SparkClient.Model.Entity.ApiEntity;
using SparkClient.Model.Helper;
namespace SparkClient.Model.Services namespace SparkClient.Model.Services
{ {
@ -17,10 +19,26 @@ namespace SparkClient.Model.Services
private static extern void FreeString(IntPtr ptr); private static extern void FreeString(IntPtr ptr);
// 添加公共方法 // 添加公共方法
public AlgorithmResultEntity CallParseJsonAndReturnActions(string shape, string shape_mode, string image_file_base_path, string image_files, string algo_config, Boolean half_circle) public AlgorithmResultEntity CallParseJsonAndReturnActions(string shape, string shape_mode, string image_files)
{ {
try try
{ {
//半圆
string circleSql = $"SELECT VALUE FROM CUTTER_CONFIG WHERE KEY = 'half_circle'";
DataTable circleTable = DataBaseHelper.ExecuteQuery(circleSql);
object halfCircleValue = circleTable.Rows[0][0];
bool.TryParse(halfCircleValue.ToString(), out bool boolResult);
bool half_circle = boolResult;
//算法配置参数
string sql = $"SELECT JSON FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER ASC";
DataTable table = DataBaseHelper.ExecuteQuery(sql);
object lightLevelValue = table.Rows[0][0];
string algo_config = lightLevelValue.ToString() ?? throw new InvalidOperationException();
//图片根目录
string image_file_base_path = "D:\\diamond_images";
// 将所有变量拼接成一个 JSON 对象 // 将所有变量拼接成一个 JSON 对象
JObject jsonData = new JObject( JObject jsonData = new JObject(
new JProperty("shape", shape), new JProperty("shape", shape),

@ -1,5 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Data;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
@ -8,6 +9,7 @@ using System.Windows;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
using SparkClient.Model.Common; using SparkClient.Model.Common;
using SparkClient.Model.Entity.ApiEntity; using SparkClient.Model.Entity.ApiEntity;
using SparkClient.Model.Helper;
namespace SparkClient.Model.Services namespace SparkClient.Model.Services
{ {
@ -60,17 +62,43 @@ namespace SparkClient.Model.Services
/// </summary> /// </summary>
/// <param name="lightLevel">光照级别</param> /// <param name="lightLevel">光照级别</param>
/// <returns>任务状态</returns> /// <returns>任务状态</returns>
public async Task<string> CollectImagesAsync(int lightLevel) public async Task<SocResultEntity> CollectImagesAsync()
{ {
string url = $"{_baseUrl}/collect_images?light_level={lightLevel}";
try try
{ {
// 光照度和半圆
int lightLevel = 0;
string halfCircle = string.Empty;
// 查询光照度和半圆配置
string sql = $"SELECT KEY, VALUE FROM CUTTER_CONFIG WHERE KEY IN ('light_level', 'half_circle')";
DataTable table = DataBaseHelper.ExecuteQuery(sql);
if (table == null || table.Rows.Count == 0)
{
throw new Exception("No data found for the specified keys.");
}
foreach (DataRow row in table.Rows)
{
string key = row["Key"].ToString() ?? string.Empty;
string value = row["Value"].ToString() ?? string.Empty;
if (key == "light_level" && int.TryParse(value, out int parsedLightLevel))
{
lightLevel = parsedLightLevel; // 光照度
}
else if (key == "half_circle")
{
halfCircle = value; // 半圆
}
}
string url = $"{_baseUrl}/collect_images?light_level={lightLevel}&half_circle={halfCircle}";
var response = await SendGetRequestAsync(url); var response = await SendGetRequestAsync(url);
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
return "P001"; return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() , DeviceId = ""};
} }
var jsonResponse = await response.Content.ReadAsStringAsync(); var jsonResponse = await response.Content.ReadAsStringAsync();
@ -78,16 +106,18 @@ namespace SparkClient.Model.Services
if (result == null) if (result == null)
{ {
return "P001"; return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() , DeviceId = ""};
} }
return new SocResultEntity { Status = result.Status, Images = new List<string>() , DeviceId = result.device_id};
return result.Status;
} }
catch (Exception ex) catch (Exception ex)
{ {
// 记录异常信息 // 记录日志或进行其他处理
Console.WriteLine($"An error occurred while collecting images: {ex.Message}"); Console.WriteLine($"Error in DoSoc: {ex.Message}");
return "P001"; // 或者使用日志框架记录日志
// logger.LogError(ex, "Error in DoSoc method.");
return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() , DeviceId = ""};
} }
} }
@ -186,15 +216,15 @@ namespace SparkClient.Model.Services
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
{ {
return "P001"; return StatusCodes.DeviceNotFound;
} }
catch (JsonException ex) catch (JsonException ex)
{ {
return "P001"; return StatusCodes.DeviceNotFound;
} }
catch (Exception ex) catch (Exception ex)
{ {
return "P001"; return StatusCodes.DeviceNotFound;
} }
} }
@ -202,26 +232,28 @@ namespace SparkClient.Model.Services
/// 处理图片收集、保存和状态检查。 /// 处理图片收集、保存和状态检查。
/// </summary> /// </summary>
/// <param name="lightLevel">光照级别</param> /// <param name="lightLevel">光照级别</param>
/// <param name="halfCircle">是否半圆</param>
/// <param name="savePath">图片保存路径</param> /// <param name="savePath">图片保存路径</param>
/// <returns>操作结果</returns> /// <returns>操作结果</returns>
public async Task<SocResultEntity> ProcessImageCollectionAsync(int lightLevel, string savePath) public async Task<SocResultEntity> ProcessImageCollectionAsync()
{ {
try try
{ {
// SOC接口
string savePath = @"d:\diamond_images";
// 清理 savePath 文件夹 // 清理 savePath 文件夹
if (Directory.Exists(savePath)) if (Directory.Exists(savePath))
{ {
Directory.Delete(savePath, true); Directory.Delete(savePath, true);
} }
Directory.CreateDirectory(savePath); Directory.CreateDirectory(savePath);
// 启动任务接口 // 启动任务接口
string startStatus = await CollectImagesAsync(lightLevel); SocResultEntity entity = await CollectImagesAsync();
// 成功 // 成功
if (startStatus != StatusCodes.Success) if (entity.Status != StatusCodes.Success)
{ {
// 启动任务失败 // 启动任务失败
return new SocResultEntity { Status = startStatus, Images = new List<string>() }; return new SocResultEntity { Status = entity.Status, Images = new List<string>() };
} }
// 读取图片接口 // 读取图片接口
@ -238,7 +270,7 @@ namespace SparkClient.Model.Services
} }
} }
// 按下载时间排序图片名称 // 按下载时间排序图片名称
return new SocResultEntity { Status = StatusCodes.Success, Images = imageNames }; return new SocResultEntity { Status = StatusCodes.Success, Images = imageNames, DeviceId = entity.DeviceId};
} }
catch (Exception e) catch (Exception e)
{ {
@ -288,5 +320,10 @@ namespace SparkClient.Model.Services
/// 状态消息 /// 状态消息
/// </summary> /// </summary>
public string Message { get; set; } public string Message { get; set; }
/// <summary>
/// 机器号
/// </summary>
public string device_id { get; set; }
} }
} }

@ -16,6 +16,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventRoute_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96a561fe76144633acef44f09d0dcb8a825920_003Fb0_003F8f1a0289_003FEventRoute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventRoute_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96a561fe76144633acef44f09d0dcb8a825920_003Fb0_003F8f1a0289_003FEventRoute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventToCommand_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F436b6c3e323d68842c9e251322f5d42b47569f7c925e63aa245dc65465d2843_003FEventToCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventToCommand_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F436b6c3e323d68842c9e251322f5d42b47569f7c925e63aa245dc65465d2843_003FEventToCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventTriggerBase_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffdc001c928464b80ad45ffa09b838a3a15e200_003Faf_003F9abbeb44_003FEventTriggerBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventTriggerBase_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffdc001c928464b80ad45ffa09b838a3a15e200_003Faf_003F9abbeb44_003FEventTriggerBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbd1d5c50194fea68ff3559c160230b0ab50f5acf4ce3061bffd6d62958e2182_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbd1d5c50194fea68ff3559c160230b0ab50f5acf4ce3061bffd6d62958e2182_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbd1d5c50194fea68ff3559c160230b0ab50f5acf4ce3061bffd6d62958e2182_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExecutionContext_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003F35_003F053c62c1_003FExecutionContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExecutionContext_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003F35_003F053c62c1_003FExecutionContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileSystem_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F4c69bf2d25bb4f2497b2dbd14727a7811308b0_003F9b_003F7ca26691_003FFileSystem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileSystem_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F4c69bf2d25bb4f2497b2dbd14727a7811308b0_003F9b_003F7ca26691_003FFileSystem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
@ -23,6 +24,8 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFrameworkElement_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6412d4331611499aab4eb63809a2a83bf60910_003F07_003Fdab5922a_003FFrameworkElement_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFrameworkElement_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6412d4331611499aab4eb63809a2a83bf60910_003F07_003Fdab5922a_003FFrameworkElement_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGuid_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Faa_003Fa49e75b9_003FGuid_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGuid_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Faa_003Fa49e75b9_003FGuid_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AILog_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6f4e00a876324444bc5ae4e52ed22ade46200_003F49_003Fe673ccfc_003FILog_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AILog_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6f4e00a876324444bc5ae4e52ed22ade46200_003F49_003Fe673ccfc_003FILog_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInputManager_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F59d3cbd3f2f27be170d8c07c2c3947fe0efe92848ebab828a63cfbe1ef3a1d_003FInputManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonConvert_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003Ffc_003F02691a46_003FJsonConvert_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonSerializerSettings_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003Fbe_003Fd5d07dac_003FJsonSerializerSettings_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonSerializerSettings_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003Fbe_003Fd5d07dac_003FJsonSerializerSettings_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonSerializer_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003F9d_003Fb98e2c8a_003FJsonSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonSerializer_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003F9d_003Fb98e2c8a_003FJsonSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonTextReader_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003Fcf_003F3a31e3b0_003FJsonTextReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonTextReader_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7e62198beab24380bbac29171862d1d8adf10_003Fcf_003F3a31e3b0_003FJsonTextReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
@ -32,6 +35,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMeshGeometryModel3D_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F68d37d16685244cf9996bf767117a771210200_003Fb5_003Fc0ee0c0f_003FMeshGeometryModel3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMeshGeometryModel3D_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F68d37d16685244cf9996bf767117a771210200_003Fb5_003Fc0ee0c0f_003FMeshGeometryModel3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessageBox_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F476b8dbfd2cb40ab8ff230fdcda5e37081d20_003F0e_003F12425a46_003FMessageBox_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessageBox_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F476b8dbfd2cb40ab8ff230fdcda5e37081d20_003F0e_003F12425a46_003FMessageBox_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessageBox_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffdc001c928464b80ad45ffa09b838a3a15e200_003F55_003F1a844f6e_003FMessageBox_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessageBox_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffdc001c928464b80ad45ffa09b838a3a15e200_003F55_003F1a844f6e_003FMessageBox_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fd882146b4f265f10bcbec2663fce248db9ffec5fa1aeaf76e32a11ba5eafcd6_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARoutedEventArgs_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F1a88b4a860176dd5f825206bbebf3ee3d44ff3f058ceed9eb693c1eaa018_003FRoutedEventArgs_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARoutedEventArgs_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F1a88b4a860176dd5f825206bbebf3ee3d44ff3f058ceed9eb693c1eaa018_003FRoutedEventArgs_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F955ec549fe664629353c3b5424b6ad6c7dfcec4ab59bae709ab962c228cf45_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F955ec549fe664629353c3b5424b6ad6c7dfcec4ab59bae709ab962c228cf45_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqliteCommand_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc7a59cb727594ed7a94648b2d66dbf702aa28_003F2f_003Fdc5f3094_003FSqliteCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqliteCommand_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc7a59cb727594ed7a94648b2d66dbf702aa28_003F2f_003Fdc5f3094_003FSqliteCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

Binary file not shown.

@ -16,6 +16,7 @@ using MessageBox = System.Windows.MessageBox;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Windows.Media; using System.Windows.Media;
using SparkClient.Model.Common;
using Color = System.Windows.Media.Color; using Color = System.Windows.Media.Color;
namespace SparkClient.ViewModel.Grading; namespace SparkClient.ViewModel.Grading;
@ -113,9 +114,7 @@ public class DiamondSelectVM : BaseViewModel
/// <param name="param"></param> /// <param name="param"></param>
public async void StartGrading(object param) public async void StartGrading(object param)
{ {
#if DEBUG
DoStartGrading(param);
#else
LoadingDialog loading = new LoadingDialog(); LoadingDialog loading = new LoadingDialog();
try try
{ {
@ -137,7 +136,7 @@ public class DiamondSelectVM : BaseViewModel
} }
// 模拟耗时操作 // 模拟耗时操作
//System.Threading.Thread.Sleep(50); // 休眠50毫秒 //System.Threading.Thread.Sleep(50); // 休眠50毫秒
await Task.Delay(400); await Task.Delay(710);
loading.setValue(i); loading.setValue(i);
progress = i; progress = i;
} }
@ -154,38 +153,53 @@ public class DiamondSelectVM : BaseViewModel
parameter.PavType = value.Split(" ")[2]; parameter.PavType = value.Split(" ")[2];
} }
// 初始化SOC客户端服务,传入SOC端的地址和认证Token
_socClientService = new SOCClientService();
// 启动soc // 启动soc
// socResolt = await DoSoc(); socResolt = await _socClientService.ProcessImageCollectionAsync();
// if (socResolt.Status == "P001" || socResolt.Images.Count == 0) switch (socResolt.Status)
// { {
// // /*// 使用 Dispatcher 将 UI 操作调度到主线程 case StatusCodes.DeviceNotFound:
// // Application.Current.Dispatcher.Invoke(() => ShowErrorMessage(MultilingualHelper.getString("DeviceNotFound"), loading);
// // { return;
// // MsgDialog msgDialog = new MsgDialog(); case StatusCodes.InProgress:
// // msgDialog.ShowDialog(); ShowErrorMessage(MultilingualHelper.getString("InProgress"), loading);
// // }); return;
// // loading.Dispatcher.Invoke(() => loading.Close()); case StatusCodes.CacheCleared:
// // return;*/ ShowErrorMessage(MultilingualHelper.getString("CacheCleared"), loading);
// MessageBox.Show("未找到切工仪", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return;
// loading.Dispatcher.Invoke(() => loading.Close()); case StatusCodes.CannotSendCommand:
// return; ShowErrorMessage(MultilingualHelper.getString("CannotSendCommand"), loading);
// } return;
case StatusCodes.MicrocontrollerTimeout:
ShowErrorMessage(MultilingualHelper.getString("MicrocontrollerTimeout"), loading);
return;
case StatusCodes.MicrocontrollerError:
ShowErrorMessage(MultilingualHelper.getString("MicrocontrollerError"), loading);
return;
case StatusCodes.CameraNotConnected:
ShowErrorMessage(MultilingualHelper.getString("CameraNotConnected"), loading);
return;
}
_algorithmServer = new AlgorithmServer();
//图片集合
string image_files = JsonConvert.SerializeObject(socResolt.Images, Formatting.Indented);
//string image_files =$"[ \"image_0.bmp\", \"image_1.bmp\", \"image_2.bmp\", \"image_3.bmp\", \"image_4.bmp\", \"image_5.bmp\", \"image_6.bmp\", \"image_7.bmp\", \"image_8.bmp\", \"image_9.bmp\", \"image_10.bmp\", \"image_11.bmp\", \"image_12.bmp\", \"image_13.bmp\", \"image_14.bmp\", \"image_15.bmp\", \"image_16.bmp\", \"image_17.bmp\", \"image_18.bmp\", \"image_19.bmp\", \"image_20.bmp\", \"image_21.bmp\", \"image_22.bmp\", \"image_23.bmp\", \"image_24.bmp\", \"image_25.bmp\", \"image_26.bmp\", \"image_27.bmp\", \"image_28.bmp\", \"image_29.bmp\", \"image_30.bmp\", \"image_31.bmp\", \"image_32.bmp\", \"image_33.bmp\", \"image_34.bmp\", \"image_35.bmp\", \"image_36.bmp\", \"image_37.bmp\", \"image_38.bmp\", \"image_39.bmp\", \"image_40.bmp\", \"image_41.bmp\", \"image_42.bmp\", \"image_43.bmp\", \"image_44.bmp\", \"image_45.bmp\", \"image_46.bmp\", \"image_47.bmp\", \"image_48.bmp\", \"image_49.bmp\" ]" ;
// 启动算法 // 启动算法
parameter = await DoAlgorithm(socResolt, parameter.Shape, parameter.CrownType); parameter = _algorithmServer.CallParseJsonAndReturnActions(parameter.Shape, parameter.CrownType, image_files);
MessageBox.Show(parameter.error_msg); //机器号
parameter.DeviceId = socResolt.DeviceId;
switch (parameter.status) switch (parameter.status)
{ {
case "P002": case StatusCodes.AlgorithmFailed:
MessageBox.Show("P002:调用算法失败", "错误", MessageBoxButton.OK, MessageBoxImage.Error); ShowErrorMessage(MultilingualHelper.getString("AlgorithmFailed"), loading);
loading.Dispatcher.Invoke(() => loading.Close());
return; return;
case "P003": case StatusCodes.ImageFileReadFailure:
MessageBox.Show("P003:图片文件读取失败", "错误", MessageBoxButton.OK, MessageBoxImage.Error); ShowErrorMessage(MultilingualHelper.getString("ImageFileReadFailure"), loading);
loading.Dispatcher.Invoke(() => loading.Close());
return; return;
case "P004": case StatusCodes.JsonParseFailure:
MessageBox.Show("P004:JSON解析失败", "错误", MessageBoxButton.OK, MessageBoxImage.Error); ShowErrorMessage(MultilingualHelper.getString("JsonParseFailure"), loading);
loading.Dispatcher.Invoke(() => loading.Close());
return; return;
} }
parameter.Standard = "IGI 2024"; parameter.Standard = "IGI 2024";
@ -222,9 +236,21 @@ public class DiamondSelectVM : BaseViewModel
finally { finally {
} }
#endif
} }
// 将 UI 操作调度到主线程并显示错误信息
void ShowErrorMessage(string errorMessage, LoadingDialog loading)
{
Application.Current.Dispatcher.Invoke(() =>
{
MsgDialog msgDialog = new MsgDialog();
msgDialog.ErrorMessage = errorMessage;
msgDialog.ShowDialog();
});
loading.Dispatcher.Invoke(() => loading.Close());
}
/// <summary> /// <summary>
/// 开始检测(对soc和算法开始通讯) /// 开始检测(对soc和算法开始通讯)
/// </summary> /// </summary>
@ -310,67 +336,6 @@ public class DiamondSelectVM : BaseViewModel
WindowManager.openContent.Add(vm); WindowManager.openContent.Add(vm);
} }
/// <summary>
/// 启动切工仪接口。
/// </summary>
/// <returns>图片的字节数组</returns>
private async Task<SocResultEntity> DoSoc()
{
// 光照度
string sql = new CutterConfigEntity
{
ItemName = null,
Key = null,
Value = null
}.GenerateSelectSQL(new List<string> { "Value" }, new Dictionary<string, object> { { "Key", "light_level" } });
SqliteParameter[] sqliteParameters = [new("@Key", "light_level")];
DataTable table = DataBaseHelper.ExecuteQuery(sql,sqliteParameters);
object lightLevelValue = table.Rows[0][0];
if (!int.TryParse(lightLevelValue.ToString(), out int lightLevel))
{
throw new InvalidOperationException("Light level value is not a valid integer.");
}
// 初始化SOC客户端服务,传入SOC端的地址和认证Token
_socClientService = new SOCClientService();
// SOC接口
string savePath = @"d:\\diamond_images";
SocResultEntity resultEntity = await _socClientService.ProcessImageCollectionAsync(lightLevel, savePath);
return resultEntity;
}
/// <summary>
/// 启动算法接口。
/// </summary>
/// <param name="socResolt">切工仪接口返回值</param>
/// <param name="crownType"></param>
/// <param name="shape"></param>
/// <returns>定级参数,3D模型参数</returns>
private Task<AlgorithmResultEntity> DoAlgorithm(SocResultEntity socResolt, String shape, String crownType)
{
_algorithmServer = new AlgorithmServer();
//钻石形状:shape
//钻石子形状
string shape_mode = crownType;
//图片根目录
string image_file_base_path = "D:\\diamond_images";
//图片集合
//string image_files = JsonConvert.SerializeObject(socResolt.Images, Formatting.Indented);
string image_files =$"[ \"image_0.bmp\", \"image_1.bmp\", \"image_2.bmp\", \"image_3.bmp\", \"image_4.bmp\", \"image_5.bmp\", \"image_6.bmp\", \"image_7.bmp\", \"image_8.bmp\", \"image_9.bmp\", \"image_10.bmp\", \"image_11.bmp\", \"image_12.bmp\", \"image_13.bmp\", \"image_14.bmp\", \"image_15.bmp\", \"image_16.bmp\", \"image_17.bmp\", \"image_18.bmp\", \"image_19.bmp\", \"image_20.bmp\", \"image_21.bmp\", \"image_22.bmp\", \"image_23.bmp\", \"image_24.bmp\", \"image_25.bmp\", \"image_26.bmp\", \"image_27.bmp\", \"image_28.bmp\", \"image_29.bmp\", \"image_30.bmp\", \"image_31.bmp\", \"image_32.bmp\", \"image_33.bmp\", \"image_34.bmp\", \"image_35.bmp\", \"image_36.bmp\", \"image_37.bmp\", \"image_38.bmp\", \"image_39.bmp\", \"image_40.bmp\", \"image_41.bmp\", \"image_42.bmp\", \"image_43.bmp\", \"image_44.bmp\", \"image_45.bmp\", \"image_46.bmp\", \"image_47.bmp\", \"image_48.bmp\", \"image_49.bmp\" ]" ;
//半圆
Boolean half_circle = false;
//算法配置参数
string sql = $"SELECT JSON FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER ASC";
DataTable table = DataBaseHelper.ExecuteQuery(sql);
object lightLevelValue = table.Rows[0][0];
string algo_config = lightLevelValue.ToString() ?? throw new InvalidOperationException();
AlgorithmResultEntity algoResult = _algorithmServer.CallParseJsonAndReturnActions(shape, shape_mode, image_file_base_path, image_files, algo_config,half_circle);
return Task.FromResult(algoResult);
}
} }
public class ButtonInfo public class ButtonInfo
{ {

@ -21,7 +21,7 @@
<Viewbox Stretch="Uniform"/> <Viewbox Stretch="Uniform"/>
</Button> </Button>
<!-- 标题 --> <!-- 标题 -->
<TextBlock Grid.Row="0" Text="XXXXXXXXXXXXXX" <TextBlock Grid.Row="0" Text="{Binding ErrorMessage}"
FontSize="16" FontWeight="Bold" Foreground="Black" FontSize="16" FontWeight="Bold" Foreground="Black"
HorizontalAlignment="Center" Margin="0,70" /> HorizontalAlignment="Center" Margin="0,70" />
@ -33,13 +33,13 @@
BorderBrush="Transparent" Click="Skip_Click" /> BorderBrush="Transparent" Click="Skip_Click" />
</StackPanel> </StackPanel>
<Path Data="{StaticResource CloseGeometry}" <Path Data="{StaticResource CloseGeometry}"
Fill="Azure" Fill="Azure"
Stroke="Black" Stroke="Black"
StrokeThickness="1" StrokeThickness="1"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
Margin="335,7,0,0" Margin="335,7,0,0"
Width="30" /> Width="30" />
</Grid> </Grid>
</Border> </Border>
</Window> </Window>

@ -1,4 +1,5 @@
using System.Windows; using System.ComponentModel;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
@ -7,13 +8,29 @@ namespace SparkClient.Views.Dialog
/// <summary> /// <summary>
/// MsgDialog.xaml 的交互逻辑 /// MsgDialog.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class MsgDialog : Window public partial class MsgDialog : Window, INotifyPropertyChanged
{ {
private string _errorMessage;
public string ErrorMessage
{
get { return _errorMessage; }
set
{
if (_errorMessage != value)
{
_errorMessage = value;
OnPropertyChanged(nameof(ErrorMessage));
}
}
}
public MsgDialog() public MsgDialog()
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += (s, e) => ApplyCornerRadiusClip(); this.Loaded += (s, e) => ApplyCornerRadiusClip();
this.SizeChanged += (s, e) => ApplyCornerRadiusClip(); this.SizeChanged += (s, e) => ApplyCornerRadiusClip();
this.DataContext = this; // 设置 DataContext 以便绑定
} }
/// <summary> /// <summary>
@ -58,5 +75,12 @@ namespace SparkClient.Views.Dialog
this.DragMove(); this.DragMove();
} }
} }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

Loading…
Cancel
Save