private bool RtSetValue(SetValueParam[] toSets) { if (toSets.Any(t => RtTagExpression.IsExpression(t.Topic))) { return(false); } logger.LogInformation("RtSetValue {@toSets}", System.Text.Json.JsonSerializer.Serialize(toSets)); return(toSets.All(t => { if (t.Value.ValueKind == JsonValueKind.Number) { return connector.SetNumeric(t.Topic, t.Value.GetDouble()); } else if (t.Value.ValueKind == JsonValueKind.Array || t.Value.ValueKind == JsonValueKind.Object) { return connector.SetJson(t.Topic, t.Value); } else { return connector.SetText(t.Topic, t.Value.ToString()); } })); }
private void ParseBlock(ModbusReadBlockConfiguration readBlock, byte[] data) { foreach (var tag in readBlock.Tags) { var value = data.Parser(tag.Format, tag.BlockIndex * RowSize); if (value is string valStr) { Console.WriteLine("Write String Tag {0} => {1}", tag.TagName, valStr); connector.SetText(tag.TagName, valStr); } else { var valDbl = Convert.ToDouble(value); Console.WriteLine("Write Numeric Tag {0} => {1}", tag.TagName, valDbl); connector.SetNumeric(tag.TagName, valDbl); } } }