|
|
|
|
@ -115,9 +115,9 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
public async void StartGrading(object param) |
|
|
|
|
{ |
|
|
|
|
#if DEBUG |
|
|
|
|
DoStartGrading(param); |
|
|
|
|
#else |
|
|
|
|
// #if DEBUG |
|
|
|
|
// DoStartGrading(param); |
|
|
|
|
// #else |
|
|
|
|
LoadingDialog loading = new LoadingDialog(); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
@ -158,8 +158,30 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
|
|
|
|
|
// 启动soc |
|
|
|
|
socResolt = await DoSoc(); |
|
|
|
|
if (socResolt.Status == "P001") |
|
|
|
|
{ |
|
|
|
|
// 使用 Dispatcher 将 UI 操作调度到主线程 |
|
|
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
|
|
{ |
|
|
|
|
MsgDialog msgDialog = new MsgDialog(); |
|
|
|
|
msgDialog.ShowDialog(); |
|
|
|
|
}); |
|
|
|
|
loading.Dispatcher.Invoke(() => loading.Close()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 启动算法 |
|
|
|
|
parameter = await DoAlgorithm(socResolt, parameter.Shape, parameter.CrownType); |
|
|
|
|
if (parameter.status == "P002" || parameter.status == "P003" || parameter.status == "P004") |
|
|
|
|
{ |
|
|
|
|
// 使用 Dispatcher 将 UI 操作调度到主线程 |
|
|
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
|
|
{ |
|
|
|
|
MsgDialog msgDialog = new MsgDialog(); |
|
|
|
|
msgDialog.ShowDialog(); |
|
|
|
|
}); |
|
|
|
|
loading.Dispatcher.Invoke(() => loading.Close()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
parameter.Standard = "IGI 2024"; |
|
|
|
|
parameter.Shape = value.Split(" ")[0]; |
|
|
|
|
@ -195,7 +217,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
finally { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
@ -287,35 +309,28 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
/// <summary> |
|
|
|
|
/// 启动切工仪接口。 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="index">图片索引</param> |
|
|
|
|
/// <param name="index">图片索引</param> |
|
|
|
|
/// <param name="index">图片索引</param> |
|
|
|
|
/// <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); |
|
|
|
|
// // 转换成json |
|
|
|
|
// string jsonResult = JsonConvert.SerializeObject(resultEntity, Formatting.Indented); |
|
|
|
|
|
|
|
|
|
SocResultEntity resultEntity = new SocResultEntity(); |
|
|
|
|
// 光照度 |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -346,19 +361,9 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
|
|
|
|
|
AlgorithmResultEntity algoResult = _algorithmServer.CallParseJsonAndReturnActions(shape, shape_mode, image_file_base_path, image_files, algo_config); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将 algoResult 序列化为格式化的 JSON 字符串 |
|
|
|
|
string algoJsonResult = JsonConvert.SerializeObject(algoResult, Formatting.Indented); |
|
|
|
|
ShowMessage(algoJsonResult); |
|
|
|
|
return Task.FromResult(algoResult); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ShowMessage(string message) |
|
|
|
|
{ |
|
|
|
|
MessageBox.Show(message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
public class ButtonInfo |
|
|
|
|
{ |
|
|
|
|
|