/// <summary> /// WindorsAPI的初始化. /// </summary> public static void OpenWithWindows(Action action) { //注册输入事件 输入事件来自于WindowsAPI StandardIO.GetKeyEvent += WindowsAPI.GetInput; StandardIO.GetMouseButtonEvent += WindowsAPI.GetInputMouse; //将窗体的对应方法绑到核心事件 StandardIO.DebugLogEvent += WindowsAPI.DebugLog; StandardIO.GetMousePositionInPixelEvent += WindowsAPI.GetMousePositionPixel; StandardIO.RendererEvent += WindowsAPI.Renderer; RuntimeEngine.Init(); //在这里添加新的系统 RuntimeEngine.SetSystemUpdate(); //执行引擎的初始化代码 action.Invoke(); RuntimeEngine.Run(); }
private void button5_Click(object sender, EventArgs e) { //Perform Prediction CreateNeuralNetwork(); DataTable dt = new DataTable("Runtime Result"); dt.Columns.Add("Pattern"); dt.Columns.Add("Position"); dt.Columns.Add("Prediction"); DataTable peptideDataTable; List <string> listOfTargetResidue = new List <string>(); listOfTargetResidue.Add(txtTargetResidues.Text); int sizeOfPeptide = int.Parse(textBox2.Text); peptideDataTable = ResidueBasedPeptideGenerator.ExtractPeptide(txtSequence.Text, listOfTargetResidue, sizeOfPeptide, false); List <string> listOfInputAttributesStringCollectionType = new List <string>(); List <string> listOfInputAttributesListType = new List <string>(); for (int index = (-1 * sizeOfPeptide); index <= sizeOfPeptide; index++) { listOfInputAttributesStringCollectionType.Add("P" + index.ToString()); listOfInputAttributesListType.Add("P" + index.ToString()); } DataTableEncodingManager encodingManager = new DataTableEncodingManager(codeDictionary, listOfInputAttributesListType, peptideDataTable, true, true); encodingManager.Run(); DataTable encodedPeptideDataTable = encodingManager._EncodedDataTable; int binaryStringLenghtPepAminoAcid = 0; foreach (object key in codeDictionary.Keys) { if (codeDictionary[key.ToString()].Length > binaryStringLenghtPepAminoAcid) { binaryStringLenghtPepAminoAcid = codeDictionary[key.ToString()].Length; } } listOfInputAttributesStringCollectionType = new List <string>(); int ctr; for (int index = (-1 * sizeOfPeptide); index <= sizeOfPeptide; index++) { for (ctr = 1; ctr <= binaryStringLenghtPepAminoAcid; ctr++) { listOfInputAttributesStringCollectionType.Add("P" + index.ToString() + "_" + ctr.ToString()); } } runtimeEngine = new RuntimeEngine(1, ANN, listOfInputAttributesStringCollectionType); DataRow row; string pattern; float predictedValue; float patternIndex = 1; float totalPattern = encodedPeptideDataTable.Rows.Count; richTextBox1.Text = "Prediction Evaluation Started..."; DataRow encodedPatternRrow; DataRow patternRow; dataGridView2.DataSource = encodedPeptideDataTable; for (patternIndex = 0; patternIndex < totalPattern; patternIndex++) { encodedPatternRrow = encodedPeptideDataTable.Rows[(int)patternIndex]; patternRow = peptideDataTable.Rows[(int)patternIndex]; pattern = ""; for (ctr = 0; ctr < listOfInputAttributesListType.Count; ctr++) { pattern = pattern + patternRow[listOfInputAttributesListType[ctr]].ToString(); } //row runtimeEngine.PatternRow = encodedPatternRrow; predictedValue = runtimeEngine.Run(); row = dt.NewRow(); row["Pattern"] = pattern; row["Prediction"] = predictedValue.ToString(); row["Position"] = patternRow["Position"].ToString(); dt.Rows.Add(row); SetMessage(pattern + " => " + predictedValue.ToString()); richTextBox1.Text = Convert.ToString((patternIndex + 1)) + " - " + pattern + " => " + predictedValue.ToString() + Environment.NewLine; } dataGridView2.DataSource = dt; }
private void ExecuteCommand(string command) { string[] commands = command.Split(' '); switch (commands[0]) { case "ls": ListFiles(); break; case "clear": Console.Clear(); break; case "touch": CreateBlankFile(commands[1]); break; case "cd": if (commands[1] == "..") { var bits = _myLib.CurrentDirectory.Split('/'); _myLib.CurrentDirectory = "/"; if (bits.Length == 3) { _myLib.CurrentDirectory = "/"; return; } for (var i = 0; i < bits.Length - 2; i++) { _myLib.CurrentDirectory += bits[i]; } _myLib.CurrentDirectory += "/"; return; } if (_currentDrive.Exists(FileSystemPath.Parse(_myLib.CurrentDirectory + commands[1] + "/"))) { _myLib.CurrentDirectory = _myLib.CurrentDirectory + commands[1] + "/"; _myLib.CurrentDirectory = _myLib.CurrentDirectory; } else { Console.WriteLine("Cannot find {0}", commands[1]); } break; default: if (commands[0].StartsWith("./")) { string path = commands[0].Substring(2); RuntimeEngine myaProcess = new RuntimeEngine(path, _kernel, _myLib); myaProcess.Initialize(_processManager, _myLib); _processManager.Register(myaProcess); myaProcess.Run(commands.Skip(1).ToArray()); break; } RunApplication(commands[0], commands.Skip(1).ToArray()); break; } }
private static void Main() { RuntimeEngine runtimeEngine = new RuntimeEngine(); runtimeEngine.Run(100); }