154 lines
5.3 KiB
C#
154 lines
5.3 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace VisionCommon {
|
|
public class PatternIndex : ICloneable {
|
|
public eUnitId UnitId { get; set; } = 0;
|
|
public eSubSysId SubSysId { get; set; } = 0;
|
|
public eFovId FovId { get; set; } = eFovId.Fov1;
|
|
public string FovName { get; set; } = string.Empty;
|
|
public eCamId CamId { get; set; } = eCamId.CAM1;
|
|
|
|
public int PatternId { get; set; } = 0;
|
|
public int PatternSubId { get; set; } = 0;
|
|
|
|
public PatternIndex(
|
|
SubSysInfo subSysInfo, eFovId fovId, int patternId, int patternSubId = 0)
|
|
: this(subSysInfo.UnitId, subSysInfo.SubSysId, fovId, patternId, patternSubId) {
|
|
}
|
|
|
|
public PatternIndex(
|
|
eUnitId unitid, eSubSysId subSysId, eFovId fovId, int patternId, int patternSubId = 0)
|
|
: this(unitid, subSysId, string.Empty, fovId, patternId, patternSubId) {
|
|
}
|
|
|
|
public PatternIndex(
|
|
SubSysInfo subSysInfo, eFovId fovId, string fovName, int patternId, int patternSubId = 0)
|
|
: this(subSysInfo.UnitId, subSysInfo.SubSysId, fovName, fovId, patternId, patternSubId) {
|
|
}
|
|
|
|
public PatternIndex(FovInfo fovInfo, string fovName, int patternId, int patternSubId = 0)
|
|
: this(fovInfo.UnitId, fovInfo.SubSysId, fovName, fovInfo.FovId, patternId, patternSubId) {
|
|
}
|
|
|
|
public PatternIndex(
|
|
eUnitId unitid, eSubSysId subSysId, string fovName, eFovId fovId, int patternId, int patternSubId = 0) {
|
|
|
|
UnitId = unitid;
|
|
SubSysId = subSysId;
|
|
FovName = fovName;
|
|
FovId = fovId;
|
|
CamId = VisionRecipeManager.GetCamRecipe(unitid, subSysId, fovId).CamId;
|
|
PatternId = patternId;
|
|
PatternSubId = patternSubId;
|
|
}
|
|
|
|
public string GetFullId() {
|
|
return ToString();
|
|
}
|
|
|
|
public string ToString() {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
return $"{(int)CamId}_{PatternId}_{PatternSubId}";
|
|
}
|
|
else {
|
|
return $"{(int)UnitId}_{(int)SubSysId}_{(int)FovId}_{PatternId}_{PatternSubId}";
|
|
}
|
|
}
|
|
|
|
public string GetPrefix() {
|
|
return GetPrefix(UnitId, SubSysId, FovId);
|
|
}
|
|
|
|
public static string GetPrefix(eUnitId unitId, eSubSysId subSysId, eFovId fovId) {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
var camId = VisionRecipeManager.GetCamRecipe(unitId, subSysId, fovId).CamId;
|
|
return $"{(int)camId}_";
|
|
}
|
|
else {
|
|
return $"{(int)unitId}_{(int)subSysId}_{(int)fovId}_";
|
|
}
|
|
}
|
|
|
|
public string GetPatternIdPrefix() {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
return $"{(int)CamId}_{PatternId}_";
|
|
}
|
|
else {
|
|
return $"{(int)UnitId}_{(int)SubSysId}_{(int)FovId}_{PatternId}_";
|
|
}
|
|
}
|
|
|
|
public string GetSubPatternDirectoryPath() {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
return Path.Combine(
|
|
((int)CamId).ToString(),
|
|
PatternId.ToString(),
|
|
PatternSubId.ToString());
|
|
}
|
|
else {
|
|
return Path.Combine(
|
|
((int)UnitId).ToString(),
|
|
((int)SubSysId).ToString(),
|
|
((int)FovId).ToString(),
|
|
PatternId.ToString(),
|
|
PatternSubId.ToString());
|
|
}
|
|
}
|
|
|
|
public string GetPatternDirectoryPath() {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
return Path.Combine(
|
|
((int)CamId).ToString(),
|
|
PatternId.ToString());
|
|
}
|
|
else {
|
|
return Path.Combine(
|
|
((int)UnitId).ToString(),
|
|
((int)SubSysId).ToString(),
|
|
((int)FovId).ToString(),
|
|
PatternId.ToString());
|
|
}
|
|
}
|
|
|
|
public object Clone() {
|
|
return new PatternIndex(UnitId, SubSysId, FovName, FovId, PatternId, PatternSubId);
|
|
}
|
|
|
|
public bool Equals(object obj) {
|
|
if (this.GetType() != obj.GetType()) {
|
|
return false;
|
|
}
|
|
|
|
return Equals(obj as PatternIndex);
|
|
}
|
|
|
|
public bool Equals(PatternIndex patternIndex) {
|
|
if (patternIndex is null) {
|
|
return false;
|
|
}
|
|
|
|
if (Object.ReferenceEquals(this, patternIndex)) {
|
|
return true;
|
|
}
|
|
|
|
return this.ToString() == patternIndex.ToString();
|
|
}
|
|
|
|
public int GetHashCode() {
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
return CamId.GetHashCode() ^
|
|
PatternId.GetHashCode() ^ PatternSubId.GetHashCode();
|
|
}
|
|
else {
|
|
return UnitId.GetHashCode() ^ SubSysId.GetHashCode() ^
|
|
FovId.GetHashCode() ^ PatternId.GetHashCode() ^ PatternSubId.GetHashCode();
|
|
}
|
|
}
|
|
}
|
|
}
|