I have to set one isolated core in TwinCAT from a c# code. In the documentation online it is showed how to set the number of cores, the base time, the core limit and latency warning, but nothing about the number of isolated cores.
public void AssignCPUCores()
{
ITcSysManager3 systemManager = project.Object;
ITcSmTreeItem realtimeSettings = systemManager.LookupTreeItem("TIRS");
string xml = null;
MemoryStream stream = new MemoryStream();
StringWriter stringWriter = new StringWriter();
using (XmlWriter writer = XmlTextWriter.Create(stringWriter))
{
writer.WriteStartElement("TreeItem");
writer.WriteStartElement("RTimeSetDef");
writer.WriteElementString("MaxCPUs", "4"); // looking at what changes in TwinCAT by changing this number,
// I found out that this number is the number of shared cores
string affinityString = string.Format("#x{0}", ((ulong)CpuAffinity.MaskDual).ToString("x16"));
//the MaskDual/MaskQuad/MaskSingle defines how many boxes will be checked (i.e. how many cores will be used)
writer.WriteElementString("Affinity", affinityString);
writer.WriteStartElement("CPUs");
// WriteCpuProperties(writer, int coreId , int loadLimit, int baseTime, latencyWarning)
WriteCpuProperties(writer, 0, 90, 1000, 0);
writer.WriteEndElement(); // CPUs
writer.WriteEndElement(); // RTimeSetDef
writer.WriteEndElement(); // TreeItem
}
xml = stringWriter.ToString();
realtimeSettings.ConsumeXml(xml); //here modifies are applied
ITcSmTreeItem tasks = systemManager.LookupTreeItem("TIRT");
SetTaskProperties(tasks, CpuAffinity.CPU1);
}
Seems like there is no way to set the isolated cores. Is it possible or not? The goal would be to obtain something like this:
But throw the c# code the number of isolated cores is 0 and all cores has the (shared) between brackets.
