@@ -8,7 +8,7 @@ | |||
<ItemGroup> | |||
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" /> | |||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | |||
@@ -45,11 +45,11 @@ namespace BPASmartClient.Business | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush mork)) | |||
{ | |||
Thread.Sleep(3000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(5000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(5000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(2000); | |||
} | |||
} | |||
@@ -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 | |||
@@ -144,6 +149,7 @@ namespace BPASmartClient.Business | |||
#region MQTT 订单状态修改 | |||
var clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId; | |||
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType); | |||
var q = temp.Serialize(false); | |||
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false)); | |||
#endregion | |||
} | |||
@@ -200,7 +200,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -0,0 +1,34 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Data; | |||
namespace BPASmartClient.CustomResource.Converters | |||
{ | |||
public class VisibleTypeConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value != null && parameter != null && parameter is string p && value is bool type) | |||
{ | |||
if (p != null) | |||
{ | |||
if (p == "NetworkPort") | |||
return type ? Visibility.Visible : Visibility.Collapsed; | |||
else if (p == "SerialPort") | |||
return !type ? Visibility.Visible : Visibility.Collapsed; | |||
} | |||
} | |||
return Visibility.Collapsed; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -4,5 +4,15 @@ | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters"> | |||
<!-- 文本框的字体颜色 --> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<!--<con:StringToIconConverter x:Key="StringToIconConverter"/>--> | |||
<!-- 表格头边框颜色 --> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<!-- 表格头字体颜色 --> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<!-- 数据表边框颜色 --> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
</ResourceDictionary> |
@@ -123,6 +123,60 @@ | |||
</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" /> | |||
<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="CaretBrush" Value="White" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type PasswordBox}"> | |||
<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 TargetName="border" Property="Opacity" Value="0.56" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.MouseOver.Border}" /> | |||
</Trigger> | |||
<Trigger Property="IsKeyboardFocused" Value="true"> | |||
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.Focus.Border}" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
<Style.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true" /> | |||
<Condition Property="IsSelectionActive" Value="false" /> | |||
</MultiTrigger.Conditions> | |||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" /> | |||
</MultiTrigger> | |||
</Style.Triggers> | |||
</Style> | |||
<Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
@@ -538,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" /> | |||
@@ -957,7 +957,66 @@ | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="Foreground" Value="{DynamicResource foreground}" /> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border x:Name="BD" Cursor="Hand"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<!--<Border Width="16" Margin="5"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮图标.png" /> | |||
</Border.Background> | |||
</Border>--> | |||
<TextBlock Margin="10,0,10,0" | |||
x:Name="textBlock" | |||
VerticalAlignment="Center" | |||
FontSize="14" | |||
Foreground="#4fade8" | |||
Text="{TemplateBinding Content}" /> | |||
<!-- Text="{TemplateBinding Content}" --> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮1.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/buttonOn.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#3afdff" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="CommonBtn_返回" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
@@ -1217,7 +1276,7 @@ | |||
</Style.Setters> | |||
</Style> | |||
<Style TargetType="Button"> | |||
<Style x:Key="Comm8" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
@@ -2,10 +2,12 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -60,12 +60,13 @@ namespace BPASmartClient.Device | |||
List<DevStatus> StatusALL = new List<DevStatus>(); | |||
foreach (var item in status) | |||
{ | |||
string sta = string.Empty; | |||
string name = item.Key; | |||
string Ms = string.Empty; | |||
string id = string.Empty; | |||
if (item.Key.Contains(".")) | |||
{ | |||
string sta = item.Key.Split('.')[0]; | |||
sta = item.Key.Split('.')[0]; | |||
string sop = item.Key.Split('.')[item.Key.Split('.').Length - 1]; name = sop; | |||
string value = item.Value.ToString(); | |||
if (keyValues.ContainsKey(sta)) sta = keyValues[sta]; | |||
@@ -75,8 +76,9 @@ namespace BPASmartClient.Device | |||
Ms = $"[{sta}]-[{sop}]-[{value}]"; | |||
id = $"[{sta}]-[{sop}]"; | |||
} | |||
StatusALL.Add(new DevStatus { id = id, Name = name, Status = item.Value.ToString(), Ms = Ms }); | |||
StatusALL.Add(new DevStatus { id = id, Name = name, type = sta, Status = item.Value.ToString(), Ms = Ms }); | |||
} | |||
StatusALL = StatusALL?.OrderBy(x => x.type).ToList(); | |||
return new { data = StatusALL }; | |||
} | |||
@@ -88,9 +90,10 @@ namespace BPASmartClient.Device | |||
string name = item.Key; | |||
string Ms = string.Empty; | |||
string id=string.Empty; | |||
string sta=string.Empty; | |||
if (item.Key.Contains(".")) | |||
{ | |||
string sta = item.Key.Split('.')[0]; | |||
sta = item.Key.Split('.')[0]; | |||
string sop = item.Key.Split('.')[item.Key.Split('.').Length - 1]; name = sop; | |||
string value = item.Value.ToString(); | |||
if (keyValues.ContainsKey(sta)) sta = keyValues[sta]; | |||
@@ -100,14 +103,16 @@ namespace BPASmartClient.Device | |||
Ms = $"[{sta}]-[{sop}]-[{value}]"; | |||
id= $"[{sta}]-[{sop}]"; | |||
} | |||
StatusALL.Add(new DevStatus {id= id, Name = name, Status = item.Value.ToString(), Ms = Ms }); | |||
StatusALL.Add(new DevStatus {id= id, Name = name,type=sta, Status = item.Value.ToString(), Ms = Ms }); | |||
} | |||
StatusALL = StatusALL?.OrderBy(x => x.type).ToList(); | |||
return StatusALL; | |||
} | |||
} | |||
public class DevStatus | |||
{ | |||
public string type { get; set; } | |||
public string id { get; set; } | |||
public string Name { get; set; } | |||
private string _status { get; set; } | |||
@@ -0,0 +1,80 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Helper | |||
{ | |||
/// <summary> | |||
/// 创建AES加密解密 add fyf 20211122 | |||
/// </summary> | |||
public class AESHelper | |||
{ | |||
/// <summary> | |||
/// 默认密钥-密钥的长度必须是32 | |||
/// </summary> | |||
private const string PublicKey = "9848461354184618"; | |||
/// <summary> | |||
/// 默认向量 | |||
/// </summary> | |||
private const string Iv = "dfkladnasldnfdcv"; | |||
/// <summary> | |||
/// AES加密 | |||
/// </summary> | |||
/// <param name="str">需要加密字符串</param> | |||
/// <returns>加密后字符串</returns> | |||
public static String Encrypt(string str) | |||
{ | |||
return Encrypt(str, PublicKey); | |||
} | |||
/// <summary> | |||
/// AES解密 | |||
/// </summary> | |||
/// <param name="str">需要解密字符串</param> | |||
/// <returns>解密后字符串</returns> | |||
public static String Decrypt(string str) | |||
{ | |||
return Decrypt(str, PublicKey); | |||
} | |||
/// <summary> | |||
/// AES加密 | |||
/// </summary> | |||
/// <param name="str">需要加密的字符串</param> | |||
/// <param name="key">32位密钥</param> | |||
/// <returns>加密后的字符串</returns> | |||
public static string Encrypt(string str, string key) | |||
{ | |||
Byte[] keyArray = System.Text.Encoding.UTF8.GetBytes(key); | |||
Byte[] toEncryptArray = System.Text.Encoding.UTF8.GetBytes(str); | |||
var rijndael = new System.Security.Cryptography.RijndaelManaged(); | |||
rijndael.Key = keyArray; | |||
rijndael.Mode = System.Security.Cryptography.CipherMode.ECB; | |||
rijndael.Padding = System.Security.Cryptography.PaddingMode.PKCS7; | |||
rijndael.IV = System.Text.Encoding.UTF8.GetBytes(Iv); | |||
System.Security.Cryptography.ICryptoTransform cTransform = rijndael.CreateEncryptor(); | |||
Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
return Convert.ToBase64String(resultArray, 0, resultArray.Length); | |||
} | |||
/// <summary> | |||
/// AES解密 | |||
/// </summary> | |||
/// <param name="str">需要解密的字符串</param> | |||
/// <param name="key">32位密钥</param> | |||
/// <returns>解密后的字符串</returns> | |||
public static string Decrypt(string str, string key) | |||
{ | |||
Byte[] keyArray = System.Text.Encoding.UTF8.GetBytes(key); | |||
Byte[] toEncryptArray = Convert.FromBase64String(str); | |||
var rijndael = new System.Security.Cryptography.RijndaelManaged(); | |||
rijndael.Key = keyArray; | |||
rijndael.Mode = System.Security.Cryptography.CipherMode.ECB; | |||
rijndael.Padding = System.Security.Cryptography.PaddingMode.PKCS7; | |||
rijndael.IV = System.Text.Encoding.UTF8.GetBytes(Iv); | |||
System.Security.Cryptography.ICryptoTransform cTransform = rijndael.CreateDecryptor(); | |||
Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
return System.Text.Encoding.UTF8.GetString(resultArray); | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
@@ -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(); | |||
//} | |||
} | |||
@@ -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\\"; | |||
} | |||
} | |||
} | |||
} |
@@ -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> | |||
@@ -452,44 +452,6 @@ namespace BPASmartClient.Modbus | |||
master.WriteSingleRegister(slaveAddress, startAddress, value); | |||
} | |||
#endregion | |||
} | |||
public enum ReadType | |||
{ | |||
/// <summary> | |||
/// 读线圈 | |||
/// </summary> | |||
Coils, | |||
/// <summary> | |||
/// 读输入线圈 | |||
/// </summary> | |||
Inputs, | |||
/// <summary> | |||
/// 读保持寄存器 | |||
/// </summary> | |||
HoldingRegisters, | |||
/// <summary> | |||
/// 读输入寄存器 | |||
/// </summary> | |||
InputRegisters, | |||
} | |||
public enum WriteType | |||
{ | |||
/// <summary> | |||
/// 写线圈 | |||
/// </summary> | |||
Coils, | |||
/// <summary> | |||
/// 写保持寄存器 | |||
/// </summary> | |||
HoldingRegisters, | |||
} | |||
public enum CommandType | |||
@@ -15,7 +15,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
</ItemGroup> | |||
@@ -10,7 +10,7 @@ namespace BPASmartClient.Model | |||
/// <summary> | |||
/// 订单状态改变事件 | |||
/// </summary> | |||
public class OrderStatusChangedEvent:BaseEvent | |||
public class OrderStatusChangedEvent : BaseEvent | |||
{ | |||
/// <summary> | |||
/// 子订单ID | |||
@@ -20,5 +20,10 @@ namespace BPASmartClient.Model | |||
/// 状态 | |||
/// </summary> | |||
public ORDER_STATUS Status { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodName { get; set; } | |||
} | |||
} |
@@ -2,6 +2,8 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
</Project> |
@@ -4,6 +4,8 @@ | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -2,6 +2,8 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -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; | |||
} |
@@ -2,6 +2,7 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices</BaseOutputPath> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -21,7 +21,7 @@ namespace BPASmartClient.MorkT | |||
{ | |||
public class Control_MorkT : BaseDevice | |||
{ | |||
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKIC; } } | |||
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } } | |||
GLV_MorkT morkT = new GLV_MorkT(); | |||
@@ -60,7 +60,7 @@ namespace BPASmartClient.MorkT | |||
LebaiRobot.GetInstance.GetRobotModeStatus(); | |||
} | |||
public override void Stop() | |||
{ | |||
@@ -119,7 +119,7 @@ namespace BPASmartClient.MorkT | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
//获取主料和容器位置 | |||
if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc; | |||
@@ -172,280 +172,7 @@ namespace BPASmartClient.MorkT | |||
return morkT.batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
private void Wait(int value = 101) | |||
{ | |||
while (!(morkT.lebai.Ok && morkT.lebai.Value == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
} | |||
/// <summary> | |||
/// 是否可以开始制作咖啡 | |||
/// </summary> | |||
/// <returns></returns> | |||
private bool CoffeeCanMake() | |||
{ | |||
bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false; | |||
return canMake; | |||
} | |||
/// <summary> | |||
/// 制作咖啡流程 | |||
/// </summary> | |||
private void MakeCoffeeProcess() | |||
{ | |||
if(CoffeeCanMake()) | |||
{ | |||
if(morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc)) | |||
{ | |||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | |||
GetAndCheeckCoffe(orderLoc); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);//把咖啡杯放到咖啡机机的位置后回原点 | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) }.Publish(); //接咖啡控制 | |||
DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); | |||
morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点 | |||
/// </summary> | |||
private void MakeCoffeeComplete() | |||
{ | |||
if (morkT.IsCoffeeMake&&IsHealth) | |||
{ | |||
if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1) | |||
{ | |||
DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]"); | |||
DoCoffeeQC(morkT.MakeCoffeeOrder); | |||
morkT.MakeCoffeeOrder = null; | |||
morkT.IsCoffeeMake = false; | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 将咖啡杯从咖啡机 取走到 取餐口 | |||
/// </summary> | |||
private void DoCoffeeQC(OrderLocInfo order) | |||
{ | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
} | |||
/// <summary> | |||
/// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void GetAndCheeckCoffe(OrderLocInfo order) | |||
{ | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取咖啡杯!"); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
int count = 2; | |||
p: | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
DeviceProcessLogShow("执行二次取咖啡杯"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
LebaiRobot.GetInstance.SetValue(1); | |||
count++; | |||
goto p; | |||
} | |||
DeviceProcessLogShow("取咖啡杯完成"); | |||
} | |||
/// <summary> | |||
/// 冰淇淋是否可以开始制作 | |||
/// </summary> | |||
/// <returns></returns> | |||
private bool IceCreamCanMake() | |||
{ | |||
bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false; | |||
return canMake; | |||
} | |||
/// <summary> | |||
/// 制作冰淇淋流程 | |||
/// </summary> | |||
private void MakeIceCreamProcess() | |||
{ | |||
if(IceCreamCanMake()) | |||
{ | |||
if (MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if (MorkIStatus.GetInstance().CXB >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
{ | |||
if (LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
morkT.IceIsOK = false; | |||
} | |||
else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
morkT.IceIsOK = true; | |||
DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
DoIceCream(order); | |||
} | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 做冰淇淋 | |||
/// </summary> | |||
private void DoIceCream(OrderLocInfo order) | |||
{ | |||
GetIceCreamCup(); | |||
CheckICeCreaCup(); | |||
GetIceCream(order); | |||
PutIceCream(order); | |||
} | |||
/// <summary> | |||
/// 取冰淇淋杯 | |||
/// </summary> | |||
private void GetIceCreamCup() | |||
{ | |||
LebaiRobot.GetInstance.SetValue(0); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取冰淇淋杯!"); | |||
} | |||
/// <summary> | |||
/// 冰淇淋杯检测,失败后机器人回到原点 | |||
/// </summary> | |||
private void CheckICeCreaCup() | |||
{ | |||
int count = 2; | |||
LebaiRobot.GetInstance.SetValue(1); | |||
p: | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
count++; | |||
goto p; | |||
} | |||
DeviceProcessLogShow("冰淇淋杯检测完成"); | |||
} | |||
/// <summary> | |||
/// 机器人取接冰淇淋 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void GetIceCream(OrderLocInfo order) | |||
{ | |||
//制冷模式 | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接1号冰淇淋); | |||
Wait(); | |||
bool doItResult = true; | |||
//出料 | |||
new GSIceCream_DischargeEvent().Publish(delegate (object[] args) | |||
{ | |||
doItResult = (bool)args[0]; | |||
}); | |||
if (doItResult) | |||
{ | |||
IceCreamCookCheck(); | |||
} | |||
else | |||
{ | |||
int count_1 = 0; | |||
while (MorkIStatus.GetInstance().CXB <= 86) | |||
{ | |||
Thread.Sleep(5); | |||
count_1++; | |||
if (count_1 >= 2000) | |||
break; | |||
} | |||
IceCreamCookCheck(); | |||
} | |||
LebaiRobot.GetInstance.SetValue(1); | |||
} | |||
/// <summary> | |||
/// 把冰淇淋放到取餐位后回原点 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void PutIceCream(OrderLocInfo order) | |||
{ | |||
while (LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
} | |||
/// <summary> | |||
/// 冰淇淋机器制作冰淇淋 | |||
@@ -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> | |||
@@ -0,0 +1,189 @@ | |||
| |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using DataVAPI.Tool.IOT; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
public class DataVViewModel : ObservableObject | |||
{ | |||
#region 单一变量 | |||
private volatile static DataVViewModel _Instance; | |||
public static DataVViewModel GetInstance() => _Instance ?? (_Instance = new DataVViewModel()); | |||
private DataVViewModel() | |||
{ | |||
deviceTable = new ObservableCollection<DeviceTable>(); | |||
device = new DeviceTable(); | |||
deviceTableSelectedItem = new DeviceTable(); | |||
ApiURL = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
Refresh(); | |||
} | |||
#endregion | |||
#region 公有变量 | |||
/// <summary> | |||
/// 设备表 | |||
/// </summary> | |||
public ObservableCollection<DeviceTable> deviceTable { get; set; } | |||
/// <summary> | |||
/// 选中行 | |||
/// </summary> | |||
private DeviceTable _deviceTableSelectedItem; | |||
public DeviceTable deviceTableSelectedItem | |||
{ | |||
get { return _deviceTableSelectedItem; } | |||
set | |||
{ | |||
if (_deviceTableSelectedItem == value) | |||
return; | |||
_deviceTableSelectedItem = value; | |||
OnPropertyChanged("deviceTableSelectedItem"); | |||
} | |||
} | |||
/// <summary> | |||
/// 当前设备 | |||
/// </summary> | |||
private DeviceTable _device; | |||
public DeviceTable device | |||
{ | |||
get { return _device; } | |||
set | |||
{ | |||
if (_device == value) | |||
return; | |||
_device = value; | |||
OnPropertyChanged("device"); | |||
} | |||
} | |||
/// <summary> | |||
/// API 地址 | |||
/// </summary> | |||
public string ApiURL { get; set; } | |||
#endregion | |||
#region 公有函数 | |||
/// <summary> | |||
/// 刷新 | |||
/// </summary> | |||
public void Refresh() | |||
{ | |||
deviceTable.Clear(); | |||
Inquire()?.OrderBy(o => int.Parse(o.ClientId)).ToList().ForEach(d => | |||
{ | |||
if (int.Parse(d.ClientId) > 0) | |||
{ | |||
deviceTable.Add(d); | |||
} | |||
}); | |||
} | |||
/// <summary> | |||
/// 根据客户端iD查询 | |||
/// </summary> | |||
/// <param name="clientId"></param> | |||
public List<DeviceTable> Inquire(string clientId = "") | |||
{ | |||
try | |||
{ | |||
string url = ApiURL + "/api/Device/Query"; | |||
if (!string.IsNullOrEmpty(clientId)) url = ApiURL + "/api/Device/Query?clientId=" + clientId; | |||
string json = HttpRequestHelper.HttpGetRequest(url); | |||
JsonMsg<List<DeviceTable>> jsonMsg = Tools.JsonToObjectTools<JsonMsg<List<DeviceTable>>>(json); | |||
return jsonMsg.obj.data; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return null; | |||
} | |||
} | |||
/// <summary> | |||
/// 修改 | |||
/// </summary> | |||
/// <returns></returns> | |||
public bool Update() | |||
{ | |||
try | |||
{ | |||
string url = ApiURL + "/api/Device/Modify"; | |||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); | |||
Refresh(); | |||
return true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
/// 增加 | |||
/// </summary> | |||
/// <returns></returns> | |||
public bool Add() | |||
{ | |||
try | |||
{ | |||
string url = ApiURL + "/api/Device/Create"; | |||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); | |||
Refresh(); | |||
return true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
public bool Add(DeviceTable deviceTable) | |||
{ | |||
try | |||
{ | |||
string url = ApiURL + "/api/Device/Create"; | |||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(deviceTable)); | |||
Refresh(); | |||
return true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <returns></returns> | |||
public bool Delete() | |||
{ | |||
try | |||
{ | |||
string url = ApiURL + "/api/Device/DeleteDate?id=" + device.Id; | |||
string json = HttpRequestHelper.HttpGetRequest(url); | |||
Refresh(); | |||
return true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
#endregion | |||
} | |||
} |
@@ -128,13 +128,11 @@ namespace BPASmartClient.ViewModel | |||
LogDataGrid = new ObservableCollection<LogModel>(); | |||
DateTimeStr = DateTime.Now; | |||
BookExs.Add(new BookEx(new Book() { Name = "一般日志条件", Tag = "Info" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备日志条件", Tag = "DeviceLog" })); | |||
BookExs.Add(new BookEx(new Book() { Name = "错误日志条件", Tag = "Error" })); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备告警条件", Tag = "DeviceAlarm" })); | |||
SelectedText = "一般日志条件"; | |||
BookExs.Add(new BookEx(new Book() { Name = "设备日志条件", Tag = "DeviceLog" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "错误日志条件", Tag = "Error" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备告警条件", Tag = "DeviceAlarm" }) { IsChecked = true }); | |||
SelectBookExs = new ObservableCollection<BookEx>(); | |||
SelectBookExs.Add(new BookEx(new Book() { Name = "一般日志条件", Tag = "Info" }) { IsChecked = true }); | |||
ItemPropertyChanged(new BookEx(new Book()) { IsChecked = true },new PropertyChangedEventArgs("IsChecked")); | |||
//查询 | |||
QueryCommand = new RelayCommand(() => | |||
{ | |||
@@ -158,8 +156,8 @@ namespace BPASmartClient.ViewModel | |||
LogDataGrid.Clear(); | |||
//2.根据选中查询日志 | |||
DataTable dataTable = ReadFile(path); | |||
DataRow[] datas = dataTable.Select(sql); | |||
if (datas.Count() <= 0) | |||
List<DataRow> datas = dataTable.Select($"({sql})").OrderByDescending(o => o["TIME"])?.ToList(); | |||
if (datas==null || datas.Count() <= 0) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "提示", $"查询结果为空!"); | |||
return; | |||
@@ -170,8 +168,8 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
time = item["TIME"].ToString(), | |||
type = item["LOGGER"].ToString(), | |||
message = item["MESSAGE"].ToString(), | |||
foreground = (item["LOGGER"].ToString() == "Error" || item["LOGGER"].ToString() == "DeviceAlarm") ? new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032")) : new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e")) | |||
message = item["MESSAGE"].ToString() | |||
// foreground = (item["LOGGER"].ToString() == "ERROR" || item["LOGGER"].ToString() == "DEVICEALARM") ? new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032")) : new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e")) | |||
}); | |||
} | |||
} | |||
@@ -1,12 +1,14 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.ComponentModel; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
@@ -26,6 +28,7 @@ namespace BPASmartClient.ViewModel | |||
#region 变量 | |||
public DispatcherTimer dispatcherTimer; | |||
public string ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
public ObservableCollection<LogModel> LogDataGridData { get; set; } | |||
private ObservableCollection<LogModel> _LogModels;public ObservableCollection<LogModel> LogDataGrid | |||
{ | |||
get | |||
@@ -68,6 +71,54 @@ namespace BPASmartClient.ViewModel | |||
OnPropertyChanged("TimedClear"); | |||
} | |||
} | |||
private string _SelectedText = ""; | |||
public string SelectedText | |||
{ | |||
get | |||
{ | |||
return _SelectedText; | |||
} | |||
set | |||
{ | |||
if (_SelectedText == value) | |||
return; | |||
_SelectedText = value; | |||
OnPropertyChanged("SelectedText"); | |||
} | |||
} | |||
public ObservableCollection<BookEx> SelectBookExs { set; get; } | |||
private ObservableCollection<BookEx> _books; | |||
public ObservableCollection<BookEx> BookExs | |||
{ | |||
get | |||
{ | |||
if (_books == null) | |||
{ | |||
_books = new ObservableCollection<BookEx>(); | |||
_books.CollectionChanged += (sender, e) => | |||
{ | |||
if (e.OldItems != null) | |||
{ | |||
foreach (BookEx bookEx in e.OldItems) | |||
{ | |||
bookEx.PropertyChanged -= ItemPropertyChanged; | |||
} | |||
} | |||
if (e.NewItems != null) | |||
{ | |||
foreach (BookEx bookEx in e.NewItems) | |||
{ | |||
bookEx.PropertyChanged += ItemPropertyChanged; | |||
} | |||
} | |||
}; | |||
} | |||
return _books; | |||
} | |||
} | |||
#endregion | |||
#region 单一 | |||
@@ -85,14 +136,23 @@ namespace BPASmartClient.ViewModel | |||
/// </summary> | |||
public void Init() | |||
{ | |||
if (LogDataGrid == null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory); | |||
if (LogDataGrid == null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
if (LogDataGridData == null) LogDataGridData = new ObservableCollection<LogModel>(); | |||
BookExs.Add(new BookEx(new Book() { Name = "一般日志", Tag = "Info" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备日志", Tag = "DeviceLog" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "错误日志", Tag = "Error" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "告警日志", Tag = "DeviceAlarm" }) { IsChecked = true }); | |||
SelectBookExs = new ObservableCollection<BookEx>(); | |||
ItemPropertyChanged(new BookEx(new Book()) { IsChecked = true }, new PropertyChangedEventArgs("IsChecked")); | |||
//一般日志 | |||
MessageLog.GetInstance.InfoNotify = new Action<string>((s) => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Info" }); | |||
LogModel logModel = new LogModel { message = s, type = "Info" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s); | |||
})); | |||
}); | |||
@@ -101,7 +161,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "DeviceLog" }); | |||
LogModel logModel = new LogModel { message = s, type = "DeviceLog" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.DEBUG, s); | |||
})); | |||
}); | |||
@@ -110,7 +172,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = id, type = "DeviceAlarm" }); | |||
LogModel logModel = new LogModel { message = id, type = "DeviceAlarm" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.WARN, id); | |||
})); | |||
}); | |||
@@ -119,7 +183,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Error" }); | |||
LogModel logModel = new LogModel { message = s, type = "Error" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.ERROR, s); | |||
DataVClient.GetInstance().HttpAddLog(new LogTable | |||
{ | |||
@@ -154,9 +220,11 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
if (LogDataGrid.Count > 100) | |||
if (LogDataGridData.Count > 200) | |||
{ | |||
LogDataGrid.RemoveAt(LogDataGrid.Count - 1); | |||
LogModel logModel= LogDataGridData.Last(); | |||
DeleteLog(logModel); | |||
LogDataGridData.Remove(logModel); | |||
} | |||
})); | |||
@@ -164,6 +232,43 @@ namespace BPASmartClient.ViewModel | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(10); | |||
dispatcherTimer.Start(); | |||
} | |||
/// <summary> | |||
/// 增加日志 | |||
/// </summary> | |||
public void AddLog(LogModel logModel) | |||
{ | |||
BookEx book= SelectBookExs?.ToList().Find(par => par.IsChecked && par.BookN.Tag == logModel.type); | |||
if (book != null) | |||
{ | |||
LogDataGrid.Insert(0, logModel); | |||
} | |||
} | |||
/// <summary> | |||
/// 刷新日志 | |||
/// </summary> | |||
/// <param name="logModel"></param> | |||
public void RefreshLog() | |||
{ | |||
LogDataGrid.Clear(); | |||
LogDataGridData?.ToList().ForEach(b => { | |||
BookEx book = SelectBookExs?.ToList().Find(par => par.IsChecked && par.BookN.Tag == b.type); | |||
if (book != null) | |||
{ | |||
LogDataGrid.Add(b); | |||
} | |||
}); | |||
} | |||
/// <summary> | |||
/// 删除日志 | |||
/// </summary> | |||
public void DeleteLog(LogModel logModel) | |||
{ | |||
LogModel log= LogDataGrid?.ToList().Find(par => par == logModel); | |||
if(log!=null) LogDataGrid.Remove(log); | |||
} | |||
/// <summary> | |||
/// 导出数据 | |||
/// </summary> | |||
@@ -210,6 +315,33 @@ namespace BPASmartClient.ViewModel | |||
System.Windows.MessageBox.Show("无数据!"); | |||
} | |||
/// <summary> | |||
/// 选中改变 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void ItemPropertyChanged(object sender, PropertyChangedEventArgs e) | |||
{ | |||
if (e.PropertyName == "IsChecked") | |||
{ | |||
BookEx bookEx = sender as BookEx; | |||
if (bookEx != null) | |||
{ | |||
IEnumerable<BookEx> bookExs = BookExs.Where(b => b.IsChecked == true); | |||
StringBuilder builder = new StringBuilder(); | |||
SelectBookExs.Clear(); | |||
foreach (BookEx item in bookExs) | |||
{ | |||
builder.Append(item.BookN.Name.Replace("日志","") + ","); | |||
SelectBookExs.Add((BookEx)item); | |||
} | |||
SelectedText = builder == null ? string.Empty : builder.ToString(); | |||
RefreshLog(); | |||
} | |||
} | |||
} | |||
#endregion | |||
#region Command | |||
@@ -233,7 +365,7 @@ namespace BPASmartClient.ViewModel | |||
if (_type == value) | |||
return; | |||
_type = value; | |||
if (_type == "Error") foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032")); | |||
if (_type == "Error" || _type == "Error".ToUpper() || _type == "DeviceAlarm".ToUpper() || _type == "DeviceAlarm") foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032")); | |||
OnPropertyChanged("type"); | |||
OnPropertyChanged("foreground"); | |||
@@ -58,7 +58,7 @@ namespace BPASmartClient.ViewModel | |||
public MainViewModel() | |||
{ | |||
IsAlarm =new AlarmModel(); | |||
IsAlarm = new AlarmModel(); | |||
OrderStatusViewModel.Init(); | |||
//设备告警日志 | |||
MessageLog.GetInstance.AlarmLogNotify = new Action(() => | |||
@@ -91,6 +91,12 @@ namespace BPASmartClient.ViewModel | |||
} | |||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||
} | |||
public class AlarmModel : ObservableObject | |||
@@ -134,7 +140,7 @@ namespace BPASmartClient.ViewModel | |||
public AlarmModel() | |||
{ | |||
} | |||
} | |||
} |
@@ -5,6 +5,8 @@ using System.Text; | |||
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 | |||
{ | |||
@@ -13,6 +15,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// </summary> | |||
public class DeviceConfigModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
@@ -28,7 +31,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// <summary> | |||
/// 设备集合 | |||
/// </summary> | |||
public ObservableCollection<DeviceModel> deviceModels = new ObservableCollection<DeviceModel>(); | |||
public ObservableCollection<DeviceModel> deviceModels { get; set; } = new ObservableCollection<DeviceModel>(); | |||
} | |||
/// <summary> | |||
@@ -48,6 +51,11 @@ namespace BPASmartClient.ViewModel.Model | |||
public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } } | |||
private string _mDeviceModule = string.Empty; | |||
public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||
private string _mId = string.Empty; | |||
/// <summary> | |||
/// 设备ID | |||
/// </summary> | |||
@@ -57,7 +65,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// <summary> | |||
/// 通讯模块 | |||
/// </summary> | |||
public ObservableCollection<CommunicationModel> communicationDevcies = new ObservableCollection<CommunicationModel>(); | |||
public ObservableCollection<CommunicationModel> communicationDevcies { get; set; } = new ObservableCollection<CommunicationModel>(); | |||
} | |||
@@ -72,6 +80,14 @@ namespace BPASmartClient.ViewModel.Model | |||
public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } } | |||
private string _mCommunicationModule = string.Empty; | |||
public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } } | |||
private string _mCommunicationName = string.Empty; | |||
public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } } | |||
private string _mDeviceModelId = string.Empty; | |||
public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } } | |||
private CommunicationPar _mcommunicationPar = new CommunicationPar(); | |||
} | |||
@@ -81,44 +97,95 @@ namespace BPASmartClient.ViewModel.Model | |||
/// </summary> | |||
public class CommunicationPar : ObservableObject | |||
{ | |||
public CommunicationParType communicationType { get { return _mcommunicationType; } set { _mcommunicationType = value; OnPropertyChanged(); } } | |||
private CommunicationParType _mcommunicationType; | |||
///// <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; | |||
public string CommunicationValue { get { return _mCommunicationValue; } set { _mCommunicationValue = value; OnPropertyChanged(); } } | |||
private string _mCommunicationValue = string.Empty; | |||
/// <summary> | |||
/// 选择串口通讯 | |||
/// </summary> | |||
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; | |||
public enum CommunicationParType | |||
{ | |||
/// <summary> | |||
/// IP地址 | |||
/// </summary> | |||
IPAddress, | |||
public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } } | |||
private string _mIPAddress; | |||
/// <summary> | |||
/// 端口号 | |||
/// IP 端口号 | |||
/// </summary> | |||
Port, | |||
public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } } | |||
private int _mIPPort; | |||
/// <summary> | |||
/// 串口端口号 | |||
/// ip 串口 站号 | |||
/// </summary> | |||
SerialPort, | |||
public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } } | |||
private int _mStationNo; | |||
/// <summary> | |||
/// 串口单口号 | |||
/// </summary> | |||
public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } } | |||
private string _mSerialPort; | |||
/// <summary> | |||
/// 波特率 | |||
/// </summary> | |||
BaudRate, | |||
public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } } | |||
private int _mBaudRate; | |||
/// <summary> | |||
/// 数据位 | |||
/// </summary> | |||
DataBits, | |||
public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } } | |||
private int _mDataBits = 8; | |||
/// <summary> | |||
/// 停止位 | |||
/// </summary> | |||
StopBits, | |||
public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } } | |||
private string _mStopBits = "1"; | |||
/// <summary> | |||
/// 校验位 | |||
/// </summary> | |||
Parity, | |||
public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } } | |||
private string _mParity; | |||
public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>(); | |||
} | |||
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; | |||
} | |||
} |
@@ -3,15 +3,52 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
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() | |||
{ | |||
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 }); | |||
ActionManage.GetInstance.Send("OkCloseWindow"); | |||
}); | |||
} | |||
//public RelayCommand CloseWindowCommand { get; set; } | |||
public RelayCommand CancelCommand { get; set; } | |||
public RelayCommand DefineCommand { get; set; } | |||
public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } } | |||
private string _mShopName; | |||
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; | |||
} | |||
} |
@@ -3,17 +3,238 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.ViewModel.Model; | |||
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() | |||
{ | |||
//NewCommand = new Action(() => {ActionManager }); | |||
ActionManage.GetInstance.Register(new Action<object[]>((o) => | |||
{ | |||
if (o != null && o is string[] par) | |||
{ | |||
if (par.Length == 2) | |||
{ | |||
configModel.ShopName = par[0]; | |||
configModel.ShopId = par[1]; | |||
deviceConfig.Clear(); | |||
deviceConfig.Add(configModel); | |||
} | |||
} | |||
}), "ShopPar"); | |||
NewDeviceCommand = new RelayCommand<object>(NewDevice); | |||
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) | |||
{ | |||
if (com != null) | |||
{ | |||
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == com.DeviceModelId); | |||
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName == com.CommunicationName); | |||
if (res != null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Remove(res); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private void NewCommunication(object? obj) | |||
{ | |||
if (obj != null && obj is DeviceModel dm) | |||
{ | |||
if (dm != null) | |||
{ | |||
string CommunicationName = string.Empty; | |||
int num = 1; | |||
while (true) | |||
{ | |||
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == dm.DeviceName); | |||
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName.Contains($"Communication_{num}")); | |||
if (res == null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Add(new CommunicationModel() | |||
{ | |||
CommunicationName = $"Communication_{num}", | |||
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id, | |||
communicationPar = new CommunicationPar() { IsNetworkPort = false } | |||
}); | |||
break; | |||
} | |||
} | |||
else break; | |||
num++; | |||
} | |||
} | |||
} | |||
} | |||
private void RemoveDevice(object? obj) | |||
{ | |||
if (obj != null && deviceConfig.Count == 1) | |||
{ | |||
string DeviceName = obj?.ToString(); | |||
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == DeviceName); | |||
if (res != null) | |||
deviceConfig.ElementAt(0).deviceModels.Remove(res); | |||
} | |||
} | |||
private void NewDevice(object? obj) | |||
{ | |||
if (obj != null && deviceConfig.Count == 1) | |||
{ | |||
string DeviceName = string.Empty; | |||
int num = 1; | |||
while (true) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == $"Device_{num}"); | |||
if (res == null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.Add(new DeviceModel() { DeviceId = "0", DeviceName = $"Device_{num}", Id = Guid.NewGuid().ToString() }); | |||
break; | |||
} | |||
num++; | |||
} | |||
} | |||
} | |||
#endregion | |||
#region Command | |||
/// <summary> | |||
/// 新建设备 | |||
/// </summary> | |||
public RelayCommand<object> NewDeviceCommand { get; set; } | |||
/// <summary> | |||
/// 删除设备 | |||
/// </summary> | |||
public RelayCommand<object> RemoveDeviceCommand { get; set; } | |||
/// <summary> | |||
/// 新建通讯 | |||
/// </summary> | |||
public RelayCommand<object> NewCommunicationCommand { get; set; } | |||
/// <summary> | |||
/// 删除通讯 | |||
/// </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 | |||
public Action NewCommand { get; set; } | |||
} | |||
} |
@@ -12,41 +12,49 @@ | |||
<!--<add key="ClientId" value="2"/>--> | |||
<!--开发环境--> | |||
<!--<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="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<add key="IsEnableTest" value="false"/> | |||
<!--<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="ApolloUri" value="http://10.2.1.21:28070"/> | |||
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/> | |||
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.test1.Config"/>--> | |||
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/> | |||
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.test1.Config"/>--> | |||
<!--正式环境--> | |||
<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="WebServiceUri" value="https://witt.black-pa.com"/> | |||
<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 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
<!--LOCAL:直接使用下方本地“设备连接信息”--> | |||
<add key="StartupMode" value="API"/> | |||
<add key="ProductKey" value="grgpECHSL7q"/> | |||
<add key="DeviceName" value="qsqd"/> | |||
<add key="DeviceSecret" value="3c0f2390943bff4fece523af22655196"/> | |||
<add key="PasswordBox" value="6WrKhYmTIhLV7g24jIH/lg=="/> | |||
<!--外设配置--> | |||
@@ -13,12 +13,15 @@ | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" /> | |||
<!--<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>--> | |||
<ResourceDictionary> | |||
<con:ColorConverter x:Key="ColorConverter" /> | |||
<con:TextConverter x:Key="TextConverter" /> | |||
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
@@ -0,0 +1,163 @@ | |||
<UserControl x:Class="BPASmartClient.Control.DataVView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
mc:Ignorable="d" | |||
d:DesignHeight="550" d:DesignWidth="800"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.8*"></ColumnDefinition> | |||
<ColumnDefinition Width="2*"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel Grid.Column="0" Margin="10"> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">API查询地址:</TextBlock> | |||
<TextBox x:Name="apiurl" Margin="10,0,0,0" Width="200" Text="{Binding ApiURL}"/> | |||
<Button Tag="SetUrl" Margin="10,0,0,0" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">设置</Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">客户端ID:</TextBlock> | |||
<TextBox x:Name="chen" Margin="10,0,0,0" Width="200" >1</TextBox> | |||
<Button Tag="Inquire" Margin="10,0,0,0" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">查询</Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">客户端ID:</TextBlock> | |||
<TextBox x:Name="clientId" Margin="10,0,0,0" Width="200" Text="{Binding device.ClientId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">devicename:</TextBlock> | |||
<TextBox x:Name="devicename" Margin="10,0,0,0" Width="200" Text="{Binding device.devicename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">productkey:</TextBlock> | |||
<TextBox x:Name="productkey" Margin="10,0,0,0" Width="200" Text="{Binding device.productkey, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">devicesecret:</TextBlock> | |||
<TextBox x:Name="devicesecret" Margin="10,0,0,0" Width="200" Text="{Binding device.devicesecret, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">设备类型:</TextBlock> | |||
<TextBox x:Name="devtype" Margin="10,0,0,0" Width="200" Text="{Binding device.devtype, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">经度:</TextBlock> | |||
<TextBox x:Name="jd" Margin="10,0,0,0" Width="200" Text="{Binding device.jd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">纬度:</TextBlock> | |||
<TextBox x:Name="wd" Margin="10,0,0,0" Width="200" Text="{Binding device.wd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">备注:</TextBlock> | |||
<TextBox x:Name="remark" Margin="10,0,0,0" Width="200" Text="{Binding device.remark, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" > | |||
<Button Margin="80,0,0,0" Tag="Add" Click="Button_Click" Width="45">增加</Button> | |||
<Button Margin="20,0,0,0" Tag="Update" Click="Button_Click" Width="45">修改</Button> | |||
<Button Margin="20,0,0,0" Tag="Delete" Click="Button_Click" Width="45">删除</Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,20,0,0" > | |||
<Button Margin="80,0,0,0" Tag="Save" Click="Button_Click" >保存text</Button> | |||
<Button Margin="20,0,0,0" Tag="Insert" Click="Button_Click" >导入text</Button> | |||
</StackPanel> | |||
</StackPanel> | |||
<Grid Grid.Column="1" Margin="10"> | |||
<DataGrid HorizontalScrollBarVisibility="Visible" Margin="10" SelectedItem="{Binding deviceTableSelectedItem, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding deviceTable, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" MouseDoubleClick="DataGrid_MouseDoubleClick"> | |||
<DataGrid.Columns> | |||
<DataGridTemplateColumn Header="客户端ID" Width="2*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding ClientId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="云名称" Width="5*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding devicename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="云key" Width="6*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding productkey, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="云secret" Width="12*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding devicesecret, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="类型" Width="4*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding devtype, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="经度" Width="4.4*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding jd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="纬度" Width="4.4*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding wd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="备注" Width="5.4*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding remark, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
</DataGrid.Columns> | |||
</DataGrid> | |||
</Grid> | |||
<Grid x:Name="Pass" Grid.ColumnSpan="2" Background="#99020202"> | |||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<TextBlock Width="80" FontSize="16" Margin="0,0,0,5">密码解锁:</TextBlock> | |||
<PasswordBox x:Name="passbox" Width="180" Height="22" ></PasswordBox> | |||
<Button HorizontalAlignment="Right" Margin="0,5,0,0" Tag="OkPass" Click="Button_Click" IsDefault="True">确定</Button> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,147 @@ | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using BPASmartClient.ViewModel; | |||
using DataVAPI.Tool.IOT; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Threading; | |||
namespace BPASmartClient.Control | |||
{ | |||
/// <summary> | |||
/// DataVView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DataVView : UserControl | |||
{ | |||
string OnPass=string.Empty; | |||
public DispatcherTimer dispatcherTimer; | |||
public DataVView() | |||
{ | |||
InitializeComponent(); | |||
OnPass = AESHelper.Decrypt(System.Configuration.ConfigurationManager.AppSettings["PasswordBox"].ToString()); | |||
this.DataContext = DataVViewModel.GetInstance(); | |||
dispatcherTimer = new DispatcherTimer(); | |||
dispatcherTimer.Tick += delegate | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
Pass.Visibility = Visibility.Visible; | |||
dispatcherTimer.Stop(); | |||
})); | |||
}; | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(120); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
{ | |||
if (sender is Button) | |||
{ | |||
bool istrue = false; | |||
Button button = sender as Button; | |||
if (button.Tag != null) | |||
{ | |||
switch (button.Tag.ToString()) | |||
{ | |||
case "Add": | |||
istrue = DataVViewModel.GetInstance().Add(); | |||
if (istrue) NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"增加成功!"); | |||
else NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, MainViewModel.GetInstance().window, "提示", $"增加失败!"); | |||
break; | |||
case "Update": | |||
if (string.IsNullOrEmpty(DataVViewModel.GetInstance().device.Id)) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "提示", $"请先“查询”或者“双击右侧表格行”,修改之后在点击“修改”!"); | |||
return; | |||
} | |||
istrue = DataVViewModel.GetInstance().Update(); | |||
if (istrue) NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"修改成功!"); | |||
else NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, MainViewModel.GetInstance().window, "提示", $"修改失败!"); | |||
break; | |||
case "Delete": | |||
if (string.IsNullOrEmpty(DataVViewModel.GetInstance().device.Id)) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "提示", $"请先“查询”或者“双击右侧表格行”,修改之后在点击“删除”!"); | |||
return; | |||
} | |||
istrue = DataVViewModel.GetInstance().Delete(); | |||
if (istrue) NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"删除成功!"); | |||
else NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, MainViewModel.GetInstance().window, "提示", $"删除失败!"); | |||
break; | |||
case "SetUrl": | |||
DataVViewModel.GetInstance().ApiURL = apiurl.Text; | |||
DataVViewModel.GetInstance().Refresh(); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"设置成功!"); | |||
//MessageBox.Show("设置成功"); | |||
break; | |||
case "Inquire": | |||
DataVViewModel.GetInstance().device = DataVViewModel.GetInstance().Inquire(chen.Text)?.FirstOrDefault(); | |||
break; | |||
case "Save": | |||
System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog(); | |||
saveFileDialog.Filter = "txt文件(*.txt)|*.txt"; | |||
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||
{ | |||
StreamWriter sw = File.CreateText(saveFileDialog.FileName); | |||
sw.Write(Tools.JsonConvertTools(DataVViewModel.GetInstance().deviceTable)); //写入文件中 | |||
sw.Flush();//清理缓冲区 | |||
sw.Close();//关闭文件 | |||
} | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"导出设备成功,条数: {DataVViewModel.GetInstance().deviceTable.Count}!"); | |||
break; | |||
case "Insert": | |||
System.Windows.Forms.OpenFileDialog file = new System.Windows.Forms.OpenFileDialog();//定义新的文件打开位置控件 | |||
file.Filter = "txt文件(*.txt)|*.txt";//设置文件后缀的过滤 | |||
if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK)//如果有选择打开文件 | |||
{ | |||
DeviceTable device = null; | |||
FileStream fs = new FileStream(file.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | |||
StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8); //选择编码方式 | |||
string str = sr.ReadToEnd(); | |||
if (!string.IsNullOrEmpty(str)) | |||
{ | |||
Tools.JsonToObjectTools<List<DeviceTable>>(str)?.ForEach(par => | |||
{ | |||
DataVViewModel.GetInstance().Add(par); | |||
}); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, MainViewModel.GetInstance().window, "提示", $"插入设备成功,条数: {Tools.JsonToObjectTools<List<DeviceTable>>(str)?.Count}!"); | |||
DataVViewModel.GetInstance().Refresh(); | |||
} | |||
} | |||
break; | |||
case "OkPass": | |||
if (passbox.Password == OnPass) | |||
{ | |||
Pass.Visibility = Visibility.Collapsed; | |||
passbox.Password = ""; | |||
dispatcherTimer.Start(); | |||
} | |||
else | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, MainViewModel.GetInstance().window, "提示", $"密码输入错误!"); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) | |||
{ | |||
DataVViewModel.GetInstance().device = DataVViewModel.GetInstance().deviceTableSelectedItem; | |||
} | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
<UserControl x:Class="BPASmartClient.Control.IOTView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Grid> | |||
<wv2:WebView2 | |||
Name="webView" | |||
Width="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth}" | |||
Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight}" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.Control | |||
{ | |||
/// <summary> | |||
/// IOTView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class IOTView : UserControl | |||
{ | |||
public IOTView() | |||
{ | |||
InitializeComponent(); | |||
webView.Source = new Uri("http://iot.black-pa.com"); | |||
} | |||
} | |||
} |
@@ -26,18 +26,16 @@ | |||
<!-- 查询按钮栏 --> | |||
<StackPanel Margin="10,0,10,0" Orientation="Horizontal"> | |||
<ComboBox Width="120" Text="{Binding SelectedText}" IsEditable="True" ItemsSource="{Binding Path=BookExs}"> | |||
<ComboBox Width="120" Text="{Binding SelectedText}" IsEditable="True" ItemsSource="{Binding Path=BookExs}"> | |||
<ComboBox.ItemTemplate> | |||
<DataTemplate DataType="{x:Type k:BookEx}"> | |||
<StackPanel Orientation="Horizontal"> | |||
<CheckBox IsChecked="{Binding IsChecked}" Margin="2,0,3,0" Background="Red" Content="{Binding BookN.Name}" /> | |||
</StackPanel> | |||
<CheckBox Width="110" IsChecked="{Binding IsChecked}" Content="{Binding BookN.Name}" /> | |||
</DataTemplate> | |||
</ComboBox.ItemTemplate> | |||
</ComboBox> | |||
<DatePicker Margin="10,0,10,0" Text="{Binding DateTimeStr,Mode=TwoWay,NotifyOnTargetUpdated=True}"></DatePicker> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding QueryCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">查询数据</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" Style="{DynamicResource CommonBtn_返回}" Width="102">打开文件目录</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding QueryCommand}" >查询数据</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" >打开文件目录</Button> | |||
</StackPanel> | |||
<!-- 表格栏 --> | |||
@@ -3,6 +3,7 @@ | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:k="clr-namespace:BPASmartClient.Model;assembly=BPASmartClient.Model" | |||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
mc:Ignorable="d" | |||
@@ -25,10 +26,15 @@ | |||
<!--查询按钮栏--> | |||
<StackPanel Orientation="Horizontal" Margin="10,0,10,0"> | |||
<!--<CheckBox Margin="10,0,0,0" IsChecked="{Binding RealTimeModel, UpdateSourceTrigger=PropertyChanged}" >实时模式</CheckBox> | |||
<CheckBox Margin="10,0,0,0" IsChecked="{Binding TimedClear, UpdateSourceTrigger=PropertyChanged}">定时清除</CheckBox>--> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">导出日志</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">打开文件</Button> | |||
<ComboBox Width="100" Text="{Binding SelectedText}" IsEditable="True" ItemsSource="{Binding Path=BookExs}"> | |||
<ComboBox.ItemTemplate> | |||
<DataTemplate DataType="{x:Type k:BookEx}"> | |||
<CheckBox Width="95" IsChecked="{Binding IsChecked}" Content="{Binding BookN.Name}" /> | |||
</DataTemplate> | |||
</ComboBox.ItemTemplate> | |||
</ComboBox> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}" >导出日志</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" >打开文件</Button> | |||
</StackPanel> | |||
<!--表格栏--> | |||
@@ -54,7 +60,7 @@ | |||
<DataGridTemplateColumn Header="日志类型" Width="300"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
@@ -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,6 +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 | |||
{ | |||
@@ -29,7 +35,134 @@ 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) | |||
{ | |||
Refresh(); | |||
} | |||
private void Refresh() | |||
{ | |||
if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel) | |||
{ | |||
} | |||
else if (this.tv.SelectedValue is DeviceModel deviceModel) | |||
{ | |||
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) | |||
{ | |||
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 rbNetwork_Checked(object sender, RoutedEventArgs e) | |||
{ | |||
rbVisibility(); | |||
} | |||
private void rbSerial_Checked(object sender, RoutedEventArgs e) | |||
{ | |||
rbVisibility(); | |||
} | |||
private void rbVisibility() | |||
{ | |||
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) | |||
{ | |||
var res = System.IO.Path.GetFileNameWithoutExtension(item.FullName); | |||
if (res != null && res.Length > 0 && item.FullName.Contains("json")) ShopDeviceConfigViewModel.Shops.Add(res); | |||
} | |||
} | |||
private void shop_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||
{ | |||
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; | |||
} | |||
} | |||
} |
@@ -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> | |||
@@ -8,8 +8,8 @@ | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
Title="NewShopWindow" | |||
Width="850" | |||
Height="450" | |||
Width="400" | |||
Height="300" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Opacity="0.8" | |||
@@ -85,7 +85,6 @@ | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="35" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="50" /> | |||
</Grid.RowDefinitions> | |||
<!--#region 标题栏设置--> | |||
@@ -126,238 +125,111 @@ | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButClose" | |||
Command="{Binding CloseCommand}" | |||
Content="" | |||
Command="{Binding CancelCommand}" | |||
Content="X" | |||
FontSize="30" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
</UniformGrid> | |||
<!--#endregion--> | |||
<!--#region 表单数据--> | |||
<Grid Grid.Row="1"> | |||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="100" /> | |||
<RowDefinition Height="200" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 店铺信息 --> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<pry:TitleTextBlock /> | |||
<TextBlock | |||
Margin="5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="雅黑" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="店铺信息" /> | |||
</Grid> | |||
<Grid Grid.Row="1"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺名称:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺ID:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
</Grid> | |||
<!-- 设备信息 --> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<pry:TitleTextBlock /> | |||
<TextBlock | |||
Margin="5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="雅黑" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="设备信息" /> | |||
</Grid> | |||
<!--#region 使用列表包裹--> | |||
<Grid Grid.Row="1"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入设备名称:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入设备ID:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="3"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请选择启动模块:" /> | |||
<ComboBox | |||
Grid.Column="5" | |||
Margin="170,0,20,0" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF23CACA" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#ff23caca" | |||
IsEditable="False" | |||
ItemsSource="{Binding Path=Device.PlcTypes}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding Path=Device.PlcType}" /> | |||
</Grid> | |||
<Grid Grid.Row="4"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请选择通讯模块:" /> | |||
<ComboBox | |||
Grid.Column="5" | |||
Margin="170,0,20,0" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF23CACA" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#ff23caca" | |||
IsEditable="False" | |||
ItemsSource="{Binding Path=Device.PlcTypes}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding Path=Device.PlcType}" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--<pry:IcoButton | |||
Grid.Row="4" | |||
Content="添加设备" | |||
FontSize="16" | |||
Foreground="{StaticResource TextBlockForeground}" | |||
IcoText="" | |||
Style="{StaticResource NewButtonStyle}" />--> | |||
</Grid> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="60" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid Grid.Row="0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.6*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺名称:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding ShopName}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.6*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺ID:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding ShopId}" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Row="3" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<Grid Grid.Row="4"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Grid.Column="0" | |||
VerticalAlignment="Center" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
Style="{StaticResource buttonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Command="{Binding DefineCommand}" | |||
Content="确认" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 信息取--> | |||
<Grid Grid.Row="2" Background="#11dddddd"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<!--<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" />--> | |||
</Grid.ColumnDefinitions> | |||
<!--<TextBlock | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="请选择需要继续制作的订单,取消或关闭将删除所有订单。" />--> | |||
<Button | |||
Grid.Column="0" | |||
VerticalAlignment="Center" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
Style="{StaticResource buttonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Command="{Binding ConfirmCommand}" | |||
Content="确认" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
<!--#endregion--> | |||
</Grid> | |||
@@ -1,4 +1,6 @@ | |||
using System; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Messaging; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -27,14 +29,28 @@ namespace BPASmartClient.DialogWindow | |||
this.DragMove(); | |||
}; | |||
//WeakReferenceMessenger.Default.Register<string, string>(this, "Close", (o, e) => | |||
//{ | |||
// App.Current.Dispatcher.Invoke(new Action(() => | |||
// { | |||
// this.DialogResult = Convert.ToBoolean(e); | |||
// this.Close(); | |||
// })); | |||
//}); | |||
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"); | |||
} | |||
@@ -13,7 +13,7 @@ | |||
Height="800" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
Topmost="False" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
@@ -76,6 +76,12 @@ | |||
FontSize="12" | |||
Header="店铺设备配置" | |||
Tag="ShopDeviceConfigView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
FontSize="12" | |||
Header="阿里连接维护" | |||
Tag="DataVView" /> | |||
</MenuItem> | |||
<MenuItem Header="状态监视"> | |||
<MenuItem | |||
@@ -96,17 +102,12 @@ | |||
Header="设备监视" | |||
Tag="DeviceMonitorView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
FontSize="12" | |||
Header="告警监视" | |||
Tag="LogView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
FontSize="12" | |||
Header="IOT监视" | |||
Tag="LogView" /> | |||
Tag="IOTView" /> | |||
<Separator /> | |||
</MenuItem> | |||
<MenuItem Header="综合查询"> | |||
<MenuItem | |||
@@ -226,9 +227,8 @@ | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Click="Button_Click" | |||
Content="返回" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Content="测试" | |||
Cursor="Hand" /> | |||
<Button | |||
Grid.Row="0" | |||
Width="100" | |||
@@ -237,10 +237,9 @@ | |||
VerticalAlignment="Top" | |||
Click="Button_Click_1" | |||
Content="测试消息弹窗" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Cursor="Hand"/> | |||
<Button | |||
<!--<Button | |||
Name="save" | |||
Grid.Row="0" | |||
Width="100" | |||
@@ -250,19 +249,23 @@ | |||
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" | |||
Content="初始化设备" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Cursor="Hand"/> | |||
<CheckBox | |||
Margin="350,0,0,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" /> | |||
<TextBlock | |||
x:Name="Title" | |||
@@ -37,7 +37,7 @@ namespace BPASmartClient | |||
{ | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
InitializeComponent(); | |||
MainViewModel.GetInstance().window = this; | |||
this.DataContext = MainViewModel.GetInstance(); | |||
Initialize(); | |||
@@ -59,7 +59,7 @@ namespace BPASmartClient | |||
else if (this.WindowState == WindowState.Normal) | |||
this.WindowState = WindowState.Maximized; | |||
} | |||
this.DragMove(); | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" }, null); | |||
@@ -161,7 +161,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; | |||
@@ -187,7 +187,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,10 +2,12 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="BPA.Models" Version="1.0.10" /> | |||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | |||
</ItemGroup> | |||