Пример #1
0
        internal static LogixTag CreateQuickTag(string Address, LogixProcessor Processor, ushort Elements)
        {
            if (Address.Contains(".") || Address.Contains("["))
            {
                return CreateLongTag(Address, Processor, Elements);
            }

            LogixTagInfo ti = Processor.GetInfoForTag(Address);

            if (ti == null)
                return null;

            if (ti.IsStructure)
            {
                //We need to build an information object about this type
                //The first two bytes are a handle to the structure...
                ushort structureId = Processor.GetStructureHandle(Address);

                //Now we can send a request to get the attributes...
                TemplateInfo tempInfo = ReadStructAttributes(structureId, Processor);

                LogixTag st = CreateStructTag(Address, Processor, Elements, tempInfo);
                st.TagInfo = ti;
            }
            else
            {
                LogixTag at = null;

                switch ((CIPType)ti.DataType)
                {
                    case CIPType.BITS:
                    case CIPType.BOOL:
                        at = new LogixBOOL(Address, Processor, Elements); break;
                    case CIPType.SINT:
                        at = new LogixSINT(Address, Processor, Elements); break;
                    case CIPType.INT:
                        at = new LogixINT(Address, Processor, Elements); break;
                    case CIPType.DINT:
                        at = new LogixDINT(Address, Processor, Elements); break;
                    case CIPType.LINT:
                        at = new LogixLINT(Address, Processor, Elements); break;
                    case CIPType.REAL:
                        at = new LogixREAL(Address, Processor, Elements); break;
                    default:
                        break;      //Unknown type...
                }

                if (at != null)
                {
                    at.TagInfo = ti;
                    return at;
                }
            }

            return null;
        }