public Status Initialize(CalculatorGraphConfig config, SidePacket sidePacket) { UnsafeNativeMethods.mp_CalculatorGraph__Initialize__Rconfig_Rsp(mpPtr, config.mpPtr, sidePacket.mpPtr, out var statusPtr).Assert(); GC.KeepAlive(this); return(new Status(statusPtr)); }
public CalculatorGraph(CalculatorGraphConfig config) : base() { var bytes = config.ToByteArray(); UnsafeNativeMethods.mp_CalculatorGraph__Rcgc(bytes, bytes.Length, out var ptr).Assert(); this.ptr = ptr; }
public CalculatorGraph(string configText) : base(UnsafeNativeMethods.MpCalculatorGraphCreate()) { graphConfig = new CalculatorGraphConfig(configText); var status = Initialize(graphConfig); status.AssertOk(); }
public CalculatorGraph(string configText) : base() { var config = CalculatorGraphConfig.ParseFromString(configText); UnsafeNativeMethods.mp_CalculatorGraph__Rconfig(config.mpPtr, out var ptr).Assert(); GC.KeepAlive(config); this.ptr = ptr; }
public Status Initialize(CalculatorGraphConfig config, SidePacket sidePacket) { var bytes = config.ToByteArray(); UnsafeNativeMethods.mp_CalculatorGraph__Initialize__PKc_i_Rsp(mpPtr, bytes, bytes.Length, sidePacket.mpPtr, out var statusPtr).Assert(); GC.KeepAlive(this); return(new Status(statusPtr)); }
public Status Initialize(CalculatorGraphConfig config) { var bytes = config.ToByteArray(); UnsafeNativeMethods.mp_ValidatedGraphConfig__Initialize__Rcgc(mpPtr, bytes, bytes.Length, out var statusPtr).Assert(); GC.KeepAlive(this); return(new Status(statusPtr)); }
public static string GetUnusedNodeName(CalculatorGraphConfig config, string nodeNameBase) { var nodeNames = new HashSet <string>(config.Node.Select(node => node.Name).Where(name => name.Length > 0)); var candidate = nodeNameBase; var iter = 1; while (nodeNames.Contains(candidate)) { candidate = $"{nodeNameBase}_{++iter:D2}"; } return(candidate); }
protected override void Dispose(bool disposing) { if (_disposed) { return; } if (OwnsResource()) { UnsafeNativeMethods.MpCalculatorGraphDestroy(ptr); } ptr = IntPtr.Zero; graphConfig = null; _disposed = true; }
/// <exception cref="ArgumentOutOfRangeException"> /// Thrown when <paramref name="nodeId" /> is invalid /// </exception> public static string CanonicalNodeName(CalculatorGraphConfig graphConfig, int nodeId) { var nodeConfig = graphConfig.Node[nodeId]; var nodeName = nodeConfig.Name.Length == 0 ? nodeConfig.Calculator : nodeConfig.Name; var nodesWithSameName = graphConfig.Node .Select((node, i) => (node.Name.Length == 0 ? node.Calculator : node.Name, i)) .Where(pair => pair.Item1 == nodeName); if (nodesWithSameName.Count() <= 1) { return(nodeName); } var seq = nodesWithSameName.Count(pair => pair.i <= nodeId); return($"{nodeName}_{seq}"); }
public static string GetUnusedSidePacketName(CalculatorGraphConfig config, string inputSidePacketNameBase) { var inputSidePackets = new HashSet <string>( config.Node.SelectMany(node => node.InputSidePacket) .Select(sidePacket => { ParseTagIndexName(sidePacket, out var tag, out var index, out var name); return(name); })); string candidate = inputSidePacketNameBase; int iter = 1; while (inputSidePackets.Contains(candidate)) { candidate = $"{inputSidePacketNameBase}_{++iter:D2}"; } return(candidate); }
public static string GetUnusedStreamName(CalculatorGraphConfig config, string streamNameBase) { var outputStreamNames = config.Node.SelectMany(node => node.OutputStream) .Select(outputStream => { ParseTagIndexName(outputStream, out var tag, out var index, out var name); return(name); }); var candidate = streamNameBase; var iter = 1; while (config.InputStream.Contains(candidate)) { candidate = $"{streamNameBase}_{++iter:D2}"; } while (outputStreamNames.Contains(candidate)) { candidate = $"{streamNameBase}_{++iter:D2}"; } return(candidate); }
public CalculatorGraph(CalculatorGraphConfig config) : this(config.ToByteArray()) { }
private Status Initialize(CalculatorGraphConfig config) { return(new Status(UnsafeNativeMethods.MpCalculatorGraphInitialize(ptr, config.GetPtr()))); }