--- ModbusTest/FormModbus.cs
+++ ModbusTest/FormModbus.cs
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 |
SerialConnectionSingleton.Instance().DataBits = 8; |
43 | 43 |
SerialConnectionSingleton.Instance().SlaveNo = 1; |
44 | 44 |
|
45 |
- UpdateBaseoilSwitch(); |
|
45 |
+ //UpdateBaseoilSwitch(); |
|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
|
... | ... | @@ -1239,15 +1239,30 @@ |
1239 | 1239 |
Dictionary<string, string> oldDic = new Dictionary<string, string>(); |
1240 | 1240 |
strSQL = "select * from T_HT_REAL_BASEOIL"; |
1241 | 1241 |
DataTable dtOld = db.OpenSQL(strSQL); |
1242 |
- foreach(DataRow drOld in dtOld.Rows) |
|
1242 |
+ foreach (DataRow drOld in dtOld.Rows) |
|
1243 | 1243 |
{ |
1244 | 1244 |
string strKey = U3Util.toStr(drOld["BASEOIL_CD"]); |
1245 | 1245 |
string strVal = U3Util.toStr(drOld["HBT_CD"]); |
1246 |
- oldDic.Add(strKey, strVal); |
|
1246 |
+ if (oldDic.ContainsKey(strKey) == false) |
|
1247 |
+ oldDic.Add(strKey, strVal); |
|
1248 |
+ } |
|
1249 |
+ |
|
1250 |
+ Dictionary<string, float> pvDic = new Dictionary<string, float>(); |
|
1251 |
+ strSQL = ""; |
|
1252 |
+ strSQL += " SELECT a.MACH_CD, (REAL_DATA * VALUE_RATIO) as PV_VAL, MACH_NM, REMARK04"; |
|
1253 |
+ strSQL += " FROM T_HT_REAL_DATA a"; |
|
1254 |
+ strSQL += " left join T_STD_MACH b on a.MACH_CD = b.MACH_CD"; |
|
1255 |
+ strSQL += " where b.REMARK04 is not null"; |
|
1256 |
+ DataTable dtPv = db.OpenSQL(strSQL); |
|
1257 |
+ foreach (DataRow drPv in dtPv.Rows) |
|
1258 |
+ { |
|
1259 |
+ string strKey = U3Util.toStr(drPv["REMARK04"]); |
|
1260 |
+ float fVal = U3Util.toFloat(drPv["PV_VAL"]); |
|
1261 |
+ if (pvDic.ContainsKey(strKey) == false) |
|
1262 |
+ pvDic.Add(strKey, fVal); |
|
1247 | 1263 |
} |
1248 | 1264 |
|
1249 | 1265 |
Dictionary<string, string> myDictionary = new Dictionary<string, string>(); |
1250 |
- |
|
1251 | 1266 |
strSQL = "select isnull(REMARK02, '') as REMARK02 from T_STD_MACH where MACH_TYPE = '05' group by REMARK02"; |
1252 | 1267 |
DataTable dt = db.OpenSQL(strSQL); |
1253 | 1268 |
foreach (DataRow dr in dt.Rows) |
... | ... | @@ -1283,14 +1298,22 @@ |
1283 | 1298 |
|
1284 | 1299 |
if (oldDic.ContainsKey(item.Key)) |
1285 | 1300 |
{ |
1301 |
+ float pvVal = 0; |
|
1302 |
+ if (pvDic.ContainsKey(item.Key)) |
|
1303 |
+ { |
|
1304 |
+ pvVal = pvDic[item.Key]; |
|
1305 |
+ } |
|
1306 |
+ |
|
1286 | 1307 |
string oldValue = oldDic[item.Key]; |
1287 |
- if (item.Value.Length > 0 && item.Value != oldValue) |
|
1308 |
+ if (item.Value != oldValue) |
|
1288 | 1309 |
{ |
1289 | 1310 |
string sql3 = ""; |
1290 |
- sql3 += " insert into T_HT_HIST_BASEOIL (COMP_CD,BASEOIL_CD,HBT_CD,REG_DT) values ("; |
|
1311 |
+ sql3 += " insert into T_HT_HIST_BASEOIL (COMP_CD,BASEOIL_CD,HBT_CD,ONOFF_YN,PV_VAL,REG_DT) values ("; |
|
1291 | 1312 |
sql3 += " '0001', "; |
1292 | 1313 |
sql3 += " '" + item.Key + "', "; |
1293 |
- sql3 += " '" + item.Value + "', "; |
|
1314 |
+ sql3 += " '" + ((item.Value.Length > 0) ? item.Value : oldValue) + "', "; |
|
1315 |
+ sql3 += " '" + ((item.Value.Length > 0) ? "Y" : "N") + "', "; |
|
1316 |
+ sql3 += " " + pvVal.ToString() + ", "; |
|
1294 | 1317 |
sql3 += " getdate() "; |
1295 | 1318 |
sql3 += " )"; |
1296 | 1319 |
sql3 += " "; |
--- ModbusTest/U3Config.cs
+++ ModbusTest/U3Config.cs
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 |
{ |
46 | 46 |
Load(); |
47 | 47 |
|
48 |
- // 테스트용 서버 |
|
48 |
+ // 테스트용 개발 서버 |
|
49 | 49 |
//m_SqlConnStr = "Provider=SQLOLEDB.1;Password=tlrmsjtm~1@3;Persist Security Info=False;User ID=sa;Initial Catalog=U3SMES;Data Source=signus-sf1.koreacentral.cloudapp.azure.com,14443"; |
50 | 50 |
|
51 | 51 |
// 한국하우톤 현장 서버 |
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?