File name
Commit message
Commit date
File name
Commit message
Commit date
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace SignusKHSVR
{
public partial class Form1 : Form
{
const int MAX_PROCESS = 10;
private Process[] m_ps = new Process[MAX_PROCESS];
private List<string> m_lstExe = new List<string>();
public Form1()
{
InitializeComponent();
}
private void ToolStripMenuItem_Close_Click(object sender, EventArgs e)
{
Program.PostMessage((IntPtr)0xffff, Program.messageQuit, 0, 0);
for (int i = 0; i < MAX_PROCESS; i++)
{
if (m_ps[i] != null)
{
m_ps[i].Kill();
m_ps[i] = null;
}
}
this.Close();
}
private string m_strUrl = "http://192.168.1.17:8080";
private void Form1_Load(object sender, EventArgs e)
{
string AppPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\"));
//string strChrome1 = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
//string strChrome2 = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
//string strChrome3 = "C:\\Users\\CUPC\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe";
//if (System.IO.File.Exists(strChrome1))
// this.m_lstExe.Add(strChrome1);
//else if (System.IO.File.Exists(strChrome2))
// this.m_lstExe.Add(strChrome2);
//else if (System.IO.File.Exists(strChrome3))
// this.m_lstExe.Add(strChrome3);
this.m_lstExe.Add(AppPath + string.Format("\\SignusServer.exe"));
this.m_lstExe.Add(AppPath + string.Format("\\KHPANEL.exe"));
timer1.Enabled = true;
timer1.Interval = 500;
timer_LogApi.Enabled = true;
timer_LogApi.Interval = 30 * 60 * 1000;
this.Visible = false; //창을 보이지 않게 한다.
this.ShowIcon = false; //작업표시줄에서 제거.
}
private int m_nPrevSec = -1;
private void timer1_Tick(object sender, EventArgs e)
{
DateTime dtNow = DateTime.Now;
if (m_nPrevSec == dtNow.Second) return;
m_nPrevSec = dtNow.Second;
if (m_nPrevSec % 10 == 0)
{
SaveLog();
SaveScaleLog();
}
UpdateProgram(m_nPrevSec % 10);
//Program.MoveFiles("C:\\EDIM\\Edge Advance 16P\\CSV", "C:\\EDIM\\Edge Advance 16P\\CSV1");
}
private void SaveLog()
{
U3Database db = new U3Database();
string strSQL = "";
strSQL += " SELECT a.MACH_CD, (a.REAL_DATA * b.VALUE_RATIO) as PV_VAL";
strSQL += " FROM T_HT_REAL_DATA a";
strSQL += " left join T_STD_MACH b on a.MACH_CD = b.MACH_CD";
strSQL += " where a.MACH_CD >= 'M0001' and a.MACH_CD <= 'M0030'";
DataTable dt = db.OpenSQL(strSQL);
Dictionary<string, float> m_dic = new Dictionary<string, float>();
foreach (DataRow dr in dt.Rows)
{
string s = U3Util.toStr(dr["MACH_CD"]);
float f = U3Util.toFloat(dr["PV_VAL"]);
m_dic[s] = f;
}
strSQL = "";
strSQL += " insert into T_TEMP_REAL_DATA_LOG (COMP_CD, REG_DT, M0001, M0002, M0003, M0004, M0005, M0006, M0007, M0008, M0009, M0010, M0011, M0012, M0013, M0014, M0015, M0016, M0017, M0018, M0019, M0020, M0021, M0022, M0023, M0024, M0025, M0026, M0027, M0028, M0029, M0030) values (";
strSQL += " '0001', ";
strSQL += " getdate(), ";
strSQL += " " + (m_dic.ContainsKey("M0001") ? m_dic["M0001"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0002") ? m_dic["M0002"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0003") ? m_dic["M0003"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0004") ? m_dic["M0004"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0005") ? m_dic["M0005"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0006") ? m_dic["M0006"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0007") ? m_dic["M0007"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0008") ? m_dic["M0008"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0009") ? m_dic["M0009"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0010") ? m_dic["M0010"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0011") ? m_dic["M0011"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0012") ? m_dic["M0012"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0013") ? m_dic["M0013"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0014") ? m_dic["M0014"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0015") ? m_dic["M0015"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0016") ? m_dic["M0016"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0017") ? m_dic["M0017"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0018") ? m_dic["M0018"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0019") ? m_dic["M0019"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0020") ? m_dic["M0020"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0021") ? m_dic["M0021"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0022") ? m_dic["M0022"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0023") ? m_dic["M0023"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0024") ? m_dic["M0024"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0025") ? m_dic["M0025"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0026") ? m_dic["M0026"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0027") ? m_dic["M0027"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0028") ? m_dic["M0028"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0029") ? m_dic["M0029"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("M0030") ? m_dic["M0030"].ToString() : "0") + ") ";
db.ExcuteSql(strSQL);
}
private void SaveScaleLog()
{
U3Database db = new U3Database();
string strSQL = "";
strSQL += " SELECT * FROM T_HT_REAL_SCALE ";
DataTable dt = db.OpenSQL(strSQL);
Dictionary<string, float> m_dic = new Dictionary<string, float>();
foreach (DataRow dr in dt.Rows)
{
string s = U3Util.toStr(dr["TOUCH_CD"]);
float f = U3Util.toFloat(dr["SCALE_VALUE"]);
if (s.Length == 0) continue;
m_dic[s] = f;
}
strSQL = "";
strSQL += " insert into T_TEMP_REAL_SCALE_LOG (COMP_CD, REG_DT, TP01, TP02, TP03, TP04, TP05, TP06, TP07, TP08, TP09, TP10) values (";
strSQL += " '0001', ";
strSQL += " getdate(), ";
strSQL += " " + (m_dic.ContainsKey("TP-01") ? m_dic["TP-01"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-02") ? m_dic["TP-02"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-03") ? m_dic["TP-03"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-04") ? m_dic["TP-04"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-05") ? m_dic["TP-05"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-06") ? m_dic["TP-06"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-07") ? m_dic["TP-07"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-08") ? m_dic["TP-08"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-09") ? m_dic["TP-09"].ToString() : "0") + ", ";
strSQL += " " + (m_dic.ContainsKey("TP-10") ? m_dic["TP-10"].ToString() : "0") + ") ";
db.ExcuteSql(strSQL);
}
public void UpdateProgram(int index)
{
if (index < 0) return;
if (index >= this.m_lstExe.Count()) return;
string AppExe = this.m_lstExe[index];
if (System.IO.File.Exists(AppExe) == false)
return;
string AppPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\"));
if (m_ps[index] == null)
{
m_ps[index] = new Process();
}
else
{
try
{
if (m_ps[index].HasExited)
{
m_ps[index].Close();
m_ps[index] = new System.Diagnostics.Process();
}
else
{
return;
}
}
catch
{
return;
}
}
if (AppExe.IndexOf("chrome") > 0)
{
m_ps[index].StartInfo.FileName = AppExe;
m_ps[index].StartInfo.WorkingDirectory = AppPath;
m_ps[index].StartInfo.Arguments = " -kiosk -fullscreen " + m_strUrl;
m_ps[index].StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
m_ps[index].Start();
return;
}
m_ps[index].StartInfo.FileName = AppExe;
m_ps[index].StartInfo.WorkingDirectory = AppPath;
m_ps[index].StartInfo.Arguments = "";
//m_ps[index].StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
m_ps[index].StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
m_ps[index].Start();
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Program.PostMessage((IntPtr)0xffff, Program.messageQuit, 0, 0);
for (int i = 0; i < MAX_PROCESS; i++)
{
if (m_ps[i] != null)
{
m_ps[i].Kill();
m_ps[i] = null;
}
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false; //창을 보이지 않게 한다.
this.ShowIcon = false; //작업표시줄에서 제거.
//m_notify.Visible = true; //트레이 아이콘을 표시한다.
}
}
private void timer_LogApi_Tick(object sender, EventArgs e)
{
SFLogApi log = new SFLogApi();
log.Run();
}
}
}