Hi,
Is it possible to edit the "allowed connections" of a matrix through an automation script or protocol?
Thank you!
Hi Maximiliano,
Unfortunately there is currently no straightforward way to do this in code. It is possible though using the generic SetDataMinerInfoMessage. The following method should allow you to set the connections that are NOT allowed in the matrix. The discretes that need to be passed to the method can be found in the matrix parameter in the protocol (values of the discretes).
public static void SetDisallowedConnections(IEngine engine, int dmaId, int elementId, int matrixId, int discrete, IEnumerable<int> disallowedDiscretes)
{
var message = new SetDataMinerInfoMessage
{
What = (int)NotifyType.UpdatePortsXml,
DataMinerID = dmaId,
HostingDataMinerID = dmaId,
Puia1 = new PUIA
{
Puia = new[] { new UIA(new[] { 2, elementId, matrixId, dmaId }) },
},
Psa2 = new PSA
{
Psa = new[] {
new SA
{
Sa = new[] { Convert.ToString(discrete), "matrix=not allowed," + String.Join(",", disallowedDiscretes) },
},
},
},
};engine.SendSLNetMessage(message);
}
Usage:
SetDisallowedConnections(engine, dmaId, elementId, matrixPid, 1, new[] { 101, 102, 103 });
- 1 is the descrete of the input
- 101, 102, 103 are the discretes of the outputs that are not allowed to connect
Perfect, thanks!