public bool AddItems(IList <TagMetaData> items) { int count = items.Count; if (_items == null) { _items = new Dictionary <short, ITag>(count); } lock (_server.SyncRoot) { for (int i = 0; i < count; i++) { ITag dataItem = null; TagMetaData meta = items[i]; DeviceAddress addr = new DeviceAddress(0, 0, 0, meta.ID, meta.Size, 0, meta.DataType); switch (meta.DataType) { case DataType.BOOL: dataItem = new BoolTag(meta.ID, addr, this); break; case DataType.BYTE: dataItem = new ByteTag(meta.ID, addr, this); break; case DataType.WORD: dataItem = new UShortTag(meta.ID, addr, this); break; case DataType.SHORT: dataItem = new ShortTag(meta.ID, addr, this); break; case DataType.INT: dataItem = new IntTag(meta.ID, addr, this); break; case DataType.DWORD: dataItem = new UIntTag(meta.ID, addr, this); break; case DataType.FLOAT: dataItem = new FloatTag(meta.ID, addr, this); break; case DataType.STR: dataItem = new StringTag(meta.ID, addr, this); break; default: dataItem = new BoolTag(meta.ID, addr, this); break; } _items.Add(meta.ID, dataItem); _server.AddItemIndex(meta.Name, dataItem); } } //Init(); return(true); }
private void LoadTag(ListTag tags) { foreach (Tag tag in tags.Tags) { if (tag is EndTag) { this.AddEndTag(); } else if (tag is ByteTag) { ByteTag t = (ByteTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is ShortTag) { ShortTag t = (ShortTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is IntTag) { IntTag t = (IntTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is LongTag) { LongTag t = (LongTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is FloatTag) { FloatTag t = (FloatTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is DoubleTag) { DoubleTag t = (DoubleTag)tag; this.AddTag(t.Data, t.TagType); } //TODO: ByteArrayTag... else if (tag is StringTag) { StringTag t = (StringTag)tag; this.AddTag(t.Data, t.TagType); } else if (tag is ListTag) { ListTag t = (ListTag)tag; this.AddListInListTagHeader(t); this.LoadTag(t); } else if (tag is CompoundTag) { CompoundTag t = (CompoundTag)tag; this.LoadTag(t, false, true); } //TODO: IntArrayTag... //TDDO: LongArrayTag... } }
public virtual ISpan SetTag(IntTag tag, int value) { _span.SetTag(tag, value); _hooks.OnSpanSetTag(_span, _operationName, new TagKeyValue { key = tag.Key, value = value }); return(this); }
/// <inheritdoc /> public ISpan SetTag(IntTag tag, int value) { if (string.IsNullOrWhiteSpace(tag.Key)) { throw new ArgumentNullException(nameof(tag.Key)); } return(SetObjectTag(tag.Key, value)); }
public bool AddItems(IList <TagMetaData> items) { int count = items.Count; if (_items == null) { _items = new List <ITag>(); } lock (_server.SyncRoot) { int j = 0; for (int i = 0; i < count; i++) { ITag dataItem = null; TagMetaData meta = items[i]; if (meta.GroupID == this._id) { DeviceAddress addr = new DeviceAddress(-1, (ushort)meta.GroupID, (ushort)meta.ID, j++, meta.Size, 0, meta.DataType); switch (meta.DataType) { case DataType.BOOL: dataItem = new BoolTag(meta.ID, addr, this); break; case DataType.BYTE: dataItem = new ByteTag(meta.ID, addr, this); break; case DataType.WORD: case DataType.SHORT: dataItem = new ShortTag(meta.ID, addr, this); break; case DataType.TIME: case DataType.INT: dataItem = new IntTag(meta.ID, addr, this); break; case DataType.FLOAT: dataItem = new FloatTag(meta.ID, addr, this); break; case DataType.STR: dataItem = new StringTag(meta.ID, addr, this); break; default: dataItem = new BoolTag(meta.ID, addr, this); break; } _items.Add(dataItem); _server.AddItemIndex(meta.Name, dataItem); } } } return(true); }
public virtual ISpanBuilder WithTag(IntTag tag, int value) { _tagsApplies.Add(s => s.SetTag(tag, value)); return(this); }
public bool AddItems(IList <TagMetaData> items) { FxSerialReader fxReader = _plcReader as FxSerialReader; if (fxReader == null) { return(false); } int count = items.Count; if (_items == null) { _items = new List <ITag>(count); } lock (_server.SyncRoot) { for (int i = 0; i < count; i++) { ITag dataItem = null; TagMetaData meta = items[i]; if (meta.GroupID == this._id) { DeviceAddress addr = fxReader.GetDeviceAddress(meta); if (addr.DataSize == 0) { addr.DataSize = meta.Size; } if (addr.VarType == DataType.NONE) { addr.VarType = meta.DataType; } if (addr.VarType != DataType.BOOL) { addr.Bit = 0; } switch (meta.DataType) { case DataType.BOOL: dataItem = new BoolTag(meta.ID, addr, this); break; case DataType.BYTE: dataItem = new ByteTag(meta.ID, addr, this); break; case DataType.WORD: dataItem = new UShortTag(meta.ID, addr, this); break; case DataType.SHORT: dataItem = new ShortTag(meta.ID, addr, this); break; case DataType.DWORD: dataItem = new UIntTag(meta.ID, addr, this); break; case DataType.INT: dataItem = new IntTag(meta.ID, addr, this); break; case DataType.FLOAT: dataItem = new FloatTag(meta.ID, addr, this); break; case DataType.STR: dataItem = new StringTag(meta.ID, addr, this); break; } if (dataItem != null) { //dataItem.Active = meta.Active; _items.Add(dataItem); _server.AddItemIndex(meta.Name, dataItem); } } } } _items.TrimExcess(); _items.Sort((x, y) => x.Address.CompareTo(y.Address)); UpdatePDUArea(); return(true); }
public ISpanBuilder WithTag(IntTag tag, int value) { throw new NotImplementedException(); }
public ISpanBuilder WithTag(IntTag tag, int value) { return(this); }
public override EventHookSpan SetTag(IntTag tag, int value) { this.spanSetTag(this, new SetTagEventArgs(tag.Key, value)); return(this); }
ISpanBuilder ISpanBuilder.WithTag(IntTag tag, int value) { return(WithTag(tag, value)); }
public ISpanBuilder WithTag(IntTag tag, int value) { _tags.Add(tag.Key, value); return(this); }
public global::OpenTracing.ISpan SetTag(IntTag tag, int value) { return(SetTag(tag.Key, value)); }
public ISpan SetTag(IntTag tag, int value) => SetTagInternal(tag.Key, value);
public ISpan SetTag(IntTag tag, int value) { SetObjectTag(tag.Key, value); return(this); }
private void LoadTag(CompoundTag tags, bool isRoot = false, bool isList = false) { if (!isRoot) { if (isList) { this.AddListInCompoundTagHeader(tags); } else { this.AddCompoundTagHeader(tags); } } foreach (KeyValuePair <string, Tag> tagKV in tags.Tags) { Tag tag = tagKV.Value; if (tag is EndTag) { this.AddEndTag(); } else if (tag is ByteTag) { ByteTag t = (ByteTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is ShortTag) { ShortTag t = (ShortTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is IntTag) { IntTag t = (IntTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is LongTag) { LongTag t = (LongTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is FloatTag) { FloatTag t = (FloatTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is DoubleTag) { DoubleTag t = (DoubleTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } //TODO: ByteArrayTag... else if (tag is StringTag) { StringTag t = (StringTag)tag; this.AddTag(t.Name, t.Data, t.TagType); } else if (tag is ListTag) { ListTag t = (ListTag)tag; this.AddListTagHeader(t); this.LoadTag(t); } else if (tag is CompoundTag) { CompoundTag t = (CompoundTag)tag; this.LoadTag(t); } //TODO: IntArrayTag... //TDDO: LongArrayTag... } if (!isRoot) { this.AddEndTag(); } }
static void Main(string[] args) { ObjectDataStructure ods = new ObjectDataStructure(new FileInfo(Directory.GetCurrentDirectory() + @"\test3.ods"), new GZIPCompression()); // Register a custom tag. ODSUtil.RegisterCustomTag(new CustomTag("", "")); Console.WriteLine(Directory.GetCurrentDirectory() + "\\test3.ods"); List <ITag> tags = new List <ITag>(); tags.Add(new StringTag("ExampleKey", "This is an example string!")); tags.Add(new IntTag("ExampleInt", 754)); ObjectTag car = new ObjectTag("Car"); car.AddTag(new StringTag("type", "Jeep")); car.AddTag(new IntTag("gas", 30)); List <IntTag> coordsList = new List <IntTag>() { new IntTag("", 10), new IntTag("", 5), new IntTag("", 10) }; car.AddTag(new ListTag <IntTag>("coords", coordsList)); ObjectTag owner = new ObjectTag("Owner"); owner.AddTag(new StringTag("firstName", "Jeff")); owner.AddTag(new StringTag("lastName", "Bob")); owner.AddTag(new IntTag("Age", 30)); car.AddTag(owner); tags.Add(car); tags.Add(new CustomTag("Test", "Test")); CompressedObjectTag compressedObjectTag = new CompressedObjectTag("TestCompressedObject"); compressedObjectTag.AddTag(ODSUtil.Wrap("TestObject", "This is a test!")); compressedObjectTag.AddTag(ODSUtil.Wrap("Number", 15)); compressedObjectTag.AddTag(ODSUtil.Wrap("Decimal", 34.5)); tags.Add(compressedObjectTag); ods.Save(tags); ods.Append(new StringTag("Test", "test")); ods.GetAll(); // Loading Example StringTag tag = (StringTag)ods.Get("ExampleKey"); Console.WriteLine("The value of the ExampleKey is: " + tag.GetValue()); ObjectTag myCar = (ObjectTag)ods.Get("Car"); StringTag myCarType = (StringTag)myCar.GetTag("type"); Console.WriteLine("The car is a " + myCarType.GetValue()); Console.WriteLine("First Name:"); StringTag ownerFirstName = (StringTag)ods.Get("Car.Owner.firstName"); Console.WriteLine("Last Name:"); StringTag ownerLastName = (StringTag)ods.Get("Car.Owner.lastName"); Console.WriteLine("The owner of the car is " + ODSUtil.UnWrap(ownerFirstName) + " " + ODSUtil.UnWrap(ownerLastName)); Console.WriteLine(ods.Find("Car.Owner.firstName")); Console.WriteLine(((CustomTag)ods.Get("Test")).GetValue()); ods.Set("Car.Owner.firstName", new StringTag("firstName", "Example")); ods.ReplaceData("Car.Owner.Age", new IntTag("Age", 3)); Console.WriteLine(ODSUtil.UnWrap((IntTag)ods.Get("Car.Owner.Age"))); CompressedObjectTag compressedObject = (CompressedObjectTag)ods.Get("TestCompressedObject"); IntTag numberTag = (IntTag)compressedObject.GetTag("Number"); Console.WriteLine("Test Compression Number: " + numberTag.GetValue()); ods.SaveToFile(new FileInfo(@"new_file.ods"), new GZIPCompression()); //ods.Set("Car.Owner.Age", new IntTag("Age", 3)); }
public override EventHookSpanBuilder WithTag(IntTag tag, int value) { var newTags = this.tagsOnStart.Add(new SetTagEventArgs(tag.Key, value)); return(new EventHookSpanBuilder(this.tracer, this.operationName, this.spanLog, this.spanSetTag, newTags, this.parentSpanContext, this.ignoreActiveSpan)); }
public ISpanBuilder WithTag(IntTag tag, int value) { return(WithTag(tag.Key, value.ToString(CultureInfo.InvariantCulture))); }
public ISpan SetTag(IntTag tag, int value) => SetTagAsObject(tag.Key, value);
public ISpan SetTag(IntTag tag, int value) { return(this); }
private CompoundTag CreateBigTestNbtTag() { var tag = new CompoundTag() { Name = "Level", }; var longTest = new LongTag() { Name = "longTest", Value = 9223372036854775807L, }; tag.Items.Add(longTest); var shortTest = new ShortTag() { Name = "shortTest", Value = 32767, }; tag.Items.Add(shortTest); var stringTest = new StringTag() { Name = "stringTest", Value = @"HELLO WORLD THIS IS A TEST STRING ÅÄÖ!", }; tag.Items.Add(stringTest); var floatTest = new FloatTag() { Name = "floatTest", Value = 0.49823147F, }; tag.Items.Add(floatTest); var intTest = new IntTag() { Name = "intTest", Value = 2147483647, }; tag.Items.Add(intTest); var nestedCompoundTest = new CompoundTag() { Name = "nested compound test", Items = new List<Tag>() { new CompoundTag() { Name = "ham", Items = new List<Tag>() { new StringTag() { Name = "name", Value = "Hampus", }, new FloatTag() { Name = "value", Value = 0.75F, } }, }, new CompoundTag() { Name = "egg", Items = new List<Tag>() { new StringTag() { Name = "name", Value = "Eggbert", }, new FloatTag() { Name = "value", Value = 0.5F, } }, } }, }; tag.Items.Add(nestedCompoundTest); var listTestLong = new ListTag() { Name = "listTest (long)", ItemType = TagType.Long, Length = 5, Items = new Tag[] { new LongTag() { Value = 11, }, new LongTag() { Value = 12, }, new LongTag() { Value = 13, }, new LongTag() { Value = 14, }, new LongTag() { Value = 15, }, }, }; tag.Items.Add(listTestLong); var listTestCompound = new ListTag() { Name = "listTest (compound)", ItemType = TagType.Compound, Length = 2, Items = new Tag[] { new CompoundTag() { Items = new List<Tag>() { new StringTag() { Name = "name", Value = "Compound tag #0", }, new LongTag() { Name = "created-on", Value = 1264099775885L, }, }, }, new CompoundTag() { Items = new List<Tag>() { new StringTag() { Name = "name", Value = "Compound tag #1", }, new LongTag() { Name = "created-on", Value = 1264099775885L, }, }, }, }, }; tag.Items.Add(listTestCompound); var byteTest = new ByteTag() { Name = "byteTest", Value = 127, }; tag.Items.Add(byteTest); var byteArrayTest = new ByteArrayTag() { Name = "byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", Length = 1000, Items = new byte[1000], }; for (int i = 0; i < 1000; ++i) { byteArrayTest.Items[i] = (byte)((i * i * 255 + i * 7) % 100); } tag.Items.Add(byteArrayTest); var doubleTest = new DoubleTag() { Name = "doubleTest", Value = 0.4931287132182315, }; tag.Items.Add(doubleTest); return tag; }
public bool AddItems(IList <TagMetaData> items) { int count = items.Count; if (_items == null) { _items = new List <ITag>(count); mapping = new Dictionary <short, ITag>(count); } List <OPCITEMDEF> itemArray = new List <OPCITEMDEF>(count); for (int i = 0; i < count; i++) { if (items[i].GroupID == this._Id) { itemArray.Add(new OPCITEMDEF { hClient = items[i].ID, szItemID = items[i].Address, bActive = true, wReserved = (short)i }); } } IntPtr pAddResults; IntPtr pErrors; if (!HRESULTS.Succeeded(_itemMgt.AddItems(itemArray.Count, itemArray.ToArray(), out pAddResults, out pErrors))) { return(false); } int iStructSize = Marshal.SizeOf(typeof(OPCITEMRESULT)); lock (_server.SyncRoot) { for (int i = 0; i < itemArray.Count; i++) { try { if (Marshal.ReadInt32(pErrors) == 0) { ITag dataItem = null; var itemDef = itemArray[i]; //string addr = string.Concat(_serverId, ',', Marshal.ReadInt32(pAddResults)); DataType type = items[itemDef.wReserved].DataType; switch (type) { case DataType.BOOL: dataItem = new BoolTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 1, 0, DataType.BOOL), this); break; case DataType.BYTE: dataItem = new ByteTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 1, 0, DataType.BYTE), this); break; case DataType.WORD: dataItem = new UShortTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 2, 0, DataType.WORD), this); break; case DataType.SHORT: dataItem = new ShortTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 2, 0, DataType.SHORT), this); break; case DataType.INT: dataItem = new IntTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 4, 0, DataType.INT), this); break; case DataType.DWORD: dataItem = new UIntTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 4, 0, DataType.DWORD), this); break; case DataType.FLOAT: dataItem = new FloatTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 4, 0, DataType.FLOAT), this); break; case DataType.SYS: case DataType.STR: dataItem = new StringTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), 64, 0, DataType.STR), this); break; default: break; //case VarEnum.VT_ARRAY: // dataItem = new ArrayTag((short)itemDef.hClient, new DeviceAddress(-0x100, 0, 0, Marshal.ReadInt32(pAddResults), (byte)Marshal.ReadInt16(pAddResults + 18), 0, DataType.ARRAY), this); // break; } if (dataItem != null) { _items.Add(dataItem); mapping.Add((short)itemDef.hClient, dataItem); _server.AddItemIndex(items[itemDef.wReserved].Name, dataItem); } pAddResults += iStructSize; pErrors += 4; } } catch (Exception err) { if (err.Message != null) { } } } //Marshal.FreeCoTaskMem(pAddResults); //Marshal.FreeCoTaskMem(pErrors); _items.TrimExcess(); return(true); } }
public ISpanBuilder WithTag(IntTag tag, int value) { _tags[tag.Key] = value; return(this); }
public void IntTagTest() { var tag = new IntTag(); Assert.AreEqual(TagType.Int, tag.Type); }
public ISpan SetTag(IntTag tag, int value) { return(SetTag(tag.Key, value)); }
/// <inheritdoc /> public ISpanBuilder WithTag(IntTag tag, int value) { return(tag == null ? this : SetTagObject(tag.Key, value)); }
public ISpanBuilder WithTag(IntTag tag, int value) { return(WithTag(tag.Key, value)); }
public override CvTextWriterSpan SetTag(IntTag tag, int value) { this.OutputData(OutputDataCategory.Tag, $"{tag.Key}: {value}"); return(this); }
public ISpan SetTag(IntTag tag, int value) { Tags.Add(tag.Key, value); return(this); }
public bool AddItems(IList <TagMetaData> items) { int count = items.Count; if (_items == null) { _items = new List <ITag>(count); _mapping = new Dictionary <short, string>(count); } lock (_server.SyncRoot) { for (int i = 0; i < count; i++) { ITag dataItem = null; TagMetaData meta = items[i]; if (meta.GroupID == this._id) { DeviceAddress addr = new DeviceAddress { Start = meta.ID, DataSize = meta.Size, VarType = meta.DataType }; switch (meta.DataType) { case DataType.BOOL: dataItem = new BoolTag(meta.ID, addr, this); break; case DataType.BYTE: dataItem = new ByteTag(meta.ID, addr, this); break; case DataType.WORD: case DataType.SHORT: dataItem = new ShortTag(meta.ID, addr, this); break; case DataType.DWORD: case DataType.INT: dataItem = new IntTag(meta.ID, addr, this); break; case DataType.FLOAT: dataItem = new FloatTag(meta.ID, addr, this); break; case DataType.STR: dataItem = new StringTag(meta.ID, addr, this); break; } if (dataItem != null) { //dataItem.Active = meta.Active; _items.Add(dataItem); _plcReader.TransactItem(meta.Name); _mapping.Add(meta.ID, meta.Address); _server.AddItemIndex(meta.Name, dataItem); } } } return(true); } }