Skip to content

Commit

Permalink
Add OpenGLTest
Browse files Browse the repository at this point in the history
Add OpenGLTest
  • Loading branch information
Jimmy-Hu committed May 12, 2019
1 parent 43fedd8 commit b015973
Show file tree
Hide file tree
Showing 53 changed files with 5,379 additions and 0 deletions.
28 changes: 28 additions & 0 deletions VisualStudioProjects/OpenGLTest/UartOscilloscope.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UartOscilloscope", "UartOscilloscope\UartOscilloscope.csproj", "{8D89102B-2B1F-43D5-83C2-DA86889BA3D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UartOscilloscopeTests", "UartOscilloscopeTests\UartOscilloscopeTests.csproj", "{7EC5AE58-596E-4960-8DFC-BBBE353B1F7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D89102B-2B1F-43D5-83C2-DA86889BA3D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D89102B-2B1F-43D5-83C2-DA86889BA3D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D89102B-2B1F-43D5-83C2-DA86889BA3D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D89102B-2B1F-43D5-83C2-DA86889BA3D7}.Release|Any CPU.Build.0 = Release|Any CPU
{7EC5AE58-596E-4960-8DFC-BBBE353B1F7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EC5AE58-596E-4960-8DFC-BBBE353B1F7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EC5AE58-596E-4960-8DFC-BBBE353B1F7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EC5AE58-596E-4960-8DFC-BBBE353B1F7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions VisualStudioProjects/OpenGLTest/UartOscilloscope/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/********************************************************************
* Develop by Jimmy Hu *
* This program is licensed under the Apache License 2.0. *
* CommandClass.cs *
* 本檔案建立程式指令模式下指令單元物件 *
********************************************************************
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UartOscilloscope // UartOscilloscope命名空間
{ // 進入UartOscilloscope命名空間
class CommandClass // CommandClass指令類別
{ // 進入CommandClass指令類別
private int CommandID; // 宣告指令編號
private string CommandName; // 宣告指令名稱
private string ChineseDescription; // 宣告指令中文描述
private string EnglishDescription; // 宣告指令英文描述
private Task task; // 宣告指令工作
/// <summary>
/// CommandClass建構子
/// </summary>
/// <param name="CommandID">為指令編號</param>
/// <param name="CommandName">為指令名稱</param>
/// <param name="ChineseDescription">為指令中文敘述</param>
/// <param name="EnglishDescription">為指令英文敘述</param>
/// <param name="task">為指令工作</param>
public CommandClass(int CommandID, string CommandName, string ChineseDescription, string EnglishDescription, Task task)
// CommandClass constructor, CommandClass建構子
{ // CommandClass constructor start, 進入CommandClass建構子

} // CommandClass constructor end, 結束CommandClass建構子

/// <summary>
/// CommandClass建構子
/// </summary>
/// <param name="CommandID">為指令編號</param>
/// <param name="CommandName">為指令名稱</param>
/// <param name="ChineseDescription">為指令中文敘述</param>
/// <param name="task">為指令工作</param>
public CommandClass(int CommandID, string CommandName, string ChineseDescription, Task task)
// CommandClass建構子
{ // 進入CommandClass建構子
this.CommandID = CommandID; // 初始化指令編號
this.CommandName = CommandName; // 初始化指令名稱
this.ChineseDescription = ChineseDescription; // 初始化指令中文描述
this.EnglishDescription = ""; // 初始化指令英文描述
this.task = task; // 初始化指令工作
} // 結束CommandClass建構子

public CommandClass(int CommandID, string CommandName, Task task)
// CommandClass建構子
{ // 進入CommandClass建構子
this.CommandID = CommandID; // 初始化指令編號
this.CommandName = CommandName; // 初始化指令名稱
this.ChineseDescription = ""; // 初始化指令中文描述
this.EnglishDescription = ""; // 初始化指令英文描述
this.task = task; // 初始化指令工作
} // 結束CommandClass建構子
/// <summary>
/// 覆寫ToString方法可回傳指令名稱
/// </summary>
/// <returns>回傳值為指令名稱</returns>
public override string ToString() // 覆寫ToString方法
{ // 進入覆寫ToString方法
return CommandName; // 回傳指令名稱
} // 結束覆寫ToString方法
} // 結束CommandClass指令類別
} // 結束UartOscilloscope命名空間
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System; // 使用System函式庫
using System.Collections.Generic; // 使用System.Collections.Generic函式庫
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UartOscilloscope // UartOscilloscope命名空間
{ // 進入UartOscilloscope命名空間
class CommandDatabase // CommandDatabase類別
{ // 進入CommandDatabase類別
public readonly static CommandDatabase Instance = new CommandDatabase();// 設計CommandDatabase存取介面
private List<CommandClass> CommandSet = new List<CommandClass>(); // 宣告CommandSet
/// <summary>
/// CommandDatabase類別
/// </summary>
public CommandDatabase() // CommandDatabase建構子
{ // 進入CommandDatabase建構子
CreateCommandSet(); // 呼叫CreateCommandSet方法
} // 結束CommandDatabase建構子

/// <summary>
/// CreateCommandSet方法用於建立命令集合
/// </summary>
public void CreateCommandSet()
{
CommandSet.Add(new CommandClass( // Add command, 新增指令
1, // 指令編號
"connect", // 指令名稱
new System.Threading.Tasks.Task(() => // 建立指令工作
{ // 進入指令工作內容

}))); // 結束指令工作內容
CommandSet.Add(new CommandClass( // 新增指令
2, // 指令編號
"help", // 指令名稱
new System.Threading.Tasks.Task(() => // 建立指令工作
{ // 進入指令工作內容

}))); // 結束指令工作內容
CommandSet.Add(new CommandClass( // 新增指令
3, // 指令編號
"lscom", // 指令名稱
new System.Threading.Tasks.Task(() => // 建立指令工作
{ // 進入指令工作內容
UARTConnection UARTConnection1; // 宣告UARTConnection1物件
UARTConnection1 = new UARTConnection(0, false);
Console.WriteLine(UARTConnection1.GetComportList().ToString());
}))); // 結束指令工作內容
CommandSet.Add(new CommandClass( // 新增指令
3, // 指令編號
"version", // 指令名稱
new System.Threading.Tasks.Task(() => // 建立指令工作
{ // 進入指令工作內容
Console.WriteLine(VersionInfo.Instance.GetProgramVersion());
}))); // 結束指令工作內容
}
/// <summary>
/// 顯示CommandSet指令列表
/// </summary>
/// <returns></returns>
public override string ToString() // 覆寫ToString方法
{ // 進入覆寫ToString方法
string OutputStr = ""; // 宣告輸出字串
foreach (CommandClass Item in this.CommandSet) // 以foreach迴圈依序取出指令物件
{ // 進入foreach敘述
OutputStr = OutputStr + Item.ToString() + '\t'; // 生成輸出字串
} // 結束foreach敘述
return OutputStr; // 回傳輸出字串
} // 結束覆寫ToString方法
/// <summary>
/// GetCommandSet方法用於取得命令集合中指令列表
/// </summary>
/// <returns></returns>
public string[] GetCommandSet() // GetCommandSet方法
{ // 進入GetCommandSet方法
string[] OutputStrArray; // 宣告輸出字串陣列
OutputStrArray = new string[] { }; // 初始化字串陣列
int OutputStrArraySize = CommandSet.Count; // 宣告OutputStrArraySize,用於記錄輸出陣列大小
Array.Resize<string>(ref OutputStrArray, OutputStrArraySize); // 調整字串陣列大小
int Index = 0; // 宣告索引值用於存取陣列元素
foreach(CommandClass Item in this.CommandSet) // 取出命令集合中指令
{ // 進入foreach敘述
OutputStrArray[Index] = Item.ToString(); // 填入資料至輸出陣列
Index = Index + 1; // 遞增索引值
} // 結束foreach敘述
return OutputStrArray; // 回傳字串陣列
} // 結束GetCommandSet方法
/// <summary>
/// GetCommandSetCount方法用於取得命令集合指令數量
/// </summary>
/// <returns></returns>
private int GetCommandSetCount() // GetCommandSetCount方法
{ // 進入GetCommandSetCount方法
return this.CommandSet.Count; // 回傳命令集合指令數量
} // 結束GetCommandSetCount方法
private string GetCommandHelp() // GetCommandHelp方法
{ // 進入GetCommandHelp方法
string OutputStr = "";
return OutputStr;
} // 結束GetCommandHelp方法
} // 結束CommandDatabase類別
} // 結束UartOscilloscope命名空間
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UartOscilloscope // UartOscilloscope命名空間
{ // 進入UartOscilloscope命名空間
/// <summary>
/// CommandParser類別用於建立指令語法分析器
/// </summary>
class CommandParser // CommandParser類別
{ // 進入CommandParser類別

/// <summary>
/// CommandParser建構子
/// </summary>
public CommandParser() // CommandParser建構子
{ // 進入CommandParser建構子

} // 結束CommandParser建構子
} // 結束CommandParser類別
} // 結束UartOscilloscope命名空間
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UartOscilloscope // UartOscilloscope命名空間
{ // 進入UartOscilloscope命名空間
/// <summary>
/// ComportList類別單純為一字串陣列容器,可透過UpdateComportList方法新增Comport名稱
/// </summary>
public class ComportList // ComportList類別
{ // 進入ComportList類別
private string[] Name; // 宣告Name字串陣列
/// <summary>
/// ComportList建構子
/// </summary>
/// <param name="Name"></param>
public ComportList(string[] Name) // ComportList建構子
{ // 進入ComportList建構子
this.Name = Name; // 初始化內部物件
} // 結束ComportList建構子
/// <summary>
/// GetComportList方法用於取得Comport列表
/// </summary>
/// <returns></returns>
public string[] GetComportList() // GetComportList方法
{ // 進入GetComportList方法
return Name; // 回傳Name
} // 結束GetComportList方法
/// <summary>
/// UpdateComportList用於更新ComportList內部物件資料
/// </summary>
/// <param name="ComportList"></param>
public void UpdateComportList(string[] ComportList) // UpdateComportList方法
{ // 進入UpdateComportList方法
Name = ComportList; // 填入資料
} // 結束UpdateComportList方法
/// <summary>
/// 複寫ToString方法,以foreach依序列出comport
/// </summary>
/// <returns></returns>
public override string ToString() // 覆寫ToString方法
{ // 進入覆寫ToString方法
string OutputString = ""; // 宣告OutputString(輸出字串結果)
foreach (string item in Name) // 以foreach依序列出Name內容
{ // 進入foreach敘述
OutputString = OutputString + item + '\n'; // 填入內容至輸出字串
} // 結束foreach敘述
return OutputString; // 回傳OutputString
} // 結束覆寫ToString方法

/// <summary>
/// IsComportListNull方法用於檢測ComportList是否為空
/// </summary>
/// <returns>若未偵測到Comport回傳true,否則回傳false</returns>
public bool IsComportListNull() // IsComportListNull方法
{ // 進入IsComportListNull方法
if(Name.Length == 0) // 若未偵測到Comport
{ // 進入if敘述
return true; // 回傳true
} // 結束if敘述
else // 若偵測到Comport
{ // 進入else敘述
return false; // 回傳false
} // 結束else敘述
} // 結束IsComportListNull方法
} // 結束ComportList類別
} // 結束UartOscilloscope命名空間
Loading

0 comments on commit b015973

Please sign in to comment.