Beispiel #1
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
                }
            }
            return(true);
        }
Beispiel #2
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);
        }
Beispiel #3
0
 private void ApplyWDT_Click(bool bCommFSV, bool bPtoPFSV, bool[] bWDT, bool bShowOk)
 {
     if (adamModbus.DigitalOutput().SetWDTMask(bCommFSV, bPtoPFSV, bWDT))
     {
         if (bShowOk)
         {
             MessageBox.Show("Set WDT mask done!", "Information");
         }
         RefreshWDT();
     }
     else
     {
         MessageBox.Show("Set WDT mask failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Refresh DO Channel Information "Value" column
        /// </summary>
        /// <returns></returns>
        private bool RefreshData()
        {
            int iChannelTotal = 0;
            bool[] bVal;

            iChannelTotal = this.m_aConf.HwIoTotal[m_tmpidx];
            if (!m_adamSocket.DigitalOutput().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.Items[i].SubItems[3].Text = bVal[i].ToString();  //moduify "Value" column
            }
            return true;
        }
Beispiel #5
0
        private void btnCh_Click(int i_iCh, TextBox txtBox)
        {
            bool bRet;

            timer1.Enabled = false;
            if (m_iDITotal > 0)
            {
                i_iCh = i_iCh - 8;
            }
            if (m_iDOTotal > 8) // ADAM-4056S, ADAM-4056SO
            {
                bRet = adamSocket.DigitalOutput(m_iAddr).SetSValue(i_iCh, (txtBox.Text == "False"));
            }
            else
            {
                bRet = adamSocket.DigitalOutput(m_iAddr).SetValue(i_iCh, (txtBox.Text == "False"));
            }
            if (!bRet)
            {
                MessageBox.Show("Set digital output failed!", "Error");
            }
            timer1.Enabled = true;
        }
Beispiel #6
0
        private bool InitAdam5050()
        {
            bool[] bDIO, bMask;
            bool   bRet;
            int    iCh = 0, iDI = 0, iDO = 0;

            if (m_b5000)
            {
                bRet = (adamCom.DigitalInput(m_iAddr).GetUniversalStatus(m_iSlot, out bDIO) & adamCom.DigitalOutput(m_iAddr).GetAlarmMappingMask(m_iSlot, m_iChTotal, out bMask));
            }
            else
            {
                bRet = (adamSocket.DigitalInput(m_iAddr).GetUniversalStatus(m_iSlot, out bDIO) & adamSocket.DigitalOutput(m_iAddr).GetAlarmMappingMask(m_iSlot, m_iChTotal, out bMask));
            }
            if (bRet && bDIO.Length == 16)
            {
                InitChannelItems(true, bDIO[0], bMask[0], ref iCh, ref iDI, ref iDO, ref panelCh0, ref btnCh0);
                InitChannelItems(true, bDIO[1], bMask[1], ref iCh, ref iDI, ref iDO, ref panelCh1, ref btnCh1);
                InitChannelItems(true, bDIO[2], bMask[2], ref iCh, ref iDI, ref iDO, ref panelCh2, ref btnCh2);
                InitChannelItems(true, bDIO[3], bMask[3], ref iCh, ref iDI, ref iDO, ref panelCh3, ref btnCh3);
                InitChannelItems(true, bDIO[4], bMask[4], ref iCh, ref iDI, ref iDO, ref panelCh4, ref btnCh4);
                InitChannelItems(true, bDIO[5], bMask[5], ref iCh, ref iDI, ref iDO, ref panelCh5, ref btnCh5);
                InitChannelItems(true, bDIO[6], bMask[6], ref iCh, ref iDI, ref iDO, ref panelCh6, ref btnCh6);
                InitChannelItems(true, bDIO[7], bMask[7], ref iCh, ref iDI, ref iDO, ref panelCh7, ref btnCh7);
                InitChannelItems(true, bDIO[8], bMask[8], ref iCh, ref iDI, ref iDO, ref panelCh8, ref btnCh8);
                InitChannelItems(true, bDIO[9], bMask[9], ref iCh, ref iDI, ref iDO, ref panelCh9, ref btnCh9);
                InitChannelItems(true, bDIO[10], bMask[10], ref iCh, ref iDI, ref iDO, ref panelCh10, ref btnCh10);
                InitChannelItems(true, bDIO[11], bMask[11], ref iCh, ref iDI, ref iDO, ref panelCh11, ref btnCh11);
                InitChannelItems(true, bDIO[12], bMask[12], ref iCh, ref iDI, ref iDO, ref panelCh12, ref btnCh12);
                InitChannelItems(true, bDIO[13], bMask[13], ref iCh, ref iDI, ref iDO, ref panelCh13, ref btnCh13);
                InitChannelItems(true, bDIO[14], bMask[14], ref iCh, ref iDI, ref iDO, ref panelCh14, ref btnCh14);
                InitChannelItems(true, bDIO[15], bMask[15], ref iCh, ref iDI, ref iDO, ref panelCh15, ref btnCh15);
                return(true);
            }
            return(false);
        }