dc/SRD/SRDConfiguration.cs
13118993771@163.com 5e9d0f1e2d EAP
2022-04-01 17:03:54 +08:00

264 lines
6.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#region << >>
/*----------------------------------------------------------------
* 创建者Hupe
* 创建时间2021/12/27 10:01:10
* 版本V1.0.0
* 描述:
*
* ----------------------------------------------------------------
* 修改人:
* 时间:
* 修改说明:
*
* 版本V1.0.1
*----------------------------------------------------------------*/
#endregion << >>
using Glorysoft.SECSwell;
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace ARI.EAP.HOST.SRD
{
/// <summary>
/// SRDConfiguration 的摘要说明
/// </summary>
[Serializable]
public class SRDConfiguration
{
public List<ECV> ecvs;
public List<SV> svs;
public List<DV> dvs;
public List<EVENT> events;
public SRDConfiguration()
{
ecvs = new List<ECV>();
svs = new List<SV>();
dvs = new List<DV>();
events = new List<EVENT>();
}
public SV findSV(string SVName)
{
foreach(SV sv in svs)
{
if (sv.name.Equals(SVName))
{
return sv;
}
}
return null;
}
public DV findDV(uint id)
{
foreach (DV dv in dvs)
{
if (dv.dvid == id)
{
return dv;
}
}
return null;
}
public SV findSV(uint id)
{
foreach (SV sv in svs)
{
if (sv.svid == id)
{
return sv;
}
}
return null;
}
public ECV findEC(string ECName)
{
foreach (ECV ecv in ecvs)
{
if (ecv.name.Equals(ECName))
{
return ecv;
}
}
return null;
}
public ECV findEC(uint ecid)
{
foreach (ECV ecv in ecvs)
{
if (ecv.ecid == ecid)
{
return ecv;
}
}
return null;
}
public EVENT findEvent(uint CEID)
{
foreach (EVENT even in events)
{
if (even.ceid == CEID)
{
return even;
}
}
return null;
}
public string tryGetSVOrDV(uint id)
{
foreach(SV sv in svs)
{
if(sv.svid == id)
{
return sv.name;
}
}
foreach(DV dv in dvs)
{
if(dv.dvid == id)
{
return dv.name;
}
}
return null;
}
public eSECS_FORMAT GetSECS_FORMAT(uint id)
{
string format = null;
foreach (SV sv in svs)
{
if (sv.svid == id)
{
format = sv.format;
break;
}
}
if(format == null)
{
foreach (DV dv in dvs)
{
if (dv.dvid == id)
{
format = dv.format;
break;
}
}
}
switch(format)
{
case ("B"):
return eSECS_FORMAT.BOOLEAN;
case ("U1"):
return eSECS_FORMAT.U1;
case ("I1"):
return eSECS_FORMAT.I1;
case ("U2"):
return eSECS_FORMAT.U2;
case ("I2"):
return eSECS_FORMAT.I2;
case ("U4"):
return eSECS_FORMAT.U4;
case ("I4"):
return eSECS_FORMAT.I4;
case ("U8"):
return eSECS_FORMAT.U8;
case ("I8"):
return eSECS_FORMAT.I8;
case ("F4"):
return eSECS_FORMAT.F4;
case ("F8"):
return eSECS_FORMAT.F8;
case ("A"):
return eSECS_FORMAT.ASCII;
case ("L"):
return eSECS_FORMAT.LIST;
default: return eSECS_FORMAT.ASCII;
}
}
}
[Serializable]
public class ECV
{
[XmlAttribute]
public uint ecid { get; set; }
[XmlAttribute]
public string name { get; set; }
[XmlAttribute]
public string format { get; set; }
[XmlAttribute]
public string min { get; set; }
[XmlAttribute]
public string max { get; set; }
[XmlAttribute]
public string defaultValue { get; set; }
[XmlAttribute]
public string description { get; set; }
}
[Serializable]
public class SV
{
[XmlAttribute]
public uint svid { get; set; }
[XmlAttribute]
public string name { get; set; }
[XmlAttribute]
public string format { get; set; }
[XmlAttribute]
public string min { get; set; }
[XmlAttribute]
public string max { get; set; }
[XmlAttribute]
public string defaultValue { get; set; }
[XmlAttribute]
public string description { get; set; }
}
[Serializable]
public class DV
{
[XmlAttribute]
public uint dvid { get; set; }
[XmlAttribute]
public string name { get; set; }
[XmlAttribute]
public string format { get; set; }
[XmlAttribute]
public string min { get; set; }
[XmlAttribute]
public string max { get; set; }
[XmlAttribute]
public string defaultValue { get; set; }
[XmlAttribute]
public string description { get; set; }
}
[Serializable]
public class EVENT
{
[XmlAttribute]
public uint ceid { get; set; }
[XmlAttribute]
public string name { get; set; }
[XmlAttribute]
public string description { get; set; }
[XmlAttribute]
public uint reportid { get; set; }
public List<uint> validVariables { get; set; }
public EVENT()
{
validVariables = new List<uint>();
}
}
}