Пример #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;
        }
Пример #2
0
        internal static TemplateInfo GetTemplateInfo(string Address, LogixProcessor Processor, ushort Elements)
        {
            //lock (Processor.SyncRoot)
            {
                ReadDataServiceReply lgxRead = LogixServices.ReadLogixData(
                    Processor.SessionInfo, Address, Elements);

                if (lgxRead == null)
                    return null;

                if (lgxRead.Data == null)
                    return null;

                if (lgxRead.Status != 0x00 && lgxRead.Status != 0x06)
                {
                    return null;
                }

                //The first two bytes are the type...
                CIPType tagType = (CIPType)lgxRead.DataType;

                if (tagType == CIPType.STRUCT)
                {
                    //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 ti = ReadStructAttributes(structureId, Processor);

                    return ti;
                }
            }

            return null;
        }
Пример #3
0
        internal static LogixTag CreateLongTag(string Address, LogixProcessor Processor, ushort Elements)
        {
            //It doesn't exist in the list, maybe it was added later?
            //lock (Processor.SyncRoot)
            {
                ReadDataServiceReply lgxRead = LogixServices.ReadLogixData(
                    Processor.SessionInfo, Address, Elements);

                if (lgxRead == null)
                    return null;

                if (lgxRead.Data == null)
                    return null;

                if (lgxRead.Status != 0x00 && lgxRead.Status != 0x06)
                {
                    return null;
                }

                //The first two bytes are the type...
                CIPType tagType = (CIPType)lgxRead.DataType;

                if (tagType == CIPType.STRUCT)
                {
                    //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 ti = ReadStructAttributes(structureId, Processor);

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

                return null;
            }
        }