67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using VisionCommon;
|
|
using Hermes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace MilPattern {
|
|
public class CodeParamExt : ICloneable {
|
|
private const string FILE_NAME = "CodeParamExt.json";
|
|
|
|
public eMilCodeType CodeType { get; set; } = eMilCodeType.Barcode_Any;
|
|
public int FindNumber { get; set; } = 1; // µ¿½Ã¿¡ ãÀ» ¹ÙÄÚµå ¼ö
|
|
public ROI FindROI { get; set; } = new ROI();
|
|
|
|
public CodeParamExt() {
|
|
}
|
|
|
|
public CodeParamExt(eMilCodeType codeType, int findNum, ROI findRoi) {
|
|
CodeType = codeType;
|
|
FindNumber = findNum;
|
|
FindROI = findRoi.Clone() as ROI;
|
|
}
|
|
|
|
public object Clone() {
|
|
return new CodeParamExt() {
|
|
CodeType = CodeType,
|
|
FindNumber = FindNumber,
|
|
FindROI = FindROI.Clone() as ROI
|
|
};
|
|
}
|
|
|
|
internal static CodeParamExt Load(string dirPath) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
|
|
if (File.Exists(filePath)) {
|
|
return JsonConvert.DeserializeObject(
|
|
File.ReadAllText(filePath), typeof(CodeParamExt)) as CodeParamExt;
|
|
}
|
|
|
|
return new CodeParamExt();
|
|
}
|
|
|
|
internal static int Save(string dirPath, CodeParamExt codeParamExt) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
|
|
if (!Directory.Exists(dirPath)) {
|
|
Directory.CreateDirectory(dirPath);
|
|
}
|
|
|
|
using (var fs = File.Create(filePath))
|
|
using (var sw = new StreamWriter(fs))
|
|
using (var jtw = new JsonTextWriter(sw) {
|
|
Formatting = Formatting.Indented,
|
|
Indentation = 2,
|
|
}) {
|
|
(new JsonSerializer()).Serialize(jtw, codeParamExt);
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
}
|
|
}
|