/// <summary> /// 讀取Ini中Weight Config區塊相關設定 /// </summary> /// <param name="IniFile"></param> private static void funSetWT(clsIniFile IniFile) { string strSection = "WT Config"; string strKey = string.Empty; string strValues = string.Empty; strKey = "WTQty"; clsSystem.gintWTQty = IniFile.funReadValue(strSection, strKey, 3); strKey = "WTID"; clsSystem.gstrarrWTID = IniFile.funReadValue(strSection, strKey, "").Split(','); strKey = "WTPort"; clsSystem.gstrarrWTPortName = IniFile.funReadValue(strSection, strKey, "").Split(','); for (int intCount = 0; intCount < clsSystem.gintWTQty; intCount++) { clsWTSerialPort WTSerialPort = new clsWTSerialPort(clsSystem.gstrarrWTID[intCount], clsSystem.gstrarrWTPortName[intCount]); clsSystem.glstWTMap.Add(WTSerialPort); } }
private void funGetWTInfo() { string strSQL = string.Empty; string strEM = string.Empty; DataTable objDataTable = new DataTable(); try { strSQL = "SELECT * FROM IN_Weight WHERE Weight_NO IN ('" + string.Join("', '", clsSystem.gstrarrWTID) + "')"; if (clsSystem.gobjDB.funGetDT(strSQL, ref objDataTable, ref strEM) == ErrDef.ProcSuccess) { for (int intCount = 0; intCount < objDataTable.Rows.Count; intCount++) { string strWTNo = objDataTable.Rows[intCount]["Weight_NO"].ToString(); string strWTSts = objDataTable.Rows[intCount]["Weight_STS"].ToString(); string strWTID = objDataTable.Rows[intCount]["Weight_DATA"].ToString(); if (clsSystem.glstWTMap.Exists(WT => WT.WTNo == strWTNo)) { clsWTSerialPort WTSerialPort = clsSystem.glstWTMap.Find(WT => WT.WTNo == strWTNo); if (tlpWT.Controls.ContainsKey("lblWTSts1_" + strWTNo)) { Label objLabel = (Label)tlpWT.Controls["lblWTSts1_" + strWTNo]; funShowConnect(WTSerialPort.IsOpen, objLabel); } if (tlpWT.Controls.ContainsKey("lblWTReadID_" + strWTNo)) { Label objLabel = (Label)tlpWT.Controls["lblWTReadID_" + strWTNo]; objLabel.Text = strWTID; if (tlpWT.Controls.ContainsKey("lblWTReadingTime_" + strWTNo) && strWTID != "n/a") { Label objLabel2 = (Label)tlpWT.Controls["lblWTReadingTime_" + strWTNo]; objLabel2.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); } }//lblWTSts2_ if (tlpWT.Controls.ContainsKey("lblWTSts2_" + strWTNo)) { Label objLabel = (Label)tlpWT.Controls["lblWTSts2_" + strWTNo]; funShowWTSts(strWTSts, objLabel); if (strWTSts == cstrWTReading) { WTSerialPort.DiscardOutBuffer(); WTSerialPort.DiscardInBuffer(); WTSerialPort.Write("RW" + "\r\n"); } } } } } } catch (Exception ex) { var varObject = MethodBase.GetCurrentMethod(); clsSystem.funWriteExceptionLog(varObject.DeclaringType.FullName, varObject.Name, ex.Message); } finally { if (objDataTable != null) { objDataTable.Clear(); objDataTable.Dispose(); objDataTable = null; } } }