초기 커밋.

This commit is contained in:
2025-02-03 11:02:48 +09:00
parent a7d46f415f
commit fe9aa0799f
2334 changed files with 674826 additions and 0 deletions

135
DDUtilityApp/SECS/CEID.cs Normal file
View File

@@ -0,0 +1,135 @@
using JWH;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace DDUtilityApp.SECS
{
public class CEID
{
public static CEID CreateCEID(XmlNode node)
{
CEID ceid = new CEID();
try
{
foreach (XmlAttribute attribute in node.Attributes)
{
if (string.Compare(attribute.Name, "ID", true) == 0) ceid.ID = attribute.Value;
if (string.Compare(attribute.Name, "Name", true) == 0) ceid.Name = attribute.Value;
if (string.Compare(attribute.Name, "Description", true) == 0) ceid.Description = attribute.Value;
}
if (string.IsNullOrEmpty(ceid.ID))
{
XLogger.Instance.Warn($"CEID.ID 값이 존재하지 않습니다.");
return null;
}
int seq = 1;
foreach (XmlNode child in node.ChildNodes)
{
RPT rpt = RPT.CreateRPT(child);
if (rpt.Seq == -1) rpt.Seq = seq++;
else seq = rpt.Seq + 1;
if (rpt != null) ceid.RptDictionary.Add(rpt.ID, rpt);
}
return ceid;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return null;
}
}
#region [ Properties ] ------------------------------------------------
public string ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool Enable { get; set; } = true;
public Dictionary<string, RPT> RptDictionary { get; set; } = new Dictionary<string, RPT>();
public IEnumerable<RPT> RptCollection { get { return this.RptDictionary.Values; } }
#endregion
#region [ CEID ] ------------------------------------------------------
public CEID()
{
}
public CEID(string id, string name = "", string description = "", bool enable = true)
{
this.ID = id;
this.Name = name;
this.Description = description;
this.Enable = enable;
}
#endregion
#region [ Method ] ----------------------------------------------------
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append($"ID={this.ID}");
sb.Append($", Name={this.Name}");
if (!string.IsNullOrEmpty(this.Description)) sb.Append($", Description={this.Description}");
if (this.Enable == false) sb.Append($", Enable={this.Enable}");
StringBuilder sbRpt = new StringBuilder();
sbRpt.Append($"RPT[{this.RptCollection.Count()}] {{ ");
foreach (RPT rpt in this.RptCollection)
sbRpt.Append($"{rpt.ID} ");
sbRpt.Append($"}}");
return $"{sb.ToString()}, {sbRpt.ToString()}";
}
public string ToXml(string indent = "", bool inReport = true, bool inSvid = true)
{
StringBuilder sb = new StringBuilder();
if (inReport)
{
sb.Append($"{indent}<CEID ID='{this.ID}'");
sb.Append($" NAME='{this.Name}'");
sb.Append($" ENABLE='{this.Enable}' ");
if (!string.IsNullOrEmpty(this.Description)) sb.Append($" DESCRIPTION='{this.Description}'");
sb.AppendLine($">");
foreach (RPT rpt in this.RptCollection.OrderBy(x => x.Seq))
sb.AppendLine($"{indent}{rpt.ToXml($" ", inSvid)}");
sb.Append($"{indent}</CEID>");
}
else
{
sb.Append($"{indent}<CEID ID='{this.ID}'");
sb.Append($" NAME='{this.Name}'");
sb.Append($" ENABLE='{this.Enable}' ");
if (!string.IsNullOrEmpty(this.Description)) sb.Append($" DESCRIPTION='{this.Description}'");
sb.Append($" />");
}
return sb.ToString();
}
#endregion
}
}

134
DDUtilityApp/SECS/RPT.cs Normal file
View File

@@ -0,0 +1,134 @@
using JWH;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace DDUtilityApp.SECS
{
public class RPT
{
public static RPT CreateRPT(XmlNode node)
{
RPT rpt = new RPT();
try
{
foreach (XmlAttribute attribute in node.Attributes)
{
if (string.Compare(attribute.Name, "ID", true) == 0) rpt.ID = attribute.Value;
if (string.Compare(attribute.Name, "Seq", true) == 0) { int nSeq; int.TryParse(attribute.Value, out nSeq); rpt.Seq = nSeq; };
if (string.Compare(attribute.Name, "Name", true) == 0) rpt.Name = attribute.Value;
if (string.Compare(attribute.Name, "Description", true) == 0) rpt.Description = attribute.Value;
}
if (string.IsNullOrEmpty(rpt.ID))
{
XLogger.Instance.Warn($"RPT.ID 값이 존재하지 않습니다.");
return null;
}
int seq = 1;
foreach (XmlNode child in node.ChildNodes)
{
VID vid = VID.CreateVID(child);
if (vid.Seq == -1) vid.Seq = seq++;
else seq = rpt.Seq + 1;
if (vid != null) rpt.VidDictionary.Add(vid.ID, vid);
}
return rpt;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return null;
}
}
#region [ Properties ] ------------------------------------------------
public string ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Seq { get; set; } = -1;
public Dictionary<string, VID> VidDictionary { get; set; } = new Dictionary<string, VID>();
public IEnumerable<VID> VidCollection { get { return this.VidDictionary.Values; } }
#endregion
#region [ RPT ] -------------------------------------------------------
public RPT()
{
}
public RPT(string id, string name = "", string description = "")
{
this.ID = id;
this.Name = name;
this.Description = description;
}
#endregion
#region [ Method ] ----------------------------------------------------
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append($"ID={this.ID}");
sb.Append($", Name={this.Name}");
if (!string.IsNullOrEmpty(this.Description)) sb.Append($", Description={this.Description}");
StringBuilder sbVid = new StringBuilder();
sbVid.Append($"VID[{this.VidCollection.Count()}] {{ ");
foreach(VID vid in this.VidCollection)
sbVid.Append($"{vid.ID} ");
sbVid.Append($"}}");
return $"{sb.ToString()}, {sbVid.ToString()}";
}
public string ToXml(string indent = "", bool inSvid = true)
{
StringBuilder sb = new StringBuilder();
if (inSvid)
{
sb.Append($"{indent}<RPT ID='{this.ID}'");
if (!string.IsNullOrEmpty(this.Name)) sb.Append($" NAME='{this.Name}'");
if (!string.IsNullOrEmpty(this.Description)) sb.Append($" DESCRIPTION='{this.Description}'");
sb.AppendLine($">");
foreach (VID vid in this.VidCollection.OrderBy(x => x.Seq))
sb.AppendLine($"{indent}{vid.ToXml($" ", true)}");
sb.Append($"{indent}</RPT>");
}
else
{
sb.Append($"{indent}<RPT");
sb.Append($" SEQ ='{this.Seq}'");
sb.Append($" ID ='{this.ID}'");
if (!string.IsNullOrEmpty(this.Name)) sb.Append($" NAME='{this.Name}'");
sb.Append($" />");
}
return sb.ToString();
}
#endregion
}
}

View File

@@ -0,0 +1,272 @@
using EIS.Framework.Service.GEM;
using JWH;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml;
namespace DDUtilityApp.SECS
{
public class SECSDefine
{
#region [ Properties ] ------------------------------------------------
public string Name { get; set; }
public Dictionary<string, CEID> CeidDictionary { get; set; } = new Dictionary<string, CEID>();
public Dictionary<string, RPT> RptDictionary { get; set; } = new Dictionary<string, RPT>();
public Dictionary<string, VID> VidDictionary { get; set; } = new Dictionary<string, VID>();
public IEnumerable<CEID> CeidCollection { get { return CeidDictionary.Values; } }
public IEnumerable<RPT> RptCollection { get { return RptDictionary.Values; } }
public IEnumerable<VID> VidCollection { get { return VidDictionary.Values; } }
#endregion
#region [ SECSSetting ] -----------------------------------------------
public SECSDefine()
{
}
public SECSDefine(XmlNode node)
{
try
{
this.Name = node.Attributes["NAME"].Value;
foreach (XmlNode child in node.ChildNodes)
{
if (string.Compare(child.Name, "CEID_LIST", true) == 0) this.Load_CEID(child);
else if (string.Compare(child.Name, "RPT_LIST", true) == 0) this.Load_RPT(child);
}
this.VidDictionary = this.GetVidDictionary();
Trace.WriteLine($" <MODEL NAME='{this.Name}'>");
Trace.WriteLine($" <CEID_LIST>");
foreach (CEID ceid in this.CeidCollection.OrderBy(x => x.ID))
Trace.WriteLine($"{ceid.ToXml(" ")}");
Trace.WriteLine($" </CEID_LIST>");
Trace.WriteLine($" <RPT_LIST>");
foreach (RPT rpt in this.RptCollection.OrderBy(x => x.ID))
Trace.WriteLine($"{rpt.ToXml(" ")}");
Trace.WriteLine($" </RPT_LIST>");
Trace.WriteLine($" <VID_LIST>");
foreach (VID vid in this.VidCollection.OrderBy(x => x.ID))
Trace.WriteLine($"{vid.ToXml(" ")}");
Trace.WriteLine($" </VID_LIST>");
Trace.WriteLine($" </MODEL>");
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
}
}
public SECSDefine(EIS.Framework.Service.GEM.GEMSettings gem)
{
try
{
foreach (VIDInfo gemVid in gem.VIDList.Values)
{
VID vid = new VID(gemVid.ID, gemVid.Name, gemVid.Class.ToString(), "", gemVid.Description);
this.VidDictionary.Add(vid.ID, vid);
//Trace.WriteLine($"<VID ID='{gemVid.ID}' NAME='{gemVid.Name}' CLASS='{gemVid.Class}' DESCRIPTION='{gemVid.Description}' />");
}
foreach (RPTIDInfo gemRpt in gem.RPTIDList.Values)
{
RPT rpt = new RPT(gemRpt.ID, "", gemRpt.Description);
this.RptDictionary.Add(rpt.ID, rpt);
int vidSeq = 1;
foreach (string strVid in gemRpt.VIDList)
{
VID vid = this.VidDictionary[strVid].Clone();
vid.Seq = vidSeq++;
rpt.VidDictionary.Add(strVid, vid);
}
//Trace.WriteLine($"<RPT ID='{gemRpt.ID}'>");
//foreach (string vID in gemRpt.VIDList)
// Trace.WriteLine($" <VID ID='{vID}' />");
//Trace.WriteLine($"</RPT>");
}
foreach (CEIDInfo gemCeid in gem.CEIDList.Values)
{
CEID ceid = new CEID(gemCeid.ID, gemCeid.Name, gemCeid.Description, gemCeid.Enable);
this.CeidDictionary.Add(ceid.ID, ceid);
int rptSeq = 1;
foreach (string strRpt in gemCeid.RPTIDList)
{
RPT rpt = this.RptDictionary[strRpt].Clone();
rpt.Seq = rptSeq++;
ceid.RptDictionary.Add(rpt.ID, rpt);
}
//Trace.WriteLine($"<CEID ID='{gemCeid.ID}' NAME='{gemCeid.Name}' ENABLE='{gemCeid.Enable}' DESCRIPTION='{gemCeid.Description}'>");
//foreach (string rptID in gemCeid.RPTIDList)
// Trace.WriteLine($" <RPT ID='{rptID}' />");
//Trace.WriteLine($"</CEID>");
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
}
}
#endregion
#region [ Method ] ----------------------------------------------------
private void Load_CEID(XmlNode root)
{
try
{
CEID ceid = null;
foreach (XmlNode node in root.ChildNodes)
{
ceid = CEID.CreateCEID(node);
if (ceid != null)
{
if (this.CeidDictionary.ContainsKey(ceid.ID))
XLogger.Instance.Warn($"CEID.ID={ceid.ID} 가 이미 존재합니다.");
else
this.CeidDictionary.Add(ceid.ID, ceid);
}
else
{
XLogger.Instance.Warn($"CEID를 생성하지 못하였습니다.");
}
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
}
}
private void Load_RPT(XmlNode root)
{
try
{
RPT rpt = null;
foreach (XmlNode node in root.ChildNodes)
{
rpt = RPT.CreateRPT(node);
if (rpt != null)
{
if (this.RptDictionary.ContainsKey(rpt.ID))
XLogger.Instance.Warn($"RPT.ID={rpt.ID} 가 이미 존재합니다.");
else
this.RptDictionary.Add(rpt.ID, rpt);
}
else
{
XLogger.Instance.Warn($"RPT를 생성하지 못하였습니다.");
}
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
}
}
private Dictionary<string, VID> GetVidDictionary()
{
Dictionary<string, VID> dicVID = new Dictionary<string, VID>();
try
{
foreach (RPT rpt in this.RptCollection)
{
foreach (VID vid in rpt.VidCollection)
{
if (dicVID.ContainsKey(vid.ID)) continue;
dicVID.Add(vid.ID, vid);
}
}
return dicVID;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return dicVID;
}
}
public void SetInformation(SECSItem item)
{
try
{
if ($"S{item.Stream}F{item.Function}" == "S6F11")
{
if (item.ChildItems.Count != 3)
{
XLogger.Instance.Warn($"S6F11 하위 항목의 갯수가 일치하지 않습니다.");
return;
}
if (string.IsNullOrEmpty(item.ChildItems[0].Name)) item.ChildItems[0].Name = "DATAID";
if (string.IsNullOrEmpty(item.ChildItems[1].Name)) item.ChildItems[1].Name = "CEID";
if (!this.CeidDictionary.ContainsKey(item.ChildItems[1].Value))
{
XLogger.Instance.Warn($"CEID={item.ChildItems[1].Value}가 정의되지 않았습니다.");
return;
}
CEID ceid = this.CeidDictionary[item.ChildItems[1].Value];
item.ChildItems[1].Description = ceid.Name;
foreach (SECSItem itemRPT in item.ChildItems[2].ChildItems)
{
if (itemRPT.ChildItems.Count != 2)
{
XLogger.Instance.Warn($"CEID={item.ChildItems[1].Value}의 레포트 갯수가 일치하지 않습니다.");
continue;
}
if (string.IsNullOrEmpty(itemRPT.ChildItems[0].Name)) itemRPT.ChildItems[0].Name = "RPTID";
if (!this.RptDictionary.ContainsKey(itemRPT.ChildItems[0].Value))
{
XLogger.Instance.Warn($"RPTID={itemRPT.ChildItems[0].Value}가 정의되지 않았습니다.");
continue;
}
RPT rpt = this.RptDictionary[itemRPT.ChildItems[0].Value];
if (rpt.VidDictionary.Count != itemRPT.ChildItems[1].Count)
{
XLogger.Instance.Warn($"RPTID={itemRPT.ChildItems[0].Value}의 VID 갯수가 일치하지 않습니다.");
continue;
}
int index = 0;
foreach (VID vid in rpt.VidCollection)
{
if (string.IsNullOrEmpty(itemRPT.ChildItems[1][index].Name)) itemRPT.ChildItems[1][index].Name = vid.Name;
if (string.IsNullOrEmpty(itemRPT.ChildItems[1][index].Description)) itemRPT.ChildItems[1][index].Description = vid.Description;
index++;
}
}
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
}
}
#endregion
}
}

View File

@@ -0,0 +1,163 @@
using JWH;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DDUtilityApp.SECS
{
public class SECSItem : IList<SECSItem>
{
#region [ Propeties ] -------------------------------------------------
public string Stream { get; set; } = string.Empty;
public string Function { get; set; } = string.Empty;
public string ID { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Format { get; set; } = string.Empty;
public int Length { get; set; } = 0;
public string Value { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public SECSItem Parent { get; set; } = null;
public List<SECSItem> ChildItems { get; set; } = new List<SECSItem>();
#endregion
#region [ SECSItem ] -------------------------------------------------
public SECSItem()
{
}
public SECSItem(SECSItem parent)
{
this.Parent = parent;
}
public SECSItem(string stream, string function)
{
this.Stream = stream;
this.Function = function;
}
#endregion
#region [ Method ] ----------------------------------------------------
public override string ToString()
{
try
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat($"<{this.Format} ");
sb.AppendFormat($"[{this.Length}] ");
if (!string.IsNullOrEmpty(this.Name)) sb.AppendFormat($"{this.Name} ");
if (new string[] { "L" }.Contains(this.Format) == false) sb.AppendFormat($"'{this.Value}' ");
if (new string[] { "L" }.Contains(this.Format) == false) sb.AppendFormat($">");
return sb.ToString();
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return string.Empty;
}
}
public string ToFullString(string intendted = "")
{
try
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(intendted + this.ToString());
foreach(SECSItem item in this.ChildItems)
sb.AppendFormat(item.ToFullString(intendted + " "));
return sb.ToString();
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return string.Empty;
}
}
#endregion
#region [ IList<SECSItem> ] -------------------------------------------
public int Count => this.ChildItems.Count;
public bool IsReadOnly => throw new NotImplementedException();
public SECSItem this[int index] { get => this.ChildItems[index]; set => this.ChildItems[index] = value; }
public int IndexOf(SECSItem item)
{
throw new NotImplementedException();
}
public void Insert(int index, SECSItem item)
{
throw new NotImplementedException();
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
public void Add(SECSItem item)
{
item.Parent = this;
this.ChildItems.Add(item);
}
public void Clear()
{
throw new NotImplementedException();
}
public bool Contains(SECSItem item)
{
throw new NotImplementedException();
}
public void CopyTo(SECSItem[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public bool Remove(SECSItem item)
{
throw new NotImplementedException();
}
public IEnumerator<SECSItem> GetEnumerator()
{
return this.ChildItems.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@@ -0,0 +1,71 @@
using JWH;
using System;
using System.Collections;
using System.Collections.Generic;
namespace DDUtilityApp.SECS
{
static class SECSLib
{
public static Dictionary<string, Type> ItemFormat = new Dictionary<string, Type>()
{
{ "L", typeof(IList) }, { "A", typeof(string) }, { "B", typeof(byte) }, { "BOOL", typeof(bool) },
{ "J", typeof(int) }, { "F4", typeof(float) }, { "F8", typeof(float) },
{ "I1", typeof(Int16) }, { "I2", typeof(Int16) }, { "I4", typeof(Int32) }, { "I8", typeof(Int64) },
{ "U1", typeof(UInt16) }, { "U2", typeof(UInt16) }, { "U4", typeof(UInt32) }, { "U8", typeof(UInt64) },
};
public enum ItemType { None, Format, Length, Name, Value }
public static SECSItem[] GetItemByName(this SECSItem item, params string[] names)
{
List<SECSItem> items = new List<SECSItem>();
foreach (string name in names)
if (string.Compare(item.Name, name, true) == 0) items.Add(item);
foreach(SECSItem childItem in item)
items.AddRange(childItem.GetItemByName(names));
return items.ToArray();
}
public static SECSItem[] GetItemCPValue(this SECSItem item, params string[] names)
{
List<SECSItem> items = new List<SECSItem>();
if (item.ChildItems.Count != 2) return items.ToArray();
foreach (SECSItem childItem in item.ChildItems[1])
{
if (childItem.Format != "L") continue;
if (childItem.ChildItems.Count != 2) continue;
foreach(string name in names)
{
if (string.Compare(childItem.ChildItems[0].Value, name, true) == 0)
{
items.Add(childItem.ChildItems[1]);
break;
}
}
}
return items.ToArray();
}
public static SECSItem[] GetItemByID(this SECSItem item, string id)
{
List<SECSItem> items = new List<SECSItem>();
if (string.Compare(item.ID, id, true) == 0) items.Add(item);
foreach (SECSItem childItem in item)
items.AddRange(childItem.GetItemByID(id));
return items.ToArray();
}
}
}

115
DDUtilityApp/SECS/VID.cs Normal file
View File

@@ -0,0 +1,115 @@
using JWH;
using System;
using System.Text;
using System.Xml;
namespace DDUtilityApp.SECS
{
public class VID
{
public static VID CreateVID(XmlNode node)
{
VID vid = new VID();
try
{
foreach (XmlAttribute attribute in node.Attributes)
{
if (string.Compare(attribute.Name, "ID", true) == 0) vid.ID = attribute.Value;
if (string.Compare(attribute.Name, "Seq", true) == 0) { int seq; int.TryParse(attribute.Value, out seq); vid.Seq = seq; };
if (string.Compare(attribute.Name, "Name", true) == 0) vid.Name = attribute.Value;
if (string.Compare(attribute.Name, "Format", true) == 0) vid.Format = attribute.Value;
if (string.Compare(attribute.Name, "Length", true) == 0) { int length; int.TryParse(attribute.Value, out length); vid.Length = length; };
if (string.Compare(attribute.Name, "Description", true) == 0) vid.Description = attribute.Value;
}
if (string.IsNullOrEmpty(vid.ID))
{
XLogger.Instance.Warn($"VID.ID 값이 존재하지 않습니다.");
return null;
}
return vid;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return null;
}
}
#region [ Properties ] ------------------------------------------------
public string ID { get; set; }
public string Name { get; set; }
public string Class { get; set; } = "SVID";
public string Format { get; set; }
public int Length { get; set; } = 1;
public string Description { get; set; }
public int Seq { get; set; } = -1;
#endregion
#region [ VID ] -------------------------------------------------------
public VID()
{
}
public VID(string id, string name="", string vidClass="", string format="", string description="")
{
this.ID = id;
this.Name = name;
this.Class = vidClass;
this.Format = format;
this.Description = description;
}
#endregion
#region [ Method ] ----------------------------------------------------
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append($"ID={this.ID}");
sb.Append($", Name={this.Name}");
if (string.IsNullOrEmpty(this.Format) == false) sb.Append($", Format={this.Format}");
if (string.IsNullOrEmpty(this.Description) == false) sb.Append($", Description={this.Description}");
return $"{sb.ToString()}";
}
public string ToXml(string indent = "", bool inSeq = false)
{
StringBuilder sb = new StringBuilder();
if (inSeq) sb.Append($"{indent}<SVID SEQ='{this.Seq}'");
else sb.Append($"{indent}<VID");
sb.Append($" ID='{this.ID}'");
sb.Append($" NAME='{this.Name}'");
if (!string.IsNullOrEmpty(this.Format))
{
sb.Append($" FORMAT='{this.Format}'");
sb.Append($" LENGTH='{this.Length}'");
}
if (!string.IsNullOrEmpty(this.Description)) sb.Append($" DESCRIPTION='{this.Description}'");
sb.Append($" />");
return sb.ToString();
}
#endregion
}
}