public override void Process() { Dictionary <InputPort, double[]> datas = new Dictionary <InputPort, double[]>(); foreach (var port in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>()) { var read = port.Read(); datas.Add(port, read.Data.Take(read.Available).ToArray()); } object result = null; if (datas.Values.Count == 1) { _matlab.Feval(_funcHeader.Name, _funcHeader.ReturnValues.Length, out result, datas.Values.ElementAt(0)); } else if (datas.Values.Count == 2) { _matlab.Feval(_funcHeader.Name, _funcHeader.ReturnValues.Length, out result, datas.Values.ElementAt(0), datas.Values.ElementAt(1)); } var data = (double[, ])((object[])result)[0]; ((NodeSystemLib2.FormatData1D.OutputPortData1D)OutputPorts.First()).Buffer.Write(data, 0, data.Length); }
private IntPtr WriteDataPort(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var data = new PyArray(argTuple.Get(0)); var portName = argTuple.Get(1).GetString(); var dataPort = OutputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.OutputPortData1D; var result = data.ToArrayDouble(); dataPort.Buffer.Write(result, 0, result.Length); return(new PyLong(1, false).Handle); }
private IntPtr SetSamplerate(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var portName = argTuple.Get(0).GetString(); var samplerate = argTuple.Get(1).GetDouble(); var dataPort = OutputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.OutputPortData1D; if (dataPort != null) { dataPort.Samplerate = (int)samplerate; return(new PyLong(1, false).Handle); } return(new PyLong(0, false).Handle); }