Exemple #1
0
        private void slaveModuleInitialize()
        {
            uint mask = 0x00000001;

            uint[] deviceTable   = new uint[2];
            I16    retOfGetTable = CMNET_L132.CS_mnet_get_ring_active_table((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, ref deviceTable[0]);

            if (retOfGetTable != 0)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("DeviceTableError") + "(" + DeviceName + ")"));
            }
            if ((deviceTable[0] == 0) && (deviceTable[1] == 0))
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("DidntFindM1X1") + "(" + DeviceName + ")"));
            }

            for (int i = 0; i < 64; i++)
            {
                if (axisPara.SlaveIP > 63)
                {
                    throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongSlaveIP") + "(" + DeviceName + ")"));
                }

                if (axisPara.SlaveIP == i)
                {
                    if (i < 32)
                    {
                        if ((deviceTable[0] & mask) == 0)
                        {
                            throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongSlaveIP") + "(" + DeviceName + ")"));
                        }
                    }
                    else
                    {
                        if (i == 32)
                        {
                            mask = 0x00000001;
                        }
                        if ((deviceTable[1] & mask) == 0)
                        {
                            throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongSlaveIP") + "(" + DeviceName + ")"));
                        }
                    }
                }
                mask = mask << 1;
            }

            I16 retOfStartRing = CMNET_L132.CS_mnet_start_ring((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard);

            if (retOfStartRing != 0)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("StartCommError") + "(" + DeviceName + ")"));
            }

            U8  slaveType         = 0;
            I16 retOfGetSlaveType = CMNET_L132.CS_mnet_get_slave_type((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, axisPara.SlaveIP, ref slaveType);

            if (retOfGetSlaveType == 0)
            {
                if (slaveType != 0xA3)
                {
                    throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("WrongDeviceTypeM1X1") + "(" + DeviceName + ")"));
                }
            }
            else
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("DeviceTableError") + "(" + DeviceName + ")"));
            }

            I16 retOfInitial = CMNET_L132.CS_mnet_m1_initial((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, axisPara.SlaveIP);

            if (retOfInitial != 0)
            {
                throw new Exception(ExceptionHelper.GetFullCurrentMethod(ResourceHelper.Language.GetString("InitializeErrorM1X1") + "(" + DeviceName + ")"));
            }
        }