Пример #1
0
        private bool SelectModule()
        {
            int nModuleCount = 0;

            CAXD.AxdInfoGetModuleCount(ref nModuleCount);

            if (nModuleCount > 0)
            {
                int   nBoardNo   = 0;
                int   nModulePos = 0;
                uint  uModuleID  = 0;
                short nIndex     = 0;
                uint  uDataHigh  = 0;
                uint  uDataLow   = 0;
                uint  uFlagHigh  = 0;
                uint  uFlagLow   = 0;
                uint  uUse       = 0;

                CAXD.AxdInfoGetModule(comboModule.SelectedIndex, ref nBoardNo, ref nModulePos, ref uModuleID);

                switch ((AXT_MODULE)uModuleID)
                {
                case AXT_MODULE.AXT_SIO_DI32:
                case AXT_MODULE.AXT_SIO_RDI32:
                    groupHigh.Text = "INPUT  0bit ~ 15Bit";
                    groupLow.Text  = "INPUT 16bit ~ 31Bit";

                    if (((AXT_MODULE)uModuleID) == AXT_MODULE.AXT_SIO_RDI32)
                    {
                        checkInterrupt.Checked   = false;
                        radioCallback.Enabled    = false;
                        radioMessage.Enabled     = false;
                        radioEvent.Enabled       = false;
                        checkRigingEdge.Checked  = false;
                        checkFallingEdge.Checked = false;
                    }
                    else
                    {
                        checkInterrupt.Checked   = true;
                        radioCallback.Enabled    = true;
                        radioMessage.Enabled     = true;
                        radioEvent.Enabled       = true;
                        checkRigingEdge.Checked  = true;
                        checkFallingEdge.Checked = true;

                        CAXD.AxdiInterruptGetModuleEnable(comboModule.SelectedIndex, ref uUse);
                        if (uUse == (uint)AXT_USE.ENABLE)
                        {
                            checkInterrupt.Checked = true;
                            SelectMessage();
                        }
                        else
                        {
                            checkInterrupt.Checked = false;
                        }

                        CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 0, (uint)AXT_DIO_EDGE.UP_EDGE, ref uDataHigh);
                        CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 1, (uint)AXT_DIO_EDGE.UP_EDGE, ref uDataLow);
                        if (uDataHigh == 0xFFFF && uDataLow == 0xFFFF)
                        {
                            checkRigingEdge.Checked = true;
                        }
                        else
                        {
                            checkRigingEdge.Checked = false;
                        }

                        CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 0, (uint)AXT_DIO_EDGE.DOWN_EDGE, ref uDataHigh);
                        CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 1, (uint)AXT_DIO_EDGE.DOWN_EDGE, ref uDataLow);
                        if (uDataHigh == 0xFFFF && uDataLow == 0xFFFF)
                        {
                            checkFallingEdge.Checked = true;
                        }
                        else
                        {
                            checkFallingEdge.Checked = false;
                        }
                    }

                    for (nIndex = 0; nIndex < 16; nIndex++)
                    {
                        checkHigh[nIndex].Text = String.Format("{0:D2}", nIndex);
                        checkLow[nIndex].Text  = String.Format("{0:D2}", nIndex + 16);
                    }
                    break;

                case AXT_MODULE.AXT_SIO_DO32P:
                case AXT_MODULE.AXT_SIO_DO32T:
                case AXT_MODULE.AXT_SIO_RDO32:
                    groupHigh.Text = "OUTPUT  0bit ~ 15Bit";
                    groupLow.Text  = "OUTPUT 16bit ~ 31Bit";

                    checkInterrupt.Checked   = false;
                    radioCallback.Enabled    = false;
                    radioMessage.Enabled     = false;
                    radioEvent.Enabled       = false;
                    checkRigingEdge.Checked  = false;
                    checkFallingEdge.Checked = false;

                    //++
                    // Read outputting signal in WORD
                    CAXD.AxdoReadOutportWord(comboModule.SelectedIndex, 0, ref uDataHigh);
                    CAXD.AxdoReadOutportWord(comboModule.SelectedIndex, 1, ref uDataLow);

                    for (nIndex = 0; nIndex < 16; nIndex++)
                    {
                        // Verify the last bit value of data read
                        uFlagHigh = uDataHigh & 0x0001;
                        uFlagLow  = uDataLow & 0x0001;

                        // Shift rightward by bit by bit
                        uDataHigh = uDataHigh >> 1;
                        uDataLow  = uDataLow >> 1;

                        // Updat bit value in control
                        if (uFlagHigh == 1)
                        {
                            checkHigh[nIndex].Checked = true;
                        }
                        else
                        {
                            checkHigh[nIndex].Checked = false;
                        }

                        if (uFlagLow == 1)
                        {
                            checkLow[nIndex].Checked = true;
                        }
                        else
                        {
                            checkLow[nIndex].Checked = false;
                        }

                        checkHigh[nIndex].Text = String.Format("{0:D2}", nIndex);
                        checkLow[nIndex].Text  = String.Format("{0:D2}", nIndex + 16);
                    }
                    break;

                case AXT_MODULE.AXT_SIO_DB32P:
                case AXT_MODULE.AXT_SIO_DB32T:
                case AXT_MODULE.AXT_SIO_RDB128MLII:
                    groupHigh.Text = "INPUT  0bit ~ 15Bit";
                    groupLow.Text  = "OUTPUT  0bit ~ 15Bit";

                    // Only Digital Input was used
                    checkInterrupt.Enabled   = true;
                    checkRigingEdge.Enabled  = true;
                    checkFallingEdge.Enabled = true;

                    CAXD.AxdiInterruptGetModuleEnable(comboModule.SelectedIndex, ref uUse);
                    if (uUse == (uint)AXT_USE.ENABLE)
                    {
                        checkInterrupt.Checked = true;
                        SelectMessage();
                    }
                    else
                    {
                        checkInterrupt.Checked = false;
                    }

                    CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 0, (uint)AXT_DIO_EDGE.UP_EDGE, ref uDataHigh);
                    if (uDataHigh == 0xFFFF)
                    {
                        checkRigingEdge.Checked = true;
                    }
                    else
                    {
                        checkRigingEdge.Checked = false;
                    }

                    CAXD.AxdiInterruptEdgeGetWord(comboModule.SelectedIndex, 0, (uint)AXT_DIO_EDGE.DOWN_EDGE, ref uDataHigh);
                    if (uDataHigh == 0xFFFF)
                    {
                        checkFallingEdge.Checked = true;
                    }
                    else
                    {
                        checkFallingEdge.Checked = false;
                    }

                    //++
                    // Read outputting signal in WORD
                    CAXD.AxdoReadOutportWord(comboModule.SelectedIndex, 0, ref uDataLow);

                    for (nIndex = 0; nIndex < 16; nIndex++)
                    {
                        // Verify the last bit value of data read
                        uFlagLow = uDataLow & 0x0001;

                        // Shift rightward by bit by bit
                        uDataLow = uDataLow >> 1;

                        // Updat bit value in control
                        if (uFlagLow == 1)
                        {
                            checkLow[nIndex].Checked = true;
                        }
                        else
                        {
                            checkLow[nIndex].Checked = false;
                        }

                        checkHigh[nIndex].Text = String.Format("{0:D2}", nIndex);
                        checkLow[nIndex].Text  = String.Format("{0:D2}", nIndex);
                    }
                    break;
                }
            }

            return(true);
        }