diff --git a/HuimMasterServer.sln b/HuimMasterServer.sln new file mode 100644 index 0000000..d5cbed8 --- /dev/null +++ b/HuimMasterServer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36121.58 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuimMasterServer", "HuimMasterServer\HuimMasterServer.csproj", "{54D62E9F-8085-47C5-A7B4-3233516CDB70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54D62E9F-8085-47C5-A7B4-3233516CDB70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54D62E9F-8085-47C5-A7B4-3233516CDB70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54D62E9F-8085-47C5-A7B4-3233516CDB70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54D62E9F-8085-47C5-A7B4-3233516CDB70}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E3088683-A8FF-4806-BDBA-1DA2AA3567D5} + EndGlobalSection +EndGlobal diff --git a/HuimMasterServer/CommandList.txt b/HuimMasterServer/CommandList.txt new file mode 100644 index 0000000..105c8df --- /dev/null +++ b/HuimMasterServer/CommandList.txt @@ -0,0 +1,18 @@ +pressButton : 0, typeText : 정우진, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER, delay : 1000, move : 100, 100 +pressButton : 0, typeText : 문도균1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 최민준, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 손솔빈, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 이지율1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 이오늘1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김아름, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김다움, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 최성준1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 조미연1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 이하민, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 우수정, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김경찬2, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 다이스, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김다흰, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김민준2, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 정에린1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER +pressButton : 0, typeText : 김다슬1, pressKey : KEY_KP_ENTER, typePw, pressKey : KEY_KP_ENTER \ No newline at end of file diff --git a/HuimMasterServer/HuimMasterServer.csproj b/HuimMasterServer/HuimMasterServer.csproj new file mode 100644 index 0000000..c01e67f --- /dev/null +++ b/HuimMasterServer/HuimMasterServer.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/HuimMasterServer/KeyboardLayoutConverter.cs b/HuimMasterServer/KeyboardLayoutConverter.cs new file mode 100644 index 0000000..767523b --- /dev/null +++ b/HuimMasterServer/KeyboardLayoutConverter.cs @@ -0,0 +1,68 @@ +using System.Text; + +namespace HuimMasterServer +{ + public static class KeyboardLayoutConverter + { + //해줘 코드 mk2 + // 각 자모에 해당하는 영문 자판 배열을 미리 선언해 둡니다. + private static readonly string[] Choseong = { + "r", "R", "s", "e", "E", "f", "a", "q", "Q", "t", + "T", "d", "w", "W", "c", "z", "x", "v", "g" + }; + + private static readonly string[] Jungseong = { + "k", "o", "i", "O", "j", "p", "u", "P", "h", "hk", + "ho", "hl", "y", "n", "nj", "np", "nl", "b", "m", "ml", "l" + }; + + private static readonly string[] Jongseong = { + "", "r", "R", "rt", "s", "sw", "sg", "e", "f", "fr", + "fa", "fq", "ft", "fx", "fv", "fg", "a", "q", "qt", + "t", "T", "d", "w", "c", "z", "x", "v", "g" + }; + + /// + /// 한글 문자열을 QWERTY 키보드 레이아웃 기준 영문으로 변환합니다. + /// 예: "안녕" -> "dkssud" + /// + /// 변환할 한글 문자열 + /// 영문으로 변환된 문자열 + public static string KorToEng(string koreanText) + { + if (string.IsNullOrEmpty(koreanText)) + { + return string.Empty; + } + + var resultBuilder = new StringBuilder(); + + // 입력된 문자열을 한 글자씩 순회합니다. + foreach (char c in koreanText) + { + // 한글 완성형 글자(U+AC00 ~ U+D7A3)인지 확인합니다. + if (c >= 0xAC00 && c <= 0xD7A3) + { + int syllableIndex = c - 0xAC00; + int cho = syllableIndex / (21 * 28); + int jung = (syllableIndex % (21 * 28)) / 28; + int jong = syllableIndex % 28; + + resultBuilder.Append(Choseong[cho]); + resultBuilder.Append(Jungseong[jung]); + if (jong > 0) // 종성이 있는 경우에만 추가합니다. + { + resultBuilder.Append(Jongseong[jong]); + } + } + else + { + // 한글이 아닌 문자는 그대로 추가합니다. + resultBuilder.Append(c); + } + } + + return resultBuilder.ToString(); + } + } +} diff --git a/HuimMasterServer/Program.cs b/HuimMasterServer/Program.cs new file mode 100644 index 0000000..c2024c4 --- /dev/null +++ b/HuimMasterServer/Program.cs @@ -0,0 +1,111 @@ +namespace HuimMasterServer +{ + internal static class Program + { + //Ƶ̳밡 ͳݿ Ǿ Ŭ̾Ʈμ ڽ ipּ ( ip) װ ˷ óƮũ ִ ٸ + //Ⱑ װ + // + //Ȥ ׳ Ƶ̳밡 ü ؼ ű⿡ Ѽ Ű + + //Ƶ̳밡 Ǿ ޾Ƽ ϰ + // ڵ ּ űϴ ڵ忡 ؼ ִ ö + private static void Main(string[] args) + { + if (!File.Exists("CommandList.txt")) + { + File.Create("CommandList.txt").Close(); + } + var cmdText = File.ReadAllLines("CommandList.txt"); + List cmdList = []; + for (int i = 0; i < cmdText.Length; i++) + { + string cmd = cmdText[i]; + cmdList.Add(cmd.ToString()); + Console.WriteLine(cmd); + } + + int index = 0; + + bool deviceControlCmdInBuffer = false; + + string cmdBuffer = string.Empty; + + var builder = WebApplication.CreateBuilder(args); + var app = builder.Build(); + + app.UseDefaultFiles(); + app.UseStaticFiles(); + + app.MapGet("/api/{msgToServer}", (string msgToServer) => + { + switch (msgToServer) + { + case "ready": + cmdBuffer = KeyboardLayoutConverter.KorToEng(cmdList[index]); + index++; + return cmdBuffer; + + case "prepare": + if (deviceControlCmdInBuffer) + { + deviceControlCmdInBuffer = false; + return cmdBuffer; + } + cmdBuffer = KeyboardLayoutConverter.KorToEng(cmdList[index]); + return null; + + case "next": + if (deviceControlCmdInBuffer) + { + deviceControlCmdInBuffer = false; + return cmdBuffer; + } + index++; + if (index >= cmdList.Count) + { + cmdBuffer = "end"; + return cmdBuffer; + } + else + { + //cmdBuffer = KeyboardLayoutConverter.KorToEng(cmdList[index]); + //index++; + return KeyboardLayoutConverter.KorToEng(cmdList[index]); + } + + case "acting": + if (deviceControlCmdInBuffer) + { + deviceControlCmdInBuffer = false; + return cmdBuffer; + } + return null; + + default: + return null; + } + }); + + app.MapGet("/", context => + { + context.Response.Redirect("home/index.html"); + return Task.CompletedTask; + }); + + app.MapGet("home/stop", () => + { + cmdBuffer = "stop"; + Console.WriteLine("aaa"); + deviceControlCmdInBuffer = true; + return "device will stop"; + }); + + //app.UseAuthorization(); + + app.UseRouting(); + + + app.Run("http://localhost:8005"); + } + } +} \ No newline at end of file diff --git a/HuimMasterServer/Properties/launchSettings.json b/HuimMasterServer/Properties/launchSettings.json new file mode 100644 index 0000000..3dd5d86 --- /dev/null +++ b/HuimMasterServer/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:56694", + "sslPort": 44349 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5246", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7188;http://localhost:5246", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/HuimMasterServer/appsettings.Development.json b/HuimMasterServer/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/HuimMasterServer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/HuimMasterServer/appsettings.json b/HuimMasterServer/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/HuimMasterServer/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/HuimMasterServer/wwwroot.zip b/HuimMasterServer/wwwroot.zip new file mode 100644 index 0000000..eaa721e Binary files /dev/null and b/HuimMasterServer/wwwroot.zip differ diff --git a/HuimMasterServer/wwwroot/home/index.html b/HuimMasterServer/wwwroot/home/index.html new file mode 100644 index 0000000..9cea76b --- /dev/null +++ b/HuimMasterServer/wwwroot/home/index.html @@ -0,0 +1,25 @@ + + + + 후임 + + + + + + +
+ + + + \ No newline at end of file