aboutsummaryrefslogtreecommitdiff
path: root/Oscilloscope
diff options
context:
space:
mode:
Diffstat (limited to 'Oscilloscope')
-rw-r--r--Oscilloscope/Oscilloscope.sln25
-rw-r--r--Oscilloscope/Oscilloscope/App.config6
-rw-r--r--Oscilloscope/Oscilloscope/Command.cs31
-rw-r--r--Oscilloscope/Oscilloscope/Oscilloscope.csproj55
-rw-r--r--Oscilloscope/Oscilloscope/Program.cs32
-rw-r--r--Oscilloscope/Oscilloscope/Properties/AssemblyInfo.cs36
-rw-r--r--Oscilloscope/Oscilloscope/Screen.cs121
7 files changed, 306 insertions, 0 deletions
diff --git a/Oscilloscope/Oscilloscope.sln b/Oscilloscope/Oscilloscope.sln
new file mode 100644
index 0000000..2482a4c
--- /dev/null
+++ b/Oscilloscope/Oscilloscope.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29102.190
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oscilloscope", "Oscilloscope\Oscilloscope.csproj", "{36E3F0B2-B785-4AF3-B59F-483FDA57672A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {36E3F0B2-B785-4AF3-B59F-483FDA57672A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {36E3F0B2-B785-4AF3-B59F-483FDA57672A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {36E3F0B2-B785-4AF3-B59F-483FDA57672A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {36E3F0B2-B785-4AF3-B59F-483FDA57672A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {4F0BFF39-C20B-4BA7-8F27-2218F165F21D}
+ EndGlobalSection
+EndGlobal
diff --git a/Oscilloscope/Oscilloscope/App.config b/Oscilloscope/Oscilloscope/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+ </startup>
+</configuration> \ No newline at end of file
diff --git a/Oscilloscope/Oscilloscope/Command.cs b/Oscilloscope/Oscilloscope/Command.cs
new file mode 100644
index 0000000..c14454d
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/Command.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Oscilloscope {
+ class Command {
+ private static string[] input = new string[2];
+
+ public static void Do() {
+ Take();
+ Execute();
+ }
+
+ private static void Take() {
+ input = Console.ReadLine().Split(' ').ToArray();
+ }
+
+ private static void Execute() {
+ switch (input[0]) {
+ case "screen":
+ Screen.SetValues(input.Skip(1).ToArray());
+ break;
+ case "fps":
+ Program.Fps = double.Parse(input[1]);
+ break;
+ }
+ }
+ }
+}
diff --git a/Oscilloscope/Oscilloscope/Oscilloscope.csproj b/Oscilloscope/Oscilloscope/Oscilloscope.csproj
new file mode 100644
index 0000000..de6a2a2
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/Oscilloscope.csproj
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{36E3F0B2-B785-4AF3-B59F-483FDA57672A}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Oscilloscope</RootNamespace>
+ <AssemblyName>Oscilloscope</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Command.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Screen.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/Oscilloscope/Oscilloscope/Program.cs b/Oscilloscope/Oscilloscope/Program.cs
new file mode 100644
index 0000000..ea91a62
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/Program.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Oscilloscope
+{
+ class Program
+ {
+ public static double Fps = 100;
+
+ static void Main(string[] args)
+ {
+ Screen.SetDefaults();
+
+ while (true) {
+ Screen.DEMO();
+ Screen.Print();
+
+
+ if (Console.KeyAvailable) {
+ Command.Do();
+ }
+
+ Thread.Sleep((int)(1000 / Fps));
+ Console.Clear();
+ }
+ }
+ }
+}
diff --git a/Oscilloscope/Oscilloscope/Properties/AssemblyInfo.cs b/Oscilloscope/Oscilloscope/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0bfa319
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Oscilloscope")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Oscilloscope")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("36e3f0b2-b785-4af3-b59f-483fda57672a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Oscilloscope/Oscilloscope/Screen.cs b/Oscilloscope/Oscilloscope/Screen.cs
new file mode 100644
index 0000000..1b04f4d
--- /dev/null
+++ b/Oscilloscope/Oscilloscope/Screen.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Oscilloscope
+{
+ class Screen
+ {
+ public static int Height { get; private set; }
+ public static int Width { get; private set; }
+
+ public static char VerWall { get; private set; }
+ public static char HorWall { get; private set; }
+
+ public static char Ray { get; private set; }
+ public static int RayXPos { get; set; }
+ public static int RayYPos { get; set; }
+
+ public static void SetDefaults() {
+ Height = 10;
+ Width = 20;
+
+ VerWall = '|';
+ HorWall = '-';
+
+ Ray = '*';
+ RayXPos = Width / 2;
+ RayYPos = Height / 2;
+
+ map = new StringBuilder[Height + 2];
+ for (int i = 0; i < map.Length; i++) {
+ map[i] = new StringBuilder(new string(' ', Width + 2));
+ }
+ }
+
+ public static void SetValues(string[] command) {
+ try {
+ //TODO: add other commands
+ switch (command[0]) {
+ case "size":
+ Height = int.Parse(command[1]); Width = int.Parse(command[2]);
+ break;
+ case "char":
+ if (command[1] == "ray") Ray = command[2][0];
+ //TODO: add other chars
+ break;
+ }
+ } catch (Exception) {
+ Console.WriteLine("ERR");
+ Thread.Sleep(1000);
+ }
+ }
+
+ private static StringBuilder[] map;
+
+ public static void Print() {
+ map[0] = new StringBuilder(new string(HorWall, Width + 2));
+ map[map.Length - 1] = new StringBuilder(new string(HorWall, Width + 2));
+
+ for (int row = 1; row < Height; row++) {
+
+ var currRow = map[row];
+ for (int col = 0; col < Width; col++) {
+
+ if (row == RayYPos && col == RayXPos) {
+ currRow[col] = Ray;
+
+ for (int j = 1; j < Height + 1; j++) {
+ if (j != row) map[j][col] = ' ';
+ }
+ }
+ }
+
+ currRow[0] = VerWall; currRow[Width - 1] = VerWall;
+ map[row] = currRow;
+ }
+
+ PrintMap();
+ }
+
+ private static void PrintMap() {
+ for (int i = 0; i < map.Length; i++) {
+ Console.WriteLine(map[i]);
+ }
+ }
+
+ private static int t;
+ private static int val;
+ public static void DEMO() {
+ switch (val) {
+ case 0: RayYPos = 5; break;
+ case 1: RayYPos = 4; break;
+ case 2: RayYPos = 3; break;
+ case 3: RayYPos = 2; break;
+ case 4: RayYPos = 1; break;
+ case 5: RayYPos = 0; break;
+ case 6: RayYPos = 1; break;
+ case 7: RayYPos = 2; break;
+ case 8: RayYPos = 3; break;
+ case 9: RayYPos = 4; break;
+ case 10: RayYPos = 5; break;
+ case 11: RayYPos = 6; break;
+ case 12: RayYPos = 7; break;
+ case 13: RayYPos = 8; break;
+ case 14: RayYPos = 9; break;
+ case 15: RayYPos = 8; break;
+ case 16: RayYPos = 7; break;
+ case 17: RayYPos = 6; val = -1; break;
+ }
+ val++;
+
+ if (t == Width) t = 0;
+ else t++;
+
+ RayXPos = t;
+ }
+ }
+}