public bool TagImit(TagId tag) { try { lock (TagLocker) { var index = _tagValues.FindIndex(a => Equals(a.Tag, tag)); if (index != -1) { _tagValues.ElementAt(index).Imitation = !_tagValues.ElementAt(index).Imitation; _tagValues.ElementAt(index).RealLastValue = null; Logger.Logged("Info", "[ ] [WARN] [" + tag + "//] Set imitation to tag.", "", "TagImit"); return(true); } else { Logger.Logged("Info", "[ ] [WARN] [" + tag + "//] Cant set imitation to tag. No in _tagValues", "", "TagImit"); return(false); } } } catch (Exception ex) { Logger.Logged("Info", "[ ] [ERR] [" + tag + "//] Cant set imitation to tag. " + ex.Message + ".", "", "TagImit"); return(false); } }
protected virtual void OnSelectedIdChanged(TagId value) { //Check if (!itemIndex.ContainsKey(value)) { return; } //Begin Update TagList.BeginUpdate(); TagList.Items.Clear(); //Load Path TagList_LoadPath(itemIndex[value].Parent); //Sort TagList.Sort(); //Select foreach (ListViewItem item in TagList.Items) { if (item.Tag is FileSystemItem && ((FileSystemItem)item.Tag).ID == value) { item.Selected = true; TagList.EnsureVisible(item.Index); break; } } //End Update TagList.EndUpdate(); }
private void okButton_Click(object sender, EventArgs e) { //Check if (currentListItem == null) { return; } //Get File System Item FileSystemItem item = (FileSystemItem)currentListItem.Tag; //Check if (item.ID == 0) { //Begin Update TagList.BeginUpdate(); TagList.Items.Clear(); //Load Path TagList_LoadPath(item); //Sort TagList.Sort(); //End Update TagList.EndUpdate(); } else if (item != null) { //Select Tag selectedId = item.ID; DialogResult = DialogResult.OK; } }
public TagTestBuilder WithId(long id) { var tagId = new TagId(id); Id = tagId; return(this); }
public override bool WriteTag(TagId tag, string value) { try { groupWrite.RemoveItems(groupWrite.Items); List <Item> writeList = new List <Item>(); List <ItemValue> valueList = new List <ItemValue>(); Item itemToWrite = new Item(); itemToWrite.ItemName = tag.TagName; ItemValue itemValue = new ItemValue(itemToWrite); itemValue.Value = value; writeList.Add(itemToWrite); valueList.Add(itemValue); groupWrite.AddItems(writeList.ToArray()); for (int i = 0; i < valueList.Count; i++) { valueList[i].ServerHandle = groupWrite.Items[i].ServerHandle; } groupWrite.Write(valueList.ToArray()); return(true); } catch (Exception ex) { logger.Logged("Error", "Не удалось записать значние OPC DA сервера {" + tag.TagName + "[" + value + "]}: {" + ex.Message + "}", "OpcDaPoller", "WriteTag"); return(false); } }
public override int GetHashCode() { unchecked { return((TagId.GetHashCode() * 397) ^ Name.GetHashCode()); } }
public void AddTagTest() { TagPassing target = new TagPassing(); // TODO: Initialize to an appropriate value TagId tagId = new TagId(); // TODO: Initialize to an appropriate value target.AddTag(tagId); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
void toggleGroup_OnChange(Toggle toggle) { TagId tag = toggle.GetComponent <TagId> (); currentActiveLoop = tag.tagId; gridCreation.UpdateToggles(GameGrid.gameCells); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (InventoryVariantName != null) { hashCode = hashCode * 59 + InventoryVariantName.GetHashCode(); } if (TagId != null) { hashCode = hashCode * 59 + TagId.GetHashCode(); } if (AssetNumber != null) { hashCode = hashCode * 59 + AssetNumber.GetHashCode(); } if (SubNumber != null) { hashCode = hashCode * 59 + SubNumber.GetHashCode(); } if (CompanyCode != null) { hashCode = hashCode * 59 + CompanyCode.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (TagId != null) { hashCode = hashCode * 59 + TagId.GetHashCode(); } if (SecondTagId != null) { hashCode = hashCode * 59 + SecondTagId.GetHashCode(); } if (IsUntaggable != null) { hashCode = hashCode * 59 + IsUntaggable.GetHashCode(); } if (Comment != null) { hashCode = hashCode * 59 + Comment.GetHashCode(); } if (ShareTags != null) { hashCode = hashCode * 59 + ShareTags.GetHashCode(); } return(hashCode); } }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; } return(phTag); }
private void TreeView_CreateTagNode(TreeView treeView, string fileName, TagId id) { //Split TreeNode node = null; string[] parts = fileName.Split('\\'); TreeNodeCollection collection = treeView.Nodes; string lastPart = parts.Last(); //Loop for (int i = 0; i < parts.Length - 1; i++) { //Check if (!collection.ContainsKey(parts[i])) { node = collection.Add(parts[i], parts[i], 0); } else { node = collection[parts[i]]; } //Get nodes collection = node.Nodes; } //Add file node node = collection.Add(lastPart, lastPart, 1); node.Tag = id; }
//Helper method to check if source or tag have same Id and same content private bool CheckForIdAndPropertiesEqual(TagId placeholderId, IPlaceholderTagProperties phTagProperties) { if (_dictionaryTags.ContainsKey(int.Parse(placeholderId.Id)) && _dictionaryTags.ContainsValue(phTagProperties)) { return(true); } return(false); }
private void DemoMenuButton_Click(object sender, EventArgs e) { //Prepare TagId selectedId = SelectedEntry?.ID ?? TagId.Null; //Check Host.SelectEntry(this, Host.BrowseTag(this, selectedId)); }
public int CompareTo(object obj) { if (obj == null || obj.GetType() != GetType()) { throw new ArgumentException("Different types comparison"); } return(TagId.CompareTo((obj as Tag).TagId)); }
private string tagId_GetPath(TagId value) { if (Map.IndexEntries[value] != null) { return(Map.IndexEntries[value].Root); } return("null"); }
private string tagId_GetRoot(TagId value) { if (Map.IndexEntries[value] != null) { return(Map.IndexEntries[value].Filename); } return("Nulled Tag Reference"); }
public ActionResult OpcTagWriteValue(string tagName, int tagId, int pollerId, string val) { TagId tag = new TagId { TagName = tagName, Id = tagId, PollerId = pollerId }; bool z = MvcApplication.OpcPoller.WriteTag(tag, val); return(Json(z)); }
public EMVQRTagMeta(TagId tagId, string name, List <EMVQRTagMeta> tagParents, DataFormatterBase dataFormatter, string description, bool isTemplate = false) { Tag = tagId; Name = name; TagParents = tagParents; DataFormatter = dataFormatter; Description = description; IsTemplate = isTemplate; }
public static List <TagId> readTags(int opc_id) { var jss = new JavaScriptSerializer(); var resultTags = new List <TagId>(); bool result = false; while (result == false && must_break == false) { try { var tags = (from ti in context.Objects.Where(x => x.Type == 2 && x.ParentId == opc_id) join to in context.Properties.Where(x => x.PropId == 0) on ti.Id equals to.ObjectId select new { Id = ti.Id, Prop = to.Value }); //var tags = from to context.Objects foreach (var tag in tags) { try { var dict = jss.Deserialize <Dictionary <string, dynamic> >(tag.Prop); var newTag = new TagId { PollerId = opc_id, TagName = dict["Connection"] }; /* * tag_database[new_tag] = value_container; * //logger.Logged("Info", "Добавлен тэг {0} ({1})", tag.signal_id, tag.opc); */ resultTags.Add(newTag); logger.Logged("Info", "Тэг " + newTag.TagName + " (" + newTag.PollerId + ") добавлен", "PollerWatchdog", "readTags"); } catch (Exception ex) { logger.Logged("Error", "Тэг " + tag.Id + " (" + tag.Prop + ") не добавлен: " + ex.Message, "PollerWatchdog", "readTags"); continue; } } result = true; } catch (Exception ex) { logger.Logged("Error", "Не удалось считать список тегов для OPC-сервера из БД:" + ex.Message, "PollerWatchdog", "readTags"); logger.Logged("Warn", "Повторим попытку через 5 секунд...", "PollerWatchdog", "readTags"); Thread.Sleep(5000); } } logger.Logged("Info", "Добавление тэгов для сервера #" + opc_id + " завершено.", "PollerWatchdog", "readTags"); logger.Logged("Info", "Всего " + resultTags.Count() + " тэг(ов)", "PollerWatchdog", "readTags"); return(resultTags); }
/// <summary> /// Sets the index entry's internal object entry. /// </summary> /// <param name="tag">The tag.</param> /// <param name="id">The tag identifier.</param> /// <param name="size">The length of the data.</param> /// <param name="address">The memory address of the data.</param> public void SetObjectEntry(TagFourCc tag, TagId id, uint size, uint address) { objectEntry = new ObjectEntry() { Tag = tag, Id = id, Size = size, Offset = address }; }
public void ValueTest() { TagId target = new TagId(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.Value = expected; actual = target.Value; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
private void NewTagButton_Click(object sender, EventArgs e) { TagId id = TagId.Null; if (Map.CreateTag("bitm", @"dev\test_bitmap\test", 4, 108, out id)) { System.Windows.Forms.MessageBox.Show(id.ToString()); Host.Request(this, "ReloadMap"); } }
private void CreateMappedFile() { if (!File.Exists(FileName)) { throw new InvalidOperationException("Invalid file name.", new FileNotFoundException("System cannot find the file specified.", FileName)); } _mapped = MemoryMappedFile.CreateFromFile(FileName, FileMode.Open, TagId.ToString()); }
public ActionResult OpcTagSetImitation(string tagName, int tagId, int pollerId) { TagId tag = new TagId { TagName = tagName, Id = tagId, PollerId = pollerId }; bool z = MvcApplication.OpcPoller.TagImit(tag); return(Json(z)); }
/// <summary> /// Register a new Tag to listen for. /// </summary> /// <param name="tagId">The <typeparamref name="TagId"/> of the new Tag.</param> /// <remarks>If the tag already exists or is registered, no error is generated, /// but it may be logged.</remarks> public void AddTag(TagId tagId) { if (passingStrategy.ContainsKey(tagId)) { // TODO: Log a message or error, throw an exception? } // TODO: We need a factory or someway to make this configurable. // TODO: Should we allow different strategies per tag? If so, how? passingStrategy[tagId] = new PassingTimeDumb(); }
public Tag(string tagName, Category category, uint?tagId = null) { TagName = tagName; Category = category; if (tagId != null) { TagId.UpdateTagId(tagId.Value); } Id = tagId ?? TagId.GetNextTagId(); }
public static TagDto MapTag(TagId tagId, IEnumerable <Tag> tags) { var tag = tags.Single(t => Equals(t.Id, tagId)); return(new TagDto { Id = tag.Id.DbId, Name = tag.Name }); }
private IPlaceholderTag CreatePhTag(string tagContent, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = tagContent; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; if (source) { var thisId = new TagId(totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (tags.ContainsKey(int.Parse(thisId.Id)) && !tags.ContainsValue(phTagProperties)) { totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } if (!(tags.ContainsKey(int.Parse(thisId.Id)) && tags.ContainsValue(phTagProperties))) { tags.Add(totalTagCount, phTagProperties); } tagIds.Enqueue(totalTagCount); totalTagCount++; } else { int id; if (tagIds.Count != 0) { id = tagIds.Dequeue(); } else { id = totalTagCount++; } var thisId = new TagId(id.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (tags.ContainsKey(int.Parse(thisId.Id)) && !tags.ContainsValue(phTagProperties)) { totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } } return(phTag); }
/// <summary> /// Initializes a new <see cref="IndexEntryWrapper"/> instance. /// </summary> /// <param name="mapFile">The map file that contains this entry.</param> /// <param name="root">The root of the entry.</param> /// <param name="filename">The filename of the entry.</param> /// <param name="id">The ID of the entry.</param> /// <param name="tagData">The Tag data stream of the entry.</param> /// <param name="offset">The offset of the entry.</param> /// <param name="size">The size of the entry.</param> private IndexEntryWrapper(MapFile mapFile, TagFourCc root, string filename, TagId id, VirtualStream tagData, uint offset, uint size) { //Setup this.mapFile = mapFile; this.root = root; this.filename = filename; this.id = id; this.tagData = tagData; this.offset = offset; this.size = size; }
//Helper function for source or tag with the same Id but different content private int CreatePlaceholderTagHelper(TagId placeholderId, IPlaceholderTagProperties phTagProperties) { var max = _dictionaryTags.Keys.Max(); var id = max + 1; placeholderId.Id = id.ToString(); phTagProperties.TagId = placeholderId; _dictionaryTags.Add(id, phTagProperties); return(id); }
private static TagId GetNextId(TagId id) { //Get Dword uint idDword = id.Dword; ushort idLow = (ushort)((idDword & 0xFFFF) + 1); ushort idHi = (ushort)((idDword >> 16 & 0xFFFF) + 1); //Return return(idLow | (idHi << 16)); }
public override int GetHashCode() { int hashCode = -2103575766; unchecked { hashCode = (hashCode * -1521134295) + Section.GetHashCode(); hashCode = (hashCode * -1521134295) + TagId.GetHashCode(); } return(hashCode); }
public TagInfo Process(string line) { Dictionary<string, string> tokenPairs = ParseLine(line); //long id = System.Int64.Parse(tokenPairs["tag"], System.Globalization.NumberStyles.AllowHexSpecifier); TagId id = new TagId(); if (!tokenPairs.ContainsKey("tag")) throw new ApplicationException("The keyword tag does not exist in the read packet: " + line); id.Value = tokenPairs["tag"]; if (!tokenPairs.ContainsKey("freq")) throw new ApplicationException("The keyword freq does not exist in the read packet: " + line); float frequency = System.Single.Parse(tokenPairs["freq"]); if (!tokenPairs.ContainsKey("sig")) throw new ApplicationException("The keyword sig does not exist in the read packet: " + line); float signalStrength = System.Single.Parse(tokenPairs["sig"]); if (!tokenPairs.ContainsKey("ant")) throw new ApplicationException("The keyword ant does not exist in the read packet: " + line); int antenna = System.Int32.Parse(tokenPairs["ant"]); if (!tokenPairs.ContainsKey("time")) throw new ApplicationException("The keyword time does not exist in the read packet: " + line); long time = System.Int64.Parse(tokenPairs["time"]); TagInfo tagInfo = new TagInfo(id, frequency, signalStrength, antenna, time); return tagInfo; }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; } return phTag; }
public TagCreated(string tag, TagId tagId) { Tag = tag; TagId = tagId; }
public TagAddedToStory(StoryId storyId, TagId tagId, string tag, string storyName) { StoryId = storyId; TagId = tagId; Tag = tag; StoryName = storyName; }
public void IDTest() { TagReadEventArgs target = new TagReadEventArgs(); TagId expected = new TagId(); TagId actual; target.ID = expected; actual = target.ID; Assert.AreEqual(expected, actual); }
public void TagReadEventArgsConstructorTest1() { TagId id = new TagId(); id.Value = "foo"; float frequency = 5609.3F; float signalStrength = 732.5F; int antenna = 3; long time = 0230124812040; TagReadEventArgs target = new TagReadEventArgs(id, frequency, signalStrength, antenna, time); Assert.AreEqual(id, target.ID); Assert.AreEqual(frequency, target.Frequency); Assert.AreEqual(signalStrength, target.SignalStrenth); Assert.AreEqual(antenna, target.Antenna); Assert.AreEqual(time, target.Time); }
public DirectoryEntry Lookup (TagId id) { foreach (DirectoryEntry entry in entries) if (entry.Id == id) return entry; return null; }
public static int ParseHeader (byte [] data, int start, out TagId tagid, out EntryType type, Endian endian) { tagid = (TagId) BitConverter.ToUInt16 (data, start, endian == Endian.Little); type = (EntryType) BitConverter.ToUInt16 (data, start + 2, endian == Endian.Little); return 4; }
//Helper function for source or tag with the same Id but different content private int CreatePlaceholderTagHelper(TagId placeholderId, IPlaceholderTagProperties phTagProperties) { var max = _dictionaryTags.Keys.Max(); var id = max + 1; placeholderId.Id = id.ToString(); phTagProperties.TagId = placeholderId; _dictionaryTags.Add(id, phTagProperties); return id; }
//Helper method to check if source or tag have same Id and same content private bool CheckForIdAndPropertiesEqual(TagId placeholderId, IPlaceholderTagProperties phTagProperties) { if (_dictionaryTags.ContainsKey(int.Parse(placeholderId.Id)) && _dictionaryTags.ContainsValue(phTagProperties)) { return true; } return false; }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; //check for source with the same Id and different properties if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } //check for source with the same Id and same properties if (!CheckForIdAndPropertiesEqual(thisId, phTagProperties)) { _dictionaryTags.Add(int.Parse(thisId.Id), phTagProperties); } } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount= CreatePlaceholderTagHelper(thisId, phTagProperties); } } return phTag; }