Bläddra i källkod

参数配置

master
pry 2 år sedan
förälder
incheckning
07a4f828d7
12 ändrade filer med 113 tillägg och 77 borttagningar
  1. +2
    -11
      HBLConsole.Communication/LebaiHelper.cs
  2. +2
    -1
      HBLConsole.MORKIC/Control_MORKIC.cs
  3. +1
    -0
      HBLConsole.MainConsole/Main.cs
  4. +0
    -0
      HBLConsole.Model/Enums/ELebaiRModel.cs
  5. +3
    -1
      HBLConsole.Model/KeepParameter/KeepDataBase.cs
  6. +4
    -3
      HBLConsole.Service/Json.cs
  7. +4
    -0
      HBLConsole/App.xaml.cs
  8. +15
    -1
      HBLConsole/DialogWindow/ViewModel/SimOrderConfitViewModel.cs
  9. +3
    -3
      HBLConsole/SqlHelper.cs
  10. +59
    -55
      HBLConsole/View/DebugView.xaml
  11. +1
    -1
      HBLConsole/View/MainView.xaml
  12. +19
    -1
      HBLConsole/ViewModel/DebugViewModel.cs

+ 2
- 11
HBLConsole.Communication/LebaiHelper.cs Visa fil

@@ -20,6 +20,7 @@ namespace HBLConsole.Communication
private LebaiHelper() { }
private LebaiRobotClient client;
private RobotData robotData;
public bool IsIdle { get; set; } = false;
public void Connect(string ip)
{
bool ErrorFlag = false;
@@ -42,22 +43,13 @@ namespace HBLConsole.Communication
}
StartRobot();
MessageLog.GetInstance.Show("乐百机器人连接成功!");
//GetSpeed();
//ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
}


public void GetSpeed()
{
//client.StartSys().GetAwaiter();
var aa = client.GetActualTcpSpeed().GetAwaiter();
//robotData.RobotMode.Mode
}

public void GetRobotModeStatus()
{
if (robotData == null) return;
int mode = robotData.RobotMode.Mode;
IsIdle = mode == 5;
for (int i = 0; i < 14; i++)
{
if (RTrig.GetInstance(((ELebaiRModel)i).ToString()).Start(mode == i))
@@ -77,7 +69,6 @@ namespace HBLConsole.Communication
await client.Sync();
MessageLog.GetInstance.Show("机器人启动成功");
}

}

/// <summary>


+ 2
- 1
HBLConsole.MORKIC/Control_MORKIC.cs Visa fil

@@ -60,7 +60,7 @@ namespace HBLConsole.MORKIC
/// <summary>
/// 获取乐百机器人的数据
/// </summary>
SignalResult lebai=new SignalResult();
SignalResult lebai = new SignalResult();

public void ConnectOk()
{
@@ -258,6 +258,7 @@ namespace HBLConsole.MORKIC
ThreadOperate.GetInstance.StartLong(new Action(() =>
{
lebai = LebaiHelper.GetInstance.GetValueAsync();
LebaiHelper.GetInstance.GetRobotModeStatus();
Thread.Sleep(100);
}), "乐百机器人数据读取");
}


+ 1
- 0
HBLConsole.MainConsole/Main.cs Visa fil

@@ -25,6 +25,7 @@ namespace HBLConsole.MainConsole

public void DataInit()
{

Json<SetPar>.Read();
if (Enum.TryParse(Json<SetPar>.Data.ClientDeviceType, out DeviceClientType dct))
{


HBLConsole.Model/ELebaiRModel.cs → HBLConsole.Model/Enums/ELebaiRModel.cs Visa fil


+ 3
- 1
HBLConsole.Model/KeepParameter/KeepDataBase.cs Visa fil

@@ -8,6 +8,7 @@ using HBLConsole.Service;
using System.Collections.ObjectModel;
using System.Collections.Concurrent;


namespace HBLConsole.Model
{
public class KeepDataBase
@@ -15,7 +16,8 @@ namespace HBLConsole.Model
/// <summary>
/// 模拟订单数据的配置
/// </summary>
public ObservableCollection<SimOrderVisibleData> simOrderConfig { get; set; } = new ObservableCollection<SimOrderVisibleData>();
public ConcurrentDictionary<string, ObservableCollection<SimOrderVisibleData>> simOrderConfig { get; set; } = new ConcurrentDictionary<string, ObservableCollection<SimOrderVisibleData>>();
//public ObservableCollection<SimOrderVisibleData> simOrderConfig { get; set; } = new ObservableCollection<SimOrderVisibleData>();


}


+ 4
- 3
HBLConsole.Service/Json.cs Visa fil

@@ -13,13 +13,14 @@ namespace HBLConsole.Service
//private volatile static Json<T> _Instance;
//public static Json<T> GetInstance => _Instance ?? (_Instance = new Json<T>());
//private Json() { }

static string deviceType => ActionOperate.GetInstance.SendResult("GetDeviceType").ToString();
static string FilePath = $"AccessFile\\{deviceType}\\JSON";
static string path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\JSON"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\JSON\\{typeof(T).Name}.json";
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FilePath));
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}\\{typeof(T).Name}.json";
}
}



+ 4
- 0
HBLConsole/App.xaml.cs Visa fil

@@ -27,6 +27,10 @@ namespace HBLConsole
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ActionOperate.GetInstance.Register(new Func<object>(() =>
{
return GeneralConfig.DeviceType.ToString();
}), "GetDeviceType");
SystemHelper.GetInstance.AutoStart(false);
SystemHelper.GetInstance.CreateDesktopShortcut();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;


+ 15
- 1
HBLConsole/DialogWindow/ViewModel/SimOrderConfitViewModel.cs Visa fil

@@ -17,7 +17,11 @@ namespace HBLConsole.DialogWindow.ViewModel
{
ConfirmCommand = new RelayCommand(() =>
{
Json<KeepDataBase>.Data.simOrderConfig.Add(new SimOrderVisibleData()
if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString()))
{
Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>());
}
Json<KeepDataBase>.Data.simOrderConfig[GVL.GeneralConfig.DeviceType.ToString()].Add(new SimOrderVisibleData()
{
ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(),
IsEnable = true,
@@ -27,6 +31,16 @@ namespace HBLConsole.DialogWindow.ViewModel
MaxValue = Max,
MinValue = Min,
});
//Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(),new SimOrderVisibleData()
//{
// ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(),
// IsEnable = true,
// IsSelected = true,
// Text = Name,
// Loc = Min,
// MaxValue = Max,
// MinValue = Min,
//});
ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit");
});
CancelCommand = new RelayCommand(() => { ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit"); });


+ 3
- 3
HBLConsole/SqlHelper.cs Visa fil

@@ -14,13 +14,13 @@ namespace HBLConsole
private volatile static SqlHelper _Instance;
public static SqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper());
private SqlHelper() { }
private string FilePath = $"AccessFile\\{GVL.GeneralConfig.DeviceType.ToString()}\\DB";
private string path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DB\\{GVL.GeneralConfig.DeviceType.ToString()}_{typeof(VariableInfo).Name}.db";
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FilePath));
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}\\{GVL.GeneralConfig.DeviceType.ToString()}_{typeof(VariableInfo).Name}.db";
}
}



+ 59
- 55
HBLConsole/View/DebugView.xaml Visa fil

@@ -35,7 +35,7 @@
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="#00c2f4" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Margin" Value="10 0"/>
<Setter Property="Margin" Value="10,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
@@ -159,62 +159,66 @@
</Grid.ColumnDefinitions>

<Grid Grid.Column="0">
<Grid.RowDefinitions>
<!--<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding simOrderConfig}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="16"
Foreground="#00c2f4"
Text="{Binding Text}" />

<TextBox
Grid.Column="1"
Margin="10 0"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Loc}" />

<CheckBox
Grid.Column="2"
Height="20"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="启用随机数"
FontSize="16"
Foreground="#00c2f4"
IsChecked="{Binding IsSelected}"
Template="{StaticResource CbTemplate}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<UniformGrid Columns="2" Grid.Row="1">
<Button
Grid.Column="1"
Command="{Binding bql}"
Content="模拟订单"
Style="{StaticResource ButtonStyle}" />
<Button
Command="{Binding AddSimDataCommand}"
Content="新增模拟数据"
Style="{StaticResource ButtonStyle}" />
</UniformGrid>
</Grid.RowDefinitions>-->

<StackPanel Orientation="Vertical">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding simOrderConfig}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="16"
Foreground="#00c2f4"
Text="{Binding Text}" />

<TextBox
Grid.Column="1"
Margin="10,0"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Loc}" />

<CheckBox
Grid.Column="2"
Height="20"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="启用随机数"
FontSize="16"
Foreground="#00c2f4"
IsChecked="{Binding IsSelected}"
Template="{StaticResource CbTemplate}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<UniformGrid Grid.Row="1" Columns="2">
<Button
Grid.Column="1"
Command="{Binding bql}"
Content="模拟订单"
Style="{StaticResource ButtonStyle}" />
<Button
Command="{Binding AddSimDataCommand}"
Content="新增模拟数据"
Style="{StaticResource ButtonStyle}" />
</UniformGrid>
</StackPanel>



</Grid>



+ 1
- 1
HBLConsole/View/MainView.xaml Visa fil

@@ -13,7 +13,7 @@
Height="850"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">


+ 19
- 1
HBLConsole/ViewModel/DebugViewModel.cs Visa fil

@@ -114,7 +114,25 @@ namespace HBLConsole.ViewModel
// simOrderVisibleDatas.Add(new SimOrderVisibleData() { Text = "取碗位置:", IsEnable = false, IsSelected = true, Loc = 11 });
//}

public ObservableCollection<SimOrderVisibleData> simOrderConfig { get; set; } = Json<KeepDataBase>.Data.simOrderConfig;
public ObservableCollection<SimOrderVisibleData> simOrderConfig
{
get
{
if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString()))
{
Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>());
}
return Json<KeepDataBase>.Data.simOrderConfig[GVL.GeneralConfig.DeviceType.ToString()];
}
set
{
if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString()))
{
Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>());
}
Json<KeepDataBase>.Data.simOrderConfig[GVL.GeneralConfig.DeviceType.ToString()] = value;
}
}





Laddar…
Avbryt
Spara