Exemplo n.º 1
0
        private void RefreshAOValue()
        {
            float fValue;
            int   iValue;

            if (adamCom.AnalogOutput(m_iAddr).GetCurrentValue((byte)m_adamConfig.Format, out fValue))
            {
                if (m_adamConfig.Format == Adam4000_DataFormat.EngineerUnit)
                {
                    txtAOValue.Text = fValue.ToString("#0.000") + " " + AnalogOutput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode);
                }
                else if (m_adamConfig.Format == Adam4000_DataFormat.Percent)
                {
                    txtAOValue.Text = fValue.ToString("#0.000") + " %";
                }
                else
                {
                    iValue          = Convert.ToInt32(fValue);
                    txtAOValue.Text = "0X" + iValue.ToString("X03");
                }
            }
            else
            {
                txtAOValue.Text = "GetCurrentValue() failed";
            }
        }
Exemplo n.º 2
0
        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
            }
        }
Exemplo n.º 3
0
        private void RefreshChannelValue(int i_iChannel, ref TextBox i_txtCh)
        {
            float  fValue;
            string szFormat;

            if (adamCom.AnalogOutput(m_iAddr).GetCurrentValue(i_iChannel, out fValue))
            {
                szFormat     = AnalogOutput.GetFloatFormat(m_Adam4000Type, m_byRange[i_iChannel]);
                i_txtCh.Text = fValue.ToString(szFormat) + " " + AnalogOutput.GetUnitName(m_Adam4000Type, m_byRange[i_iChannel]);
            }
            else
            {
                i_txtCh.Text = "GetCurrentValue() failed";
            }
        }
Exemplo n.º 4
0
        private void RefreshAoChannelValue(int i_iChannel)
        {
            int iStart = 11 + i_iChannel;

            int[]  iData;
            float  fValue;
            string szFormat;

            if (adamModbus.Modbus().ReadInputRegs(iStart, 1, out iData))
            {
                fValue = AnalogOutput.GetScaledValue(m_Adam6000Type, m_byAoRange[i_iChannel], iData[0]);
                //
                szFormat = AnalogOutput.GetFloatFormat(m_Adam6000Type, m_byAoRange[i_iChannel]);
                //
                txtCurrentValue.Text = fValue.ToString(szFormat) + " " + AnalogOutput.GetUnitName(m_Adam6000Type, m_byAoRange[i_iChannel]);
            }
            else
            {
                txtReadCount.Text += "ReadInputRegs() failed;";
            }
        }
Exemplo n.º 5
0
        private void RefreshChannelValue(int i_iChannel, ref TextBox i_txtCh)
        {
            int iStart = m_iSlot * 8 + i_iChannel + 1;

            int[]  iData;
            float  fValue;
            string szFormat;

            if (m_b5000)
            {
                if (adamCom.AnalogOutput(m_iAddr).GetCurrentValue(m_iSlot, i_iChannel, out fValue))
                {
                    szFormat     = AnalogOutput.GetFloatFormat(m_Adam5000Type, m_byRange[i_iChannel]);
                    i_txtCh.Text = fValue.ToString(szFormat) + " " + AnalogOutput.GetUnitName(m_Adam5000Type, m_byRange[i_iChannel]);
                }
                else
                {
                    i_txtCh.Text = "Failed to get";
                }
            }
            else
            {
                if (adamSocket.Modbus(m_iAddr).ReadInputRegs(iStart, 1, out iData))
                {
                    fValue = AnalogOutput.GetScaledValue(m_Adam5000Type, m_byRange[i_iChannel], iData[0]);
                    //
                    szFormat = AnalogOutput.GetFloatFormat(m_Adam5000Type, m_byRange[i_iChannel]);
                    //
                    i_txtCh.Text = fValue.ToString(szFormat) + " " + AnalogOutput.GetUnitName(m_Adam5000Type, m_byRange[i_iChannel]);
                }
                else
                {
                    i_txtCh.Text = "Failed to get";
                }
            }
        }
Exemplo n.º 6
0
        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
            }
        }