Переглянути джерело

配置修改

样式分支
pry 2 роки тому
джерело
коміт
b6f9d66b5b
26 змінених файлів з 582 додано та 312 видалено
  1. +6
    -1
      BPASmartClient.Business/Plugin/OrderProxy.cs
  2. +31
    -23
      BPASmartClient.CustomResource/Themes/GenricStyle.xaml
  3. +2
    -0
      BPASmartClient.Device/BPASmartClient.Device.csproj
  4. +4
    -4
      BPASmartClient.Helper/ActionManage.cs
  5. +21
    -15
      BPASmartClient.Helper/ExpandMethod.cs
  6. +10
    -3
      BPASmartClient.Helper/LocaPath.cs
  7. +1
    -1
      BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
  8. +2
    -0
      BPASmartClient.MorkD/BPASmartClient.MorkD.csproj
  9. +2
    -0
      BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
  10. +2
    -0
      BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
  11. +42
    -11
      BPASmartClient.MorkS/Control_Morks.cs
  12. +1
    -0
      BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
  13. +2
    -0
      BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj
  14. +8
    -2
      BPASmartClient.ViewModel/MainViewModel.cs
  15. +39
    -36
      BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
  16. +17
    -4
      BPASmartClient.ViewModel/NewShopWindowModel.cs
  17. +92
    -91
      BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
  18. +15
    -9
      BPASmartClient/App.config
  19. +149
    -68
      BPASmartClient/Control/ShopDeviceConfigView.xaml
  20. +101
    -32
      BPASmartClient/Control/ShopDeviceConfigView.xaml.cs
  21. +1
    -1
      BPASmartClient/DeviceInfo.xml
  22. +2
    -2
      BPASmartClient/DialogWindow/NewShopWindow.xaml
  23. +19
    -3
      BPASmartClient/DialogWindow/NewShopWindow.xaml.cs
  24. +8
    -3
      BPASmartClient/MainWindow.xaml
  25. +3
    -3
      BPASmartClient/MainWindow.xaml.cs
  26. +2
    -0
      HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj

+ 6
- 1
BPASmartClient.Business/Plugin/OrderProxy.cs Переглянути файл

@@ -122,7 +122,12 @@ namespace BPASmartClient.Business
{
OrderStatusChangedEvent orderStatusChangedEvent = @event as OrderStatusChangedEvent;
string result = string.Empty;
OrderStatusChange orderStatusChange = new OrderStatusChange() { CookingStatus = orderStatusChangedEvent.Status, SuborderId = orderStatusChangedEvent.SubOrderId };
OrderStatusChange orderStatusChange = new OrderStatusChange()
{
CookingStatus = orderStatusChangedEvent.Status,
SuborderId = orderStatusChangedEvent.SubOrderId,
GoodName = orderStatusChangedEvent.GoodName
};

#region API 订单状态修改
try


+ 31
- 23
BPASmartClient.CustomResource/Themes/GenricStyle.xaml Переглянути файл

@@ -123,37 +123,45 @@
</Setter.Value>
</Setter>
</Style>
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3" />
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA" />
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5" />
<Style TargetType="{x:Type PasswordBox}">
<Setter Property="PasswordChar" Value="●"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
<Setter Property="Foreground" Value="#FF02C9FD"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="PasswordChar" Value="●" />
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}" />
<Setter Property="Foreground" Value="#FF02C9FD" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="AllowDrop" Value="true" />
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="CaretBrush" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type PasswordBox}">
<Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" BorderBrush="#FF08335F">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
<Border
x:Name="border"
BorderBrush="#FF08335F"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<ScrollViewer
x:Name="PART_ContentHost"
Focusable="false"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
<Setter TargetName="border" Property="Opacity" Value="0.56" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.Focus.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -162,10 +170,10 @@
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true" />
<Condition Property="IsSelectionActive" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
</MultiTrigger>
</Style.Triggers>
</Style>
@@ -584,7 +592,7 @@
<Setter Property="SelectedDateFormat" Value="Short" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="2" />
<Setter Property="Height" Value="24"/>
<Setter Property="Height" Value="24" />
<Setter Property="BorderBrush" Value="#08335f" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />


+ 2
- 0
BPASmartClient.Device/BPASmartClient.Device.csproj Переглянути файл

@@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>


+ 4
- 4
BPASmartClient.Helper/ActionManage.cs Переглянути файл

@@ -72,13 +72,13 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key))
if (par == null)
{
if (actions[key].FuncObj != null)
return actions[key].FuncObj;
//if (actions[key].FuncObj != null)
return actions[key].FuncObj?.Invoke();
}
else
{
if (actions[key].FuncPar != null)
return actions[key].FuncPar(par);
//if (actions[key].FuncPar != null)
return actions[key].FuncPar?.Invoke(par);
}
return default;
}


+ 21
- 15
BPASmartClient.Helper/ExpandMethod.cs Переглянути файл

@@ -41,11 +41,13 @@ namespace BPASmartClient.Helper
/// <param name="callback">委托回调</param>
public static void Invoke(this Action action, Action callback)
{
if (action != null)
{
action();
if (callback != null) callback();
}
action?.Invoke();
callback?.Invoke();
//if (action != null)
//{
// action();
// if (callback != null) callback();
//}
}

/// <summary>
@@ -56,20 +58,24 @@ namespace BPASmartClient.Helper
/// <param name="callback">委托回调</param>
public static void Invoke(this Action<object> action, object par, Action callback)
{
if (action != null)
{
action(par);
if (callback != null) callback();
}
action?.Invoke(par);
callback?.Invoke();
//if (action != null)
//{
// action(par);
// if (callback != null) callback();
//}
}

public static void Invokes(this Action<object[]> action, object[] par, Action callback)
{
if (action != null)
{
action(par);
if (callback != null) callback();
}
action?.Invoke(par);
callback?.Invoke();
//if (action != null)
//{
// action(par);
// if (callback != null) callback();
//}
}




+ 10
- 3
BPASmartClient.Helper/LocaPath.cs Переглянути файл

@@ -7,10 +7,8 @@ using System.Threading.Tasks;

namespace BPASmartClient.Helper
{
public class LocaPath:Singleton<LocaPath>
public class LocaPath : Singleton<LocaPath>
{


public string FilePath { get; set; } = string.Empty;

public string Getpath(string name)
@@ -19,5 +17,14 @@ namespace BPASmartClient.Helper
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}JSON\\{name}.json";
}

public string GetDeviceConfigPath
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DeviceConfig"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DeviceConfig\\";
}
}

}
}

+ 1
- 1
BPASmartClient.MQTT/BPASmartClient.MQTT.csproj Переглянути файл

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.MQTTClient" Version="1.0.10" />
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" />
<PackageReference Include="BPA.MQTTnet" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
</ItemGroup>


+ 2
- 0
BPASmartClient.MorkD/BPASmartClient.MorkD.csproj Переглянути файл

@@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

</Project>

+ 2
- 0
BPASmartClient.MorkF/BPASmartClient.MorkF.csproj Переглянути файл

@@ -4,6 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>


+ 2
- 0
BPASmartClient.MorkS/BPASmartClient.MorkS.csproj Переглянути файл

@@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>


BPASmartClient.MorkS/Control.cs → BPASmartClient.MorkS/Control_Morks.cs Переглянути файл

@@ -17,7 +17,7 @@ using System.Reflection;

namespace BPASmartClient.MorkS
{
public class Control : BaseDevice
public class Control_Morks : BaseDevice
{
public override DeviceClientType DeviceType => DeviceClientType.MORKS;
GVL_MORKS mORKS = new GVL_MORKS();
@@ -223,16 +223,19 @@ namespace BPASmartClient.MorkS
mORKS.AllowRun = mORKS.InitComplete;
//IsHealth = mORKS.Error && mORKS.InitComplete;
IsHealth = true;
TakeBowlTask();

TakeNoodleTask();
if (mORKS.AllowRun)
{
TakeBowlTask();

OutNoodleTask();
TakeNoodleTask();

SingleDetect();
OutNoodleTask();

TurntableControl();
SingleDetect();

TurntableControl();
}
}


@@ -245,11 +248,39 @@ namespace BPASmartClient.MorkS
{
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo))
{
mORKS.TakeBowlId = orderLocInfo.SuborderId;
TakeBowlControl(orderLocInfo.Loc);
SetRecipeNumber(orderLocInfo.RecipeNumber);
OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
ushort BowLoc = 0;
var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == orderLocInfo.BatchingId).ToList();
if (res != null)
{
foreach (var item in res)
{
if (ushort.TryParse(item.BatchingLoc, out ushort loc))
{
if (loc == 10 && alarm.Supply1_LossBowl)
{
BowLoc = loc;
break;
}
else if (loc == 11 && alarm.Supply2_LossBowl)
{
BowLoc = loc;
break;
}
}

}
}

if (BowLoc >= 10 && BowLoc <= 11)
{
mORKS.TakeBowlId = orderLocInfo.SuborderId;
//TakeBowlControl(orderLocInfo.Loc);
TakeBowlControl(BowLoc);
SetRecipeNumber(orderLocInfo.RecipeNumber);
OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
}

}
mORKS.TakeBowlInterlock = true;
}

+ 1
- 0
BPASmartClient.MorkT/BPASmartClient.MorkT.csproj Переглянути файл

@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<BaseOutputPath>D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices</BaseOutputPath>
</PropertyGroup>

<ItemGroup>


+ 2
- 0
BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj Переглянути файл

@@ -8,6 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
</ItemGroup>

<ItemGroup>


+ 8
- 2
BPASmartClient.ViewModel/MainViewModel.cs Переглянути файл

@@ -52,7 +52,7 @@ namespace BPASmartClient.ViewModel

public MainViewModel()
{
IsAlarm =new AlarmModel();
IsAlarm = new AlarmModel();
OrderStatusViewModel.Init();
//设备告警日志
MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
@@ -75,6 +75,12 @@ namespace BPASmartClient.ViewModel
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
dispatcherTimer.Start();
}


public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }



}

public class AlarmModel : ObservableObject
@@ -118,7 +124,7 @@ namespace BPASmartClient.ViewModel

public AlarmModel()
{
}
}
}

+ 39
- 36
BPASmartClient.ViewModel/Model/DeviceConfigModel.cs Переглянути файл

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input;
using System.Windows;

namespace BPASmartClient.ViewModel.Model
{
@@ -96,12 +97,29 @@ namespace BPASmartClient.ViewModel.Model
/// </summary>
public class CommunicationPar : ObservableObject
{
///// <summary>
///// 通讯类型,false:串口,true:网口
///// </summary>
//public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
//private bool _mCommunicationType;

/// <summary>
/// 选择网口通讯
/// </summary>
public bool IsNetworkPort { get { return _mIsNetworkPort; } set { _mIsNetworkPort = value; OnPropertyChanged(); } }
private bool _mIsNetworkPort = false;

/// <summary>
/// 通讯类型,false:串口,true:网口
/// 选择串口通讯
/// </summary>
public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
private bool _mCommunicationType;
public bool IsSerialPort { get { return _mIsSerialPort; } set { _mIsSerialPort = value; OnPropertyChanged(); } }
private bool _mIsSerialPort = true;

//public Visibility NetworkVisibility { get { return _mNetworkVisibility; } set { _mNetworkVisibility = value; OnPropertyChanged(); } }
//private Visibility _mNetworkVisibility = Visibility.Collapsed;

//public Visibility SerialVisibility { get { return _mSerialVisibility; } set { _mSerialVisibility = value; OnPropertyChanged(); } }
//private Visibility _mSerialVisibility = Visibility.Visible;

/// <summary>
/// IP地址
@@ -138,13 +156,13 @@ namespace BPASmartClient.ViewModel.Model
/// 数据位
/// </summary>
public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } }
private int _mDataBits;
private int _mDataBits = 8;

/// <summary>
/// 停止位
/// </summary>
public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } }
private string _mStopBits;
private string _mStopBits = "1";

/// <summary>
/// 校验位
@@ -152,37 +170,22 @@ namespace BPASmartClient.ViewModel.Model
public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } }
private string _mParity;

public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>();
}

//public enum CommunicationParType
//{
// /// <summary>
// /// IP地址
// /// </summary>
// IPAddress,
// /// <summary>
// /// 端口号
// /// </summary>
// Port,
// /// <summary>
// /// 串口端口号
// /// </summary>
// SerialPort,
// /// <summary>
// /// 波特率
// /// </summary>
// BaudRate,
// /// <summary>
// /// 数据位
// /// </summary>
// DataBits,
// /// <summary>
// /// 停止位
// /// </summary>
// StopBits,
// /// <summary>
// /// 校验位
// /// </summary>
// Parity,
//}
public class Variable : ObservableObject
{
public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
private int _mId;


public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } }
private string _mAddress;


public int ReadLeng { get { return _mReadLeng; } set { _mReadLeng = value; OnPropertyChanged(); } }
private int _mReadLeng;


}
}

+ 17
- 4
BPASmartClient.ViewModel/NewShopWindowModel.cs Переглянути файл

@@ -7,23 +7,32 @@ using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
using System.Windows;
using System.IO;

namespace BPASmartClient.ViewModel
{
public class NewShopWindowModel : ObservableObject
{

public NewShopWindowModel()
{
CloseWindowCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
CancelCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseWindow"); });
DefineCommand = new RelayCommand(() =>
{
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
var files = directoryInfo.GetFiles();
if (files != null && files.FirstOrDefault(p => p.FullName.Contains(ShopName)) != null)
{
ErrorInfo = "已存在该店铺,请重新输入!";
return;
}
ActionManage.GetInstance.Send("ShopPar", new string[] { ShopName, ShopId });
WeakReferenceMessenger.Default.Send("", "CloseWindow");
ActionManage.GetInstance.Send("OkCloseWindow");
});
}

public RelayCommand CloseWindowCommand { get; set; }
//public RelayCommand CloseWindowCommand { get; set; }

public RelayCommand CancelCommand { get; set; }

@@ -35,6 +44,10 @@ namespace BPASmartClient.ViewModel
public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
private string _mShopId;

public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;




}


+ 92
- 91
BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs Переглянути файл

@@ -11,12 +11,16 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.IO.Ports;
using System.IO;
using Newtonsoft.Json;

namespace BPASmartClient.ViewModel
{
public class ShopDeviceConfigViewModel : ObservableObject
{
private DeviceConfigModel configModel = new DeviceConfigModel();
string FileName => deviceConfig.Count > 0 ? deviceConfig[0].ShopName : string.Empty;

public ShopDeviceConfigViewModel()
{
@@ -28,6 +32,7 @@ namespace BPASmartClient.ViewModel
{
configModel.ShopName = par[0];
configModel.ShopId = par[1];
deviceConfig.Clear();
deviceConfig.Add(configModel);
}
}
@@ -37,8 +42,19 @@ namespace BPASmartClient.ViewModel
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice);
NewCommunicationCommand = new RelayCommand<object>(NewCommunication);
RemoveCommunicationCommand = new RelayCommand<object>(RemoveCommunication);

DataListInit();

SaveData = new Action(() =>
{
if (deviceConfig.Count > 0)
{
File.WriteAllText($"{LocaPath.GetInstance().GetDeviceConfigPath}{FileName}.json", JsonConvert.SerializeObject(deviceConfig));
}
});
}

#region 右键菜单按钮操作
private void RemoveCommunication(object? obj)
{
if (obj != null && obj is CommunicationModel com)
@@ -78,7 +94,7 @@ namespace BPASmartClient.ViewModel
{
CommunicationName = $"Communication_{num}",
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id,
communicationPar = new CommunicationPar() { CommunicationType = false }
communicationPar = new CommunicationPar() { IsNetworkPort = false }

});
break;
@@ -120,97 +136,9 @@ namespace BPASmartClient.ViewModel
}
}
}
#endregion


public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
private static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
{
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
}


//public static string DeviceNamePar
//{
// get { return _mDeviceNamePar; }
// set
// {
// _mDeviceNamePar = value;
// if (deviceConfig.Count == 1)
// {
// int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
// if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
// {
// deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceName = value;
// }
// }
// OnStaticPropertyChanged();
// }
//}
//private static string _mDeviceNamePar;

//public static string DeviceIdPar
//{
// get { return _mDeviceIdPar; }
// set
// {
// _mDeviceIdPar = value;
// if (deviceConfig.Count == 1)
// {
// int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
// if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
// {
// deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceId = value;
// }
// }
// OnStaticPropertyChanged();
// }
//}
//private static string _mDeviceIdPar;

public static Visibility DeviceParVisibility { get { return _mDeviceParVisibility; } set { _mDeviceParVisibility = value; OnStaticPropertyChanged(); } }
private static Visibility _mDeviceParVisibility = Visibility.Hidden;
public static Visibility CommunicationVisibility { get { return _mCommunicationVisibility; } set { _mCommunicationVisibility = value; OnStaticPropertyChanged(); } }
private static Visibility _mCommunicationVisibility = Visibility.Hidden;




//public static string DeviceModelId
//{
// get { return _mDeviceModelId; }
// set
// {
// _mDeviceModelId = value;

// }
//}
//private static string _mDeviceModelId;


//public static string DeviceName
//{
// get { return _mDeviceName; }
// set
// {
// _mDeviceName = value;
// if (deviceConfig.Count == 1)
// {
// var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == value);
// if (res != null)
// {
// DeviceIdPar = res.DeviceId;
// DeviceNamePar = res.DeviceName;
// }
// }
// }
//}
//private static string _mDeviceName;


//public static string CommunicationName { get; set; }



#region Command
/// <summary>
/// 新建设备
/// </summary>
@@ -231,8 +159,81 @@ namespace BPASmartClient.ViewModel
/// </summary>
public RelayCommand<object> RemoveCommunicationCommand { get; set; }

public Action SaveData { get; set; }
#endregion

#region 列表集合
/// <summary>
/// 设备信息列表
/// </summary>
public static ObservableCollection<DeviceConfigModel> deviceConfig { get; set; } = new ObservableCollection<DeviceConfigModel>();

/// <summary>
/// 端口号列表
/// </summary>
public static ObservableCollection<string> Ports { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 波特率列表
/// </summary>
public static ObservableCollection<int> BaudRates { get; set; } = new ObservableCollection<int>();

/// <summary>
/// 奇偶校验列表
/// </summary>
public static ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 设备模块
/// </summary>
public static ObservableCollection<string> DeviceModels { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 通讯模块
/// </summary>
public static ObservableCollection<string> CommunicationModel { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 店铺集合
/// </summary>
public static ObservableCollection<string> Shops { get; set; } = new ObservableCollection<string>();

private void DataListInit()
{
Ports.Clear();
SerialPort.GetPortNames().ToList().ForEach((item) => { Ports.Add(item); });

BaudRates.Clear();
int[] rb = new int[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 43000, 57600, 76800, 115200 };
rb.ToList().ForEach((item) => { BaudRates.Add(item); });

Paritys.Clear();
Enum.GetNames(typeof(Parity)).ToList().ForEach((item) => { Paritys.Add(item); });

DeviceModels.Clear();
DeviceModels.Add("Morks");
DeviceModels.Add("Morkt");
DeviceModels.Add("Morkic");
DeviceModels.Add("Morkjc");

CommunicationModel.Clear();
CommunicationModel.Add("乐百");
CommunicationModel.Add("节卡");
CommunicationModel.Add("单片机");
CommunicationModel.Add("咖啡机");
CommunicationModel.Add("冰淇淋机");

Shops.Clear();
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
var files = directoryInfo.GetFiles();
foreach (var item in files)
{
var res = Path.GetFileNameWithoutExtension(item.FullName);
if (res != null && res.Length > 0 && item.FullName.Contains("json")) Shops.Add(res);
}
}
#endregion



}


+ 15
- 9
BPASmartClient/App.config Переглянути файл

@@ -3,7 +3,7 @@
<appSettings>
<!--通用配置-->
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺-->
<add key="ClientId" value="46232"/>
<add key="ClientId" value="46"/>
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/>
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/>
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>-->
@@ -12,16 +12,19 @@
<!--<add key="ClientId" value="2"/>-->

<!--开发环境-->
<add key="apollouri" value="http://10.2.1.21:28080"/>
<!--<add key="apollouri" value="http://10.2.1.21:28080"/>
<add key="orderserviceuri" value="https://bpa.black-pa.com:21527/order/"/>
<add key="stockserviceuri" value="https://bpa.black-pa.com:21527/stock/"/>
<add key="datavserviceuri" value="https://bpa.black-pa.com:21527/datav"/>
<add key="webserviceuri" value="https://bpa.black-pa.com:21527"/>
<add key="broadcastpubtopic" value="/broadcast/grgpechsl7q/transit_test_setdevice"/>
<add key="AppId" value="dev1_common"/>
<add key ="Namespaces" value="DEV.Config"/>
<add key="IsEnableTest" value="true"/>-->




<add key="AppId" value="order"/>
<add key ="Namespaces" value="TEST1.Config"/>
<add key="IsEnableTest" value="true"/>

<!--测试环境-->
<!--<add key="ApolloUri" value="http://10.2.1.21:28070"/>
@@ -34,12 +37,15 @@
<add key ="Namespaces" value="DEV.test1.Config"/>-->

<!--正式环境-->
<!--<add key="ApolloUri" value="http://47.108.65.220:28080"/>
<add key="ApolloUri" value="http://47.108.65.220:28080"/>
<add key="OrderServiceUri" value="https://witt.black-pa.com/order/"/>
<add key="StockServiceUri" value="https://witt.black-pa.com/stock/"/>
<add key="DataVServiceUri" value="https://witt.black-pa.com/datav"/>
<add key="WebServiceUri" value="https://witt.black-pa.com"/>
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/>-->
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/>
<add key="AppId" value="order"/>
<add key ="Namespaces" value="TEST1.Config"/>
<add key="IsEnableTest" value="False"/>

<!--阿里云上报启动方式:API 或者 LOCAL-->
<!--API :通过客户端ID,调用接口查询“设备连接信息”-->
@@ -48,10 +54,10 @@
<add key="ProductKey" value="grgpECHSL7q"/>
<add key="DeviceName" value="qsqd"/>
<add key="DeviceSecret" value="3c0f2390943bff4fece523af22655196"/>
<add key="PasswordBox" value="6WrKhYmTIhLV7g24jIH/lg=="/>
<add key="PasswordBox" value="6WrKhYmTIhLV7g24jIH/lg=="/>


<!--外设配置-->
<!--外设配置-->
<add key="COM_Coffee" value="COM3"/>
<add key="BAUD_Coffee" value="115200"/>
<add key="COM_IceCream" value="COM12"/>


+ 149
- 68
BPASmartClient/Control/ShopDeviceConfigView.xaml Переглянути файл

@@ -27,6 +27,16 @@
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style x:Key="InputTextboxStyle" TargetType="TextBox">
<Setter Property="Margin" Value="3,0,0,0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="CaretBrush" Value="{StaticResource TitleBorderColor}" />
<Setter Property="Foreground" Value="{StaticResource TitleBorderColor}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,20,0" />
@@ -332,7 +342,7 @@

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="250" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

@@ -352,18 +362,21 @@
Text="请选择店铺:" />

<ComboBox
Name="shop"
Grid.Column="1"
Width="170"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
DropDownOpened="ComboBox_DropDownOpened"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding ClientDevices}"
ItemsSource="{Binding Shops}"
SelectedIndex="0"
SelectionChanged="shop_SelectionChanged"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding ClientDeviceType}" />

@@ -382,11 +395,11 @@
Grid.Column="5"
Width="170"
HorizontalAlignment="Left"
Command="{Binding SaveData}"
Content="保存配置"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}"
IcoText="&#xe626;"
MouseLeftButtonDown="IcoButton_MouseLeftButtonDown"
Style="{StaticResource NewButtonStyle}" />

</Grid>
@@ -401,15 +414,13 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!--#region 设备目录树-->
<Grid>

<TreeView
Name="tv"
Background="Transparent"
BorderThickness="1"
ItemsSource="{Binding deviceConfig}"
MouseRightButtonDown="tv_MouseRightButtonDown"
PreviewMouseRightButtonDown="tv_PreviewMouseRightButtonDown"
SelectedItemChanged="TreeView_SelectedItemChanged">
<TreeView.Resources>

@@ -445,18 +456,6 @@
Header="删除设备" />
</ContextMenu>
</TextBlock.ContextMenu>

<!--<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<EventSetter Event="MouseRightButtonDown" Handler="DeviceInfo" />
</Style>
</TextBlock.Style>-->

</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
@@ -473,36 +472,25 @@
Header="删除通讯" />
</ContextMenu>
</TextBlock.ContextMenu>

<!--<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<EventSetter Event="MouseRightButtonDown" Handler="CommunicationInfo" />
</Style>
</TextBlock.Style>-->

</TextBlock>
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>
</Grid>
<!--#endregion-->

<Grid Grid.Column="1" Margin="10">

<Grid.RowDefinitions>
<RowDefinition Height="55" />
<RowDefinition Height="55" />
<RowDefinition Height="55" />
<RowDefinition Height="55" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
<RowDefinition />
</Grid.RowDefinitions>

<!-- 店铺参数 -->
<!--#region 店铺参数-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@@ -514,17 +502,26 @@
</Grid.ColumnDefinitions>

<UniformGrid
Name="CommType"
Grid.Column="1"
VerticalAlignment="Center"
Columns="2">
Columns="2"
Visibility="Collapsed">
<RadioButton
Name="rbNetwork"
Checked="rbNetwork_Checked"
Content="网口"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}" />
Foreground="{StaticResource TextBlockForeground}"
IsChecked="{Binding SelectedValue.communicationPar.IsNetworkPort, ElementName=tv, Mode=TwoWay}" />

<RadioButton
Name="rbSerial"
Checked="rbSerial_Checked"
Content="串口"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}" />
Foreground="{StaticResource TextBlockForeground}"
IsChecked="{Binding SelectedValue.communicationPar.IsSerialPort, ElementName=tv, Mode=TwoWay}" />
</UniformGrid>

<TextBlock
@@ -554,10 +551,13 @@
Text="{Binding deviceConfig[0].ShopId}" />

</Grid>
<!--#endregion-->


<!-- 设备参数 -->
<Grid Grid.Row="1" Visibility="{Binding DeviceParVisibility}">
<!--#region 设备参数-->
<Grid
Name="Device"
Grid.Row="1"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -584,9 +584,9 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding Path=Device.PlcTypes}"
ItemsSource="{Binding DeviceModels}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding Path=Device.PlcType}" />
Text="{Binding SelectedValue.DeviceModule, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Column="2"
@@ -617,9 +617,13 @@
Text="{Binding SelectedValue.DeviceId, ElementName=tv, Mode=TwoWay}" />

</Grid>
<!--#endregion-->

<!--#region TCP 通讯参数-->
<Grid Grid.Row="1" Visibility="{Binding SelectedValue.communicationPar.CommunicationType, ElementName=tv, Mode=TwoWay, Converter={StaticResource VisibleTypeConverter}, ConverterParameter=NetworkPort}">
<Grid
Name="Network"
Grid.Row="1"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -671,9 +675,10 @@

<!--#region 串口设备-->
<Grid
Grid.Row="2"
Name="Serial"
Grid.Row="1"
Grid.RowSpan="2"
Visibility="{Binding SelectedValue.communicationPar.CommunicationType, ElementName=tv, Mode=TwoWay, Converter={StaticResource VisibleTypeConverter}, ConverterParameter=SerialPort}">
Visibility="Collapsed">

<Grid.RowDefinitions>
<RowDefinition />
@@ -707,7 +712,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding Path=Device.Ports}"
ItemsSource="{Binding Ports}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.SerialPort, ElementName=tv, Mode=TwoWay}" />
@@ -730,7 +735,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding Path=Device.BaudRates}"
ItemsSource="{Binding BaudRates}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.BaudRate, ElementName=tv, Mode=TwoWay}" />
@@ -753,7 +758,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding Path=Device.Paritys}"
ItemsSource="{Binding Paritys}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.Parity, ElementName=tv, Mode=TwoWay}" />
@@ -802,8 +807,77 @@
</Grid>
<!--#endregion-->

<!--#region 通讯参数-->
<Grid
Name="GridCommunication"
Grid.Row="3"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="请选择通讯模块:" />

<ComboBox
Grid.Column="1"
Width="170"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommunicationModel}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.CommunicationModule, ElementName=tv, Mode=TwoWay}" />

<!--<TextBlock
Grid.Column="2"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="设备名称:" />

<TextBox
Grid.Column="3"
Width="170"
Margin="0"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding SelectedValue.DeviceName, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Column="4"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="设备ID:" />

<TextBox
Grid.Column="5"
Width="170"
Margin="0"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding SelectedValue.DeviceId, ElementName=tv, Mode=TwoWay}" />-->

</Grid>
<!--#endregion-->

<!--#region 设备交互数据配置-->
<Grid Grid.Row="4">
<Grid
x:Name="VarTab"
Grid.Row="4"
Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
@@ -850,7 +924,7 @@
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding orderStatusLists}">
<ItemsControl ItemsSource="{Binding SelectedValue.communicationPar.variables, ElementName=tv, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Height="30">
@@ -860,28 +934,35 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>


<TextBlock
Grid.Column="0"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.SortNum}" />

<Grid Grid.Column="1">
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.GoodsName}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource TitleBorderColor}"
Text="{Binding Id}" />

<TextBox
Grid.Column="1"
Width="400"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding Address}" />

<Border
Grid.Column="1"
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1,0,1,0" />

<TextBlock
<TextBox
Grid.Column="2"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding StartDate}" />
Width="400"
HorizontalAlignment="Left"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding ReadLeng}" />

<Border
Grid.ColumnSpan="3"


+ 101
- 32
BPASmartClient/Control/ShopDeviceConfigView.xaml.cs Переглянути файл

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -13,8 +15,10 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BPASmartClient.DialogWindow;
using BPASmartClient.Helper;
using BPASmartClient.ViewModel;
using BPASmartClient.ViewModel.Model;
using Newtonsoft.Json;

namespace BPASmartClient.Control
{
@@ -31,7 +35,12 @@ namespace BPASmartClient.Control
private void IcoButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
NewShopWindow newShopWindow = new NewShopWindow();
newShopWindow.ShowDialog();
var res = newShopWindow.ShowDialog();

if (res != null && res == true)
{
VisibilityControl();
}
}

private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
@@ -40,60 +49,120 @@ namespace BPASmartClient.Control
Refresh();
}

private void tv_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
//if (e.ButtonState == MouseButtonState.Pressed)
//{
// Refresh();
//}
}

private void Refresh()
{
if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel)
{
//ShopDeviceConfigViewModel.ShopName = deviceConfigModel.ShopName;
}
else if (this.tv.SelectedValue is DeviceModel deviceModel)
{
ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Visible;
ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Hidden;
//ShopDeviceConfigViewModel.DeviceName = deviceModel.DeviceName;
this.Device.Visibility = Visibility.Visible;
this.CommType.Visibility = Visibility.Collapsed;
this.VarTab.Visibility = Visibility.Collapsed;
this.Serial.Visibility = Visibility.Collapsed;
this.Network.Visibility = Visibility.Collapsed;
this.GridCommunication.Visibility = Visibility.Collapsed;
}
else if (this.tv.SelectedValue is CommunicationModel communicationModel)
{
ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Visible;
ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Hidden;
//ShopDeviceConfigViewModel.CommunicationName = communicationModel.CommunicationName;
//ShopDeviceConfigViewModel.DeviceModelId = communicationModel.DeviceModelId;
this.Device.Visibility = Visibility.Collapsed;
this.CommType.Visibility = Visibility.Visible;
this.VarTab.Visibility = Visibility.Visible;
this.GridCommunication.Visibility = Visibility.Visible;
this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed;
this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed;


if (ShopDeviceConfigViewModel.deviceConfig.Count > 0)
{
int index = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == communicationModel.DeviceModelId);
if (index >= 0 && index < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.Count)
{
int commIndex = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ToArray(), p => p.DeviceModelId == communicationModel.DeviceModelId);
if (commIndex >= 0 && commIndex < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Count)
{
if (ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count <= 0)
{
for (int i = 0; i < 20; i++)
{
ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Add(new Variable()
{
Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count,
Address = string.Empty,
ReadLeng = 0
});
}
}
}
}
}

}
}

private void tv_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
private void rbNetwork_Checked(object sender, RoutedEventArgs e)
{
rbVisibility();
}

private void rbSerial_Checked(object sender, RoutedEventArgs e)
{
rbVisibility();
}

private void DeviceInfo(object sender, MouseButtonEventArgs e)
private void rbVisibility()
{
var tb = sender as TextBlock;
if (tb != null)
this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed;
this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed;
}

private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
ShopDeviceConfigViewModel.Shops.Clear();
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
var files = directoryInfo.GetFiles();
foreach (var item in files)
{
//ShopDeviceConfigViewModel.DeviceName = tb.Text.Trim();
//tb.Background = Brushes.Blue;
var res = System.IO.Path.GetFileNameWithoutExtension(item.FullName);
if (res != null && res.Length > 0 && item.FullName.Contains("json")) ShopDeviceConfigViewModel.Shops.Add(res);
}
}
private void CommunicationInfo(object sender, MouseButtonEventArgs e)

private void shop_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//var tb = sender as TextBlock;
//if (tb != null)
//{
// ShopDeviceConfigViewModel.CommunicationName = tb.Text.Trim();
// ShopDeviceConfigViewModel.DeviceModelId = tb.Tag.ToString();
// tb.Focus();
// //tb.Background = Brushes.Blue;
var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig");
if (this.shop.Items.Contains(text)) this.shop.SelectedValue = text;
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
var files = directoryInfo.GetFiles();
if (files != null && this.shop.SelectedValue != null && this.shop.SelectedValue.ToString().Length > 0)
{
var file = files.FirstOrDefault(p => p.FullName.Contains(this.shop.SelectedValue.ToString()));
if (file != null && File.Exists(file.FullName))
{
string JsonString = File.ReadAllText(file.FullName);
var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModel>>(JsonString);
if (result != null)
{
ShopDeviceConfigViewModel.deviceConfig.Clear();
foreach (var item in result)
{
ShopDeviceConfigViewModel.deviceConfig.Add(item);
}
VisibilityControl();
}
}
}
TextHelper.GetInstance.WriteTextInfo(this.shop.SelectedValue?.ToString(), "StartShop", "DeviceConfig");
}

//}
private void VisibilityControl()
{
if (this.Device != null) this.Device.Visibility = Visibility.Collapsed;
if (this.CommType != null) this.CommType.Visibility = Visibility.Collapsed;
if (this.VarTab != null) this.VarTab.Visibility = Visibility.Collapsed;
if (this.Serial != null) this.Serial.Visibility = Visibility.Collapsed;
if (this.Network != null) this.Network.Visibility = Visibility.Collapsed;
if (this.GridCommunication != null) this.GridCommunication.Visibility = Visibility.Collapsed;
}
}
}

+ 1
- 1
BPASmartClient/DeviceInfo.xml Переглянути файл

@@ -38,7 +38,7 @@
</Peripherals>
</Device>-->

<Device Name="Morks" Module="BPASmartClient.MorkS.Control" DeviceId="28">
<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="28">
<Peripherals>
<Peripheral Module="BPASmartClient.PLC.MorksMachine">
<Parameters>


+ 2
- 2
BPASmartClient/DialogWindow/NewShopWindow.xaml Переглянути файл

@@ -125,7 +125,7 @@
Visibility="Hidden" />
<Button
Name="ButClose"
Command="{Binding CloseWindowCommand}"
Command="{Binding CancelCommand}"
Content="X"
FontSize="30"
Style="{StaticResource TitleBarStyle}" />
@@ -200,7 +200,7 @@
FontFamily="楷体"
FontSize="20"
Foreground="Red"
Text="错误提示" />
Text="{Binding ErrorInfo}" />

<Grid Grid.Row="4">



+ 19
- 3
BPASmartClient/DialogWindow/NewShopWindow.xaml.cs Переглянути файл

@@ -1,4 +1,5 @@
using Microsoft.Toolkit.Mvvm.Messaging;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,13 +29,28 @@ namespace BPASmartClient.DialogWindow
this.DragMove();
};

WeakReferenceMessenger.Default.Register<string, string>(this, "CloseWindow", (o, e) =>
ActionManage.GetInstance.CancelRegister("CloseWindow");
ActionManage.GetInstance.CancelRegister("OkCloseWindow");

ActionManage.GetInstance.Register(new Action(() =>
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
this.DialogResult = false;
this.Close();
}));
});
}), "CloseWindow");

ActionManage.GetInstance.Register(new Action(() =>
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
this.DialogResult = true;
this.Close();
}));
}), "OkCloseWindow");


}




+ 8
- 3
BPASmartClient/MainWindow.xaml Переглянути файл

@@ -241,7 +241,7 @@
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}" />

<Button
<!--<Button
Name="save"
Grid.Row="0"
Width="100"
@@ -251,13 +251,13 @@
Click="Button_Click_2"
Content="保存订单数据"
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}" />
Style="{DynamicResource CommonBtn_返回}" />-->

<Button
Name="init"
Grid.Row="0"
Width="90"
Margin="350,0,0,0"
Margin="230,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Click="init_Click"
@@ -265,6 +265,11 @@
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}" />

<CheckBox
Margin="350,0,0,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />

<TextBlock
x:Name="Title"
HorizontalAlignment="Center"


+ 3
- 3
BPASmartClient/MainWindow.xaml.cs Переглянути файл

@@ -36,7 +36,7 @@ namespace BPASmartClient
{
public MainWindow()
{
InitializeComponent();
InitializeComponent();
MainViewModel.GetInstance().window = this;
this.DataContext = MainViewModel.GetInstance();
Initialize();
@@ -160,7 +160,7 @@ namespace BPASmartClient

private void Button_Click_2(object sender, RoutedEventArgs e)
{
this.save.IsEnabled = false;
//this.save.IsEnabled = false;
Task.Run(new Action(() =>
{
var res = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.DeviceId == "2")?.morkOrderPushes;
@@ -186,7 +186,7 @@ namespace BPASmartClient
count = 0;
}
}
App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; }));
//App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; }));
}));




+ 2
- 0
HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj Переглянути файл

@@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>


Завантаження…
Відмінити
Зберегти