Hello,
our application needs to read multiple modbus address pools from different modbus slave controllers.
Due to that it is very hard to instance hundreds of tags and then use huges "switch-cases" structures to parse them since we need to "switch the contest" among the devices from the same screen without using a screen for each controller.
The question is:
Is there any way to index a specific modbus address (for read/write) from scripting?
We need to do something like a baseaddress+offset indirect addressing.
thanks very much.
Read MODBUS controller register from script without tags
Re: Read MODBUS controller register from script without tags
Code: Select all
public void SetTag(string tagName, VariantValue val) {
// Use reflection to find everything about Tags class in memory
Type tagType = Globals.Tags.GetType();
// Must have an instance in memory to write to otherwise it cannot write to a class directly
var tag = (GlobalDataItem)tagType.GetProperty( tagName ).GetValue(Globals.Tags, null);
tag.Value = val;
}
void Button_Click(System.Object sender, System.EventArgs e)
{
SetTag("Tag1", 5);
}