private void RefreshSingleAiChannel(int i_iIndex, ref TextBox txtCh, float fValue, int i_iStatus) { string szFormat; if (m_bChEnabled[i_iIndex]) { if (i_iStatus == 0) { szFormat = AnalogInput.GetFloatFormat(m_Adam6000Type, m_byAiRange[i_iIndex]); txtCh.Text = fValue.ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam6000Type, m_byAiRange[i_iIndex]); } else if (i_iStatus == 1) { txtCh.Text = "Over(H)"; } else if (i_iStatus == 2) { txtCh.Text = "Over(L)"; } else { txtCh.Text = "Invalid(R)"; } } }
public string ReadInputChannelAsString(int channel) { var b = ReadInputChannelAsByte(channel); var ff = GetFloatFormat(b); var inputRegs = ReadInputRegs(); var res = AnalogInput.GetScaledValue(adamtype, b, inputRegs[channel]); var s = res.ToString(ff) + " " + AnalogInput.GetUnitName(adamtype, b); return(s); }
private void RefreshSingleChannel(int i_iIndex, ref TextBox txtCh, float fValue) { string szFormat; if (m_bChEnabled[i_iIndex]) { szFormat = AnalogInput.GetFloatFormat(m_Adam6000Type, m_byRange[i_iIndex]); txtCh.Text = fValue.ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam6000Type, m_byRange[i_iIndex]); } }
private void RefreshAdam5000Information() { int iIdx; byte byCode; Adam5000Type adamType; adamType = (Adam5000Type)cbxModuleType.SelectedItem; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); for (iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // range name } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); for (iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Bi_Direction))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Bi_Direction)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Up_Down))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Up_Down)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Frequency))); // mode name listViewCounter.Items[2].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }
/// <summary> /// 获取当前使用单位,电压或电流单位 /// </summary> public static string GetSymbol(AdamModule6018 Adam, int Channel) { string str = AnalogInput.GetUnitName(Adam6000Type.Adam6018, Adam.Range[Channel]); if (str == "'C") { str = " ℃"; } else if (str == "'F") { str = " ℉"; } return(str); }
private void RefreshSingleChannelBurn(int i_iIndex, ref TextBox i_txtCh, float i_fValue, bool i_bBurn) { string szFormat; if (m_bChEnabled[i_iIndex]) { if (i_bBurn) { i_txtCh.Text = "Burn out"; } else { szFormat = AnalogInput.GetFloatFormat(m_Adam6000Type, m_byRange[i_iIndex]); i_txtCh.Text = i_fValue.ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam6000Type, m_byRange[i_iIndex]); } } }
private void RefreshSingleChannelWithAiStatus(int i_iIndex, ref TextBox i_txtCh, float i_fValue, ushort i_usAiStatus) { string szFormat; string szRange; string szErrorMsg = string.Empty; string szComma = " , "; szRange = AnalogInput.GetRangeName(m_Adam6000Type, m_usRange[i_iIndex]); if (m_bChEnabled[i_iIndex]) { if (i_usAiStatus == (ushort)Adam_AiStatus_LowAddress.No_Fault_Detected) { szErrorMsg = string.Empty; szFormat = AnalogInput.GetFloatFormat(m_Adam6000Type, m_usRange[i_iIndex]); i_txtCh.Text = i_fValue.ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam6000Type, m_usRange[i_iIndex]); } else { if ((i_usAiStatus & (ushort)Adam_AiStatus_LowAddress.FailToProvideAiValueUartTimeout) == (ushort)Adam_AiStatus_LowAddress.FailToProvideAiValueUartTimeout) { szErrorMsg = "Fail to provide AI value (UART timeout)"; } else if ((i_usAiStatus & (ushort)Adam_AiStatus_LowAddress.Over_Range) == (ushort)Adam_AiStatus_LowAddress.Over_Range) { szErrorMsg = (szErrorMsg == string.Empty) ? ("Over Range") : (szErrorMsg + szComma + "Over Range"); } else if ((i_usAiStatus & (ushort)Adam_AiStatus_LowAddress.Under_Range) == (ushort)Adam_AiStatus_LowAddress.Under_Range) { szErrorMsg = (szErrorMsg == string.Empty) ? ("Under Range") : (szErrorMsg + szComma + "Under Range"); } else if ((i_usAiStatus & (ushort)Adam_AiStatus_LowAddress.Open_Circuit_Burnout) == (ushort)Adam_AiStatus_LowAddress.Open_Circuit_Burnout) { szErrorMsg = (szErrorMsg == string.Empty) ? ("Open Circuit (Burnout)") : (szErrorMsg + szComma + "Open Circuit (Burnout)"); } else if ((i_usAiStatus & (ushort)Adam_AiStatus_LowAddress.Zero_Span_CalibrationError) == (ushort)Adam_AiStatus_LowAddress.Zero_Span_CalibrationError) { szErrorMsg = (szErrorMsg == string.Empty) ? ("Zero/Span Calibration Error") : (szErrorMsg + szComma + "Zero/Span Calibration Error"); } i_txtCh.Text = szErrorMsg; } } }
/// <summary> /// 返回特定通道的数据字符串,数据格式在这里设置 /// </summary> /// <param name="channelIndex">通道的索引0-7</param> /// <returns></returns> public string GetChannelSingleValue(int channelIndex) { string value = string.Empty; int[] data; float fValue; int index = channelIndex; if (adamModbus.Modbus().ReadInputRegs(channelIndex + 1, 1, out data)) { fValue = AnalogInput.GetScaledValue(adamType, channelRange[index], (ushort)data[0]); if (channelEnabled[index]) { string valueFormat = AnalogInput.GetFloatFormat(adamType, channelRange[index]); value = fValue.ToString(valueFormat) + " " + AnalogInput.GetUnitName(adamType, channelRange[index]); } } return(value); }
private void RefreshAdam5013ChannelValue() { int iStart = m_iSlot * 8 + 1; float[] fVal; string szFormat, szUnit; if (adamCtl.AnalogInput().GetValues(m_iSlot, m_iChTotal, out fVal)) { // floating format szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange); szUnit = AnalogInput.GetUnitName(m_Adam5000Type, m_byRange); // if (chkboxCh0.Checked) { txtAIValue0.Text = fVal[0].ToString(szFormat) + " " + szUnit; } if (chkboxCh1.Checked) { txtAIValue1.Text = fVal[1].ToString(szFormat) + " " + szUnit; } if (chkboxCh2.Checked) { txtAIValue2.Text = fVal[2].ToString(szFormat) + " " + szUnit; } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } } }
/// <summary> /// 返回所有通道的数据,格式处理在这里设置 /// </summary> /// <returns></returns> public string[] GetAllChannelValue() { string[] values = new string[channelTotal]; int startIndex = 1; int[] data; float[] fValue = new float[channelTotal]; if (adamModbus.Modbus().ReadInputRegs(startIndex, channelTotal, out data)) { for (int i = 0; i < channelTotal; i++) { fValue[i] = AnalogInput.GetScaledValue(adamType, channelRange[i], (ushort)data[i]); if (channelEnabled[i]) { string valueFormat = AnalogInput.GetFloatFormat(adamType, channelRange[i]); values[i] = fValue[i].ToString(valueFormat) + " " + AnalogInput.GetUnitName(adamType, channelRange[i]); } } } return(values); }
/// <summary> /// 获取当前使用单位,电压或电流单位 /// </summary> /// <param name="AdamIndex">已连接的Adam模块ID序号</param> /// <param name="Channel">模块通道序号</param> /// <returns>返回温度单位</returns> public static string GetSymbol(int AdamIndex, int Channel) { string Symbol = ""; switch (GetAdamType(AdamIndex, ref AdamIndex)) { case HaveAdamType.AdamModule6017: Symbol = AnalogInput.GetUnitName(Adam6000Type.Adam6017, Adam6017[AdamIndex].Range[Channel]); break; case HaveAdamType.AdamModule6018: Symbol = AnalogInput.GetUnitName(Adam6000Type.Adam6018, Adam6018[AdamIndex].Range[Channel]); if (Symbol == "'C") { Symbol = " ℃"; } else { Symbol = " ℉"; } break; case HaveAdamType.AdamModule6250: break; case HaveAdamType.AdamModule6256: break; } return(Symbol); }
/// <summary> /// 获取当前使用单位,电压或电流单位 /// </summary> public static string GetSymbol(AdamModule6017 Adam, int Channel) { return(AnalogInput.GetUnitName(Adam6000Type.Adam6017, Adam.Range[Channel])); }
private void RefreshAIValue() { float[] fVals; int[] iVals; Adam4000_ChannelStatus[] status; if (m_adamConfig.Format == Adam4000_DataFormat.TwosComplementHex) { if (adamCom.AnalogInput(m_iAddr).GetValues(1, out iVals)) { txtAIValue.Text = "0x" + iVals[0].ToString("X04"); } else { txtAIValue.Text = "GetValues() failed;"; } } else { if (adamCom.AnalogInput(m_iAddr).GetValues(1, out fVals, out status)) { if (status[0] == Adam4000_ChannelStatus.Normal) { if (m_adamConfig.Format == Adam4000_DataFormat.EngineerUnit) { txtAIValue.Text = fVals[0].ToString(AnalogInput.GetFloatFormat(m_Adam4000Type, m_adamConfig.TypeCode)) + " " + AnalogInput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode); } else if (m_adamConfig.Format == Adam4000_DataFormat.Percent) { txtAIValue.Text = fVals[0].ToString("#0.00") + " %"; } else if (m_adamConfig.Format == Adam4000_DataFormat.Ohms) { txtAIValue.Text = fVals[0].ToString("#0.000") + " ohms"; } } else { txtAIValue.Text = status[0].ToString(); } } else { txtAIValue.Text = "GetValues() failed;"; } } }
private void RefreshChannelValue() { int iStart = m_iSlot * 8 + 1; int iIdx; int[] iData; float[] fValue; string szFormat; if (m_b5000) { if (m_byFormat == (byte)Adam5000_DataFormat.EngineerUnit) { if (adamCom.AnalogInput(m_iAddr).GetValues(m_iSlot, m_iChTotal, out fValue)) { // szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange[0]); // if (chkboxCh0.Checked) { txtAIValue0.Text = fValue[0].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[0]); } if (chkboxCh1.Checked) { txtAIValue1.Text = fValue[1].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[1]); } if (chkboxCh2.Checked) { txtAIValue2.Text = fValue[2].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[2]); } if (chkboxCh3.Checked) { txtAIValue3.Text = fValue[3].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[3]); } if (chkboxCh4.Checked) { txtAIValue4.Text = fValue[4].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[4]); } if (chkboxCh5.Checked) { txtAIValue5.Text = fValue[5].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[5]); } if (chkboxCh6.Checked) { txtAIValue6.Text = fValue[6].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[6]); } if (chkboxCh7.Checked) { txtAIValue7.Text = fValue[7].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[7]); } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } if (chkboxCh7.Checked) { txtAIValue7.Text = "Failed to get!"; } } } else if (m_byFormat == (byte)Adam5000_DataFormat.TwosComplementHex) { if (adamCom.AnalogInput(m_iAddr).GetValues(m_iSlot, m_iChTotal, out iData)) { szFormat = "X04"; // if (chkboxCh0.Checked) { txtAIValue0.Text = "0x" + iData[0].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[0]); } if (chkboxCh1.Checked) { txtAIValue1.Text = "0x" + iData[1].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[1]); } if (chkboxCh2.Checked) { txtAIValue2.Text = "0x" + iData[2].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[2]); } if (chkboxCh3.Checked) { txtAIValue3.Text = "0x" + iData[3].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[3]); } if (chkboxCh4.Checked) { txtAIValue4.Text = "0x" + iData[4].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[4]); } if (chkboxCh5.Checked) { txtAIValue5.Text = "0x" + iData[5].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[5]); } if (chkboxCh6.Checked) { txtAIValue6.Text = "0x" + iData[6].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[6]); } if (chkboxCh7.Checked) { txtAIValue7.Text = "0x" + iData[7].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[7]); } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } if (chkboxCh7.Checked) { txtAIValue7.Text = "Failed to get!"; } } } } else { if (adamSocket.Modbus().ReadInputRegs(iStart, m_iChTotal, out iData)) { fValue = new float[m_iChTotal]; for (iIdx = 0; iIdx < m_iChTotal; iIdx++) { fValue[iIdx] = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange[iIdx], iData[iIdx]); } // szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange[0]); // if (chkboxCh0.Checked) { txtAIValue0.Text = fValue[0].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[0]); } if (chkboxCh1.Checked) { txtAIValue1.Text = fValue[1].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[1]); } if (chkboxCh2.Checked) { txtAIValue2.Text = fValue[2].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[2]); } if (chkboxCh3.Checked) { txtAIValue3.Text = fValue[3].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[3]); } if (chkboxCh4.Checked) { txtAIValue4.Text = fValue[4].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[4]); } if (chkboxCh5.Checked) { txtAIValue5.Text = fValue[5].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[5]); } if (chkboxCh6.Checked) { txtAIValue6.Text = fValue[6].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[6]); } if (chkboxCh7.Checked) { txtAIValue7.Text = fValue[7].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[7]); } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } if (chkboxCh7.Checked) { txtAIValue7.Text = "Failed to get!"; } } } }
private void RefreshAdam5018ChannelValue() { int iStart = m_iSlot * 8 + 1; int[] iData; float[] fVal; float fValue; string szFormat, szUnit; if (m_b5000) { if (adamCom.AnalogInput(m_iAddr).GetValues(m_iSlot, m_iChTotal, out fVal)) { // floating format szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange); szUnit = AnalogInput.GetUnitName(m_Adam5000Type, m_byRange); // if (chkboxCh0.Checked) { txtAIValue0.Text = fVal[0].ToString(szFormat) + " " + szUnit; } if (chkboxCh1.Checked) { txtAIValue1.Text = fVal[1].ToString(szFormat) + " " + szUnit; } if (chkboxCh2.Checked) { txtAIValue2.Text = fVal[2].ToString(szFormat) + " " + szUnit; } if (chkboxCh3.Checked) { txtAIValue3.Text = fVal[3].ToString(szFormat) + " " + szUnit; } if (chkboxCh4.Checked) { txtAIValue4.Text = fVal[4].ToString(szFormat) + " " + szUnit; } if (chkboxCh5.Checked) { txtAIValue5.Text = fVal[5].ToString(szFormat) + " " + szUnit; } if (chkboxCh6.Checked) { txtAIValue6.Text = fVal[6].ToString(szFormat) + " " + szUnit; } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } } } else { if (adamSocket.Modbus().ReadInputRegs(iStart, m_iChTotal, out iData)) { // floating format szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange); szUnit = AnalogInput.GetUnitName(m_Adam5000Type, m_byRange); // if (chkboxCh0.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[0]); txtAIValue0.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh1.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[1]); txtAIValue1.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh2.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[2]); txtAIValue2.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh3.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[3]); txtAIValue3.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh4.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[4]); txtAIValue4.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh5.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[5]); txtAIValue5.Text = fValue.ToString(szFormat) + " " + szUnit; } if (chkboxCh6.Checked) { fValue = AnalogInput.GetScaledValue(m_Adam5000Type, m_byRange, iData[6]); txtAIValue6.Text = fValue.ToString(szFormat) + " " + szUnit; } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } } } }
private void RefreshValue(ref TextBox i_txtCh, Adam4000_ChannelStatus i_status, float i_fValue, byte i_byRange) { if (i_status == Adam4000_ChannelStatus.Normal) { if (m_adamConfig.Format == Adam4000_DataFormat.EngineerUnit) { i_txtCh.Text = i_fValue.ToString(AnalogInput.GetFloatFormat(m_Adam4000Type, i_byRange)) + " " + AnalogInput.GetUnitName(m_Adam4000Type, i_byRange); } else if (m_adamConfig.Format == Adam4000_DataFormat.Percent) { i_txtCh.Text = i_fValue.ToString("#0.00") + " %"; } } else { i_txtCh.Text = i_status.ToString(); } }
private void RefreshAdam6000Information() { byte byCode; ushort usCode; int intAdamType; Adam6000Type adamType; adamType = (Adam6000Type)cbxModuleType.SelectedItem; intAdamType = (int)adamType; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); if ((intAdamType == 6017) || ((intAdamType >= 6217) && (intAdamType <= 6224))) { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogInput.GetRangeCode2Byte(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // unit name } } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); if ((intAdamType >= 6217) && (intAdamType <= 6224)) { for (int iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogOutput.GetRangeCode2Byte(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Counter))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Counter)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Frequency))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (int iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }
private void timer1_Tick(object sender, EventArgs e) { long lVal; bool bDI; float[] fVal; bool[] DOStatus; Adam4000_ChannelStatus[] status; Adam_AIAlarmMode mode; m_iCount++; txtReadCount.Text = "Polling " + m_iCount.ToString() + " times..."; if (adamCom.AnalogInput(m_iAddr).GetValues(1, out fVal, out status)) // read AI value { if (status[0] == Adam4000_ChannelStatus.Normal) // the value is normal { txtAI.Text = fVal[0].ToString() + " " + AnalogInput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode); } else // the value is invalid { txtAI.Text = status[0].ToString(); } } else { txtAI.Text = "Failed to get!"; } // for ADAM-4011, ADAM-4011D, or ADAM-4012 if (m_Adam4000Type != Adam4000Type.Adam4013) { // event counter if (adamCom.Counter(m_iAddr).GetValue(out lVal)) { txtCounter.Text = lVal.ToString(); } else { txtCounter.Text = "Failed to get!"; } // event status if (adamCom.DigitalInput(m_iAddr).GetValue(out bDI)) { txtEvent.Text = bDI.ToString(); } else { txtEvent.Text = "Failed to get!"; } // alarm if (adamCom.Alarm(m_iAddr).GetModeAlarmDO(2, out mode, out DOStatus)) { m_DOStatus[0] = DOStatus[0]; m_DOStatus[1] = DOStatus[1]; txtLowAlarm.Text = DOStatus[0].ToString(); txtHighAlarm.Text = DOStatus[1].ToString(); } else { txtLowAlarm.Text = "Failed to get!"; txtHighAlarm.Text = "Failed to get!"; } } }
private void RefreshValue(ref TextBox i_txtCh, Adam4000_ChannelStatus i_status, float i_fValue) { if (i_status == Adam4000_ChannelStatus.Normal) { i_txtCh.Text = i_fValue.ToString(AnalogInput.GetFloatFormat(m_Adam4000Type, m_adamConfig.TypeCode)) + " " + AnalogInput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode); } else { i_txtCh.Text = i_status.ToString(); } }
private bool RefreshValue(int i_iCh, ref TextBox i_txtCh) { float fVal; Adam4000_ChannelStatus status; if (m_bCh[i_iCh] == false) // channel disabled { i_txtCh.Text = ""; return(true); } if (adamCom.AnalogInput(m_iAddr).GetValue(i_iCh, out fVal, out status)) { if (status == Adam4000_ChannelStatus.Normal) { i_txtCh.Text = fVal.ToString(AnalogInput.GetFloatFormat(m_Adam4000Type, m_adamConfig.TypeCode)) + " " + AnalogInput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode); } else { i_txtCh.Text = fVal.ToString(); } return(true); } return(false); }
private void RefreshChannelValue() { float[] fValue; string szFormat; if (adamCtl.AnalogInput().GetValues(m_iSlot, m_iChTotal, out fValue)) { // szFormat = AnalogInput.GetFloatFormat(m_Adam5000Type, m_byRange[0]); // if (chkboxCh0.Checked) { txtAIValue0.Text = fValue[0].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[0]); } if (chkboxCh1.Checked) { txtAIValue1.Text = fValue[1].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[1]); } if (chkboxCh2.Checked) { txtAIValue2.Text = fValue[2].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[2]); } if (chkboxCh3.Checked) { txtAIValue3.Text = fValue[3].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[3]); } if (chkboxCh4.Checked) { txtAIValue4.Text = fValue[4].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[4]); } if (chkboxCh5.Checked) { txtAIValue5.Text = fValue[5].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[5]); } if (chkboxCh6.Checked) { txtAIValue6.Text = fValue[6].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[6]); } if (chkboxCh7.Checked) { txtAIValue7.Text = fValue[7].ToString(szFormat) + " " + AnalogInput.GetUnitName(m_Adam5000Type, m_byRange[7]); } } else { if (chkboxCh0.Checked) { txtAIValue0.Text = "Failed to get!"; } if (chkboxCh1.Checked) { txtAIValue1.Text = "Failed to get!"; } if (chkboxCh2.Checked) { txtAIValue2.Text = "Failed to get!"; } if (chkboxCh3.Checked) { txtAIValue3.Text = "Failed to get!"; } if (chkboxCh4.Checked) { txtAIValue4.Text = "Failed to get!"; } if (chkboxCh5.Checked) { txtAIValue5.Text = "Failed to get!"; } if (chkboxCh6.Checked) { txtAIValue6.Text = "Failed to get!"; } if (chkboxCh7.Checked) { txtAIValue7.Text = "Failed to get!"; } } }