-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKernel.cs
More file actions
114 lines (95 loc) · 3.12 KB
/
Kernel.cs
File metadata and controls
114 lines (95 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosKernel1
{
public class Kernel : Sys.Kernel
{
Memory mem = new Memory();
ProgramClass[] ProgramMemory = new ProgramClass[6];
string versionString = "Version 0.1";
DateTime momentOfStart;
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
momentOfStart = DateTime.Now;
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
string[] args = input.Split(' ');
switch(args[0])
{
case "help":
{
Help();
break;
}
case "version":
{
Console.WriteLine(versionString);
break;
}
case "echo":
{
EchoFunction(args);
break;
}
case "runtime":
{
Console.WriteLine(RunTime());
break;
}
case "calc":
{
Calculator calcProgramm = new Calculator();
ProgramMemory[0] = calcProgramm;
Console.WriteLine("Info Program[0] = " + ProgramMemory[0].Identifier);
ProgramMemory[0].Run();
break;
}
case "tempsave":
{
mem.WriteAt(0, 255);
Console.WriteLine(mem.ReadAt(0).ToString());
break;
}
default:
{
Console.WriteLine("Unknown command! Enter \"help\" for more information!");
break;
}
}
// help
// version
// echo
Console.Write("Text typed: ");
Console.WriteLine(input);
}
private void EchoFunction(string[] payload)
{
if(payload.Length > 1)
{
Console.WriteLine("Input: " + payload[1]);
}
else
{
Console.WriteLine(" Nothing to show");
}
}
private void Help()
{
Console.WriteLine("Mögliche Befehle:\n " +
" \"version\" \tAusgabe Versionsnummer.\n" +
" \"echo\" \t Ausgabe Text. \n" +
" \"runtime\" \t Ausgabe Systemlaufzeit \n");
}
private string RunTime()
{
TimeSpan span = DateTime.Now -momentOfStart ;
return String.Format("System running for {0} Hours {1} Minutes {2} Seconds", span.Hours, span.Minutes, span.Seconds);
}
}
}