public static bool ModifyItemName(this ITag tag, string name) { IDataServer server = tag.Parent.Server; lock (server.SyncRoot) { int index = server.GetItemProperties(tag.ID); if (index < 0) { return(false); } var meta = server.MetaDataList[index]; if (meta.Name == name) { return(true); } server.MetaDataList[index] = new TagMetaData(meta.ID, meta.GroupID, name, meta.Address, meta.DataType, meta.Size, meta.Archive, meta.Maximum, meta.Minimum, meta.Cycle); server.RemoveItemIndex(meta.Name); server.AddItemIndex(name, tag); return(true); } }
public static string GetTagName(this IDataServer srv, short id) { int ind = srv.GetItemProperties(id); return(ind < 0 ? null : srv.MetaDataList[ind].Name); }