bool IPIZ.Open() { bool ret = true; try { string sErrMsg = string.Empty; string sIdInfo = string.Empty; StringBuilder sIdn = new StringBuilder(1024); StringBuilder sErrorMessage = new StringBuilder(1024); int iError; ////////////////////////////////////////////////////////////////////////// // connect to the controller over RS-232 (COM port 1, baudrate 115200). // ////////////////////////////////////////////////////////////////////////// m_iControllerId = PI_GCS.ConnectRS232(sysCfg.PI_ComPort_Num, sysCfg.PI_ComBaudRate); if (m_iControllerId < 0) { iError = PI_GCS.GetError(m_iControllerId); PI_GCS.TranslateError(iError, sErrorMessage, sErrorMessage.Capacity); sErrMsg = "ERROR From ConnectRS232 " + iError.ToString() + ": " + sErrorMessage.ToString(); ret = false; } else { //////////////////////////////////// // Get the IDeNtification string. // //////////////////////////////////// if (PI_GCS.qIDN(m_iControllerId, sIdn, sIdn.Capacity) == 0) { iError = PI_GCS.GetError(m_iControllerId); PI_GCS.TranslateError(iError, sErrorMessage, sErrorMessage.Capacity); sErrMsg = "ERROR From IDN? " + iError.ToString() + ": " + sErrorMessage.ToString(); ret = false; } else { sIdInfo = sIdn.ToString(); } } } catch (Exception ex) { ret = false; } return(ret); }