- Radar Graph 추가
- Graph 클릭 이벤트 추가
This commit is contained in:
@@ -22,7 +22,21 @@ namespace friction
|
||||
public float m_fDiffByVel;
|
||||
}
|
||||
|
||||
public struct CHART
|
||||
public struct RADAR_CHART
|
||||
{
|
||||
public string m_strTable;
|
||||
public float m_fMin;
|
||||
public float m_fMax;
|
||||
public float m_fAvg;
|
||||
public int m_iCnt;
|
||||
|
||||
override public string ToString()
|
||||
{
|
||||
return string.Format("{0}: {1}-{2}-{3}", m_strTable, m_fMin, m_fAvg, m_fMax);
|
||||
}
|
||||
}
|
||||
|
||||
public struct TREND_CHART
|
||||
{
|
||||
public float HUMIDITY;
|
||||
public float TEMPERATURE;
|
||||
@@ -49,26 +63,17 @@ namespace friction
|
||||
List<string> m_SpringList = new List<string>();
|
||||
List<string> m_TableList = new List<string>();
|
||||
|
||||
Dictionary<string, string> m_ColumnMap = new Dictionary<string, string>();
|
||||
|
||||
public DataHandler()
|
||||
{
|
||||
m_ColumnMap["spring"] = "Material spring";
|
||||
m_ColumnMap["table"] = "material 2 table";
|
||||
m_ColumnMap["rpn"] = "Risk priority number";
|
||||
m_ColumnMap["force"] = "normal force";
|
||||
m_ColumnMap["temp"] = "Temperature";
|
||||
m_ColumnMap["humidity"] = "Relative humidity";
|
||||
m_ColumnMap["velocity"] = "Relative velocity";
|
||||
}
|
||||
|
||||
bool IsNumberColumn(string strColumn)
|
||||
{
|
||||
return (strColumn == m_ColumnMap["rpn"] ||
|
||||
strColumn == m_ColumnMap["force"] ||
|
||||
strColumn == m_ColumnMap["temp"] ||
|
||||
strColumn == m_ColumnMap["humidity"] ||
|
||||
strColumn == m_ColumnMap["velocity"]);
|
||||
return (strColumn == Config.COLUMN_NAME.RPN ||
|
||||
strColumn == Config.COLUMN_NAME.FORCE ||
|
||||
strColumn == Config.COLUMN_NAME.TEMP ||
|
||||
strColumn == Config.COLUMN_NAME.HUMIDITY ||
|
||||
strColumn == Config.COLUMN_NAME.VELOCITY);
|
||||
}
|
||||
|
||||
public void LoadData(string strFilePath)
|
||||
@@ -133,10 +138,10 @@ namespace friction
|
||||
|
||||
|
||||
m_SpringList = (from r in m_Data.AsEnumerable()
|
||||
select r[m_ColumnMap["spring"]]).Distinct().Cast<string>().ToList();
|
||||
select r[Config.COLUMN_NAME.SPRING]).Distinct().Cast<string>().ToList();
|
||||
|
||||
m_TableList = (from r in m_Data.AsEnumerable()
|
||||
select r[m_ColumnMap["table"]]).Distinct().Cast<string>().ToList();
|
||||
select r[Config.COLUMN_NAME.TABLE]).Distinct().Cast<string>().ToList();
|
||||
|
||||
m_ColumnsNames = (from c in m_Data.Columns.Cast<DataColumn>()
|
||||
select c.ColumnName).ToList<string>();
|
||||
@@ -178,19 +183,43 @@ namespace friction
|
||||
return m_strCurTable;
|
||||
}
|
||||
|
||||
public List<CHART> GetHumidityChart(string strSpring, string strTable)
|
||||
public List<RADAR_CHART> GetAvgAll(string strSpring)
|
||||
{
|
||||
string strQuery = string.Format("[{0}]='{1}' and [{2}]='{3}'", m_ColumnMap["spring"], strSpring, m_ColumnMap["table"], strTable);
|
||||
string strQuery = string.Format("[{0}]='{1}'", Config.COLUMN_NAME.SPRING, strSpring);
|
||||
DataRow[] rows = m_Data.Select(strQuery);
|
||||
|
||||
List<CHART> result = new List<CHART>();
|
||||
var group = rows
|
||||
.GroupBy(r => r[Config.COLUMN_NAME.TABLE]);
|
||||
|
||||
|
||||
List<RADAR_CHART> result = rows
|
||||
.GroupBy(r => r[Config.COLUMN_NAME.TABLE])
|
||||
.Select(t => new RADAR_CHART
|
||||
{
|
||||
m_strTable = t.Key.ToString(),
|
||||
m_iCnt = t.Count(),
|
||||
m_fMin = t.Min(k => (float)k[Config.COLUMN_NAME.RPN]),
|
||||
m_fMax = t.Max(k => (float)k[Config.COLUMN_NAME.RPN]),
|
||||
m_fAvg = t.Average(k => (float)k[Config.COLUMN_NAME.RPN])
|
||||
})
|
||||
.ToList<RADAR_CHART>();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<TREND_CHART> GetHumidityChart(string strSpring, string strTable)
|
||||
{
|
||||
string strQuery = string.Format("[{0}]='{1}' and [{2}]='{3}'", Config.COLUMN_NAME.SPRING, strSpring, Config.COLUMN_NAME.TABLE, strTable);
|
||||
DataRow[] rows = m_Data.Select(strQuery);
|
||||
|
||||
List<TREND_CHART> result = new List<TREND_CHART>();
|
||||
foreach(DataRow r in rows)
|
||||
{
|
||||
result.Add(new CHART
|
||||
result.Add(new TREND_CHART
|
||||
{
|
||||
HUMIDITY = (float)r[m_ColumnMap["humidity"]],
|
||||
TEMPERATURE = (float)r[m_ColumnMap["temp"]],
|
||||
RPN = (float)r[m_ColumnMap["rpn"]],
|
||||
HUMIDITY = (float)r[Config.COLUMN_NAME.HUMIDITY],
|
||||
TEMPERATURE = (float)r[Config.COLUMN_NAME.TEMP],
|
||||
RPN = (float)r[Config.COLUMN_NAME.RPN],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,8 +232,8 @@ namespace friction
|
||||
{
|
||||
// 각 그룹의 평균들의 표준편차
|
||||
var AvgOfGroup = rows
|
||||
.GroupBy(r => r[m_ColumnMap["force"]])
|
||||
.Select(t => t.Average(k => (float)k[m_ColumnMap["rpn"]]));
|
||||
.GroupBy(r => r[Config.COLUMN_NAME.FORCE])
|
||||
.Select(t => t.Average(k => (float)k[Config.COLUMN_NAME.RPN]));
|
||||
var Avg = AvgOfGroup.Average();
|
||||
var Squares = AvgOfGroup.Select(r => (r - Avg) * (r - Avg));
|
||||
var result = (float)Math.Sqrt(Squares.Average());
|
||||
@@ -215,14 +244,14 @@ namespace friction
|
||||
{
|
||||
CalcResult result = new CalcResult();
|
||||
|
||||
string strQuery = string.Format("[{0}]='{1}' and [{2}]='{3}'", m_ColumnMap["spring"], strSpring, m_ColumnMap["table"], strTable);
|
||||
string strQuery = string.Format("[{0}]='{1}' and [{2}]='{3}'", Config.COLUMN_NAME.SPRING, strSpring, Config.COLUMN_NAME.TABLE, strTable);
|
||||
DataRow[] rows = m_Data.Select(strQuery);
|
||||
|
||||
if(rows.Length > 0)
|
||||
{
|
||||
result.m_iCnt = rows.Length;
|
||||
result.m_fAvgRPN = rows.Average(r => (float)r[m_ColumnMap["rpn"]]);
|
||||
result.m_fStdRPN = rows.Average(r => (float)Math.Pow((float)r[m_ColumnMap["rpn"]] - result.m_fAvgRPN, 2));
|
||||
result.m_fAvgRPN = rows.Average(r => (float)r[Config.COLUMN_NAME.RPN]);
|
||||
result.m_fStdRPN = rows.Average(r => (float)Math.Pow((float)r[Config.COLUMN_NAME.RPN] - result.m_fAvgRPN, 2));
|
||||
result.m_fStdRPN = (float)Math.Sqrt(result.m_fStdRPN);
|
||||
|
||||
result.m_fDiffByForce = CalcDependency(rows, "force");
|
||||
|
||||
Reference in New Issue
Block a user