public void Close() { if (_mathKernel != null) { _mathKernel.Dispose(); } }
public static string CreateNotebook(string mathCommand, string fileLocation, MathKernel kernel) { //Add common functions here; string commonFuncs = "GetScan[index_] := Transpose[{data[index, ScanParams[\"ScanParameterName\"]], data[index, #]}] & /@ DAQmx[\"AINames\"];\n"; commonFuncs += "PlotAll[] := Show[ListPlot[GetScan[#], ImageSize -> 600], ListPlot[GetScan[#], ImageSize -> 600, Joined -> True]] & /@ Range[1, ScanParams[\"NumberOfScans\"]];\n"; mathCommand += commonFuncs; mathCommand = string.Format("{0}{1}{2}", "FullForm[ToBoxes[Defer[", mathCommand, "]]]"); // mathCommand = ComputeMathCommand(mathCommand, kernel); mathCommand = string.Format("{0}{1}{2}", "Notebook[{Cell[\"Import\", \"Section\"], Cell[BoxData[", mathCommand, "], \"Input\"], Cell[\"Analysis\", \"Section\"]}, WindowSize->{615, 750}, WindowMargins->{{328, Automatic}, {Automatic, 76}}]"); File.WriteAllText(fileLocation, mathCommand); kernel.Dispose(); return(fileLocation); }