提交 2511ba50 编写于 作者: cdy816's avatar cdy816

日常更新

上级 f7f62ba2
...@@ -56,6 +56,7 @@ namespace DBDevelopService ...@@ -56,6 +56,7 @@ namespace DBDevelopService
{ {
try try
{ {
LoggerService.Service.Info("GrpcDBService", "Ready to start to GrpcDBService......");
StartAsync("0.0.0.0", port); StartAsync("0.0.0.0", port);
} }
catch(Exception ex) catch(Exception ex)
......
...@@ -32,8 +32,9 @@ namespace DBDevelopService ...@@ -32,8 +32,9 @@ namespace DBDevelopService
DBDevelopService.SecurityManager.Manager.Init(); DBDevelopService.SecurityManager.Manager.Init();
//驱动初始化 //驱动初始化
Cdy.Tag.DriverManager.Manager.Init(); Cdy.Tag.DriverManager.Manager.Init();
//注册日志
ServiceLocator.Locator.Registor<ILog>(new ConsoleLogger()); ////注册日志
//ServiceLocator.Locator.Registor<ILog>(new ConsoleLogger());
} }
#endregion ...Constructor... #endregion ...Constructor...
...@@ -49,12 +50,20 @@ namespace DBDevelopService ...@@ -49,12 +50,20 @@ namespace DBDevelopService
/// </summary> /// </summary>
public void Start(int grpcPort = 5001, int webSocketPort = 8000, bool isEnableGrpc = true, bool isEnableWebApi = true) public void Start(int grpcPort = 5001, int webSocketPort = 8000, bool isEnableGrpc = true, bool isEnableWebApi = true)
{ {
DbManager.Instance.Load(); try
if (isEnableGrpc) {
grpcDBService.Start(grpcPort); LoggerService.Service.Info("Service", "Ready to start....");
DbManager.Instance.Load();
if (isEnableWebApi) if (isEnableGrpc)
webDBService.Start(webSocketPort); grpcDBService.Start(grpcPort);
if (isEnableWebApi)
webDBService.Start(webSocketPort);
}
catch(Exception ex)
{
LoggerService.Service.Erro("Service","start "+ ex.Message);
}
} }
/// <summary> /// <summary>
......
...@@ -43,7 +43,15 @@ namespace DBDevelopService ...@@ -43,7 +43,15 @@ namespace DBDevelopService
/// </summary> /// </summary>
public void Start(int port) public void Start(int port)
{ {
StartAsync("0.0.0.0", port); try
{
LoggerService.Service.Info("WebAPIDBService", "Ready to start to WebAPI DBService.....");
StartAsync("0.0.0.0", port);
}
catch(Exception ex)
{
LoggerService.Service.Erro("WebAPIDBService", ex.Message);
}
} }
/// <summary> /// <summary>
......
...@@ -63,7 +63,7 @@ namespace DBStudio ...@@ -63,7 +63,7 @@ namespace DBStudio
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public bool IsGrpcEnable { get; set; } public bool IsGrpcEnable { get; set; } = true;
/// <summary> /// <summary>
/// ///
...@@ -79,14 +79,24 @@ namespace DBStudio ...@@ -79,14 +79,24 @@ namespace DBStudio
/// </summary> /// </summary>
public void Load() public void Load()
{ {
string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.FullName), "DbInStudioServer.cfg"); try
if(System.IO.File.Exists(spath)) {
string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "DbInStudioServer.cfg");
LoggerService.Service.Info("Config", "Start to load config");
if (System.IO.File.Exists(spath))
{
var xxx = XElement.Load(spath);
this.IsWebApiEnable = bool.Parse(xxx.Attribute("IsWebApiEnable")?.Value);
this.IsGrpcEnable = bool.Parse(xxx.Attribute("IsGrpcEnable")?.Value);
this.WebApiPort = int.Parse(xxx.Attribute("WebApiPort")?.Value);
this.GrpcPort = int.Parse(xxx.Attribute("GrpcPort")?.Value);
}
}
catch(Exception ex)
{ {
var xxx = XElement.Load(spath); LoggerService.Service.Erro("Config", ex.Message);
this.IsWebApiEnable = bool.Parse(xxx.Attribute("IsWebApiEnable")?.Value);
this.IsGrpcEnable = bool.Parse(xxx.Attribute("IsGrpcEnable")?.Value);
this.WebApiPort = int.Parse(xxx.Attribute("WebApiPort")?.Value);
this.GrpcPort = int.Parse(xxx.Attribute("GrpcPort")?.Value);
} }
} }
...@@ -100,6 +110,10 @@ namespace DBStudio ...@@ -100,6 +110,10 @@ namespace DBStudio
static void Main(string[] args) static void Main(string[] args)
{ {
LogoHelper.Print();
//注册日志
ServiceLocator.Locator.Registor<ILog>(new ConsoleLogger());
Program pg = new Program(); Program pg = new Program();
Config.Instance.Load(); Config.Instance.Load();
...@@ -123,7 +137,7 @@ namespace DBStudio ...@@ -123,7 +137,7 @@ namespace DBStudio
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
LogoHelper.Print();
DBDevelopService.Service.Instanse.Start(port, webPort,Config.Instance.IsGrpcEnable,Config.Instance.IsWebApiEnable); DBDevelopService.Service.Instanse.Start(port, webPort,Config.Instance.IsGrpcEnable,Config.Instance.IsWebApiEnable);
Thread.Sleep(100); Thread.Sleep(100);
......
...@@ -384,6 +384,15 @@ namespace DBInStudio.Desktop.Properties { ...@@ -384,6 +384,15 @@ namespace DBInStudio.Desktop.Properties {
} }
} }
/// <summary>
/// 查找类似 Manual 的本地化字符串。
/// </summary>
internal static string Manual {
get {
return ResourceManager.GetString("Manual", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Welcome to Mars realtime iot database 的本地化字符串。 /// 查找类似 Welcome to Mars realtime iot database 的本地化字符串。
/// </summary> /// </summary>
......
...@@ -227,6 +227,9 @@ ...@@ -227,6 +227,9 @@
<data name="MainwindowTitle" xml:space="preserve"> <data name="MainwindowTitle" xml:space="preserve">
<value>Mars database developer</value> <value>Mars database developer</value>
</data> </data>
<data name="Manual" xml:space="preserve">
<value>Manual</value>
</data>
<data name="MarsTitle" xml:space="preserve"> <data name="MarsTitle" xml:space="preserve">
<value>Welcome to Mars realtime iot database</value> <value>Welcome to Mars realtime iot database</value>
</data> </data>
......
...@@ -227,6 +227,9 @@ ...@@ -227,6 +227,9 @@
<data name="MainwindowTitle" xml:space="preserve"> <data name="MainwindowTitle" xml:space="preserve">
<value>Mars数据库开发平台</value> <value>Mars数据库开发平台</value>
</data> </data>
<data name="Manual" xml:space="preserve">
<value>手动</value>
</data>
<data name="MarsTitle" xml:space="preserve"> <data name="MarsTitle" xml:space="preserve">
<value>欢迎来到Mars实时物联数据库</value> <value>欢迎来到Mars实时物联数据库</value>
</data> </data>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"profiles": { "profiles": {
"DBInStudio.Desktop": { "DBInStudio.Desktop": {
"commandName": "Executable", "commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInStudio.exe" "executablePath": "C:\\Users\\chongdaoyang\\source\\repos\\mars\\Output\\DBInStudio.exe"
} }
} }
} }
\ No newline at end of file
...@@ -176,9 +176,18 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -176,9 +176,18 @@ namespace DBInStudio.Desktop.ViewModel
if(mServer=="127.0.0.1"||mServer=="localhost") if(mServer=="127.0.0.1"||mServer=="localhost")
{ {
var pps = Process.GetProcessesByName("DBInStudioServer"); var pps = Process.GetProcessesByName("DBInStudioServer");
if(pps==null||pps.Length==0) if(pps==null||pps.Length==0)
{ {
Process.Start("DBInStudioServer.exe").WaitForExit(5000); try
{
var vfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "DBInStudioServer.exe");
Process.Start(vfile).WaitForExit(5000);
}
catch
{
}
} }
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SpiderDriverDemo" xmlns:local="clr-namespace:SpiderDriverDemo"
mc:Ignorable="d" mc:Ignorable="d"
Title="SpiderSim" Height="290" Width="634"> Title="SpiderSim" Height="353" Width="634">
<Grid> <Grid>
<Button x:Name="Start" Content="Start" HorizontalAlignment="Left" Margin="502,33,0,0" VerticalAlignment="Top" Width="86" Click="Start_Click"/> <Button x:Name="Start" Content="Start" HorizontalAlignment="Left" Margin="502,33,0,0" VerticalAlignment="Top" Width="86" Click="Start_Click"/>
<Label Content="IP:" HorizontalAlignment="Left" Margin="31,33,0,0" VerticalAlignment="Top"/> <Label Content="IP:" HorizontalAlignment="Left" Margin="31,33,0,0" VerticalAlignment="Top"/>
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<Label Content="{Binding CosValue}" HorizontalAlignment="Left" Margin="102,164,0,0" VerticalAlignment="Top" Width="106"/> <Label Content="{Binding CosValue}" HorizontalAlignment="Left" Margin="102,164,0,0" VerticalAlignment="Top" Width="106"/>
<Label Content="{Binding BoolValue}" HorizontalAlignment="Left" Margin="102,207,0,0" VerticalAlignment="Top" Width="106"/> <Label Content="{Binding BoolValue}" HorizontalAlignment="Left" Margin="102,207,0,0" VerticalAlignment="Top" Width="106"/>
<Label Content="{Binding DateTimeValue}" HorizontalAlignment="Left" Margin="102,247,0,0" VerticalAlignment="Top" Width="106"/> <Label Content="{Binding DateTimeValue}" HorizontalAlignment="Left" Margin="102,247,0,0" VerticalAlignment="Top" Width="106"/>
<Button x:Name="hisDataWrite" Content="历史数据写入" HorizontalAlignment="Left" Margin="18,277,0,0" VerticalAlignment="Top" Width="86" Click="hisDataWrite_Click"/>
</Grid> </Grid>
</Window> </Window>
...@@ -289,5 +289,23 @@ namespace SpiderDriverDemo ...@@ -289,5 +289,23 @@ namespace SpiderDriverDemo
} }
driverProxy.SetTagValue(values); driverProxy.SetTagValue(values);
} }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void hisDataWrite_Click(object sender, RoutedEventArgs e)
{
List<TagValue> vals = new List<TagValue>();
DateTime dt = DateTime.Now.AddSeconds(-100);
Random rd = new Random((int)dt.Ticks);
for(int i=0;i<100;i++)
{
vals.Add(new TagValue() { Quality = 0, Time = dt, Value = rd.NextDouble() });
}
driverProxy.SetTagHisValue(0, TagType.Double, vals);
}
} }
} }
...@@ -71,45 +71,45 @@ namespace Cdy.Tag ...@@ -71,45 +71,45 @@ namespace Cdy.Tag
switch (TagType) switch (TagType)
{ {
case TagType.Bool: case TagType.Bool:
return Compress<bool>(source, sourceAddr, target, targetAddr+8, size,TagType) + 8; return Compress<bool>(source, sourceAddr, target, targetAddr+12, size,TagType) + 12;
case TagType.Byte: case TagType.Byte:
return Compress<byte>(source, sourceAddr, target, targetAddr+8, size, TagType) + 8; return Compress<byte>(source, sourceAddr, target, targetAddr+ 12, size, TagType) + 12;
case TagType.UShort: case TagType.UShort:
return Compress<ushort>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<ushort>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.Short: case TagType.Short:
return Compress<short>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<short>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.UInt: case TagType.UInt:
return Compress<uint>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<uint>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.Int: case TagType.Int:
return Compress<int>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<int>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.ULong: case TagType.ULong:
return Compress<ulong>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<ulong>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.Long: case TagType.Long:
return Compress<long>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<long>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.Double: case TagType.Double:
return Compress<double>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<double>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.Float: case TagType.Float:
return Compress<float>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<float>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.String: case TagType.String:
return Compress<string>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<string>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.IntPoint: case TagType.IntPoint:
return Compress<IntPointData>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<IntPointData>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.UIntPoint: case TagType.UIntPoint:
return Compress<UIntPointData>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<UIntPointData>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.LongPoint: case TagType.LongPoint:
return Compress<LongPointData>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<LongPointData>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.ULongPoint: case TagType.ULongPoint:
return Compress<ULongPointData>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<ULongPointData>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.IntPoint3: case TagType.IntPoint3:
return Compress<IntPoint3Data>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<IntPoint3Data>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.UIntPoint3: case TagType.UIntPoint3:
return Compress<UIntPoint3Data>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<UIntPoint3Data>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.LongPoint3: case TagType.LongPoint3:
return Compress<LongPoint3Data>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<LongPoint3Data>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
case TagType.ULongPoint3: case TagType.ULongPoint3:
return Compress<ULongPoint3Data>(source, sourceAddr, target, targetAddr + 8, size, TagType) + 8; return Compress<ULongPoint3Data>(source, sourceAddr, target, targetAddr + 12, size, TagType) + 12;
} }
return 8+4; return 12;
} }
///// <summary> ///// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册