-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAodData.cs
101 lines (92 loc) · 3.7 KB
/
AodData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Reflection;
using static ZenStates.Core.AOD;
namespace ZenStates.Core
{
// [Serializable]
public class AodData
{
public int SMTEn { get; set; }
public int MemClk { get; set; }
public int Tcl { get; set; }
public int Trcd { get; set; }
public int TrcdWr { get; set; }
public int TrcdRd { get; set; }
public int Trp { get; set; }
public int Tras { get; set; }
public int Trc { get; set; }
public int Twr { get; set; }
public int Trfc { get; set; }
public int Trfc2 { get; set; }
public int Trfcsb { get; set; }
public int Trtp { get; set; }
public int TrrdL { get; set; }
public int TrrdS { get; set; }
public int Tfaw { get; set; }
public int TwtrL { get; set; }
public int TwtrS { get; set; }
public int TrdrdScL { get; set; }
public int TrdrdSc { get; set; }
public int TrdrdSd { get; set; }
public int TrdrdDd { get; set; }
public int TwrwrScL { get; set; }
public int TwrwrSc { get; set; }
public int TwrwrSd { get; set; }
public int TwrwrDd { get; set; }
public int Twrrd { get; set; }
public int Trdwr { get; set; }
public CadBusDrvStren CadBusDrvStren { get; set; }
public ProcDataDrvStren ProcDataDrvStren { get; set; }
public ProcOdt ProcOdt { get; set; }
public ProcOdt ProcOdtPullUp { get; set; }
public ProcOdt ProcOdtPullDown { get; set; }
public ProcOdtImpedance ProcCaOdt { get; set; }
public ProcOdtImpedance ProcCkOdt { get; set; }
public ProcOdtImpedance ProcDqOdt { get; set; }
public ProcOdtImpedance ProcDqsOdt { get; set; }
public DramDataDrvStren DramDataDrvStren { get; set; }
public Rtt RttNomWr { get; set; }
public Rtt RttNomRd { get; set; }
public Rtt RttWr { get; set; }
public Rtt RttPark { get; set; }
public Rtt RttParkDqs { get; set; }
public Voltage MemVddio { get; set; }
public Voltage MemVddq { get; set; }
public Voltage MemVpp { get; set; }
public Voltage ApuVddio { get; set; }
public static AodData CreateFromByteArray(byte[] byteArray, Dictionary<string, int> fieldDictionary)
{
AodData data = new AodData();
if (byteArray == null) return data;
foreach (var entry in fieldDictionary)
{
try
{
string fieldName = entry.Key;
int fieldOffset = entry.Value;
PropertyInfo property = typeof(AodData).GetProperty(fieldName);
if (fieldOffset > -1 && fieldOffset <= byteArray.Length - sizeof(int) && property != null)
{
Type propertyType = property.PropertyType;
object fieldValue;
if (propertyType.IsClass && propertyType != typeof(string))
{
fieldValue = Activator.CreateInstance(propertyType, BitConverter.ToInt32(byteArray, fieldOffset));
}
else
{
fieldValue = Convert.ChangeType(BitConverter.ToInt32(byteArray, fieldOffset), propertyType);
}
property.SetValue(data, fieldValue, null);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString(), e.Message);
}
}
return data;
}
}
}