- Congig 추가

- friction.exe -> squeak.exe
- 색상 변경
- analysis 기준 변경
This commit is contained in:
2017-06-21 02:41:29 +09:00
parent 9bf6a38f6d
commit 44841453e9
7 changed files with 271 additions and 77 deletions

120
Config.cs Normal file
View File

@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace friction
{
public static class Config
{
static string m_strPath = "";
static Config()
{
string strPrjName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
string strFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), strPrjName);
m_strPath = strFolder + "\\config.ini";
if (!Directory.Exists(strFolder))
Directory.CreateDirectory(strFolder);
Load();
}
public static void Init()
{
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
private static void Load()
{
StringBuilder temp = new StringBuilder(10240);
int iRes = GetPrivateProfileString("Option", "recent", "", temp, 10240, m_strPath);
if(temp.Length > 0)
{
string[] astrList = temp.ToString().Split(new string[] { "//" }, StringSplitOptions.None);
foreach (string strFile in astrList)
OPTION.AddRecentFile(strFile);
}
}
private static void Save()
{
WritePrivateProfileString("Option", "recent", OPTION.GetRecentAll(), m_strPath);
}
public static class OPTION
{
public static List<string> m_RecentList = new List<string>();
public static void AddRecentFile(string strPath)
{
if(m_RecentList.Find(s => s==strPath) != null)
m_RecentList.Remove(strPath);
m_RecentList.Add(strPath);
Save();
}
public static string GetRecentAll()
{
return string.Join("//", m_RecentList);
}
}
public static class ANALYSIS
{
public enum RISK
{
NO,
POTENTIAL,
HIGH
}
public enum DEPENDANCY
{
NO,
POTENTIAL,
HIGH,
NOT_ENNOUGH_DATA
}
public static RISK GetRisk(float fAvg)
{
if (fAvg <= 3)
return RISK.NO;
else if (fAvg <= 5)
return RISK.POTENTIAL;
else
return RISK.HIGH;
}
public static DEPENDANCY GetDependancy(float fStdev, int iTestCnt)
{
if (iTestCnt <= 3)
return DEPENDANCY.NOT_ENNOUGH_DATA;
else if (fStdev < 3.5f)
return DEPENDANCY.NO;
else if (fStdev < 5.5f)
return DEPENDANCY.POTENTIAL;
else
return DEPENDANCY.HIGH;
}
}
}
}

View File

@@ -37,6 +37,65 @@ namespace friction
Theme.Apply(menuStrip);
Theme.Apply(toolStripMain);
Theme.Apply(statusStrip);
Config.Init();
UpdateRecentFile();
}
void UpdateRecentFile()
{
recentToolStripMenuItem.DropDownItems.Clear();
foreach (string file in Enumerable.Reverse(Config.OPTION.m_RecentList))
{
ToolStripItem item = recentToolStripMenuItem.DropDownItems.Add(file);
item.BackColor = Theme.Backcolor;
item.ForeColor = Theme.Forecolor;
item.Click += RecentToolStripMenuItem_Click;
}
}
private void RecentToolStripMenuItem_Click(object sender, EventArgs e)
{
string strFile = ((ToolStripItem)sender).Text;
OpenDB(strFile);
}
private void OpenDB(string strFile=null)
{
if (strFile == null)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "엑셀 파일 (*.xlsx)|*.xlsx|엑셀 파일 (*.xls)|*.xls|전체|*";
DialogResult result = ofd.ShowDialog();
if (result == DialogResult.OK)
m_DBFileName = ofd.FileName;
}
else
{
m_DBFileName = strFile;
}
m_DataHandler.LoadData(m_DBFileName);
toolStripButtonTrendGraph.Enabled = false;
toolStripButtonRadarGraph.Enabled = true;
m_MaterialPanel.UpdateData(m_DataHandler);
OpenPanel(m_MaterialPanel);
m_ResultPanel.UpdateData(m_DataHandler);
OpenPanel(m_ResultPanel);
m_AnalysisPanel.Reset();
m_AnalysisPanel.UpdateData(m_DataHandler);
OpenPanel(m_AnalysisPanel);
toolStripStatusLabel.Text = m_DBFileName;
Config.OPTION.AddRecentFile(m_DBFileName);
UpdateRecentFile();
}
private void OpenPanel(DockContent panel)
@@ -58,11 +117,12 @@ namespace friction
#region Events from menu
private void openDBToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenDB();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void resultTableToolStripMenuItem_Click(object sender, EventArgs e)
@@ -90,29 +150,7 @@ namespace friction
#region Events from toolbox
private void toolStripButtonOpen_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "엑셀 파일 (*.xlsx)|*.xlsx|엑셀 파일 (*.xls)|*.xls|전체|*";
DialogResult result = ofd.ShowDialog();
if (result == DialogResult.OK)
{
m_DBFileName = ofd.FileName;
m_DataHandler.LoadData(m_DBFileName);
toolStripButtonTrendGraph.Enabled = false;
toolStripButtonRadarGraph.Enabled = true;
m_MaterialPanel.UpdateData(m_DataHandler);
OpenPanel(m_MaterialPanel);
m_ResultPanel.UpdateData(m_DataHandler);
OpenPanel(m_ResultPanel);
m_AnalysisPanel.Reset();
m_AnalysisPanel.UpdateData(m_DataHandler);
OpenPanel(m_AnalysisPanel);
toolStripStatusLabel.Text = m_DBFileName;
}
OpenDB();
}
private void toolStripButtonMaterial_Click(object sender, EventArgs e)

View File

@@ -39,7 +39,6 @@
this.lbInfo22 = new System.Windows.Forms.Label();
this.lbInfo23 = new System.Windows.Forms.Label();
this.lbInfo24 = new System.Windows.Forms.Label();
this.lbInfo25 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgvAnalysis)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
@@ -57,7 +56,7 @@
this.dgvAnalysis.Name = "dgvAnalysis";
this.dgvAnalysis.ReadOnly = true;
this.dgvAnalysis.RowTemplate.Height = 23;
this.dgvAnalysis.Size = new System.Drawing.Size(856, 543);
this.dgvAnalysis.Size = new System.Drawing.Size(856, 567);
this.dgvAnalysis.TabIndex = 0;
//
// tableLayoutPanel1
@@ -78,8 +77,7 @@
this.tableLayoutPanel1.Controls.Add(this.lbInfo22, 3, 1);
this.tableLayoutPanel1.Controls.Add(this.lbInfo23, 3, 2);
this.tableLayoutPanel1.Controls.Add(this.lbInfo24, 3, 3);
this.tableLayoutPanel1.Controls.Add(this.lbInfo25, 3, 4);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 561);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 585);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 5;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
@@ -87,7 +85,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(856, 86);
this.tableLayoutPanel1.Size = new System.Drawing.Size(856, 62);
this.tableLayoutPanel1.TabIndex = 1;
//
// label1
@@ -97,7 +95,7 @@
this.label1.Location = new System.Drawing.Point(3, 0);
this.label1.Name = "label1";
this.tableLayoutPanel1.SetRowSpan(this.label1, 5);
this.label1.Size = new System.Drawing.Size(165, 86);
this.label1.Size = new System.Drawing.Size(165, 62);
this.label1.TabIndex = 0;
this.label1.Text = "For smaller than 10 number of tests (marked red) results should be considered car" +
"efully";
@@ -116,8 +114,9 @@
// lbInfo11
//
this.lbInfo11.AutoSize = true;
this.lbInfo11.BackColor = System.Drawing.Color.YellowGreen;
this.lbInfo11.BackColor = System.Drawing.Color.LimeGreen;
this.lbInfo11.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo11.ForeColor = System.Drawing.Color.Silver;
this.lbInfo11.Location = new System.Drawing.Point(174, 0);
this.lbInfo11.Name = "lbInfo11";
this.lbInfo11.Size = new System.Drawing.Size(250, 12);
@@ -129,6 +128,7 @@
this.lbInfo12.AutoSize = true;
this.lbInfo12.BackColor = System.Drawing.Color.Gold;
this.lbInfo12.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo12.ForeColor = System.Drawing.Color.Silver;
this.lbInfo12.Location = new System.Drawing.Point(174, 12);
this.lbInfo12.Name = "lbInfo12";
this.lbInfo12.Size = new System.Drawing.Size(250, 12);
@@ -138,8 +138,9 @@
// lbInfo13
//
this.lbInfo13.AutoSize = true;
this.lbInfo13.BackColor = System.Drawing.Color.DarkOrange;
this.lbInfo13.BackColor = System.Drawing.Color.OrangeRed;
this.lbInfo13.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo13.ForeColor = System.Drawing.Color.Silver;
this.lbInfo13.Location = new System.Drawing.Point(174, 24);
this.lbInfo13.Name = "lbInfo13";
this.lbInfo13.Size = new System.Drawing.Size(250, 12);
@@ -149,8 +150,9 @@
// lbInfo21
//
this.lbInfo21.AutoSize = true;
this.lbInfo21.BackColor = System.Drawing.Color.YellowGreen;
this.lbInfo21.BackColor = System.Drawing.Color.LimeGreen;
this.lbInfo21.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo21.ForeColor = System.Drawing.Color.Silver;
this.lbInfo21.Location = new System.Drawing.Point(601, 0);
this.lbInfo21.Name = "lbInfo21";
this.lbInfo21.Size = new System.Drawing.Size(252, 12);
@@ -162,6 +164,7 @@
this.lbInfo22.AutoSize = true;
this.lbInfo22.BackColor = System.Drawing.Color.Gold;
this.lbInfo22.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo22.ForeColor = System.Drawing.Color.Silver;
this.lbInfo22.Location = new System.Drawing.Point(601, 12);
this.lbInfo22.Name = "lbInfo22";
this.lbInfo22.Size = new System.Drawing.Size(252, 12);
@@ -171,8 +174,9 @@
// lbInfo23
//
this.lbInfo23.AutoSize = true;
this.lbInfo23.BackColor = System.Drawing.Color.DarkOrange;
this.lbInfo23.BackColor = System.Drawing.Color.OrangeRed;
this.lbInfo23.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo23.ForeColor = System.Drawing.Color.Silver;
this.lbInfo23.Location = new System.Drawing.Point(601, 24);
this.lbInfo23.Name = "lbInfo23";
this.lbInfo23.Size = new System.Drawing.Size(252, 12);
@@ -184,23 +188,13 @@
this.lbInfo24.AutoSize = true;
this.lbInfo24.BackColor = System.Drawing.Color.DarkGray;
this.lbInfo24.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo24.ForeColor = System.Drawing.Color.Silver;
this.lbInfo24.Location = new System.Drawing.Point(601, 36);
this.lbInfo24.Name = "lbInfo24";
this.lbInfo24.Size = new System.Drawing.Size(252, 12);
this.lbInfo24.TabIndex = 2;
this.lbInfo24.Text = "Not Enough Data";
//
// lbInfo25
//
this.lbInfo25.AutoSize = true;
this.lbInfo25.BackColor = System.Drawing.Color.Snow;
this.lbInfo25.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbInfo25.Location = new System.Drawing.Point(601, 48);
this.lbInfo25.Name = "lbInfo25";
this.lbInfo25.Size = new System.Drawing.Size(252, 38);
this.lbInfo25.TabIndex = 2;
this.lbInfo25.Text = "Not Enough Data";
//
// PanelAnalysis
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -234,6 +228,5 @@
private System.Windows.Forms.Label lbInfo22;
private System.Windows.Forms.Label lbInfo23;
private System.Windows.Forms.Label lbInfo24;
private System.Windows.Forms.Label lbInfo25;
}
}

View File

@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -26,7 +27,17 @@ namespace friction
Theme.Apply(this);
Theme.Apply(dgvAnalysis);
lbInfo25.ForeColor = Theme.Backcolor;
typeof(DataGridView).InvokeMember("DoubleBuffered",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
null, dgvAnalysis, new object[] { true });
lbInfo11.BackColor = Theme.Green;
lbInfo12.BackColor = Theme.Yellow;
lbInfo13.BackColor = Theme.Red;
lbInfo21.BackColor = Theme.Green;
lbInfo22.BackColor = Theme.Yellow;
lbInfo23.BackColor = Theme.Red;
lbInfo24.BackColor = Theme.Gray;
}
public void Reset()
@@ -34,6 +45,27 @@ namespace friction
m_CurSpring = "";
}
private Color GetDependancyColor(float fValue, int iCnt)
{
Config.ANALYSIS.DEPENDANCY Type = Config.ANALYSIS.GetDependancy(fValue, iCnt);
switch(Type)
{
case Config.ANALYSIS.DEPENDANCY.NO:
return Theme.Green;
case Config.ANALYSIS.DEPENDANCY.POTENTIAL:
return Theme.Yellow;
case Config.ANALYSIS.DEPENDANCY.HIGH:
return Theme.Red;
case Config.ANALYSIS.DEPENDANCY.NOT_ENNOUGH_DATA:
return Theme.Gray;
}
return Theme.White;
}
public void UpdateData(DataHandler data)
{
string strSpring = data.GetCurSpring();
@@ -44,53 +76,57 @@ namespace friction
dgvAnalysis.Columns.Clear();
dgvAnalysis.Rows.Clear();
dgvAnalysis.DefaultCellStyle.Format = "N2";
dgvAnalysis.Columns.Add("chTable", "Table");
dgvAnalysis.Columns.Add("chNoTest", "No. of Tests");
dgvAnalysis.Columns.Add("chAvg", "Average RPN");
dgvAnalysis.Columns.Add("chSTD", "stdev RPN");
dgvAnalysis.Columns.Add("chSTD", "Standard Deviation");
dgvAnalysis.Columns.Add("chForce", "Normal Force");
dgvAnalysis.Columns.Add("chTemp", "Temperature");
dgvAnalysis.Columns.Add("chHumi", "Rel. Humidity");
dgvAnalysis.Columns.Add("chVel", "Velocity");
foreach(string strTable in data.GetTableList())
foreach (string strTable in data.GetTableList())
{
DataHandler.CalcResult result = data.GetCalc(strSpring, strTable);
int iIdx = dgvAnalysis.Rows.Add(strTable, result.m_iCnt, result.m_fAvgRPN, result.m_fStdRPN, result.m_fDiffByForce, result.m_fDiffByTemp, result.m_fDiffByHumid, result.m_fDiffByVel);
if(result.m_iCnt <= 5)
Config.ANALYSIS.RISK RiskType = Config.ANALYSIS.GetRisk(result.m_fAvgRPN);
Config.ANALYSIS.DEPENDANCY DependancyType = Config.ANALYSIS.GetDependancy(result.m_fStdRPN, result.m_iCnt);
if(DependancyType == Config.ANALYSIS.DEPENDANCY.NOT_ENNOUGH_DATA)
{
for (int i = 2; i <= 7; i++)
{
dgvAnalysis.Rows[iIdx].Cells[i].Style.BackColor = Theme.White;
dgvAnalysis.Rows[iIdx].Cells[i].Style.BackColor = Theme.Gray;
dgvAnalysis.Rows[iIdx].Cells[i].Style.ForeColor = Theme.Backcolor;
}
}
else if(result.m_iCnt <= 10)
{
for (int i = 2; i <= 7; i++)
{
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Gray;
dgvAnalysis.Rows[iIdx].Cells[2].Style.ForeColor = Theme.Backcolor;
}
}
else
{
if (result.m_fAvgRPN <= 3)
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Green;
else if (result.m_fAvgRPN <= 5)
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Yellow;
else
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Red;
switch (RiskType)
{
case Config.ANALYSIS.RISK.NO:
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Green;
break;
dgvAnalysis.Rows[iIdx].Cells[3].Style.BackColor = (result.m_fStdRPN <= 1.5) ? Theme.Green : Theme.Red;
dgvAnalysis.Rows[iIdx].Cells[4].Style.BackColor = (result.m_fDiffByForce <= 1.5) ? Theme.Green : Theme.Red;
dgvAnalysis.Rows[iIdx].Cells[5].Style.BackColor = (result.m_fDiffByTemp <= 1.5) ? Theme.Green : Theme.Red;
dgvAnalysis.Rows[iIdx].Cells[6].Style.BackColor = (result.m_fDiffByHumid <= 1.5) ? Theme.Green : Theme.Red;
dgvAnalysis.Rows[iIdx].Cells[7].Style.BackColor = (result.m_fDiffByVel <= 1.5) ? Theme.Green : Theme.Red;
case Config.ANALYSIS.RISK.POTENTIAL:
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Yellow;
break;
case Config.ANALYSIS.RISK.HIGH:
dgvAnalysis.Rows[iIdx].Cells[2].Style.BackColor = Theme.Red;
break;
}
dgvAnalysis.Rows[iIdx].Cells[3].Style.BackColor = GetDependancyColor(result.m_fStdRPN, result.m_iCnt);
dgvAnalysis.Rows[iIdx].Cells[4].Style.BackColor = GetDependancyColor(result.m_fDiffByForce, result.m_iCnt);
dgvAnalysis.Rows[iIdx].Cells[5].Style.BackColor = GetDependancyColor(result.m_fDiffByTemp, result.m_iCnt);
dgvAnalysis.Rows[iIdx].Cells[6].Style.BackColor = GetDependancyColor(result.m_fDiffByHumid, result.m_iCnt);
dgvAnalysis.Rows[iIdx].Cells[7].Style.BackColor = GetDependancyColor(result.m_fDiffByVel, result.m_iCnt);
}
}

View File

@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -25,6 +26,9 @@ namespace friction
Theme.Apply(dgvData);
Theme.Apply(lvColumn);
typeof(DataGridView).InvokeMember("DoubleBuffered",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
null, dgvData, new object[] { true });
dgvData.CellFormatting += DgvData_CellFormatting;
}
@@ -45,6 +49,7 @@ namespace friction
public void UpdateData(DataHandler data)
{
dgvData.DataSource = data.GetData();
dgvData.DefaultCellStyle.Format = "N2";
Dictionary<string, bool> CacheChecked = new Dictionary<string, bool>();
foreach (ListViewItem item in lvColumn.Items)

View File

@@ -12,12 +12,12 @@ namespace friction
{
public static Color Backcolor = Color.FromArgb(255, 45, 45, 48);
public static Color BackColorTrans = Color.FromArgb(230, 45, 45, 48);
public static Color Forecolor = Color.FromArgb(255, 241, 241, 241);
public static Color Forecolor = Color.FromArgb(255, 235, 235, 235);
public static Color Green = Color.YellowGreen;
public static Color Yellow = Color.Gold;
public static Color Red = Color.DarkOrange;
public static Color Green = Color.LimeGreen;
//public static Color Yellow = Color.Gold;
public static Color Yellow = Color.FromArgb(255, 255, 165, 0);
public static Color Red = Color.OrangeRed;
public static Color Gray = Color.DarkGray;
public static Color White = Color.Snow;
@@ -29,6 +29,7 @@ namespace friction
public static void Apply(DataGridView ctrl)
{
ctrl.BackgroundColor = Backcolor;
ctrl.DefaultCellStyle.BackColor = Backcolor;
ctrl.DefaultCellStyle.ForeColor = Forecolor;
ctrl.EnableHeadersVisualStyles = false;

View File

@@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>friction</RootNamespace>
<AssemblyName>friction</AssemblyName>
<AssemblyName>squeak</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -70,6 +70,7 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="DataHandler.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>