public static ProcessSystem ToDoSplitChoice(this ProcessSystem processSystem) { var first = string.Empty; var second = string.Empty; return(processSystem.BeginChoice("拆解多步") .BeginQuestion() .SetTitle("先做什么?") .SetContext(string.Empty) .SetContextTextArea(string.Empty, (str1) => { first = str1; }) .NewBtn("保存", () => { ToDoDataManager.AddToDoItem(first); EditorGUI.FocusTextInControl(null); }) .EndQuestion() //================= .BeginQuestion() .SetTitle("接着做什么?") .SetContext(string.Empty) .SetContextTextArea(string.Empty, (str2) => { second = str2; }) .RepeatSelfMenu("接着", () => { ToDoDataManager.AddToDoItem(second); EditorGUI.FocusTextInControl(null); //processSystem.RepeatThen(); }) .NewBtn("保存并结束", () => { ToDoDataManager.AddToDoItem(second); EditorGUI.FocusTextInControl(null); }) .EndQuestion() .EndChoice()); }
public List <Warning> Analyze(ProcessSystem system) { base.VisitParentBeforeChildren = false; //Backwards analysis _warnings = new List <Warning>(); this.Start(system); return(_warnings); }
public List <Warning> Analyze(ProcessSystem system) { _warnings = new List <Warning>(); foreach (ProcessDefinition def in system) { _procNames.Add(def.Name); } this.Start(system); foreach (string name in _procNames) { for (int i = system.ChildNodes.Count - 1; i >= 0; i--) { ProcessDefinition def = (ProcessDefinition)system.ChildNodes[i]; if (def.Name == name && !def.EntryProc) { _warnings.Add(new Warning(def.LexicalInfo, "Process " + def.Name + " is never invoked in the system")); if (_removeUnused) { system.ChildNodes.Remove(def); } } } } return(_warnings); }
public void ResolveNodeReferences() { if (NodeReferencesResolved) { return; } world = GetNode <Node>("World"); HUD = GetNode <MicrobeHUD>("MicrobeHUD"); tutorialGUI = GetNode <MicrobeTutorialGUI>("TutorialGUI"); rootOfDynamicallySpawned = GetNode <Node>("World/DynamicallySpawned"); Camera = world.GetNode <MicrobeCamera>("PrimaryCamera"); Clouds = world.GetNode <CompoundCloudSystem>("CompoundClouds"); worldLight = world.GetNode <DirectionalLight>("WorldLight"); guidanceLine = GetNode <GuidanceLine>(GuidanceLinePath); pauseMenu = GetNode <PauseMenu>(PauseMenuPath); // These need to be created here as well for child property save load to work TimedLifeSystem = new TimedLifeSystem(rootOfDynamicallySpawned); ProcessSystem = new ProcessSystem(rootOfDynamicallySpawned); microbeAISystem = new MicrobeAISystem(rootOfDynamicallySpawned); FluidSystem = new FluidSystem(rootOfDynamicallySpawned); spawner = new SpawnSystem(rootOfDynamicallySpawned); NodeReferencesResolved = true; }
private static void CheckPrintout(CompileOptions options, ProcessSystem system) { //Check whether we want to print out a formatted version of the source if (options["p"] != "") { string format = options["p"]; BaseFormatter formatter = null; if (format.ToLower() == "html") { formatter = new BaseFormatter(); } else if (format.ToLower() == "latex" || format.ToLower() == "tex") { format = "tex"; formatter = new LaTeXFormatter(); } else if (format.ToLower() == "txt" || format.ToLower() == "ccs") { format = "formatted_ccs"; //So we don't overwrite the original file... formatter = new BaseFormatter(); } else { DieIf(true, "Format for /print options must be one of ccs,html,latex"); } formatter.Start(system); string result = formatter.GetFormatted(); string filename = Path.ChangeExtension(options.OutputFile, format); File.WriteAllText(filename, result); Console.WriteLine("Formatted source written to {0}", filename); } }
public override void Visit(ProcessSystem sys) { List <string> children = PopChildren(); Return( @"\documentclass[a4paper,11pt]{article} \usepackage{amsmath} %<CCS commands> \newcommand{\defeq}{\ \stackrel{\mathrm{def}}{=}\ } \newcommand{\proc}[1]{\mathrm{#1}} \newcommand{\ccsdot}{\ \textbf{.}\ } %</CCS commands> \begin{document} \begin{align*} " + Join(" \\\\\n", children) + @" \end{align*} \end{document} "); }
private void Awake() { if (Instance == null) { Instance = this; } }
private void OpenAssembly(object sender, EventArgs e) { DialogResult result = openProcessExeDialog.ShowDialog(); if (result == DialogResult.OK) { try { _assembly = Assembly.Load(File.ReadAllBytes(openProcessExeDialog.FileName)); MethodInfo m = _assembly.GetModules(false)[0].GetMethod("Main"); if (m == null) { MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to have been compiled with the PLR!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception) { MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to be a .NET assembly!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } btnStart.Enabled = true; btnStartStep.Enabled = true; this.Text = "Process Viewer - " + openProcessExeDialog.FileName; ClearAll(); result = openProcessSourceDialog.ShowDialog(); _loadedSystem = null; _visual = null; txtProcessState.Text = ""; if (result == DialogResult.Cancel) { MessageBox.Show("No source file selected. Visualization of the current state of the system will not be available during execution", "No source file chosen", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result == DialogResult.OK) { _sourceFile = openProcessSourceDialog.FileName; txtProcessState.Text = File.ReadAllText(_sourceFile); string ext = Path.GetExtension(_sourceFile).ToLower().Substring(1); if (!_parsers.ContainsKey(ext)) { ErrorMsg("No suitable parser found", "No parser is loaded that parses files of type \"" + ext + "\""); } else { _parser = _parsers[ext]; try { _loadedSystem = _parser.Parse(_sourceFile); FindUnsupportedNodes f = new FindUnsupportedNodes(); f.Start(_loadedSystem); if (f.typeName != "") { MessageBox.Show("Sorry, visualization are currently not supported for systems that use the class " + f.typeName + ", however, the application can be run without visualization!", "Cannot show visualization", MessageBoxButtons.OK, MessageBoxIcon.Warning); _loadedSystem = null; } } catch (ParseException pex) { ErrorMsg("Failed to parse source file", "Failed to parse source file " + _sourceFile + ", error: \n" + pex.Message); } } } } }
public ProcessStateVisualization(ProcessSystem ast, BaseFormatter formatter) { _ast = ast; _formatter = formatter; foreach (ProcessDefinition pd in _ast.ChildNodes) { _procConstants.Add(pd.Name, pd.Process); } }
public void Compile(List <TupleInfo> tuples, ProcessSystem processes, CompileOptions options) { this.processes = processes; this.processes.MeetTheParents(); this.tuples = tuples; this.processes.MainMethodStart += new CompileEventHandler(CompileTupleSpaces); PLRString.DisplayWithoutQuotes = true; //To make localities look right... processes.Compile(options); }
/// <summary> /// Calculates the energy balance for a cell with the given organelles /// </summary> public void CalculateEnergyBalanceWithOrganellesAndMembraneType(List <OrganelleTemplate> organelles, MembraneType membrane, Patch patch = null) { if (patch == null) { patch = CurrentPatch; } gui.UpdateEnergyBalance(ProcessSystem.ComputeEnergyBalance(organelles.Select((i) => i.Definition), patch.Biome, membrane)); }
public PatchManager(SpawnSystem spawnSystem, ProcessSystem processSystem, CompoundCloudSystem compoundCloudSystem, TimedLifeSystem timedLife, DirectionalLight worldLight, GameProperties currentGame) { this.spawnSystem = spawnSystem; this.processSystem = processSystem; this.compoundCloudSystem = compoundCloudSystem; this.timedLife = timedLife; this.worldLight = worldLight; this.currentGame = currentGame; }
/// <summary> /// Calculates the effectiveness of organelles in the current or /// given patch /// </summary> public void CalculateOrganelleEffectivenessInPatch(Patch patch = null) { if (patch == null) { patch = CurrentPatch; } var organelles = SimulationParameters.Instance.GetAllOrganelles(); var result = ProcessSystem.ComputeOrganelleProcessEfficiencies(organelles, patch.Biome); gui.UpdateOrganelleEfficiencies(result); }
public PatchManager(SpawnSystem spawnSystem, ProcessSystem processSystem, CompoundCloudSystem compoundCloudSystem, TimedLifeSystem timedLife, DirectionalLight worldLight, GameProperties currentGame) { this.spawnSystem = spawnSystem; this.processSystem = processSystem; this.compoundCloudSystem = compoundCloudSystem; this.timedLife = timedLife; this.worldLight = worldLight; CloudSpawner = new CompoundCloudSpawner(compoundCloudSystem); ChunkSpawner = new ChunkSpawner(compoundCloudSystem); MicrobeSpawner = new MicrobeSpawner(compoundCloudSystem, currentGame); }
private void Init() { //避免重复打开 Clear(); var verticalLayout = new VerticalLayout().AddTo(this); // ButtonView finishedBtn = new ButtonView("转换", () => // { // listView.UpdateList(); // Close(); // ToDoListMainWindow.instance.Focus(); // }, true).AddTo(verticalLayout); // // finishedBtn.Hide(); ProcessSystem.CreateQuestions() //------------------------ .BeginQuestion() .SetTitle(note.content) .SetContext("这是什么?") .NewBtn("目标") .NewBtn("参考/阅读资料") .NewBtn("想法/Idea") .NewChoice("事项/事件", "事项") .EndQuestion() //------------------------ .BeginChoice("事项") .BeginQuestion() .SetTitle("是否可以拆解为多步?") .NewChoice("是", "拆解多步") .NewChoice("否", "现在是否可以执行") .EndQuestion() .EndChoice() //------------------------ .BeginChoice("现在是否可以执行") .BeginQuestion() .SetTitle("现在是否可以执行") .NewBtn("是", () => { ToDoDataManager.Data.ConvertToDoNote(note, false); }) .NewBtn("否", () => { }) .EndQuestion() .EndChoice() //------------------------ .ToDoSplitChoice() .AddTo(verticalLayout) .StartProcess(Close); }
public override void _Process(float delta) { FluidSystem.Process(delta); TimedLifeSystem.Process(delta); ProcessSystem.Process(delta); microbeAISystem.Process(delta); if (gameOver) { // Player is extinct and has lost the game // Show the game lost popup if not already visible HUD.ShowExtinctionBox(); return; } if (Player != null) { spawner.Process(delta, Player.Translation); Clouds.ReportPlayerPosition(Player.Translation); } else { if (!spawnedPlayer) { GD.PrintErr("MicrobeStage was entered without spawning the player"); SpawnPlayer(); } else { // Respawn the player once the timer is up playerRespawnTimer -= delta; if (playerRespawnTimer <= 0) { HandlePlayerRespawn(); } } } // Start auto-evo if not already and settings have auto-evo be started during gameplay if (Settings.Instance.RunAutoEvoDuringGamePlay) { GameWorld.IsAutoEvoFinished(true); } }
public List <Warning> Analyze(ProcessSystem system) { DateTime start = DateTime.Now; base.VisitParentBeforeChildren = false; _warnings = new List <Warning>(); this.Start(system); GeneratePossibleChannels(_inActions); GeneratePossibleChannels(_outActions); Match(_inActions, _outActions, "output"); Match(_outActions, _inActions, "input"); TimeSpan t = DateTime.Now.Subtract(start); //TODO: Measure on larger systems... //Console.WriteLine("Unmatched channels finished in {0}ms", t.TotalMilliseconds); return(_warnings); }
/// <summary> /// This should get called the first time the stage scene is put /// into an active scene tree. So returning from the editor /// might be safe without it unloading this. /// </summary> public override void _Ready() { world = GetNode <Node>("World"); HUD = GetNode <MicrobeHUD>("MicrobeHUD"); rootOfDynamicallySpawned = GetNode <Node>("World/DynamicallySpawned"); spawner = new SpawnSystem(rootOfDynamicallySpawned); Camera = world.GetNode <MicrobeCamera>("PrimaryCamera"); Clouds = world.GetNode <CompoundCloudSystem>("CompoundClouds"); worldLight = world.GetNode <DirectionalLight>("WorldLight"); TimedLifeSystem = new TimedLifeSystem(rootOfDynamicallySpawned); ProcessSystem = new ProcessSystem(rootOfDynamicallySpawned); microbeAISystem = new MicrobeAISystem(rootOfDynamicallySpawned); FluidSystem = new FluidSystem(rootOfDynamicallySpawned); HUD.Init(this); // Do stage setup to spawn things and setup all parts of the stage SetupStage(); }
private void openInOtherDeviceToolStripMenuItem_Click(object sender, EventArgs e) { ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE break; case 2: //DIRECTORY break; case 3: //FILE r.FileInformationResponse.FileInfo fill = (r.FileInformationResponse.FileInfo)sItem.Tag; ProcessSystem.RequestExecuteProcess(server.serverPort.Stream, fill.FullName); break; case 0: MessageBox.Show("UnKnown Item found", "Error"); return; } }
private void allcoateNewConnection(RServer openServer, CommunicationNetworkStream _stream) { ChatBoxForm chatWindow = null;; //CHAT WINDOW //CHECK IF THEIR IS PORT LEFT TO ALLOCATE if (ConnectedClients.Count < ALLOCABLE_PORTS.Length) { NetworkClient client = new NetworkClient(); client.othId = Guid.NewGuid().ToString(); //ALLOCATE ID //START THE SERVER client.clientPort = new RServer(fileManagement.fileData.myIpAddress, allocateNewPort().ToString()); client.clientPort.setOnNewDeviceConnectedCallback( new RServer.NewDeviceConnected( (RServer sender, CommunicationNetworkStream stream) => { String cId = stream.ReadString(true); //WAIT TO GET ID Debug.WriteLine($"CONNECTION: {((NetworkClient)ConnectedClients[cId]).clientPort.ServerPort}:{cId}"); if (((NetworkClient)ConnectedClients[cId]).clientPort.ServerPort != sender.ServerPort) { sender.DetachClient(); } } ) ); client.clientPort.setOnDataReceivedCallback( new RServer.DataReceived( (RServer sender, CommunicationNetworkStream stream, string Data) => { switch (CommandRecognization.Recognize(Data)) { case ExchangeType.CLOSE_CONNECTION_REQUEST: closeConnection(sender); //CLOSE CONNECTION MessageBox.Show("CLOSE_CONNECTION_REQUEST"); break; case ExchangeType.FS_LIST_DRIVE_REQUEST: FileSystem.SentDriveList(stream); break; case ExchangeType.FS_LIST_DIRECTORY_REQUEST: FileSystem.SentDirectoryList(stream); break; case ExchangeType.FS_LIST_FILE_REQUEST: FileSystem.SentFileList(stream); break; case ExchangeType.FS_DELETE_REQUEST: FileSystem.ExecuteDelete(stream); break; case ExchangeType.FS_RENAME_REQUEST: FileSystem.ExecuteRename(stream); break; case ExchangeType.PROCESS_LIST_ALL_REQUEST: ProcessSystem.SentAllProcess(stream); break; case ExchangeType.PROCESS_KILL_REQUEST: ProcessSystem.ExecuteKillProcess(stream); break; case ExchangeType.PROCESS_START_REQUEST: ProcessSystem.ExecuteProcess(stream); break; case ExchangeType.FILE_TRANSFER: FileReceiver fr = new FileReceiver(stream).Initialize(); fr.StartReceiving(); break; case ExchangeType.FILE_TRANSFER_REQUEST: FileTransferRequest ft = new FileTransferRequest(stream).Initialize(); ft.StartTransfering(); Thread.Sleep(1000); break; case ExchangeType.NULL: //EXTENDED MODE int len = Data.IndexOf(':'); string command = Data; if (len > 0) { command = Data.Substring(0, len); } string arg = ""; if (len > 0) { arg = Data.Substring(len + 1); } switch (command) { case "CREATE_DIR": try { System.IO.Directory.CreateDirectory(arg); } catch (Exception) { } break; case "CHAT_START": chatWindow = new ChatBoxForm(); Invoke(new UpdateData(() => { chatWindow.client = sender; chatWindow.connectedIp = arg; chatWindow.Show(); })); break; case "CHAT_STOP": Invoke(new UpdateData(() => { if (chatWindow != null) { chatWindow.Close(); chatWindow.Dispose(); chatWindow = null; } })); closeConnection(sender); //CLOSE CONNECTION break; case "CHAT_MESSAGE": Invoke(new UpdateData(() => { if (chatWindow != null) { chatWindow.newMessage(arg); } })); break; default: break; } break; } } ) ); client.clientPort.Initialize(true); //TELL THE CLIENT TO MOVE TO A NEW PORT //INSTRUCT TO MOVE _stream.WriteString($"MOVE_TO_PORT:{client.clientPort.ServerPort}:{client.othId}"); Debug.WriteLine($"NEW_CONNECTION: new port allocated.{client.clientPort.ServerPort}:{client.othId}"); ConnectedClients.Add(client.othId, client); //REGISTER CLIENT } else { _stream.WriteString("WAIT_FOR_CONNECTION"); } //DISCONNECT THE CLIENT FORM THIS PORT openServer.DetachClient(); }
static int Main(string[] args) { if (args.Length == 0) { Console.Error.WriteLine(@" CCS Compiler Copyright (C) 2009 Einar Egilsson Usage: CCS [options] <filename> "); return(1); } List <string> listArgs = new List <string>(args); CompileOptions.AddOptionWithArgument("p", "print", ""); //Allow printouts CompileOptions options = CompileOptions.Parse(listArgs); if (options.Help) { Console.Error.WriteLine(@" CCS Compiler Copyright (C) 2009 Einar Egilsson Usage: CCS [options] <filename> Available options: /reference:<filenames> The assemblies that this program requires. It is /r:<filenames> not neccessary to specify the PLR assembly. Other assemblies should be specified in a comma seperated list, e.g. /reference:Foo.dll,Bar.dll. /optimize If specified then the generated assembly will be /op optimized, dead code eliminated and expressions pre-evaluated where possible. Do not combine this with the /debug switch. /embedPLR Embeds the PLR into the generated file, so it can /e be distributed as a stand-alone file. /debug Emit debugging symbols in the generated file, /d this allows it to be debugged in Visual Studio, or in the free graphical debugger that comes with the .NET Framework SDK. /out:<filename> Specify the name of the compiled executable. If /o:<filename> this is not specified then the name of the input file is used, with .ccs replaced by .exe. /print:<format> Prints a version of the program source in the /p:<format> specified format. Allowed formats are ccs, html and latex. The generated file will have the same name as the input file, except with the format as extension. "); return(1); } DieIf(options.Arguments.Count == 0, "ERROR: Missing input file name"); DieIf(options.Arguments.Count > 1, "ERROR: Only one input file is expected"); string filename = options.Arguments[0]; DieIf(!File.Exists(filename), "ERROR: File '{0}' does not exist!", filename); if (string.IsNullOrEmpty(options.OutputFile)) { options.OutputFile = filename; if (options.OutputFile.ToLower().EndsWith(".ccs")) { options.OutputFile = options.OutputFile.Substring(0, options.OutputFile.Length - 4); } } if (!options.OutputFile.ToLower().EndsWith(".exe")) { options.OutputFile += ".exe"; } try { Parser parser = new Parser(new Scanner(new FileStream(filename, FileMode.Open))); parser.Parse(); if (parser.errors.count > 0) { Environment.Exit(1); } ProcessSystem system = parser.System; system.MeetTheParents(); List <Warning> warnings = system.Analyze(new ReachingDefinitions()); if (warnings.Count > 0) { foreach (Warning warn in warnings) { Console.Error.WriteLine("ERROR({0},{1}): {2}", warn.LexicalInfo.StartLine, warn.LexicalInfo.StartColumn, warn.Message); } return(1); //This is an error so we die before attempting to compile } //These are just warnings, so just warn... warnings = system.Analyze( new LiveVariables(), new NilProcessWarning(), new UnmatchedChannels(), new UnusedProcesses(options.Optimize) ); foreach (Warning warn in warnings) { Console.Error.WriteLine("WARNING({0},{1}): {2}", warn.LexicalInfo.StartLine, warn.LexicalInfo.StartColumn, warn.Message); } //This optimizes the tree before compilation, only do if we should optimize if (options.Optimize) { system.Analyze(new FoldConstantExpressions()); } CheckPrintout(options, system); system.Compile(options); } catch (Exception ex) { //Console.WriteLine(ex.StackTrace); DieIf(true, "ERROR: " + ex.Message); } return(0); }
//Root namespace nodes public override void Visit(ProcessSystem node) { Return(Join("\n", PopChildren())); }
public override void _Process(float delta) { // https://github.com/Revolutionary-Games/Thrive/issues/1976 if (delta <= 0) { return; } FluidSystem.Process(delta); TimedLifeSystem.Process(delta); ProcessSystem.Process(delta); microbeAISystem.Process(delta); if (gameOver) { guidanceLine.Visible = false; // Player is extinct and has lost the game // Show the game lost popup if not already visible HUD.ShowExtinctionBox(); return; } if (Player != null) { spawner.Process(delta, Player.Translation, Player.Rotation); Clouds.ReportPlayerPosition(Player.Translation); TutorialState.SendEvent(TutorialEventType.MicrobePlayerOrientation, new RotationEventArgs(Player.Transform.basis, Player.RotationDegrees), this); TutorialState.SendEvent(TutorialEventType.MicrobePlayerCompounds, new CompoundBagEventArgs(Player.Compounds), this); TutorialState.SendEvent(TutorialEventType.MicrobePlayerTotalCollected, new CompoundEventArgs(Player.TotalAbsorbedCompounds), this); elapsedSinceCompoundPositionCheck += delta; if (elapsedSinceCompoundPositionCheck > Constants.TUTORIAL_COMPOUND_POSITION_UPDATE_INTERVAL) { elapsedSinceCompoundPositionCheck = 0; if (TutorialState.WantsNearbyCompoundInfo()) { TutorialState.SendEvent(TutorialEventType.MicrobeCompoundsNearPlayer, new CompoundPositionEventArgs(Clouds.FindCompoundNearPoint(Player.Translation, glucose)), this); } guidancePosition = TutorialState.GetPlayerGuidancePosition(); } if (guidancePosition != null) { guidanceLine.Visible = true; guidanceLine.LineStart = Player.Translation; guidanceLine.LineEnd = guidancePosition.Value; } else { guidanceLine.Visible = false; } } else { guidanceLine.Visible = false; if (!spawnedPlayer) { GD.PrintErr("MicrobeStage was entered without spawning the player"); SpawnPlayer(); } else { // Respawn the player once the timer is up playerRespawnTimer -= delta; if (playerRespawnTimer <= 0) { HandlePlayerRespawn(); } } } // Start auto-evo if stage entry finished, don't need to auto save, // settings have auto-evo be started during gameplay and auto-evo is not already started if (TransitionFinished && !wantsToSave && Settings.Instance.RunAutoEvoDuringGamePlay) { GameWorld.IsAutoEvoFinished(true); } // Save if wanted if (TransitionFinished && wantsToSave) { if (!CurrentGame.FreeBuild) { SaveHelper.AutoSave(this); } wantsToSave = false; } }
public List <Warning> Analyze(ProcessSystem system) { this.Start(system); return(new List <Warning>()); }
public List <Warning> Analyze(ProcessSystem system) { _warnings = new List <Warning>(); this.Start(system); return(_warnings); }
public virtual string Format(ProcessSystem sys) { return(Join("\n", sys)); }
public override void Visit(ProcessSystem sys) { Return("<table>\n\t<tr>" + Join("</tr>\n\t<tr>", PopChildren()) + "\n\t</tr>\n</table>"); }