Пример #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            float[] values;
            Adam4000_ChannelStatus[] status;

            m_iCount++;
            txtReadCount.Text = "Polling " + m_iCount.ToString() + " times...";
            if (adamCom.AnalogInput(m_iAddr).GetValues(8, out values, out status))
            {
                RefreshValue(ref txtAIValue0, status[0], values[0]);
                RefreshValue(ref txtAIValue1, status[1], values[1]);
                RefreshValue(ref txtAIValue2, status[2], values[2]);
                RefreshValue(ref txtAIValue3, status[3], values[3]);
                RefreshValue(ref txtAIValue4, status[4], values[4]);
                RefreshValue(ref txtAIValue5, status[5], values[5]);
                RefreshValue(ref txtAIValue6, status[6], values[6]);
                RefreshValue(ref txtAIValue7, status[7], values[7]);
            }
            else
            {
                txtAIValue0.Text = "Failed to get!";
                txtAIValue1.Text = "Failed to get!";
                txtAIValue2.Text = "Failed to get!";
                txtAIValue3.Text = "Failed to get!";
                txtAIValue4.Text = "Failed to get!";
                txtAIValue5.Text = "Failed to get!";
                txtAIValue6.Text = "Failed to get!";
                txtAIValue7.Text = "Failed to get!";
            }
        }
Пример #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            float[] fVals;
            int[]   iVals;
            Adam4000_ChannelStatus[] status;

            m_iCount++;
            txtReadCount.Text = "Polling " + m_iCount.ToString() + " times...";
            if (m_adamConfig.Format == Adam4000_DataFormat.TwosComplementHex)
            {
                if (adamCom.AnalogInput(m_iAddr).GetValues(8, out iVals))
                {
                    txtAIValue0.Text = "0x" + iVals[0].ToString("X04");
                    txtAIValue1.Text = "0x" + iVals[1].ToString("X04");
                    txtAIValue2.Text = "0x" + iVals[2].ToString("X04");
                    txtAIValue3.Text = "0x" + iVals[3].ToString("X04");
                    txtAIValue4.Text = "0x" + iVals[4].ToString("X04");
                    txtAIValue5.Text = "0x" + iVals[5].ToString("X04");
                    txtAIValue6.Text = "0x" + iVals[6].ToString("X04");
                    txtAIValue7.Text = "0x" + iVals[7].ToString("X04");
                }
                else
                {
                    txtAIValue0.Text = "Failed to get!";
                    txtAIValue1.Text = "Failed to get!";
                    txtAIValue2.Text = "Failed to get!";
                    txtAIValue3.Text = "Failed to get!";
                    txtAIValue4.Text = "Failed to get!";
                    txtAIValue5.Text = "Failed to get!";
                    txtAIValue6.Text = "Failed to get!";
                    txtAIValue7.Text = "Failed to get!";
                }
            }
            else
            {
                if (adamCom.AnalogInput(m_iAddr).GetValues(8, out fVals, out status))
                {
                    RefreshValue(ref txtAIValue0, status[0], fVals[0], m_byRange[0]);
                    RefreshValue(ref txtAIValue1, status[1], fVals[1], m_byRange[1]);
                    RefreshValue(ref txtAIValue2, status[2], fVals[2], m_byRange[2]);
                    RefreshValue(ref txtAIValue3, status[3], fVals[3], m_byRange[3]);
                    RefreshValue(ref txtAIValue4, status[4], fVals[4], m_byRange[4]);
                    RefreshValue(ref txtAIValue5, status[5], fVals[5], m_byRange[5]);
                    RefreshValue(ref txtAIValue6, status[6], fVals[6], m_byRange[6]);
                    RefreshValue(ref txtAIValue7, status[7], fVals[7], m_byRange[7]);
                }
                else
                {
                    txtAIValue0.Text = "Failed to get!";
                    txtAIValue1.Text = "Failed to get!";
                    txtAIValue2.Text = "Failed to get!";
                    txtAIValue3.Text = "Failed to get!";
                    txtAIValue4.Text = "Failed to get!";
                    txtAIValue5.Text = "Failed to get!";
                    txtAIValue6.Text = "Failed to get!";
                    txtAIValue7.Text = "Failed to get!";
                }
            }
        }
Пример #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int   iCh, iIdx;
            float fData;
            long  lElapse;

            timer1.Enabled = false;
            if (m_iCount < m_iMax)
            {
                iIdx = m_iIndex + m_iCount;
                if (adamCom.AnalogInput(m_iAddr).GetMemRecordData(iIdx, out iCh, out fData, out lElapse))
                {
                    m_listView.Items.Add(new ListViewItem(iIdx.ToString("0000")));
                    m_listView.Items[m_iCount].SubItems.Add(iCh.ToString());
                    m_listView.Items[m_iCount].SubItems.Add(fData.ToString());
                    m_listView.Items[m_iCount].SubItems.Add(lElapse.ToString());
                    m_iCount++;
                    progressBar1.Value = m_iCount * 100 / m_iMax;
                    timer1.Enabled     = true;
                }
                else
                {
                    MessageBox.Show("Get record failed!", "Error");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Get record done!", "Information");
                this.Close();
            }
        }
Пример #4
0
        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;";
                }
            }
        }
Пример #5
0
        private void RefreshChannelEnable()
        {
            bool[] bEnabled;
            int    idx;

            if (adamCom.AnalogInput(m_iAddr).GetChannelEnabled(m_iChTotal, out bEnabled))
            {
                for (idx = 0; idx < m_iChTotal; idx++)
                {
                    m_bCh[idx] = bEnabled[idx];
                }
                chkboxCh0.Checked = bEnabled[0];
                chkboxCh1.Checked = bEnabled[1];
                chkboxCh2.Checked = bEnabled[2];
                chkboxCh3.Checked = bEnabled[3];
                chkboxCh4.Checked = bEnabled[4];
                chkboxCh5.Checked = bEnabled[5];
                chkboxCh6.Checked = bEnabled[6];
                chkboxCh7.Checked = bEnabled[7];
            }
            else
            {
                MessageBox.Show("GetChannelEnabled() failed", "Error");
            }
        }
Пример #6
0
        private void RefreshChannelEnable()
        {
            bool bRet;

            bool[] bEnabled;

            if (m_b5000)
            {
                bRet = adamCom.AnalogInput(m_iAddr).GetChannelEnabled(m_iSlot, m_iChTotal, out bEnabled);
            }
            else
            {
                bRet = adamSocket.AnalogInput(m_iAddr).GetChannelEnabled(m_iSlot, m_iChTotal, out bEnabled);
            }
            if (bRet)
            {
                if (m_iChTotal > 0)
                {
                    chkboxCh0.Checked = bEnabled[0];
                }
                if (m_iChTotal > 1)
                {
                    chkboxCh1.Checked = bEnabled[1];
                }
                if (m_iChTotal > 2)
                {
                    chkboxCh2.Checked = bEnabled[2];
                }
                if (m_iChTotal > 3)
                {
                    chkboxCh3.Checked = bEnabled[3];
                }
                if (m_iChTotal > 4)
                {
                    chkboxCh4.Checked = bEnabled[4];
                }
                if (m_iChTotal > 5)
                {
                    chkboxCh5.Checked = bEnabled[5];
                }
                if (m_iChTotal > 6)
                {
                    chkboxCh6.Checked = bEnabled[6];
                }
                if (m_iChTotal > 7)
                {
                    chkboxCh7.Checked = bEnabled[7];
                }
                txtAIValue0.Text = "";
                txtAIValue1.Text = "";
                txtAIValue2.Text = "";
                txtAIValue3.Text = "";
                txtAIValue4.Text = "";
                txtAIValue5.Text = "";
                txtAIValue6.Text = "";
                txtAIValue7.Text = "";
            }
            else
            {
                MessageBox.Show("GetChannelEnabled() failed", "Error");
            }
        }
Пример #7
0
        private void GetVoltageValue()
        {
            float[] fVals;
            int[]   iVals;
            Adam4000_ChannelStatus[] status;
            VM_VoltageInfo           vi = new VM_VoltageInfo();

            m_iCount++;
            strReadCount = "Polling " + m_iCount.ToString() + " times...";
            if (m_adamConfig.Format == Adam4000_DataFormat.TwosComplementHex)
            {
                //if (adamCom.AnalogInput(m_iAddr).GetValues(8, out iVals))
                //{
                //    vi.V0 = "0x" + iVals[0].ToString("X04");
                //    vi.V1 = "0x" + iVals[1].ToString("X04");
                //    vi.V2 = "0x" + iVals[2].ToString("X04");
                //    vi.V3 = "0x" + iVals[3].ToString("X04");
                //    vi.V4 = "0x" + iVals[4].ToString("X04");
                //    vi.V5 = "0x" + iVals[5].ToString("X04");
                //    vi.V6 = "0x" + iVals[6].ToString("X04");
                //    vi.V7 = "0x" + iVals[7].ToString("X04");
                //}
                //else
                //{
                //    vi.V0 = "Failed to get!";
                //    vi.V1 = "Failed to get!";
                //    vi.V2 = "Failed to get!";
                //    vi.V3 = "Failed to get!";
                //    vi.V4 = "Failed to get!";
                //    vi.V5 = "Failed to get!";
                //    vi.V6 = "Failed to get!";
                //    vi.V7 = "Failed to get!";
                //}
            }
            else
            {
                if (adamCom.AnalogInput(m_iAddr).GetValues(8, out fVals, out status))
                {
                    string a0 = "";
                    string a1 = "";
                    string a2 = "";
                    string a3 = "";
                    string a4 = "";
                    string a5 = "";
                    string a6 = "";
                    string a7 = "";
                    if (vi == null)
                    {
                        vi = new VM_VoltageInfo();
                    }
                    RefreshValue(ref a0, status[0], fVals[0], m_byRange[0]);
                    vi.V0 = a0;
                    RefreshValue(ref a1, status[1], fVals[1], m_byRange[1]);
                    vi.V1 = a1;
                    RefreshValue(ref a2, status[2], fVals[2], m_byRange[2]);
                    vi.V2 = a2;
                    RefreshValue(ref a3, status[3], fVals[3], m_byRange[3]);
                    vi.V3 = a3;
                    RefreshValue(ref a4, status[4], fVals[4], m_byRange[4]);
                    vi.V4 = a4;
                    RefreshValue(ref a5, status[5], fVals[5], m_byRange[5]);
                    vi.V5 = a5;
                    RefreshValue(ref a6, status[6], fVals[6], m_byRange[6]);
                    vi.V6 = a6;
                    RefreshValue(ref a7, status[7], fVals[7], m_byRange[7]);
                    vi.V7 = a7;
                    ///传送电压变化值
                    PrintVoltageValueInfo(vi);
                }
                else
                {
                    vi.V0 = "0";
                    vi.V1 = "0";
                    vi.V2 = "0";
                    vi.V3 = "0";
                    vi.V4 = "0";
                    vi.V5 = "0";
                    vi.V6 = "0";
                    vi.V7 = "0";
                }
            }
        }
Пример #8
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!";
                }
            }
        }