Пример #1
0
        private void RefreshCurrentValue(int i_iChannel, ref TextBox i_txtCh)
        {
            long lVal;

            if (adamCom.Counter(m_iAddr).GetValue(i_iChannel, out lVal))
            {
                i_txtCh.Text = lVal.ToString() + " " + Counter.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode);
            }
            else
            {
                i_txtCh.Text = "Fail";
            }
        }
Пример #2
0
        private bool RefreshMode()
        {
            byte byDataFormat;
            bool bRet;

            if (m_b5000)
            {
                bRet = adamCom.Counter(m_iAddr).GetModeFormat(m_iSlot, out m_byMode, out byDataFormat);
            }
            else
            {
                bRet = adamSocket.Counter(m_iAddr).GetMode(m_iSlot, out m_byMode);
            }
            if (!bRet)
            {
                MessageBox.Show("Get mode failed", "Error");
            }
            return(bRet);
        }
Пример #3
0
        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!";
                }
            }
        }