Skip to content

Commit

Permalink
【一、新增功能】
Browse files Browse the repository at this point in the history
无

【二、优化修复】
统一 const 变量
  • Loading branch information
SuperStudio committed May 3, 2023
1 parent f2204eb commit f99a02d
Show file tree
Hide file tree
Showing 32 changed files with 467 additions and 570 deletions.
8 changes: 7 additions & 1 deletion SuperCom.Test/SuperCom.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="UnitTests\Comparers\ComPortComparer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="SampleData\command.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SuperCom\SuperCom.csproj">
<Project>{7782F9E2-0821-4C05-8DA5-04367CD670FD}</Project>
<Name>SuperCom</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
14 changes: 0 additions & 14 deletions SuperCom.Test/UnitTest1.cs

This file was deleted.

25 changes: 25 additions & 0 deletions SuperCom.Test/UnitTests/Comparers/ComPortComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;

namespace SuperCom.Test
{
[TestClass]
public class ComPortComparer
{
[TestMethod]
public void ComPortComparerTest()
{
List<string> comList = new List<string>()
{
"COM1","COM11","COM111","COM2","COM20","COM99"
};
List<string> sorted = new List<string>()
{
"COM1","COM2","COM11","COM20","COM99","COM111"
};
List<string> list = comList.OrderBy(arg => arg, new SuperCom.Comparers.ComPortComparer()).ToList();
CollectionAssert.AreEqual(list, sorted);
}
}
}
14 changes: 6 additions & 8 deletions SuperCom/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using SuperUtils.Framework.Logger;
using SuperUtils.IO;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace SuperCom
{
Expand All @@ -18,19 +16,19 @@ namespace SuperCom
public partial class App : Application
{
public static AbstractLogger Logger = Log.Logger.Instance;
private static MemoryDog memoryDog { get; set; }
private static MemoryDog MemoryDog { get; set; }

public static Action OnMemoryDog;
public static Action<long> OnMemoryChanged;

static App()
{
memoryDog = new MemoryDog();
memoryDog.OnNotFeed += () =>
MemoryDog = new MemoryDog();
MemoryDog.OnNotFeed += () =>
{
OnMemoryDog?.Invoke();
};
memoryDog.OnMemoryChanged += (memory) =>
MemoryDog.OnMemoryChanged += (memory) =>
{
OnMemoryChanged?.Invoke(memory);
};
Expand All @@ -43,7 +41,7 @@ static App()
{
Logger.Error(str);
};
Logger.Info("APP 初始化");
Logger.Info("app init");
}

protected override void OnStartup(StartupEventArgs e)
Expand All @@ -63,7 +61,7 @@ protected override void OnStartup(StartupEventArgs e)
Logger.Info("异常后处理启动");
#endif
// 看门狗
memoryDog.Watch();
MemoryDog.Watch();
base.OnStartup(e);
}

Expand Down
3 changes: 2 additions & 1 deletion SuperCom/Config/CommonSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace SuperCom.Config.WindowConfig
public class CommonSettings : AbstractConfig
{

public static string DEFAULT_LOGNAMEFORMAT = "[%C] %Y-%M-%D %h-%m-%s.%f";
public const string DEFAULT_LOGNAMEFORMAT = "[%C] %Y-%M-%D %h-%m-%s.%f";

public static string DEFAULT_LOG_SAVE_DIR = System.IO.Path.Combine(Environment.CurrentDirectory, "logs", "%Y-%M-%D");
public static List<string> SUPPORT_FORMAT = new List<string>()
{
Expand Down
4 changes: 4 additions & 0 deletions SuperCom/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public static class ConfigManager
public const string SQLITE_DATA_PATH = "user_data.sqlite";

public const string RELEASE_DATE = "2023-04-23";
public const string LICENSE = "GPL-3.0";
public const string AUTHOR = "chao";
public const string APP_NAME = "SuperCom";
public const string APP_SUB_NAME = "超级串口工具";
public static Main Main { get; set; }
public static CommonSettings CommonSettings { get; set; }
public static Settings Settings { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions SuperCom/Config/UrlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public static class UrlManager

private static string DonateJsonBasePath = "SuperSudio-Donate";
private static string PluginBasePath = "SuperPlugins";
public const string GITHUB_URL = "https://github.com/SuperStudio/SuperCom";
public static string FeedbackUrl = "https://github.com/SuperStudio/SuperCom/issues";
public static string HelpUrl = "https://github.com/SuperStudio/SuperCom/wiki";
public const string NOTICE_URL = "https://superstudio.github.io/SuperCom-Upgrade/notice.json";


public static List<ReferenceData> REFERENCE_DATAS = new List<ReferenceData>()
{
new ReferenceData("Serial and UART Tutorial",
Expand Down
6 changes: 4 additions & 2 deletions SuperCom/Converters/ColorToBrushConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public class ColorToBrushConverter : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return Brushes.Black;
SolidColorBrush solidColorBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString()));
if (value == null)
return Brushes.Black;
SolidColorBrush solidColorBrush =
new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString()));
return solidColorBrush;
}

Expand Down
36 changes: 17 additions & 19 deletions SuperCom/Entity/AdvancedSend.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
using SuperCom.Config;
using SuperUtils.Framework.ORM.Attributes;
using SuperUtils.Framework.ORM.Mapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.AvalonEdit;
using SuperUtils.Time;
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Controls;
using System.Windows.Threading;
using SuperUtils.WPF.VieModel;
using System.Collections.Generic;

namespace SuperCom.Entity
{
Expand All @@ -32,8 +19,11 @@ public enum RunningStatus

public class SendCommand : ViewModelBase
{
public const int DEFAULT_DELAY = 200;
public const int DEFAULT_TIMEOUT = 5000;

private static Dictionary<RunningStatus, string> RunningStatusToString = new Dictionary<RunningStatus, string>() {
private static readonly Dictionary<RunningStatus, string> RUN_STATUS_TABLE =
new Dictionary<RunningStatus, string>() {
{ RunningStatus.WaitingToRun,"就绪" },
{ RunningStatus.WaitingDelay,"等待中" },
{ RunningStatus.Running,"运行中" },
Expand All @@ -42,8 +32,7 @@ public class SendCommand : ViewModelBase
{ RunningStatus.Failed,"失败" },
};

public static int DEFAULT_DELAY = 200;
public static int DEFAULT_TIMEOUT = 5000;

public long CommandID { get; set; }
public string Name { get; set; }

Expand All @@ -63,7 +52,7 @@ public RunningStatus Status
set
{
_Status = value; RaisePropertyChanged();
StatusText = RunningStatusToString[value];
StatusText = RUN_STATUS_TABLE[value];
}
}
private string _StatusText = "就绪";
Expand Down Expand Up @@ -133,7 +122,16 @@ public static class SqliteTable
{
public static Dictionary<string, string> Table = new Dictionary<string, string>()
{
{"advanced_send","create table if not exists advanced_send( ProjectID INTEGER PRIMARY KEY autoincrement, ProjectName VARCHAR(200), Commands TEXT, CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) );" }
{
"advanced_send",
"create table if not exists advanced_send( " +
"ProjectID INTEGER PRIMARY KEY autoincrement, " +
"ProjectName VARCHAR(200), " +
"Commands TEXT, " +
"CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " +
"UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) " +
");"
}
};

}
Expand Down
20 changes: 17 additions & 3 deletions SuperCom/Entity/ComSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,26 @@ public static class SqliteTable
{
public static Dictionary<string, string> Table = new Dictionary<string, string>()
{
{"com_settings","create table if not exists com_settings( Id INTEGER PRIMARY KEY autoincrement, PortName VARCHAR(50), Connected INT DEFAULT 0, AddTimeStamp INT DEFAULT 0, AddNewLineWhenWrite INT DEFAULT 0, PortSetting VARCHAR(1000), WriteData VARCHAR(5000), CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), unique(PortName) );" }
{
"com_settings",
"create table if not exists com_settings( " +
"Id INTEGER PRIMARY KEY autoincrement, " +
"PortName VARCHAR(50), " +
"Connected INT DEFAULT 0, " +
"AddTimeStamp INT DEFAULT 0, " +
"AddNewLineWhenWrite INT DEFAULT 0, " +
"PortSetting VARCHAR(1000), " +
"WriteData VARCHAR(5000), " +
"CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " +
"UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " +
"unique(PortName) " +
");"
}
};

}

public static string[] SqlCommands = {
public static string[] SQL_EXTRA_CMDS = {
"ALTER TABLE com_settings ADD COLUMN EnabledFilter INT DEFAULT 0;",
"ALTER TABLE com_settings ADD COLUMN EnabledMonitor INT DEFAULT 0;",
"ALTER TABLE com_settings ADD COLUMN SendHex INT DEFAULT 0;",
Expand All @@ -82,7 +96,7 @@ public static void InitSqlite()
}

// 新增列
foreach (string sql in SqlCommands)
foreach (string sql in SQL_EXTRA_CMDS)
{
try
{
Expand Down
52 changes: 27 additions & 25 deletions SuperCom/Entity/HighLightRule.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
using SuperCom.Config;
using SuperUtils.Common;
using SuperUtils.Framework.ORM.Attributes;
using SuperUtils.Framework.ORM.Mapper;
using SuperUtils.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.AvalonEdit;
using SuperUtils.Time;
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Controls;
using System.Windows.Threading;
using SuperUtils.IO;
using SuperUtils.Common;
using SuperUtils.WPF.VieModel;

namespace SuperCom.Entity
{
[Table(tableName: "highlight_rule")]
public class HighLightRule
{
public static List<HighLightRule> AllRules = new List<HighLightRule>();
public static List<string> AllName = new List<string>();



public static List<HighLightRule> AllRules { get; set; }
public static List<string> AllName { get; set; }

[TableId(IdType.AUTO)]
public long RuleID { get; set; }
Expand All @@ -55,6 +41,19 @@ public HighLightRule()

}

public HighLightRule(int RuleID, string RuleName, string FileName)
{
this.RuleID = RuleID;
this.RuleName = RuleName;
this.FileName = FileName;
}

static HighLightRule()
{
AllRules = new List<HighLightRule>();
AllName = new List<string>();
}

public void SetFileName()
{
FileName = $"{RuleID}_{RuleName.ToProperFileName()}.xshd";
Expand Down Expand Up @@ -124,20 +123,23 @@ private string GetRuleString(RuleSet rule)
}


public HighLightRule(int RuleID, string RuleName, string FileName)
{
this.RuleID = RuleID;
this.RuleName = RuleName;
this.FileName = FileName;
}

public static class SqliteTable
{
public static Dictionary<string, string> Table = new Dictionary<string, string>()
{
{
"highlight_rule",
"create table if not exists highlight_rule( RuleID INTEGER PRIMARY KEY autoincrement, RuleName VARCHAR(200), FileName TEXT, RuleSetString TEXT,PreviewText TEXT,Extra TEXT, CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) );" }
"create table if not exists highlight_rule( " +
"RuleID INTEGER PRIMARY KEY autoincrement, " +
"RuleName VARCHAR(200), " +
"FileName TEXT, " +
"RuleSetString TEXT," +
"PreviewText TEXT," +
"Extra TEXT, " +
"CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " +
"UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) " +
");" }
};

}
Expand Down
Loading

0 comments on commit f99a02d

Please sign in to comment.