protected void Save(string path, SerializableFLProgram prog, string[] extraSteps) { using (Stream s = File.Create(path)) { FLSerializer.SaveProgram(s, prog, FLData.Container.InstructionSet, extraSteps); } }
public static string RunProgramInitBenchmark(string testAdd, List <string> files, int iterations, string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false, int workSizeMultiplier = 2) { FLSetup setup = new FLSetup("FL_ProgramInit_Performance" + testAdd, "resources/kernel", performanceFolder, checkPipeline, useMultiThreading, workSizeMultiplier); StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n"); for (int i = 0; i < files.Count; i++) { //Untimed SerializableFLProgram pr = setup.Parser.Process(new FLParserInput(files[i])); FLProgram program = null; string key = "ProgramInitPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." + i; Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1); PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations, null, (int its) => { program = pr.Initialize(setup.InstructionSet); }, (int its) => program.FreeResources()); logOut.AppendLine("\t" + result); Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1); setup.WriteResult(result); } logOut.AppendLine(); setup.WriteLog(logOut.ToString()); setup.Dispose(); return(logOut.ToString()); }
public void CorrectUnderlyingBuffer_For_IN_Test() { TestSetup.SetupTestingSession(); string file = "resources/filter/bug_checks/set_temp_to_in_bug.fl"; FLSetup s = new FLSetup(nameof(CorrectUnderlyingBuffer_For_IN_Test), "resources/kernel"); SerializableFLProgram p = s.Parser.Process(new FLParserInput(file)); FLProgram pp = p.Initialize(s.InstructionSet); FLBuffer b = new FLBuffer(CLAPI.MainThread, 128, 128, "TestInput"); pp.Run(CLAPI.MainThread, b, true); FLBuffer i = pp.GetActiveBuffer(false); byte[] c = CLAPI.ReadBuffer <byte>(CLAPI.MainThread, i.Buffer, (int)i.Size); for (int j = 0; j < c.Length; j++) { if (c[j] != 255) { Assert.Fail("Output does not match expected"); } } pp.FreeResources(); }
public static string RunProgramDeserializationBenchmark(string testAdd, List <string> files, int iterations, string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false, int workSizeMultiplier = 2) { FLSetup setup = new FLSetup("FL_DeserializationProcess_Performance" + testAdd, "resources/kernel", performanceFolder, checkPipeline, useMultiThreading, workSizeMultiplier); StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n"); MemoryStream dst = new MemoryStream(); for (int i = 0; i < files.Count; i++) { SerializableFLProgram pr = setup.Parser.Process(new FLParserInput(files[i])); string key = "ProgramDeserializationPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." + i; FLSerializer.SaveProgram(dst, pr, setup.InstructionSet, new string[] { }); Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1); PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations, (int its) => dst.Position = 0, (int its) => FLSerializer.LoadProgram(dst, setup.InstructionSet), null); logOut.AppendLine("\t" + result); Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1); setup.WriteResult(result); } dst.Dispose(); logOut.AppendLine(); setup.WriteLog(logOut.ToString()); setup.Dispose(); return(logOut.ToString()); }
public override void Unpack(string targetDir, string name, Stream stream, IProgressIndicator progressIndicator) { progressIndicator?.SetProgress($"[{UnpackerName}]Loading FL Program: {name}", 1, 3); SerializableFLProgram prog = FLSerializer.LoadProgram(stream, runner.InstructionSet); progressIndicator?.SetProgress($"[{UnpackerName}]Running FL Program: {name}", 2, 3); FLProgram p = runner.Run(prog, 512, 512, 1); string filePath = Path.Combine( targetDir, name.Replace("/", "\\").StartsWith("\\") ? name.Replace("/", "\\").Substring(1) : name.Replace("/", "\\") ); Directory.CreateDirectory(Path.GetDirectoryName(filePath)); filePath = filePath.Remove(filePath.Length - 3, 3) + "png"; progressIndicator?.SetProgress( $"[{UnpackerName}]Writing FL Program Output: {Path.GetFileNameWithoutExtension(name)}", 3, 3 ); Bitmap bmp = new Bitmap(512, 512); CLAPI.UpdateBitmap(runner.Instance, bmp, p.GetActiveBuffer(false).Buffer); bmp.Save(filePath); stream.Close(); p.FreeResources(); progressIndicator?.Dispose(); }
public override void Unpack(string targetDir, string name, Stream stream, IProgressIndicator progressIndicator) { progressIndicator?.SetProgress($"[{UnpackerName}]Loading FL Program: {name}", 1, 3); SerializableFLProgram prog = runner.Parser.Process(new FLParserInput(name)); string filePath = Path.Combine( targetDir, name.Replace("/", "\\").StartsWith("\\") ? name.Replace("/", "\\").Substring(1) : name.Replace("/", "\\") ); Directory.CreateDirectory(Path.GetDirectoryName(filePath)); filePath = filePath + "c"; progressIndicator?.SetProgress( $"[{UnpackerName}]Writing FL Program Output: {Path.GetFileNameWithoutExtension(name)}", 3, 3 ); Stream s = File.OpenWrite(filePath); FLSerializer.SaveProgram(s, prog, runner.InstructionSet, new string[0]); s.Dispose(); progressIndicator?.Dispose(); }
public static void SaveProgram(Stream s, SerializableFLProgram program, FLInstructionSet iset, string[] extraSteps, FLProgramHeader programHeader = null) { Byt3Serializer main = CreateLoader(iset); MemoryStream ms = new MemoryStream(); if (!main.TryWritePacket(ms, program)) { throw new FLDeserializationException("Can not parse stream"); } if (programHeader == null) { programHeader = new FLProgramHeader("Program", "NONE", Version.Parse("0.0.0.1")); } FLHeader header = new FLHeader(FLVersions.HeaderVersion, FLVersions.SerializationVersion, FLVersions.CommonVersion, extraSteps); byte[] p = ms.ToArray(); ms.Close(); FLFileFormat file = new FLFileFormat(header, programHeader, p); if (!main.TryWritePacket(s, file)) { throw new FLDeserializationException("Can not parse stream"); } }
public static string RunDeserializedFLExecutionBenchmark(string testAdd, List <string> files, int iterations, string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false, int workSizeMultiplier = 2) { FLSetup setup = new FLSetup("FL_DeserializedExecution_Performance" + testAdd, "resources/kernel", performanceFolder, checkPipeline, useMultiThreading, workSizeMultiplier); StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n"); for (int i = 0; i < files.Count; i++) { Bitmap bmp = null; FLBuffer buf = null; SerializableFLProgram parsedProgram = null; MemoryStream ms = new MemoryStream(); FLProgram program = null; string key = "FLDeserializedExecutionPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." + i; Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1); parsedProgram = setup.Parser.Process(new FLParserInput(files[i])); FLSerializer.SaveProgram(ms, parsedProgram, setup.InstructionSet, new string[0]); ms.Position = 0; parsedProgram = FLSerializer.LoadProgram(ms, setup.InstructionSet); ms.Dispose(); PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations, (int its) => //BeforeTest { bmp = new Bitmap(BITMAP_RESOLUTION, BITMAP_RESOLUTION); buf = new FLBuffer(CLAPI.MainThread, bmp, files[i]); program = parsedProgram.Initialize(setup.InstructionSet); }, (int its) => program.Run(CLAPI.MainThread, buf, true), (int its) => //After Test { if (its == iterations - 1) { SaveOutput("deserialized-output", bmp, program, setup, files[i]); } program.FreeResources(); bmp.Dispose(); buf.Dispose(); }); logOut.AppendLine("\t" + result); Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1); setup.WriteResult(result); } logOut.AppendLine(); setup.WriteLog(logOut.ToString()); setup.Dispose(); return(logOut.ToString()); }
public ExternalFlFunction( string name, SerializableFLProgram external, FLInstructionSet iset, FLExecutableElementModifiers modifiers) : base("ext-func") { Name = name; Modifiers = modifiers; ExternalFunctionBlueprint = external; InstructionSet = iset; }
protected override void Run(string input, string output) { Logger.Log(LogType.Log, "Parsing", 2); SerializableFLProgram prog = Parse(input, Defines); Logger.Log(LogType.Log, "Serializing", 2); using (Stream s = File.Create(output)) { FLSerializer.SaveProgram(s, prog, FLData.Container.InstructionSet, ExtraSteps); } }
protected override void Run(string input, string output) { int maxProgress = 2; int currentProgress = 1; string oldDir = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(input); if (ExportFL) { string dir = Path.Combine( oldDir, "temp_" + Path.GetFileNameWithoutExtension(Directory.GetCurrentDirectory()) ); CopyDirectory(Directory.GetCurrentDirectory(), dir); Directory.SetCurrentDirectory(dir); string[] files = Directory.GetFiles(dir, "*.fl", SearchOption.AllDirectories); maxProgress += files.Length; FLData.SetProgress("Exporting FL Scripts..", 1, currentProgress, maxProgress); currentProgress++; for (int i = 0; i < files.Length; i++) { string file = files[i]; FLData.SetProgress("Exporting File:" + file, 2, currentProgress, maxProgress); currentProgress++; SerializableFLProgram prog = Parse(file, Defines); string f = file + "c"; Save(f, prog, ExtraSteps); if (!KeepFL) { File.Delete(file); } } } FLData.SetProgress("Creating Package.", 1, currentProgress, maxProgress); currentProgress++; Directory.SetCurrentDirectory(oldDir); ResourceManager.Create( input, output, PackageName, UnpackConfig, null ); FLData.SetProgress("Cleaning Up.", 1, currentProgress, maxProgress); }
public override void Unpack(string targetDir, string name, Stream stream, IProgressIndicator progressIndicator) { progressIndicator?.SetProgress($"[{UnpackerName}]Loading FL Program: {name}", 1, 3); FLProgram p = null; try { SerializableFLProgram prog = runner.Parser.Process( new FLParserInput( name, new StreamReader(stream) .ReadToEnd().Split('\n') .Select(x => x.Trim()).ToArray(), true ) ); progressIndicator?.SetProgress($"[{UnpackerName}]Running FL Program: {name}", 2, 3); p = runner.Build(prog); if (p.HasMain) { runner.Run(p, 512, 512, 1); string filePath = Path.Combine( targetDir, name.Replace("/", "\\").StartsWith("\\") ? name.Replace("/", "\\").Substring(1) : name.Replace("/", "\\") ); Directory.CreateDirectory(Path.GetDirectoryName(filePath)); filePath = filePath.Remove(filePath.Length - 2, 2) + "png"; progressIndicator?.SetProgress( $"[{UnpackerName}]Writing FL Program Output: {Path.GetFileNameWithoutExtension(name)}", 3, 3 ); Bitmap bmp = new Bitmap(512, 512); CLAPI.UpdateBitmap(runner.Instance, bmp, p.GetActiveBuffer(false).Buffer); bmp.Save(filePath); } } catch (Exception) { } stream.Close(); p?.FreeResources(); progressIndicator?.Dispose(); }
public void OpenFL_RemoveUnusedFunctions_Test() { TestSetup.SetupTestingSession(); FLSetup setup = new FLSetup(nameof(OpenFL_RemoveUnusedFunctions_Test), "resources/kernel"); SerializableFLProgram ret = setup.Parser.Process( new FLParserInput("resources/filter/program_checks/optimizations/remove_unused_functions.fl")); Assert.AreEqual(2, ret.Functions.Count); setup.Dispose(); }
public void OpenFL_RemoveUnusedBuffers_Test() { TestSetup.SetupTestingSession(); FLSetup setup = new FLSetup(nameof(OpenFL_RemoveUnusedBuffers_Test), "resources/kernel"); SerializableFLProgram ret = setup.Parser.Process( new FLParserInput("resources/filter/program_checks/optimizations/remove_unused_buffers.fl")); Assert.AreEqual(1, ret.DefinedBuffers.Count); //1 and not 0 because the "in" (input) buffer is also in the defined buffers. setup.Dispose(); }
public void OpenFL_DefineScriptFile_Wrong_Test() { TestSetup.SetupTestingSession(); string file = "resources/filter/defines/test_wrong_script_invalid_file.fl"; Assert.Catch <Byt3Exception>(() => { FLParser parser = new FLParser(); Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator)); parser.BufferCreator.AddBufferCreatorsInAssembly(asm); SerializableFLProgram pr = parser.Process(new FLParserInput(file)); }); }
public void OpenFL_Comments_Test() { TestSetup.SetupTestingSession(); string file = "resources/filter/comments/test.fl"; FLParser parser = new FLParser(); Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator)); parser.BufferCreator.AddBufferCreatorsInAssembly(asm); SerializableFLProgram pr = parser.Process(new FLParserInput(file)); //FLFunction entryPoint = pr.EntryPoint; //Provoking an exception if main function is not found }
protected override void Validate( SerializableFLProgram prog, SerializableFLFunction func, SerializableFLInstruction inst, SerializableFLInstructionArgument arg) { FLExecutableElementModifiers calledFunc = prog.Functions.FirstOrDefault(x => x.Name == arg.Identifier)?.Modifiers ?? prog.ExternalFunctions.First(x => x.Name == arg.Identifier).Modifiers; if (calledFunc.NoCall) { throw new FLInvalidFLElementModifierUseException( func.Name, FLKeywords.NoCallKeyword, $"Can not use instruction {inst.InstructionKey} with a Defined Function that is marked with the nocall modifier." ); } }
public static FLProgram Initialize(this SerializableFLProgram program, FLInstructionSet instructionSet) { Dictionary <string, FLBuffer> buffers = new Dictionary <string, FLBuffer>(); Dictionary <string, FLFunction> functions = new Dictionary <string, FLFunction>(); Dictionary <string, ExternalFlFunction> externalFunctions = new Dictionary <string, ExternalFlFunction>(); for (int i = 0; i < program.ExternalFunctions.Count; i++) { ExternalFlFunction extFunc = new ExternalFlFunction(program.ExternalFunctions[i].Name, program.ExternalFunctions[i].ExternalProgram, instructionSet); externalFunctions.Add(program.ExternalFunctions[i].Name, extFunc); } for (int i = 0; i < program.DefinedBuffers.Count; i++) { FLBuffer extFunc = program.DefinedBuffers[i].GetBuffer(); extFunc.SetKey(program.DefinedBuffers[i].Name); buffers.Add(extFunc.DefinedBufferName, extFunc); } for (int i = 0; i < program.Functions.Count; i++) { functions.Add(program.Functions[i].Name, new FLFunction(program.Functions[i].Name)); } FLProgram p = new FLProgram(externalFunctions, buffers, functions); for (int i = 0; i < program.Functions.Count; i++) { functions[program.Functions[i].Name].Initialize(program.Functions[i], p, instructionSet); } //TODO Resolve Functions first. then in a second step resolve the references of the arguments. //When a function is defined below it beeing used the program is crashing because //it resolves the argument before the function that the argument is pointing to is parsed(e.g. not null) //Create possibility to create the function objects in another loop than creating the arguments. //For functions //add the function objects with name to the dict //for functions //initialize function p.SetRoot(); return(p); }
public void OpenFL_WFCDefines_Wrong_Test() { TestSetup.SetupTestingSession(); string[] files = IOManager.GetFiles("resources/filter/defines/", "test_wrong_define_wfc_*.fl"); Assert.IsNotEmpty(files, "No Test FL Scripts found for " + nameof(OpenFL_WFCDefines_Wrong_Test)); foreach (string file in files) { Assert.Catch <AggregateException>(() => { FLParser parser = new FLParser(); Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator)); parser.BufferCreator.AddBufferCreatorsInAssembly(asm); SerializableFLProgram pr = parser.Process(new FLParserInput(file)); }); } }
public void OpenFL_DefineFile_Wrong_Test() { TestSetup.SetupTestingSession(); string file = "resources/filter/defines/test_wrong_define_invalid_file.fl"; Assert.Catch <Byt3Exception>(() => { BufferCreator bc = new BufferCreator(); FLInstructionSet iset = new FLInstructionSet(); FLProgramCheckBuilder checkBuilder = new FLProgramCheckBuilder(iset, bc); checkBuilder.AddProgramCheck(new FilePathValidator()); FLParser parser = new FLParser(iset, bc); checkBuilder.Attach(parser, true); Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator)); parser.BufferCreator.AddBufferCreatorsInAssembly(asm); SerializableFLProgram pr = parser.Process(new FLParserInput(file)); }); }
public void OpenFL_Defines_Test() { TestSetup.SetupTestingSession(); string file = "resources/filter/defines/test.fl"; FLParser parser = new FLParser(); Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator)); parser.BufferCreator.AddBufferCreatorsInAssembly(asm); SerializableFLProgram result = parser.Process(new FLParserInput(file)); Assert.True(result.DefinedBuffers.Count == 5); Assert.True(result.DefinedBuffers.Count(x => x.Name == "in") == 1); Assert.True(result.DefinedBuffers.Count(x => x.Name == "textureD") == 1); Assert.True(result.DefinedBuffers.Count(x => x.Name == "textureC") == 1); Assert.True(result.DefinedBuffers.Count(x => x.Name == "textureB") == 1); Assert.True(result.DefinedBuffers.Count(x => x.Name == "textureA") == 1); }
private void Build() { FLConsole.Settings.SetVerbosity(); string[] inputFiles = SetInputFilesCommand.InputFiles; string[] outputFiles = SetOutputFilesCommand.OutputFiles; BufferCreator creator = new BufferCreator(); FLConsole.Settings.BufferCreatorTypes.ForEach(x => creator.AddBufferCreator((ASerializableBufferCreator)Activator.CreateInstance(x))); FLInstructionSet iset = FLInstructionSet.CreateWithBuiltInTypes(CLAPI.MainThread, FLConsole.Settings.KernelFolder); FLProgramCheckBuilder programCheckBuilder = new FLProgramCheckBuilder(iset, creator); FLParser p = new FLParser(iset, creator, new WorkItemRunnerSettings(FLConsole.Settings.MultiThread, FLConsole.Settings.WorkSizeMultiplier)); programCheckBuilder.Attach(p, true); Logger.Log(LogType.Log, $"Building {inputFiles.Length} Files", 1); for (int i = 0; i < inputFiles.Length; i++) { string inp = inputFiles[i]; Logger.Log(LogType.Log, $"Building {inp}", 2); string outp = outputFiles.Length > i ? outputFiles[i] : $"./{Path.GetFileNameWithoutExtension(inp)}.flc"; SerializableFLProgram prog = p.Process(new FLParserInput(inp)); Stream dst = File.Create(outp); FLSerializer.SaveProgram(dst, prog, iset, ExtraStepCommand.extras); dst.Close(); Logger.Log(LogType.Log, $"Output: {outp}", 2); } Logger.Log(LogType.Log, $"Finished Building {inputFiles.Length} Files", 1); }
protected override void Validate( SerializableFLProgram prog, SerializableFLFunction func, SerializableFLInstruction inst, SerializableFLInstructionArgument arg) { SerializableFLBuffer buf = prog.DefinedBuffers.First(x => x.Name == arg.Identifier); if (buf.Modifiers.IsReadOnly) { throw new FLInvalidFLElementModifierUseException( func.Name, FLKeywords.ReadOnlyBufferModifier, $"Can not use instruction {inst.InstructionKey} with a static buffer." ); } if (buf.Modifiers.IsArray) { throw new FLInvalidFLElementModifierUseException( func.Name, FLKeywords.ArrayKey, $"Can not use instruction {inst.InstructionKey} with an array buffer." ); } }
public ExternalFlFunction(string name, SerializableFLProgram external, FLInstructionSet iset) : base(name, new List <FLInstruction>()) { ExternalFunctionBlueprint = external; InstructionSet = iset; }
public SerializableExternalFLFunction(string name, SerializableFLProgram externalProgram) : base(name) { ExternalProgram = externalProgram; }
public static FLProgram Initialize( this SerializableFLProgram program, CLAPI instance, FLInstructionSet instructionSet) { foreach (EmbeddedKernelData embeddedKernelData in program.KernelData) { if (instructionSet.Database.KernelNames.Contains(embeddedKernelData.Kernel)) { continue; } instructionSet.Database.AddProgram( instance, embeddedKernelData.Source, "./", false, out CLProgramBuildResult res ); if (!res) { throw res.GetAggregateException(); } } Dictionary <string, FLBuffer> buffers = new Dictionary <string, FLBuffer>(); Dictionary <string, IFunction> functions = new Dictionary <string, IFunction>(); Dictionary <string, IFunction> externalFunctions = new Dictionary <string, IFunction>(); for (int i = 0; i < program.ExternalFunctions.Count; i++) { ExternalFlFunction extFunc = new ExternalFlFunction( program.ExternalFunctions[i].Name, program.ExternalFunctions[i].ExternalProgram, instructionSet, program.ExternalFunctions[i].Modifiers ); externalFunctions.Add(program.ExternalFunctions[i].Name, extFunc); } for (int i = 0; i < program.DefinedBuffers.Count; i++) { FLBuffer extFunc = program.DefinedBuffers[i].GetBuffer(); extFunc.SetKey(program.DefinedBuffers[i].Name); buffers.Add(extFunc.DefinedBufferName, extFunc); } for (int i = 0; i < program.Functions.Count; i++) { functions.Add( program.Functions[i].Name, new FLFunction(program.Functions[i].Name, program.Functions[i].Modifiers) ); } FLProgram p = new FLProgram(instance, externalFunctions, buffers, functions); p.SetRoot(); for (int i = 0; i < program.Functions.Count; i++) { (functions[program.Functions[i].Name] as FLFunction).Initialize( program.Functions[i], p, instructionSet ); } //TODO Resolve Functions first. then in a second step resolve the references of the arguments. //When a function is defined below it beeing used the program is crashing because //it resolves the argument before the function that the argument is pointing to is parsed(e.g. not null) //Create possibility to create the function objects in another loop than creating the arguments. //For functions //add the function objects with name to the dict //for functions //initialize function p.SetRoot(); return(p); }
public static FLProgram Initialize(this SerializableFLProgram program, FLDataContainer dataContainer) { return(Initialize(program, dataContainer.Instance, dataContainer.InstructionSet)); }
public override void Process(FLRunEndpointWorkItem item) { if (NextRateClear < DateTime.Now) { NextRateClear = DateTime.Now + TimeSpan.FromSeconds(Settings.RateLimitIntervalSeconds); RateLimits.Clear(); } if (!RateLimits.ContainsKey(item.Request.RemoteEndPoint.ToString())) { RateLimits[item.Request.RemoteEndPoint.ToString()] = Settings.RateLimit; } if (RateLimits[item.Request.RemoteEndPoint.ToString()] > 0) { RateLimits[item.Request.RemoteEndPoint.ToString()]--; try { SerializableFLProgram prog = Container.Parser.Process( new FLParserInput( "./memfile.fl", item.Source.Split('\n') .Select(x => x.Trim()).ToArray(), true ) ); FLBuffer inBuffer = Container.CreateBuffer( int.Parse(item.Width), int.Parse(item.Height), 1, "input_buffer" ); FLProgram program = prog.Initialize(Container); program.Run(inBuffer, true); Bitmap bmp = program.GetActiveBitmap(); MemoryStream ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Png); bmp.Dispose(); byte[] result = ms.GetBuffer(); StatisticCollector.OnProgramBuilt(item.Source, out string outFilePath); File.WriteAllBytes(outFilePath, result); RunResponseObject rr = new RunResponseObject { OutputData64 = Convert.ToBase64String(result) }; item.Serve(rr); } catch (Exception e) { StatisticCollector.OnProgramFailed(item.Source, e); item.Serve(new ExceptionResponseObject(e)); } } else { item.Serve( new ErrorResponseObject( 429, $"Rate limit exceeded. Try again in: {Math.Round((NextRateClear - DateTime.Now).TotalSeconds)} seconds" ) ); } }
public FLProgram Initialize(SerializableFLProgram file) { return(file.Initialize(InstructionSet)); }
public FLProgram Run(SerializableFLProgram file, int width, int height) { return(Run(file.Initialize(InstructionSet), width, height)); }