/// <summary> /// Refresh AI Channel Information /// </summary> /// <returns></returns> private bool RefreshData() { int iChannelTotal = this.m_aConf.HwIoTotal[m_tmpidx]; if (this.m_uiChMask != 0x00) { ushort[] usVal; Advantech.Adam.Apax5000_ChannelStatus[] aStatus; if (!m_adamCtl.AnalogInput().GetChannelStatus(m_idxID, iChannelTotal, out aStatus)) { StatusBar_IO.Text += "[GetChannelStatus] ApiErr:" + m_adamCtl.AnalogInput().ApiLastError.ToString() + " "; return(false); } if (!m_adamCtl.AnalogInput().GetValues(m_idxID, iChannelTotal, out usVal)) { StatusBar_IO.Text += "[GetValues] ApiErr:" + m_adamCtl.AnalogInput().ApiLastError.ToString() + " "; return(false); } string[] strVal = new string[iChannelTotal]; string[] strStatus = new string[iChannelTotal]; double[] dVals = new double[iChannelTotal]; for (int i = 0; i < iChannelTotal; i++) { if (m_aConf.wPktVer >= 0x0002) { dVals[i] = AnalogInput.GetScaledValueWithResolution(this.m_usRanges[i], usVal[i], m_aConf.wHwIoType_0_Resolution); } else { if (m_aConf.GetModuleName() == "5017H") { dVals[i] = AnalogInput.GetScaledValueWithResolution(this.m_usRanges[i], usVal[i], 12); } else { dVals[i] = AnalogInput.GetScaledValue(this.m_usRanges[i], usVal[i]); } } if (m_bChMask[i]) { if (this.IsShowRawData) { strVal[i] = usVal[i].ToString("X04"); } else { strVal[i] = dVals[i].ToString(AnalogInput.GetFloatFormat(this.m_usRanges[i])); } strStatus[i] = aStatus[i].ToString(); } else { strVal[i] = "*****"; strStatus[i] = "Disable"; } listViewChInfo.Items[i].SubItems[2].Text = strVal[i].ToString(); //moduify "Value" column listViewChInfo.Items[i].SubItems[3].Text = strStatus[i].ToString(); //modify "Ch Status" column } } else { for (int i = 0; i < iChannelTotal; i++) { listViewChInfo.Items[i].SubItems[2].Text = "******"; //moduify "Value" column listViewChInfo.Items[i].SubItems[3].Text = "******"; //modify "Ch Status" column } } return(true); }
/// <summary> /// Refresh AI Channel Information /// </summary> /// <returns></returns> private bool RefreshData() { int iChannelTotal = this.m_aConf.HwIoTotal[m_tmpidx]; if (this.m_uiChMask != 0x00) { ushort[] usVal; Advantech.Adam.Apax5000_ChannelStatus[] aStatus; if (!m_adamSocket.AnalogInput().GetChannelStatus(m_idxID, iChannelTotal, out aStatus)) { StatusBar_IO.Text += "[GetChannelStatus] ApiErr:" + m_adamSocket.Modbus().LastError.ToString() + " "; return(false); } if (!m_adamSocket.AnalogInput().GetValues(m_idxID, iChannelTotal, out usVal)) { StatusBar_IO.Text += "[GetValues] ApiErr:" + m_adamSocket.Modbus().LastError.ToString() + " "; return(false); } string[] strVal = new string[iChannelTotal]; string[] strStatus = new string[iChannelTotal]; double[] dVals = new double[iChannelTotal]; bool bHasTCRange = false; for (int i = 0; i < iChannelTotal; i++) { if (m_aConf.wPktVer >= 0x0002) { dVals[i] = AnalogInput.GetScaledValueWithResolution(this.m_usRanges[i], usVal[i], m_aConf.wHwIoType_0_Resolution); } else { if (m_aConf.GetModuleName() == "5017H") { dVals[i] = AnalogInput.GetScaledValueWithResolution(this.m_usRanges[i], usVal[i], 12); } else { dVals[i] = AnalogInput.GetScaledValue(this.m_usRanges[i], usVal[i]); } } if (m_usRanges[i] >= 0x400 && m_usRanges[i] < 0x500) { bHasTCRange = true; } if (m_bChMask[i]) { if (this.IsShowRawData) { strVal[i] = usVal[i].ToString("X04"); } else { strVal[i] = dVals[i].ToString(AnalogInput.GetFloatFormat(this.m_usRanges[i])); } strStatus[i] = aStatus[i].ToString(); } else { strVal[i] = "*****"; strStatus[i] = "Disable"; } listViewChInfo.Items[i].SubItems[3].Text = strVal[i].ToString(); //moduify "Value" column listViewChInfo.Items[i].SubItems[4].Text = strStatus[i].ToString(); //modify "Ch Status" column } if (bHasTCRange && (((m_iScanCount * timer1.Interval) % 5000 >= 0) && ((m_iScanCount * timer1.Interval) % 5000 < 1))) { float fCJCVal; Apax5000_ChannelStatus o_Status; if (m_adamSocket.AnalogInput().GetCJCValue(m_idxID, out fCJCVal, out o_Status)) { if (o_Status == Apax5000_ChannelStatus.CJCTempError) { timer1.Enabled = false; MessageBox.Show("The CJC temperature sensor failed!\nPlease check device is install correctly.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); StatusBar_IO.Text += "The CJC temperature sensor failed! Please check device is install correctly."; } } } } else { for (int i = 0; i < iChannelTotal; i++) { listViewChInfo.Items[i].SubItems[3].Text = "******"; //moduify "Value" column listViewChInfo.Items[i].SubItems[4].Text = "******"; //modify "Ch Status" column } } return(true); }