public void DefineUshortTag( RegisterFunction function, TagAddressMaskType masktype = TagAddressMaskType.None, ushort mask = ushort.MaxValue, TagAddressMergeType mergetype = TagAddressMergeType.OrMerge, ushort range = ushort.MinValue) { if (InnerTag != null) { return; } UshortTag innertag = new UshortTag(function) { MaskType = masktype, Mask = mask, MergeType = mergetype, Range = range }; InnerTag = innertag; InnerTag.TagValueChangedEvent += delegate(ITagType tag) { TagStatusChanged?.Invoke(this, EventArgs.Empty); }; }
private void Classificator(Tag addingTag) { if (addingTag.TagDirection == Direction.Write) { if (!allWriteTags.ContainsKey(addingTag.Name)) { allWriteTags.Add(addingTag.Name, addingTag); } return; } if (addingTag.InnerTag is BoolTag) { if (!allBoolTags.ContainsKey(addingTag.Name)) { allBoolTags.Add(addingTag.Name, (addingTag.InnerTag as BoolTag)); } } else if (addingTag.InnerTag is UshortTag) { allUshortTags.Add(addingTag.Name, (addingTag.InnerTag as UshortTag)); } else if (addingTag.InnerTag is FloatTag) { allFloatTags.Add(addingTag.Name, (addingTag.InnerTag as FloatTag)); } if (addingTag.InnerTag.Function == StatusFunction.CoilStatus) { if (!CoilStatuses.ContainsKey(addingTag.Name)) { CoilStatuses.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == StatusFunction.InputStatus) { if (!InputStatuses.ContainsKey(addingTag.Name)) { InputStatuses.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == RegisterFunction.HoldingRegister) { if (!InputStatuses.ContainsKey(addingTag.Name)) { HoldingRegisters.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == RegisterFunction.InputRegister) { if (!InputStatuses.ContainsKey(addingTag.Name)) { InputRegisters.Add(addingTag.Name, (addingTag.InnerTag)); } } addingTag.TagStatusChanged += delegate(Tag sender, object value, bool quality) { TagStatusChanged?.Invoke(sender, value, quality); }; }
new internal void Add(string devicename, Device device) { if (ContainsKey(devicename)) { logger.Warning(null, $"Device already added - {devicename}"); return; } base.Add(devicename, device); device.ConnectionStatusChanged += Device_ConnectionStatusChanged; device.Collection.TagStatusChanged += delegate(Tag sender, object value, bool quality) { TagStatusChanged?.Invoke(sender, value, quality); }; }
new internal void Add(string devicename, Device device) { if (ContainsKey(devicename)) { logger.Warning(null, $"Device already added - {devicename}"); return; } base.Add(devicename, device); device.ConnectionStatusChanged += Device_ConnectionStatusChanged; device.Collection.TagStatusChanged += (sender, e) => { if (sender is Tag tag) { TagStatusChanged?.Invoke(this, new TagChangedEventArgs { Name = tag.Name, Value = tag.Value, Quality = tag.Quality }); } }; }
public void DefineFloatTag( RegisterFunction function, IFloatConverter converter, float range = 0) { if (InnerTag != null) { return; } FloatTag innertag = new FloatTag(function) { Range = range, FloatConverter = converter }; InnerTag = innertag; InnerTag.TagValueChangedEvent += delegate(ITagType tag) { TagStatusChanged?.Invoke(this, EventArgs.Empty); }; }
public void DefineBoolTag( StatusFunction function, TagAddressMaskType masktype = TagAddressMaskType.None, bool mask = false, TagAddressMergeType mergetype = TagAddressMergeType.OrMerge) { if (InnerTag != null) { return; } BoolTag innertag = new BoolTag(function) { MaskType = masktype, Mask = mask, MergeType = mergetype }; InnerTag = innertag; InnerTag.TagValueChangedEvent += delegate(ITagType tag) { TagStatusChanged?.Invoke(this, EventArgs.Empty); }; }
private void Classificator(Tag addingTag) { if (addingTag.TagDirection == Direction.Write) { if (!allWriteTags.ContainsKey(addingTag.Name)) { allWriteTags.Add(addingTag.Name, addingTag); } return; } if (addingTag.InnerTag is BoolTag) { if (!allBoolTags.ContainsKey(addingTag.Name)) { allBoolTags.Add(addingTag.Name, (addingTag.InnerTag as BoolTag)); } } else if (addingTag.InnerTag is UshortTag) { allUshortTags.Add(addingTag.Name, (addingTag.InnerTag as UshortTag)); } else if (addingTag.InnerTag is FloatTag) { allFloatTags.Add(addingTag.Name, (addingTag.InnerTag as FloatTag)); } else if (addingTag.InnerTag is UintTag) { allUintTags.Add(addingTag.Name, (addingTag.InnerTag as UintTag)); } if (addingTag.InnerTag.Function == StatusFunction.CoilStatus) { if (!CoilStatuses.ContainsKey(addingTag.Name)) { CoilStatuses.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == StatusFunction.InputStatus) { if (!InputStatuses.ContainsKey(addingTag.Name)) { InputStatuses.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == RegisterFunction.HoldingRegister) { if (!HoldingRegisters.ContainsKey(addingTag.Name)) { HoldingRegisters.Add(addingTag.Name, (addingTag.InnerTag)); } } else if (addingTag.InnerTag.Function == RegisterFunction.InputRegister) { if (!InputRegisters.ContainsKey(addingTag.Name)) { InputRegisters.Add(addingTag.Name, (addingTag.InnerTag)); } } addingTag.TagStatusChanged += (sender, e) => { TagStatusChanged?.Invoke(sender, EventArgs.Empty); }; }