@@ -20,6 +20,7 @@ namespace HBLConsole.Communication | |||||
private LebaiHelper() { } | private LebaiHelper() { } | ||||
private LebaiRobotClient client; | private LebaiRobotClient client; | ||||
private RobotData robotData; | private RobotData robotData; | ||||
public bool IsIdle { get; set; } = false; | |||||
public void Connect(string ip) | public void Connect(string ip) | ||||
{ | { | ||||
bool ErrorFlag = false; | bool ErrorFlag = false; | ||||
@@ -42,22 +43,13 @@ namespace HBLConsole.Communication | |||||
} | } | ||||
StartRobot(); | StartRobot(); | ||||
MessageLog.GetInstance.Show("乐百机器人连接成功!"); | 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() | public void GetRobotModeStatus() | ||||
{ | { | ||||
if (robotData == null) return; | if (robotData == null) return; | ||||
int mode = robotData.RobotMode.Mode; | int mode = robotData.RobotMode.Mode; | ||||
IsIdle = mode == 5; | |||||
for (int i = 0; i < 14; i++) | for (int i = 0; i < 14; i++) | ||||
{ | { | ||||
if (RTrig.GetInstance(((ELebaiRModel)i).ToString()).Start(mode == i)) | if (RTrig.GetInstance(((ELebaiRModel)i).ToString()).Start(mode == i)) | ||||
@@ -77,7 +69,6 @@ namespace HBLConsole.Communication | |||||
await client.Sync(); | await client.Sync(); | ||||
MessageLog.GetInstance.Show("机器人启动成功"); | MessageLog.GetInstance.Show("机器人启动成功"); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -60,7 +60,7 @@ namespace HBLConsole.MORKIC | |||||
/// <summary> | /// <summary> | ||||
/// 获取乐百机器人的数据 | /// 获取乐百机器人的数据 | ||||
/// </summary> | /// </summary> | ||||
SignalResult lebai=new SignalResult(); | |||||
SignalResult lebai = new SignalResult(); | |||||
public void ConnectOk() | public void ConnectOk() | ||||
{ | { | ||||
@@ -258,6 +258,7 @@ namespace HBLConsole.MORKIC | |||||
ThreadOperate.GetInstance.StartLong(new Action(() => | ThreadOperate.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
lebai = LebaiHelper.GetInstance.GetValueAsync(); | lebai = LebaiHelper.GetInstance.GetValueAsync(); | ||||
LebaiHelper.GetInstance.GetRobotModeStatus(); | |||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "乐百机器人数据读取"); | }), "乐百机器人数据读取"); | ||||
} | } | ||||
@@ -25,6 +25,7 @@ namespace HBLConsole.MainConsole | |||||
public void DataInit() | public void DataInit() | ||||
{ | { | ||||
Json<SetPar>.Read(); | Json<SetPar>.Read(); | ||||
if (Enum.TryParse(Json<SetPar>.Data.ClientDeviceType, out DeviceClientType dct)) | if (Enum.TryParse(Json<SetPar>.Data.ClientDeviceType, out DeviceClientType dct)) | ||||
{ | { | ||||
@@ -8,6 +8,7 @@ using HBLConsole.Service; | |||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
namespace HBLConsole.Model | namespace HBLConsole.Model | ||||
{ | { | ||||
public class KeepDataBase | public class KeepDataBase | ||||
@@ -15,7 +16,8 @@ namespace HBLConsole.Model | |||||
/// <summary> | /// <summary> | ||||
/// 模拟订单数据的配置 | /// 模拟订单数据的配置 | ||||
/// </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>(); | |||||
} | } | ||||
@@ -13,13 +13,14 @@ namespace HBLConsole.Service | |||||
//private volatile static Json<T> _Instance; | //private volatile static Json<T> _Instance; | ||||
//public static Json<T> GetInstance => _Instance ?? (_Instance = new Json<T>()); | //public static Json<T> GetInstance => _Instance ?? (_Instance = new Json<T>()); | ||||
//private Json() { } | //private Json() { } | ||||
static string deviceType => ActionOperate.GetInstance.SendResult("GetDeviceType").ToString(); | |||||
static string FilePath = $"AccessFile\\{deviceType}\\JSON"; | |||||
static string path | static string path | ||||
{ | { | ||||
get | 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"; | |||||
} | } | ||||
} | } | ||||
@@ -27,6 +27,10 @@ namespace HBLConsole | |||||
protected override void OnStartup(StartupEventArgs e) | protected override void OnStartup(StartupEventArgs e) | ||||
{ | { | ||||
base.OnStartup(e); | base.OnStartup(e); | ||||
ActionOperate.GetInstance.Register(new Func<object>(() => | |||||
{ | |||||
return GeneralConfig.DeviceType.ToString(); | |||||
}), "GetDeviceType"); | |||||
SystemHelper.GetInstance.AutoStart(false); | SystemHelper.GetInstance.AutoStart(false); | ||||
SystemHelper.GetInstance.CreateDesktopShortcut(); | SystemHelper.GetInstance.CreateDesktopShortcut(); | ||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | ||||
@@ -17,7 +17,11 @@ namespace HBLConsole.DialogWindow.ViewModel | |||||
{ | { | ||||
ConfirmCommand = new RelayCommand(() => | 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(), | ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(), | ||||
IsEnable = true, | IsEnable = true, | ||||
@@ -27,6 +31,16 @@ namespace HBLConsole.DialogWindow.ViewModel | |||||
MaxValue = Max, | MaxValue = Max, | ||||
MinValue = Min, | 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"); | ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit"); | ||||
}); | }); | ||||
CancelCommand = new RelayCommand(() => { ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit"); }); | CancelCommand = new RelayCommand(() => { ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit"); }); | ||||
@@ -14,13 +14,13 @@ namespace HBLConsole | |||||
private volatile static SqlHelper _Instance; | private volatile static SqlHelper _Instance; | ||||
public static SqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper()); | public static SqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper()); | ||||
private SqlHelper() { } | private SqlHelper() { } | ||||
private string FilePath = $"AccessFile\\{GVL.GeneralConfig.DeviceType.ToString()}\\DB"; | |||||
private string path | private string path | ||||
{ | { | ||||
get | 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"; | |||||
} | } | ||||
} | } | ||||
@@ -35,7 +35,7 @@ | |||||
<Style x:Key="ButtonStyle" TargetType="Button"> | <Style x:Key="ButtonStyle" TargetType="Button"> | ||||
<Setter Property="Foreground" Value="#00c2f4" /> | <Setter Property="Foreground" Value="#00c2f4" /> | ||||
<Setter Property="FontSize" Value="18" /> | <Setter Property="FontSize" Value="18" /> | ||||
<Setter Property="Margin" Value="10 0"/> | |||||
<Setter Property="Margin" Value="10,0" /> | |||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="Button"> | <ControlTemplate TargetType="Button"> | ||||
@@ -159,62 +159,66 @@ | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<Grid Grid.Column="0"> | <Grid Grid.Column="0"> | ||||
<Grid.RowDefinitions> | |||||
<!--<Grid.RowDefinitions> | |||||
<RowDefinition /> | <RowDefinition /> | ||||
<RowDefinition Height="40" /> | <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> | </Grid> | ||||
@@ -13,7 +13,7 @@ | |||||
Height="850" | Height="850" | ||||
AllowsTransparency="True" | AllowsTransparency="True" | ||||
Background="{x:Null}" | Background="{x:Null}" | ||||
Topmost="True" | |||||
Topmost="False" | |||||
WindowStartupLocation="CenterScreen" | WindowStartupLocation="CenterScreen" | ||||
WindowStyle="None" | WindowStyle="None" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -114,7 +114,25 @@ namespace HBLConsole.ViewModel | |||||
// simOrderVisibleDatas.Add(new SimOrderVisibleData() { Text = "取碗位置:", IsEnable = false, IsSelected = true, Loc = 11 }); | // 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; | |||||
} | |||||
} | |||||