コード例 #1
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);
        }
コード例 #2
0
        private void btnApplyMode_Click(object sender, EventArgs e)
        {
            byte byConf, byMode, byPreConf;

            byPreConf = 0x00;

            if (cbxDiMode.SelectedIndex == 0)
            {
                byMode = (byte)Adam6051_CounterMode.Counter;
            }
            else
            {
                byMode = (byte)Adam6051_CounterMode.Frequency;
            }

            int iConfigStart = Counter.GetChannelStart(m_Adam6000Type);
            int chIdx        = iConfigStart + comboBoxCh.SelectedIndex;

            Counter.FormIOConfig(byMode, m_bRecordLastCount[comboBoxCh.SelectedIndex], m_bDigitalFilter[comboBoxCh.SelectedIndex], m_bInvert[comboBoxCh.SelectedIndex], out byConf);

            byPreConf         = m_byConfig[chIdx];
            m_byConfig[chIdx] = byConf;

            if (m_adamUDP.Counter().SetIOConfig(m_byConfig))
            {
                RefreshChannelMode();
                RefreshPanel();
                RefreshSetting();
                MessageBox.Show("Apply mode setting successfully!", "Information");
            }
            else
            {
                m_byConfig[iConfigStart + m_iCh] = byPreConf;
                MessageBox.Show("Change counter mode failed!", "Error");
            }
        }
コード例 #3
0
        /// <summary>
        /// Refresh Channel Information "Value" column
        /// </summary>
        /// <returns></returns>
        private bool RefreshData()
        {
            int    iChannelTotal  = 0;
            string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text;

            if (strSelPageName == "DI")
            {
                bool[] bVal;
                iChannelTotal = this.m_aConf.HwIoTotal[m_DIidx];
                if (!m_adamSocket.DigitalInput().GetValues(m_idxID, iChannelTotal, out bVal))
                {
                    StatusBar_IO.Text += "ApiErr:" + m_adamSocket.Modbus().LastError.ToString() + " ";
                    return(false);
                }
                for (int i = 0; i < bVal.Length; i++)
                {
                    listViewChInfo_DI.Items[i].SubItems[3].Text = bVal[i].ToString();  //moduify "Value" column
                }
            }
            else if (strSelPageName == "DO")
            {
                bool[] bVal;
                iChannelTotal = this.m_aConf.HwIoTotal[m_DOidx];
                if (!m_adamSocket.DigitalOutput().GetValues(m_idxID, m_iDoOffset + iChannelTotal, out bVal))   //Should add offset for DIO modules
                {
                    StatusBar_IO.Text += "ApiErr:" + m_adamSocket.Modbus().LastError.ToString() + " ";
                    return(false);
                }
                for (int i = 0; i < bVal.Length - m_iDoOffset; i++)
                {
                    listViewChInfo_DO.Items[i].SubItems[3].Text = bVal[i + m_iDoOffset].ToString();  //moduify "Value" column
                }
            }
            else if (strSelPageName == "PWM")
            {
                iChannelTotal = this.m_aConf.HwIoTotal[m_PWMidx];
                uint[]  uiFerquency = new uint[iChannelTotal];
                float[] fDutyCycle  = new float[iChannelTotal];
                for (int i = 0; i < iChannelTotal; i++)
                {
                    if (m_adamSocket.Counter().GetChannelConfig((int)m_idxID, (ushort)i, out uiFerquency[i], out fDutyCycle[i]))
                    {
                        listViewChInfo_PWM.Items[i].SubItems[4].Text = uiFerquency[i].ToString();           //Update Frequency column
                        listViewChInfo_PWM.Items[i].SubItems[5].Text = fDutyCycle[i].ToString("0.0");       //Update Duty Cycle column
                    }
                    else
                    {
                        listViewChInfo_PWM.Items[i].SubItems[4].Text = "*****";
                        listViewChInfo_PWM.Items[i].SubItems[5].Text = "*****";
                        StatusBar_IO.Text += "ApiErr:" + m_adamSocket.Modbus().LastError.ToString() + " ";
                    }
                }
            }
            return(true);
        }