--- ModbusTest/FormModbus.cs
+++ ModbusTest/FormModbus.cs
... | ... | @@ -1359,13 +1359,31 @@ |
1359 | 1359 |
string oldValue = oldDic[item.Key]; |
1360 | 1360 |
if (item.Value != oldValue) |
1361 | 1361 |
{ |
1362 |
+ float pvVal2 = 0; |
|
1363 |
+ if (item.Value.Length == 0) |
|
1364 |
+ { |
|
1365 |
+ // N인 경우 PV_VAL2 에 차이값을 저장한다 |
|
1366 |
+ string sql4 = ""; |
|
1367 |
+ sql4 += " select* from T_HT_HIST_BASEOiL"; |
|
1368 |
+ sql4 += " where BASEOIL_CD = '" + item.Key + "' and HBT_CD = '" + oldValue + "'"; |
|
1369 |
+ sql4 += " order by idx desc"; |
|
1370 |
+ |
|
1371 |
+ DataTable dt4 = db.OpenSQL(sql4); |
|
1372 |
+ if (dt4 != null && dt4.Rows.Count > 0) |
|
1373 |
+ { |
|
1374 |
+ float fPrev = U3Util.toFloat(dt4.Rows[0]["PV_VAL"]); |
|
1375 |
+ pvVal2 = fPrev - pvVal; |
|
1376 |
+ } |
|
1377 |
+ } |
|
1378 |
+ |
|
1362 | 1379 |
string sql3 = ""; |
1363 |
- sql3 += " insert into T_HT_HIST_BASEOIL (COMP_CD,BASEOIL_CD,HBT_CD,ONOFF_YN,PV_VAL,MACH_NM,REG_DT) values ("; |
|
1380 |
+ sql3 += " insert into T_HT_HIST_BASEOIL (COMP_CD,BASEOIL_CD,HBT_CD,ONOFF_YN,PV_VAL,PV_VAL2,MACH_NM,REG_DT) values ("; |
|
1364 | 1381 |
sql3 += " '0001', "; |
1365 | 1382 |
sql3 += " '" + item.Key + "', "; |
1366 | 1383 |
sql3 += " '" + ((item.Value.Length > 0) ? item.Value : oldValue) + "', "; |
1367 | 1384 |
sql3 += " '" + ((item.Value.Length > 0) ? "Y" : "N") + "', "; |
1368 | 1385 |
sql3 += " " + pvVal.ToString() + ", "; |
1386 |
+ sql3 += " " + pvVal2.ToString() + ", "; |
|
1369 | 1387 |
sql3 += " '" + mach_nm + "', "; |
1370 | 1388 |
sql3 += " getdate() "; |
1371 | 1389 |
sql3 += " )"; |
--- SignusKHSVR/Form1.cs
+++ SignusKHSVR/Form1.cs
... | ... | @@ -74,11 +74,109 @@ |
74 | 74 |
if (m_nPrevSec == dtNow.Second) return; |
75 | 75 |
m_nPrevSec = dtNow.Second; |
76 | 76 |
|
77 |
+ if (m_nPrevSec % 10 == 0) |
|
78 |
+ { |
|
79 |
+ SaveLog(); |
|
80 |
+ SaveScaleLog(); |
|
81 |
+ } |
|
82 |
+ |
|
77 | 83 |
UpdateProgram(m_nPrevSec % 10); |
78 | 84 |
|
79 | 85 |
//Program.MoveFiles("C:\\EDIM\\Edge Advance 16P\\CSV", "C:\\EDIM\\Edge Advance 16P\\CSV1"); |
80 | 86 |
} |
81 | 87 |
|
88 |
+ private void SaveLog() |
|
89 |
+ { |
|
90 |
+ U3Database db = new U3Database(); |
|
91 |
+ string strSQL = ""; |
|
92 |
+ strSQL += " SELECT a.MACH_CD, (a.REAL_DATA * b.VALUE_RATIO) as PV_VAL"; |
|
93 |
+ strSQL += " FROM T_HT_REAL_DATA a"; |
|
94 |
+ strSQL += " left join T_STD_MACH b on a.MACH_CD = b.MACH_CD"; |
|
95 |
+ strSQL += " where a.MACH_CD >= 'M0001' and a.MACH_CD <= 'M0030'"; |
|
96 |
+ DataTable dt = db.OpenSQL(strSQL); |
|
97 |
+ |
|
98 |
+ Dictionary<string, float> m_dic = new Dictionary<string, float>(); |
|
99 |
+ |
|
100 |
+ foreach (DataRow dr in dt.Rows) |
|
101 |
+ { |
|
102 |
+ string s = U3Util.toStr(dr["MACH_CD"]); |
|
103 |
+ float f = U3Util.toFloat(dr["PV_VAL"]); |
|
104 |
+ m_dic[s] = f; |
|
105 |
+ } |
|
106 |
+ |
|
107 |
+ strSQL = ""; |
|
108 |
+ 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 ("; |
|
109 |
+ strSQL += " '0001', "; |
|
110 |
+ strSQL += " getdate(), "; |
|
111 |
+ strSQL += " " + (m_dic.ContainsKey("M0001") ? m_dic["M0001"].ToString() : "0") + ", "; |
|
112 |
+ strSQL += " " + (m_dic.ContainsKey("M0002") ? m_dic["M0002"].ToString() : "0") + ", "; |
|
113 |
+ strSQL += " " + (m_dic.ContainsKey("M0003") ? m_dic["M0003"].ToString() : "0") + ", "; |
|
114 |
+ strSQL += " " + (m_dic.ContainsKey("M0004") ? m_dic["M0004"].ToString() : "0") + ", "; |
|
115 |
+ strSQL += " " + (m_dic.ContainsKey("M0005") ? m_dic["M0005"].ToString() : "0") + ", "; |
|
116 |
+ strSQL += " " + (m_dic.ContainsKey("M0006") ? m_dic["M0006"].ToString() : "0") + ", "; |
|
117 |
+ strSQL += " " + (m_dic.ContainsKey("M0007") ? m_dic["M0007"].ToString() : "0") + ", "; |
|
118 |
+ strSQL += " " + (m_dic.ContainsKey("M0008") ? m_dic["M0008"].ToString() : "0") + ", "; |
|
119 |
+ strSQL += " " + (m_dic.ContainsKey("M0009") ? m_dic["M0009"].ToString() : "0") + ", "; |
|
120 |
+ strSQL += " " + (m_dic.ContainsKey("M0010") ? m_dic["M0010"].ToString() : "0") + ", "; |
|
121 |
+ strSQL += " " + (m_dic.ContainsKey("M0011") ? m_dic["M0011"].ToString() : "0") + ", "; |
|
122 |
+ strSQL += " " + (m_dic.ContainsKey("M0012") ? m_dic["M0012"].ToString() : "0") + ", "; |
|
123 |
+ strSQL += " " + (m_dic.ContainsKey("M0013") ? m_dic["M0013"].ToString() : "0") + ", "; |
|
124 |
+ strSQL += " " + (m_dic.ContainsKey("M0014") ? m_dic["M0014"].ToString() : "0") + ", "; |
|
125 |
+ strSQL += " " + (m_dic.ContainsKey("M0015") ? m_dic["M0015"].ToString() : "0") + ", "; |
|
126 |
+ strSQL += " " + (m_dic.ContainsKey("M0016") ? m_dic["M0016"].ToString() : "0") + ", "; |
|
127 |
+ strSQL += " " + (m_dic.ContainsKey("M0017") ? m_dic["M0017"].ToString() : "0") + ", "; |
|
128 |
+ strSQL += " " + (m_dic.ContainsKey("M0018") ? m_dic["M0018"].ToString() : "0") + ", "; |
|
129 |
+ strSQL += " " + (m_dic.ContainsKey("M0019") ? m_dic["M0019"].ToString() : "0") + ", "; |
|
130 |
+ strSQL += " " + (m_dic.ContainsKey("M0020") ? m_dic["M0020"].ToString() : "0") + ", "; |
|
131 |
+ strSQL += " " + (m_dic.ContainsKey("M0021") ? m_dic["M0021"].ToString() : "0") + ", "; |
|
132 |
+ strSQL += " " + (m_dic.ContainsKey("M0022") ? m_dic["M0022"].ToString() : "0") + ", "; |
|
133 |
+ strSQL += " " + (m_dic.ContainsKey("M0023") ? m_dic["M0023"].ToString() : "0") + ", "; |
|
134 |
+ strSQL += " " + (m_dic.ContainsKey("M0024") ? m_dic["M0024"].ToString() : "0") + ", "; |
|
135 |
+ strSQL += " " + (m_dic.ContainsKey("M0025") ? m_dic["M0025"].ToString() : "0") + ", "; |
|
136 |
+ strSQL += " " + (m_dic.ContainsKey("M0026") ? m_dic["M0026"].ToString() : "0") + ", "; |
|
137 |
+ strSQL += " " + (m_dic.ContainsKey("M0027") ? m_dic["M0027"].ToString() : "0") + ", "; |
|
138 |
+ strSQL += " " + (m_dic.ContainsKey("M0028") ? m_dic["M0028"].ToString() : "0") + ", "; |
|
139 |
+ strSQL += " " + (m_dic.ContainsKey("M0029") ? m_dic["M0029"].ToString() : "0") + ", "; |
|
140 |
+ strSQL += " " + (m_dic.ContainsKey("M0030") ? m_dic["M0030"].ToString() : "0") + ") "; |
|
141 |
+ |
|
142 |
+ db.ExcuteSql(strSQL); |
|
143 |
+ } |
|
144 |
+ |
|
145 |
+ private void SaveScaleLog() |
|
146 |
+ { |
|
147 |
+ U3Database db = new U3Database(); |
|
148 |
+ string strSQL = ""; |
|
149 |
+ strSQL += " SELECT * FROM T_HT_REAL_SCALE "; |
|
150 |
+ DataTable dt = db.OpenSQL(strSQL); |
|
151 |
+ |
|
152 |
+ Dictionary<string, float> m_dic = new Dictionary<string, float>(); |
|
153 |
+ |
|
154 |
+ foreach (DataRow dr in dt.Rows) |
|
155 |
+ { |
|
156 |
+ string s = U3Util.toStr(dr["TOUCH_CD"]); |
|
157 |
+ float f = U3Util.toFloat(dr["SCALE_VALUE"]); |
|
158 |
+ if (s.Length == 0) continue; |
|
159 |
+ m_dic[s] = f; |
|
160 |
+ } |
|
161 |
+ |
|
162 |
+ strSQL = ""; |
|
163 |
+ strSQL += " insert into T_TEMP_REAL_SCALE_LOG (COMP_CD, REG_DT, TP01, TP02, TP03, TP04, TP05, TP06, TP07, TP08, TP09, TP10) values ("; |
|
164 |
+ strSQL += " '0001', "; |
|
165 |
+ strSQL += " getdate(), "; |
|
166 |
+ strSQL += " " + (m_dic.ContainsKey("TP-01") ? m_dic["TP-01"].ToString() : "0") + ", "; |
|
167 |
+ strSQL += " " + (m_dic.ContainsKey("TP-02") ? m_dic["TP-02"].ToString() : "0") + ", "; |
|
168 |
+ strSQL += " " + (m_dic.ContainsKey("TP-03") ? m_dic["TP-03"].ToString() : "0") + ", "; |
|
169 |
+ strSQL += " " + (m_dic.ContainsKey("TP-04") ? m_dic["TP-04"].ToString() : "0") + ", "; |
|
170 |
+ strSQL += " " + (m_dic.ContainsKey("TP-05") ? m_dic["TP-05"].ToString() : "0") + ", "; |
|
171 |
+ strSQL += " " + (m_dic.ContainsKey("TP-06") ? m_dic["TP-06"].ToString() : "0") + ", "; |
|
172 |
+ strSQL += " " + (m_dic.ContainsKey("TP-07") ? m_dic["TP-07"].ToString() : "0") + ", "; |
|
173 |
+ strSQL += " " + (m_dic.ContainsKey("TP-08") ? m_dic["TP-08"].ToString() : "0") + ", "; |
|
174 |
+ strSQL += " " + (m_dic.ContainsKey("TP-09") ? m_dic["TP-09"].ToString() : "0") + ", "; |
|
175 |
+ strSQL += " " + (m_dic.ContainsKey("TP-10") ? m_dic["TP-10"].ToString() : "0") + ") "; |
|
176 |
+ |
|
177 |
+ db.ExcuteSql(strSQL); |
|
178 |
+ } |
|
179 |
+ |
|
82 | 180 |
public void UpdateProgram(int index) |
83 | 181 |
{ |
84 | 182 |
if (index < 0) return; |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?