示例#1
0
        public int CheckCanAddTo(DWordTextBox WordTextItem)
        {
            string       strTempStation     = "";
            string       strTempWordType    = "";
            string       strTempWordAddress = "";
            PLCBaseClass plcDriver          = PLC.Driver(WordTextItem.DriverName);

            if (plcDriver == null)
            {
                WordTextItem.m_plcRes = PLCResponse.ERROR;
                WordTextItem.FreshDriverStatus();
                return(1);
            }
            if (plcDriver.GetWordAddress(
                    WordTextItem.DriverAddr, ref strTempStation, ref strTempWordType, ref strTempWordAddress) == false)
            {
                WordTextItem.m_plcRes = PLCResponse.ADDWRONG;
                WordTextItem.FreshDriverStatus();
                return(2);
            }
            int iTempWordAdd = int.Parse(strTempWordAddress);

            if (bInit == false)
            {
                strPlcName  = WordTextItem.DriverName;
                strStation  = strTempStation;
                iStartAddr  = iTempWordAdd;
                strWordType = strTempWordType;
                iEndAdd     = iTempWordAdd + 1;
                bInit       = true;
            }
            int iPHBeginWordAdd = iEndAdd - 15;
            int iPHEndWordAdd   = iStartAddr + 15;

            if (iTempWordAdd >= iPHBeginWordAdd && iTempWordAdd <= iPHEndWordAdd && strStation == strTempStation && strWordType == strTempWordType)
            {
                if (iTempWordAdd < iStartAddr)
                {
                    iStartAddr = iTempWordAdd;
                }
                if (iTempWordAdd >= iEndAdd)
                {
                    iEndAdd = iTempWordAdd + 1;
                }
            }
            else
            {
                return(3);
            }
            string strItemFullName = strTempStation + strTempWordType + strTempWordAddress;

            if (wordCtrlItemDis.Keys.Contains(strItemFullName))
            {
                WordTextItem.m_plcRes = PLCResponse.OTHERS;
                WordTextItem.FreshDriverStatus();
                return(4);
            }
            wordCtrlItemDis.Add(strItemFullName, WordTextItem);
            return(0);
        }
示例#2
0
        public int CheckCanAddTo(AlarmItem alarmItem)
        {
            string strTempStation     = "";
            string strTempWordType    = "";
            string strTempWordAddress = "";
            //string strTempWordEndAddress = "";
            string       strTempBitAddress = "";
            PLCBaseClass plcDriver         = PLC.Driver(alarmItem.strPlcName);

            if (plcDriver == null)
            {
                return(1);
            }
            if (plcDriver.GetBitAddress(
                    alarmItem.strAddress, ref strTempStation, ref strTempWordType, ref strTempWordAddress, ref strTempBitAddress) == false)
            {
                return(2);
            }
            int iTempWordAdd = int.Parse(strTempWordAddress);

            if (bInit == false)
            {
                strPlcName  = alarmItem.strPlcName;
                strStation  = strTempStation;
                iStartAddr  = iTempWordAdd;
                strWordType = strTempWordType;
                iEndAdd     = iTempWordAdd;
                bInit       = true;
            }
            int iPHBeginWordAdd = iEndAdd - 7;
            int iPHEndWordAdd   = iStartAddr + 7;

            if (iTempWordAdd >= iPHBeginWordAdd && iTempWordAdd <= iPHEndWordAdd && strStation == strTempStation && strWordType == strTempWordType)
            {
                if (iTempWordAdd < iStartAddr)
                {
                    iStartAddr = iTempWordAdd;
                }
                if (iTempWordAdd > iEndAdd)
                {
                    iEndAdd = iTempWordAdd;
                }
            }
            else
            {
                return(3);
            }
            string strItemFullName1 = strTempStation + strTempWordType + strTempWordAddress + strTempBitAddress;
            string strItemFullName  = alarmItem.strMachine + strItemFullName1;

            if (alarmItemDis.Keys.Contains(strItemFullName))
            {
                return(4);
            }
            alarmItemDis.Add(strItemFullName, alarmItem);
            return(0);
        }
        public int CheckCanAddTo(BitButton BitButtonItem)
        {
            string strTempStation     = "";
            string strTempWordType    = "";
            string strTempWordAddress = "";
            //string strTempWordEndAddress = "";
            string       strTempBitAddress = "";
            PLCBaseClass plcDriver         = PLC.Driver(BitButtonItem.DriverName);

            if (plcDriver == null)
            {
                BitButtonItem.m_plcRes = PLCResponse.ERROR;
                BitButtonItem.FreshDriverStatus();
                return(1);
            }
            if (plcDriver.GetBitAddress(
                    BitButtonItem.DriverAddrMonitor, ref strTempStation, ref strTempWordType, ref strTempWordAddress, ref strTempBitAddress) == false)
            {
                BitButtonItem.m_plcRes = PLCResponse.ADDWRONG;
                BitButtonItem.FreshDriverStatus();
                return(2);
            }
            int iTempWordAdd = int.Parse(strTempWordAddress);

            if (bInit == false)
            {
                strPlcName  = BitButtonItem.DriverName;
                strStation  = strTempStation;
                iStartAddr  = iTempWordAdd;
                strWordType = strTempWordType;
                iEndAdd     = iTempWordAdd;
                bInit       = true;
            }
            int iPHBeginWordAdd = iEndAdd - 7;
            int iPHEndWordAdd   = iStartAddr + 7;

            if (iTempWordAdd >= iPHBeginWordAdd && iTempWordAdd <= iPHEndWordAdd && strStation == strTempStation && strWordType == strTempWordType)
            {
                if (iTempWordAdd < iStartAddr)
                {
                    iStartAddr = iTempWordAdd;
                }
                if (iTempWordAdd > iEndAdd)
                {
                    iEndAdd = iTempWordAdd;
                }
            }
            else
            {
                return(3);
            }
            string strItemFullName = strTempStation + strTempWordType + strTempWordAddress + strTempBitAddress;

            if (bitCtrlItemDis.Keys.Contains(strItemFullName))
            {
                BitButtonItem.m_plcRes = PLCResponse.OTHERS;
                BitButtonItem.FreshDriverStatus();
                return(4);
            }
            bitCtrlItemDis.Add(strItemFullName, BitButtonItem);
            return(0);
        }