示例#1
0
 public Tag()
 {
     mDataType = DataType.None;
     mName = "";
     mParent = null;
     mDepth = 0;
     UseOverrideValue = false;
     mManualRead = false;
 }
示例#2
0
        public SerialIO()
        {
            mResponseReceived = false;
            mTxData = new byte[7];
            mRxData = new byte[7];
            mConnected = false;
            mInitialized = false;
            mVersionMatched = false;
            retryCount = 0;
            mWaitErrorStr = "No Response from CUBLOC - Check Cable and Serial Port";
            mVersion = 2;

            mInputTags = new Tag[11];
            mOutputTags = new Tag[10];
            for (int i = 0; i < mInputTags.Length; i++) {
                mInputTags[i] = new Tag("I.D" + i.ToString("00"), DataType.Bool);
                mInputTags[i].SetFlag(TagFlag.Input, true);
            }
            for (int i = 0; i < mOutputTags.Length; i++) {
                mOutputTags[i] = new Tag("O.D" + i.ToString("00"), DataType.Bool);
                mOutputTags[i].TagChanged += new EventHandler(OnOutputTagChanged);
                mOutputTags[i].SetFlag(TagFlag.Output, true);
            }
        }
示例#3
0
 protected int GetTagIndex(Tag tag)
 {
     for (int i = 0; i < mOutputTags.Length; i++) {
         if (mOutputTags[i] == tag) return i;
     }
     for (int i = 0; i < mInputTags.Length; i++) {
         if (mOutputTags[i] == tag) return i;
     }
     return -1;
 }
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Adds a tag to the opc server
        /// </summary>
        /// <param name="tag"></param>
        ///////////////////////////////////////////////////////////////////////////////////////////
        public bool AddTag(Tag tag)
        {
            OPCTag opcTag = new OPCTag(tag);
            if (mTagsByName.ContainsKey(opcTag.Name)) return false;

            if ((tag.Direction & TagDirection.Output) == TagDirection.Output) {
                tag.TagChanged += new TagEventHandler(OnTagChanged);
            }

            //Add an OPC Group if the update time does not alread exist
            OPCGroup group = GetGroup(opcTag.UpdateTime);
            OPCItem item = group.OPCItems.AddItem(opcTag.Name, mTagsByName.Count + 1);
            opcTag.OPCItem = item;
            opcTag.OPCGroup = group;

            if (item != null) {
                //Save the opctag in a dictionary for quick lookup by name or by ClientHandle
                mTagsByName.Add(opcTag.Name, opcTag);
                mTagsByHandle.Add(item.ClientHandle, opcTag);
                return true;
            } else {
                return false;
            }
        }
示例#5
0
 public Tag this[Tag tag]
 {
     get
     {
         return this[tag.Name];
     }
 }
示例#6
0
 public void Remove(Tag tag)
 {
     mTags.Remove(tag);
     tag.TagChanged -= new TagEventHandler(OnChildTagChanged);
 }
示例#7
0
 public void Insert(int index, Tag tag)
 {
     mTags.Insert(index, tag);
     tag.TagChanged += new TagEventHandler(OnChildTagChanged);
 }
示例#8
0
 public override void Copy(Tag tag)
 {
     base.Copy(tag);
 }
示例#9
0
 public void Add(Tag tag)
 {
     mTags.Add(tag);
     tag.Parent = this;
     tag.Depth = this.Depth + 1;
     tag.TagChanged += new TagEventHandler(OnChildTagChanged);
 }
 public TagEventArgs(Tag tag)
 {
     Tag = tag;
 }
示例#11
0
 public virtual void Copy(Tag tag, bool fireTagChanged)
 {
     Name = tag.mName;
     if (fireTagChanged) {
         Value = tag.mValue;
     } else {
         mValue = tag.mValue;
     }
 }
示例#12
0
 public virtual void Copy(Tag tag)
 {
     Copy(tag, true);
 }
示例#13
0
 public virtual object Clone()
 {
     Tag tag = new Tag(mName, mDataType);
     tag.mValue = mValue;
     return tag;
 }