@@ -1,36 +1,37 @@ | |||
namespace BPASmartClient.AGV.Enums | |||
/// <summary> | |||
/// 纯料箱任务枚举 | |||
/// </summary> | |||
public enum BinTask | |||
{ | |||
/// <summary> | |||
/// 开始移动(仅单插臂或单夹报,2.8.1后) | |||
/// </summary> | |||
MOVE_BEGIN, | |||
/// <summary> | |||
/// 到站 | |||
/// </summary> | |||
ENTER_STATION, | |||
/// <summary> | |||
/// 任务完成 | |||
/// </summary> | |||
DONE, | |||
/// <summary> | |||
/// 取料完成 | |||
/// </summary> | |||
LOAD_COMPLETED, | |||
/// <summary> | |||
/// 放料完成 | |||
/// </summary> | |||
UNLOAD_COMPLETED, | |||
/// <summary> | |||
/// 任务异常取消 | |||
/// </summary> | |||
ABNORMAL_CANCEL, | |||
/// <summary> | |||
/// 任务异常完成 | |||
/// 纯料箱任务枚举 | |||
/// </summary> | |||
ABNORMAL_COMPLETED, | |||
} | |||
public enum BinTask | |||
{ | |||
/// <summary> | |||
/// 开始移动(仅单插臂或单夹报,2.8.1后) | |||
/// </summary> | |||
MOVE_BEGIN, | |||
/// <summary> | |||
/// 到站 | |||
/// </summary> | |||
ENTER_STATION, | |||
/// <summary> | |||
/// 任务完成 | |||
/// </summary> | |||
DONE, | |||
/// <summary> | |||
/// 取料完成 | |||
/// </summary> | |||
LOAD_COMPLETED, | |||
/// <summary> | |||
/// 放料完成 | |||
/// </summary> | |||
UNLOAD_COMPLETED, | |||
/// <summary> | |||
/// 任务异常取消 | |||
/// </summary> | |||
ABNORMAL_CANCEL, | |||
/// <summary> | |||
/// 任务异常完成 | |||
/// </summary> | |||
ABNORMAL_COMPLETED, | |||
} | |||
} |
@@ -1,32 +1,33 @@ | |||
namespace BPASmartClient.AGV.Enums | |||
/// <summary> | |||
/// 货位到货位/点到点辊筒料箱搬运任务枚举 | |||
/// </summary> | |||
public enum CTC | |||
{ | |||
/// <summary> | |||
/// 正在上料 | |||
/// </summary> | |||
ROLLER_LOAD_DOING, | |||
/// <summary> | |||
/// 上料完成 | |||
/// </summary> | |||
ROLLER_LOAD_FINISH, | |||
/// <summary> | |||
/// 正在下料 | |||
/// </summary> | |||
ROLLER_UNLOAD_DOING, | |||
/// <summary> | |||
/// 下料完成 | |||
/// </summary> | |||
DONE, | |||
/// <summary> | |||
/// 任务异常取消 | |||
/// </summary> | |||
ABNORMAL_CANCEL, | |||
/// <summary> | |||
/// 任务异常完成 | |||
/// 货位到货位/点到点辊筒料箱搬运任务枚举 | |||
/// </summary> | |||
ABNORMAL_COMPLETED, | |||
} | |||
public enum CTC | |||
{ | |||
/// <summary> | |||
/// 正在上料 | |||
/// </summary> | |||
ROLLER_LOAD_DOING, | |||
/// <summary> | |||
/// 上料完成 | |||
/// </summary> | |||
ROLLER_LOAD_FINISH, | |||
/// <summary> | |||
/// 正在下料 | |||
/// </summary> | |||
ROLLER_UNLOAD_DOING, | |||
/// <summary> | |||
/// 下料完成 | |||
/// </summary> | |||
DONE, | |||
/// <summary> | |||
/// 任务异常取消 | |||
/// </summary> | |||
ABNORMAL_CANCEL, | |||
/// <summary> | |||
/// 任务异常完成 | |||
/// </summary> | |||
ABNORMAL_COMPLETED, | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.AGV.Feedback | |||
{ | |||
public class AGVToUpSystem | |||
{ | |||
/// <summary> | |||
/// 上游系统任务号,全局唯一 | |||
/// </summary> | |||
public string robotJobId { get; set; } | |||
/// <summary> | |||
/// 仓库编号 | |||
/// </summary> | |||
public int warehouseId { get; set; } | |||
/// <summary> | |||
/// 任务快仓系统编号 | |||
/// </summary> | |||
public string jobId { get; set; } | |||
/// <summary> | |||
/// 任务状态 | |||
/// </summary> | |||
public string state { get; set; } | |||
/// <summary> | |||
/// 内部任务类型 | |||
/// </summary> | |||
public string jobType { get; set; } | |||
/// <summary> | |||
/// 数据字段 | |||
/// </summary> | |||
public JobData jobData { get; set; } = new JobData(); | |||
} | |||
} |
@@ -8,16 +8,39 @@ namespace BPASmartClient.AGV.Feedback | |||
{ | |||
public class JobData | |||
{ | |||
/// <summary> | |||
/// AGV编号 | |||
/// </summary> | |||
public string agvCode { get; set; } | |||
/// <summary> | |||
/// 容器编号 | |||
/// </summary> | |||
public string containerCode { get; set; } | |||
/// <summary> | |||
/// 上料点位 | |||
/// </summary> | |||
public string startPointCode { get; set; } | |||
/// <summary> | |||
/// 上料货位编号 | |||
/// </summary> | |||
public string startSlotCode { get; set; } | |||
/// <summary> | |||
/// 下料点位 | |||
/// </summary> | |||
public string targetPointCode { get; set; } | |||
/// <summary> | |||
/// 下料货位编号 | |||
/// </summary> | |||
public string targetSlotCode { get; set; } | |||
/// <summary> | |||
/// 是否需要上料交互 | |||
/// </summary> | |||
public bool loadInteractive { get; set; } | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.AGV.Feedback | |||
{ | |||
public class Upstreamrequest | |||
{ | |||
/// <summary> | |||
/// AGV编号 | |||
/// </summary> | |||
public string agvCode { get; set; } | |||
/// <summary> | |||
/// 容器编号,如果一次上/下多个容器,则多个容器用英文逗号分隔 | |||
/// </summary> | |||
public string containerCode { get; set; } | |||
/// <summary> | |||
/// 上游设备ID 本字段适用于只有一个辊筒设备的时候使用 | |||
/// </summary> | |||
public long equipmentId { get; set; } | |||
/// <summary> | |||
/// 上游设备ID,多个用英文逗号分隔 本字段适用于多辊筒同时上下料的时候使用 | |||
/// </summary> | |||
public string equipmentIds { get; set; } | |||
/// <summary> | |||
/// 快仓任务编号 | |||
/// </summary> | |||
public string jobId { get; set; } | |||
/// <summary> | |||
/// 消息ID | |||
/// </summary> | |||
public string msgId { get; set; } | |||
/// <summary> | |||
/// 交互阶段 | |||
/// LOAD:上料阶段 | |||
/// UNLOAD:下料阶段 | |||
/// </summary> | |||
public string command { get; set; } | |||
/// <summary> | |||
/// 上游任务号 | |||
/// </summary> | |||
public string robotJobId { get; set; } | |||
} | |||
} |
@@ -1,22 +0,0 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.AGV.Feedback | |||
{ | |||
public class @event | |||
{ | |||
public string robotJobId { get; set; } | |||
public int warehouseId { get; set; } | |||
public string jobId { get; set; } | |||
public string state { get; set; } | |||
public string jobType { get; set; } | |||
public JobData jobData { get; set; } = new JobData(); | |||
} | |||
} |
@@ -10,4 +10,8 @@ | |||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.AGV\BPASmartClient.AGV.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,16 +0,0 @@ | |||
using Microsoft.AspNetCore.Mvc; | |||
namespace BPASmartClient.AgvApi.Controllers | |||
{ | |||
[ApiController] | |||
[Route("apicallback/quicktron/[Controller]")] | |||
public class AgvStatusController : ControllerBase | |||
{ | |||
[HttpPost("AgvCallback")] | |||
public string AgvCallback(Sign sign) | |||
{ | |||
return "SUCCESS"; | |||
} | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using BPASmartClient.AGV.Feedback; | |||
using Microsoft.AspNetCore.Mvc; | |||
using Microsoft.AspNetCore.SignalR; | |||
using Newtonsoft.Json; | |||
namespace BPASmartClient.AgvApi.Controllers | |||
{ | |||
[ApiController] | |||
[Route("apicallback/quicktron/[Controller]")] | |||
public class robotjobController : ControllerBase | |||
{ | |||
/// <summary> | |||
/// 搬运任务状态上报 | |||
/// </summary> | |||
/// <param name="sign"></param> | |||
/// <returns></returns> | |||
[HttpPost("report")] | |||
public string report(string sign) | |||
{ | |||
if (sign != null) | |||
{ | |||
try | |||
{ | |||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign); | |||
if (res != null) | |||
{ | |||
Factory.GetInstance.SendReport(res); | |||
return "SUCCESS"; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
} | |||
return "Error"; | |||
} | |||
/// <summary> | |||
/// AGV上下料交互请求接口 | |||
/// </summary> | |||
/// <param name="sign"></param> | |||
/// <returns></returns> | |||
[HttpPost("upstreamrequest")] | |||
public string upstreamrequest(string sign) | |||
{ | |||
if (sign != null) | |||
{ | |||
try | |||
{ | |||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(sign); | |||
if (res != null) | |||
{ | |||
Factory.GetInstance.SendUpstreamrequest(sign); | |||
return "SUCCESS"; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
} | |||
return "Error"; | |||
} | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
using Microsoft.AspNetCore.SignalR; | |||
namespace BPASmartClient.AgvApi | |||
{ | |||
public class Factory | |||
{ | |||
private volatile static Factory _Instance; | |||
public static Factory GetInstance => _Instance ?? (_Instance = new Factory()); | |||
private Factory() { } | |||
public IHubCallerClients HubCallerClient { get; set; } | |||
public Task SendReport(object obj) | |||
{ | |||
return HubCallerClient?.Caller.SendAsync("Report", obj); | |||
} | |||
public Task SendUpstreamrequest(object obj) | |||
{ | |||
return HubCallerClient?.Caller.SendAsync("Upstreamrequest", obj); | |||
} | |||
} | |||
} |
@@ -4,9 +4,11 @@ namespace BPASmartClient.AgvApi | |||
{ | |||
public class PersonHub : Hub | |||
{ | |||
public override Task OnConnectedAsync() | |||
{ | |||
Console.WriteLine($"{Context.ConnectionId}:= 连接成功"); | |||
Factory.GetInstance.HubCallerClient = Clients; | |||
return base.OnConnectedAsync(); | |||
} | |||
@@ -21,9 +23,12 @@ namespace BPASmartClient.AgvApi | |||
/// </summary> | |||
/// <param name="str"></param> | |||
/// <returns></returns> | |||
public Task Send(string str) | |||
public Task Send(object str) | |||
{ | |||
return Clients.Caller.SendAsync("SendMessage", str); | |||
} | |||
} | |||
} |
@@ -1,4 +1,7 @@ | |||
using BPASmartClient.AgvApi; | |||
using Microsoft.AspNetCore.Cors.Infrastructure; | |||
var builder = WebApplication.CreateBuilder(args); | |||
@@ -28,6 +31,7 @@ app.Use(async (context, next) => | |||
await next(); | |||
}); | |||
app.UseAuthorization(); | |||
app.MapControllers(); | |||
@@ -1,10 +0,0 @@ | |||
namespace BPASmartClient.AgvApi | |||
{ | |||
public class Sign | |||
{ | |||
public int a { get; set; } | |||
public int b { get; set; } | |||
public string c { get; set; } | |||
public string d { get; set; } | |||
} | |||
} |
@@ -8,7 +8,7 @@ | |||
<ItemGroup> | |||
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
<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" /> | |||
@@ -46,12 +46,11 @@ namespace BPASmartClient.Business | |||
mqttProxy.Connected = new Action(() => | |||
{ | |||
mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); | |||
MessageLog.GetInstance.Show("MQTT 连接成功"); | |||
}); | |||
//MQTT 连接成功 | |||
mqttProxy.LostConnect = new Action(() => | |||
{ | |||
MqttHelper.GetInstance().MqttSubscriptionAsync(TopicDefine.GetInstance().SubscribTopics.ToArray()); | |||
mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); | |||
}); | |||
//MQTT 数据接收 | |||
mqttProxy.MessageRecive = new Action<string>((message) => | |||
@@ -188,6 +188,13 @@ | |||
<None Remove="Image\顶部线条.png" /> | |||
<None Remove="Image\顶部背景.png" /> | |||
<None Remove="Image\黑菠萝科技.png" /> | |||
<None Remove="Videos\Login.mp4" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="Videos\Login.mp4"> | |||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |||
</Content> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -242,7 +249,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
</ItemGroup> | |||
@@ -8,8 +8,8 @@ | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | |||
Title="LoginView" | |||
Width="500" | |||
Height="300" | |||
Width="1920" | |||
Height="1080" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
@@ -63,9 +63,9 @@ | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="../../Fonts/#iconfont" | |||
FontSize="20" | |||
FontSize="30" | |||
Foreground="{TemplateBinding BorderBrush}" | |||
Text="" /> | |||
Text="" /> | |||
<!--<TextBlock | |||
Name="markText" | |||
@@ -144,7 +144,7 @@ | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="../../Fonts/#iconfont" | |||
FontSize="20" | |||
FontSize="30" | |||
Foreground="{TemplateBinding BorderBrush}" | |||
Text="" /> | |||
@@ -191,9 +191,157 @@ | |||
</Style> | |||
<!--#endregion--> | |||
<!--#region 操作按钮样式--> | |||
<Style x:Key="ButtonStyle" TargetType="Button"> | |||
<Setter Property="Margin" Value="20,20" /> | |||
<Setter Property="Background" Value="#cc009DFF" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="FontSize" Value="30" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
Name="TitleBarBr" | |||
Background="{TemplateBinding Background}" | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
BorderThickness="{TemplateBinding BorderThickness}" | |||
CornerRadius="20"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="TitleBarBr" Property="Background" Value="#009DFF" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</Window.Resources> | |||
<Border | |||
<Grid> | |||
<MediaElement | |||
Name="player" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LoadedBehavior="Manual" /> | |||
<!--<MediaElement | |||
Name="player" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Source="../../Videos/Login.mp4" | |||
LoadedBehavior="Play"> | |||
<MediaElement.Triggers> | |||
<EventTrigger RoutedEvent="MediaElement.Loaded"> | |||
<EventTrigger.Actions> | |||
<BeginStoryboard> | |||
<Storyboard> | |||
<MediaTimeline | |||
RepeatBehavior="Forever" | |||
Source="../../Videos/Login.mp4" | |||
Storyboard.TargetName="player" /> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</EventTrigger.Actions> | |||
</EventTrigger> | |||
</MediaElement.Triggers> | |||
</MediaElement>--> | |||
<Grid x:Name="grid" Margin="400,180"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="#009DFF" | |||
Text="用户登录" /> | |||
<TextBlock | |||
Grid.Row="4" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="30" | |||
Foreground="#FFEF2020" | |||
Text="{Binding ErrorInfo}" /> | |||
<TextBox | |||
Grid.Row="1" | |||
Margin="20,20" | |||
BorderBrush="#009DFF" | |||
BorderThickness="3" | |||
FontSize="30" | |||
Foreground="#009DFF" | |||
Style="{DynamicResource UserTextBoxStyle}" | |||
TabIndex="1" | |||
Text="{Binding UserName}" /> | |||
<PasswordBox | |||
Name="pb" | |||
Grid.Row="2" | |||
Margin="20,20" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
BorderThickness="3" | |||
FontSize="30" | |||
Foreground="#009DFF" | |||
PasswordChanged="PasswordBox_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<TextBlock | |||
Name="markText" | |||
Grid.Row="2" | |||
Margin="70,5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="30" | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请输入账号密码" | |||
Visibility="Visible" /> | |||
<Grid Grid.Row="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Command="{Binding ExitCommand}" | |||
Content="退 出" | |||
Style="{StaticResource ButtonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
Command="{Binding LoginCommand}" | |||
Content="登 录" | |||
Style="{StaticResource ButtonStyle}" | |||
TabIndex="3" /> | |||
</Grid> | |||
</Grid> | |||
</Grid> | |||
<!--<Border | |||
x:Name="br" | |||
BorderBrush="#009dff" | |||
BorderThickness="2"> | |||
@@ -204,103 +352,131 @@ | |||
Color="#009DFF" /> | |||
</Border.Effect> | |||
<Grid> | |||
<Image Source="../../Image/登录界面背景.jpg" Stretch="Fill" /> | |||
<Image Source="../../Image/阴影边框.png" Stretch="Fill" /> | |||
--> | |||
<!--<Image Source="../../Image/登录界面背景1.jpg" Stretch="Fill" /> | |||
<Image Source="../../Image/阴影边框.png" Stretch="Fill" />--> | |||
<!-- | |||
<Border | |||
Width="400" | |||
Height="260" | |||
Margin="0,0,0,250" | |||
BorderBrush="#009dff" | |||
BorderThickness="2"> | |||
<Border.Effect> | |||
<DropShadowEffect | |||
BlurRadius="10" | |||
ShadowDepth="1" | |||
Color="#009DFF" /> | |||
</Border.Effect> | |||
<Grid Width="400" Height="260"> | |||
--> | |||
<!--<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions>--> | |||
<Grid Margin="50,20"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="0,10,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#ddd" | |||
Text="用户登录" /> | |||
<TextBlock | |||
Margin="20,10,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
FontSize="16" | |||
Foreground="#FFEF2020" | |||
Text="{Binding ErrorInfo}" /> | |||
<TextBox | |||
Grid.Row="1" | |||
Height="40" | |||
Margin="20,0" | |||
BorderBrush="#009DFF" | |||
FontSize="16" | |||
Foreground="#aadddddd" | |||
Style="{DynamicResource UserTextBoxStyle}" | |||
TabIndex="1" | |||
Text="{Binding UserName}" /> | |||
<PasswordBox | |||
Name="pb" | |||
Grid.Row="2" | |||
Height="40" | |||
Margin="20,0" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
FontSize="16" | |||
Foreground="#aadddddd" | |||
PasswordChanged="PasswordBox_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<TextBlock | |||
Name="markText" | |||
Grid.Row="2" | |||
Margin="70,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请输入账号密码" | |||
Visibility="Visible" /> | |||
<Grid Grid.Row="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Margin="20,10" | |||
Background="#009DFF" | |||
BorderThickness="0" | |||
Command="{Binding ExitCommand}" | |||
Content="退 出" | |||
<!--<TextBlock | |||
Margin="0,10,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="White" /> | |||
<Button | |||
Grid.Column="1" | |||
Margin="20,10" | |||
Background="#009DFF" | |||
BorderThickness="0" | |||
Command="{Binding LoginCommand}" | |||
Content="登 录" | |||
Foreground="#ddd" | |||
Text="用户登录" /> | |||
<TextBlock | |||
Margin="20,10,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
FontSize="16" | |||
Foreground="#FFEF2020" | |||
Text="{Binding ErrorInfo}" /> | |||
<TextBox | |||
Grid.Row="1" | |||
Height="40" | |||
Margin="20,0" | |||
BorderBrush="#009DFF" | |||
FontSize="16" | |||
Foreground="#009DFF" | |||
Style="{DynamicResource UserTextBoxStyle}" | |||
TabIndex="1" | |||
Text="{Binding UserName}" /> | |||
<PasswordBox | |||
Name="pb" | |||
Grid.Row="2" | |||
Height="40" | |||
Margin="20,0" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
FontSize="16" | |||
Foreground="#009DFF" | |||
PasswordChanged="PasswordBox_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<TextBlock | |||
Name="markText" | |||
Grid.Row="2" | |||
Margin="70,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Foreground="White" | |||
TabIndex="3" /> | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请输入账号密码" | |||
Visibility="Visible" /> | |||
<Grid Grid.Row="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Margin="20,10" | |||
Background="#009DFF" | |||
BorderThickness="0" | |||
Command="{Binding ExitCommand}" | |||
Content="退 出" | |||
FontSize="20" | |||
Foreground="White" /> | |||
<Button | |||
Grid.Column="1" | |||
Margin="20,10" | |||
Background="#009DFF" | |||
BorderThickness="0" | |||
Command="{Binding LoginCommand}" | |||
Content="登 录" | |||
FontSize="20" | |||
Foreground="White" | |||
TabIndex="3" /> | |||
</Grid>--> | |||
<!-- | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Grid> | |||
</Border> | |||
--> | |||
<!--<Grid x:Name="gr"> | |||
<Grid.Background> | |||
<ImageBrush Opacity="0.8" ImageSource="../../Image/登录界面背景.jpg" /> | |||
@@ -1,8 +1,11 @@ | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
@@ -23,15 +26,60 @@ namespace BPASmartClient.CustomResource.Pages.View | |||
public LoginView() | |||
{ | |||
InitializeComponent(); | |||
this.br.MouseLeftButtonDown += (o, e) => | |||
{ | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
grid.Visibility = Visibility.Collapsed; | |||
this.Loaded += LoginView_Loaded; | |||
this.WindowState = WindowState.Maximized; | |||
ActionManage.GetInstance.CancelRegister("LoginOk"); | |||
ActionManage.GetInstance.CancelRegister("ExitAction"); | |||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk"); | |||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = false; this.Close(); }), "ExitAction"); | |||
} | |||
private void LoginView_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
string path = @"Videos\Login.mp4"; | |||
if (File.Exists(path)) | |||
{ | |||
// 绑定视频文件 | |||
player.Source = new Uri(path); | |||
// 交互式控制 | |||
player.LoadedBehavior = MediaState.Manual; | |||
// 添加元素加载完成事件 -- 自动开始播放 | |||
player.Loaded += new RoutedEventHandler(media_Loaded); | |||
// 添加媒体播放结束事件 -- 重新播放 | |||
player.MediaEnded += new RoutedEventHandler(media_MediaEnded); | |||
// 添加元素卸载完成事件 -- 停止播放 | |||
player.Unloaded += new RoutedEventHandler(media_Unloaded); | |||
player.MediaOpened += Player_MediaOpened; | |||
} | |||
} | |||
private void Player_MediaOpened(object sender, RoutedEventArgs e) | |||
{ | |||
grid.Visibility = Visibility.Visible; | |||
} | |||
private void media_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
(sender as MediaElement).Play(); | |||
} | |||
private void media_MediaEnded(object sender, RoutedEventArgs e) | |||
{ | |||
// MediaElement需要先停止播放才能再开始播放, | |||
// 否则会停在最后一帧不动 | |||
(sender as MediaElement).Stop(); | |||
(sender as MediaElement).Play(); | |||
} | |||
private void media_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
(sender as MediaElement).Stop(); | |||
} | |||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | |||
@@ -320,17 +320,22 @@ | |||
HorizontalAlignment="Right" | |||
Columns="3"> | |||
<Button | |||
Visibility="Hidden" | |||
IsEnabled="False" | |||
Name="ButMin" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
<Button | |||
Visibility="Hidden" | |||
IsEnabled="False" | |||
Name="ButMax" | |||
Content="" | |||
FontSize="22" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
<Button | |||
Name="ButClose" | |||
Content="" | |||
Content="" | |||
Foreground="Red" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
</UniformGrid> | |||
<!--#endregion--> | |||
@@ -23,6 +23,7 @@ namespace BPASmartClient.CustomResource.Pages.View | |||
public MainView() | |||
{ | |||
InitializeComponent(); | |||
this.WindowState = WindowState.Maximized; | |||
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; }; | |||
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; }; | |||
this.ButClose.Click += (o, e) => { this.Close(); }; | |||
@@ -7,7 +7,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -0,0 +1,37 @@ | |||
<Application | |||
x:Class="BPASmartClient.DosingSystem.App" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem"> | |||
<Application.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" /> | |||
<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/RecDictionarys/DatePickeerDictionary.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" /> | |||
<ResourceDictionary> | |||
<con:ColorConverter x:Key="ColorConverter" /> | |||
<con:TextConverter x:Key="TextConverter" /> | |||
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" /> | |||
<con:StatusConverter x:Key="StatusConverter" /> | |||
<con:StringToIconConverter x:Key="StringToIconConverter" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" /> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Application.Resources> | |||
</Application> |
@@ -0,0 +1,188 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPASmartClient.CustomResource.Pages.Enums; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.Pages.View; | |||
using BPASmartClient.DosingSystem.Model; | |||
using BPASmartClient.DosingSystem.View; | |||
using BPASmartClient.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
protected override void OnStartup(StartupEventArgs e) | |||
{ | |||
base.OnStartup(e); | |||
MenuInit(); | |||
DataInit(); | |||
MainView mv = new MainView(); | |||
LoginView lv = new LoginView(); | |||
var res = lv.ShowDialog(); | |||
if (res != null && res == true) | |||
mv.Show(); | |||
else | |||
mv.Close(); | |||
//MainWindow mw = new MainWindow(); | |||
//LoginView lv = new LoginView(); | |||
//var res = lv.ShowDialog(); | |||
//if (res != null && res == true) | |||
// mw.Show(); | |||
//else | |||
// mw.Close(); | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
base.OnExit(e); | |||
Json<LocaPar>.Save(); | |||
MessageLog.GetInstance.LogSave(); | |||
} | |||
private void MenuInit() | |||
{ | |||
#region 配方管理菜单 | |||
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>(); | |||
RecipeManage.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "配方管理", | |||
SubMenuPermission = new Permission[] { Permission.管理员 }, | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.RecipeSettingsView" | |||
}); | |||
RecipeManage.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "配方下发", | |||
SubMenuPermission = new Permission[] { Permission.操作员 }, | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.RecipeControlView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "配方管理", | |||
Alias = "Recipe Management", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员 }, | |||
subMenumodels = RecipeManage, | |||
}); | |||
#endregion | |||
#region 消息日志 | |||
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>(); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "操作日志", | |||
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.UserLogView" | |||
}); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "运行日志", | |||
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.RunLogView" | |||
}); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "报警记录", | |||
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.AlarmView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "消息日志", | |||
Alias = "Message Log", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
subMenumodels = InfoLog, | |||
}); | |||
#endregion | |||
#region 硬件设备监控 | |||
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "原料设备列表", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.DeviceListView" | |||
}); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "设备状态", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.HardwareStatusView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "设备监控", | |||
Alias = "Device Monitor", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
subMenumodels = DeviceMonitor, | |||
}); | |||
#endregion | |||
#region 用户管理 | |||
ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>(); | |||
UserManager.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "用户登录", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.LoginView" | |||
}); | |||
UserManager.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "密码修改", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.PasswordChangeView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "用户管理", | |||
Alias = "User Management", | |||
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
subMenumodels = UserManager, | |||
}); | |||
#endregion | |||
} | |||
private void DataInit() | |||
{ | |||
Config.GetInstance.Init(); | |||
Json<LocaPar>.Read(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
using System.Windows; | |||
[assembly: ThemeInfo( | |||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | |||
//(used if a resource is not found in the page, | |||
// or application resource dictionaries) | |||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | |||
//(used if a resource is not found in the page, | |||
// app, or any theme specific resource dictionaries) | |||
)] |
@@ -0,0 +1,28 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
<ApplicationManifest>app.manifest</ApplicationManifest> | |||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||
<PlatformTarget>AnyCPU</PlatformTarget> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class ActionMenu : ObservableObject | |||
{ | |||
public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } | |||
private string _mCommandParameter; | |||
//public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } | |||
//private Permission[] _mpermission; | |||
public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } | |||
private string _mMenuName; | |||
//public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } } | |||
//private string _mNameSpace; | |||
} | |||
} |
@@ -0,0 +1,44 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class DeviceAddress | |||
{ | |||
/// <summary> | |||
/// 设备名称起始地址 | |||
/// </summary> | |||
public static string DeviceName { get; set; } = "LW0"; | |||
/// <summary> | |||
/// 料仓重量反馈起始地址 | |||
/// </summary> | |||
public static string WeightFeedback { get; set; } = "LW204"; | |||
/// <summary> | |||
/// 重量设置地址 | |||
/// </summary> | |||
public static string WeightSet { get; set; } = "LW200"; | |||
/// <summary> | |||
/// 启动信号地址 | |||
/// </summary> | |||
public static string Start { get; set; } = "LW210"; | |||
/// <summary> | |||
/// 下料重量反馈地址 | |||
/// </summary> | |||
public static string CutWeightFeedback { get; set; } = "LW202"; | |||
/// <summary> | |||
/// 设备运行状态地址 | |||
/// </summary> | |||
public static string RunStatus { get; set; } = "LW206"; | |||
} | |||
} |
@@ -0,0 +1,221 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class DeviceInquire | |||
{ | |||
private volatile static DeviceInquire _Instance; | |||
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | |||
private DeviceInquire() { } | |||
string IPSegment = "192.168.0."; | |||
ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>(); | |||
List<string> InvalidIP = new List<string>();//无效 IP 集合 | |||
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合 | |||
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列 | |||
public void Init() | |||
{ | |||
IpAddressLines(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (IPQueues.Count >= IPLists.Count) | |||
IpAddressLines(); | |||
Thread.Sleep(5000); | |||
}), "配料机设备上线监听", true); | |||
} | |||
public void Rescan() | |||
{ | |||
InvalidIP.Clear(); | |||
} | |||
public DeviceStatus GetDevice(string ip) | |||
{ | |||
if (ip != null) | |||
{ | |||
var res = DeviceLists.Values.FirstOrDefault(p => p.IpAddress == ip); | |||
if (res != null) return res; | |||
} | |||
return new DeviceStatus(); | |||
} | |||
private void IpAddressLines() | |||
{ | |||
IPLists.Clear(); | |||
IPQueues.Clear(); | |||
for (int i = 1; i <= 255; i++) | |||
{ | |||
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}")) | |||
{ | |||
IPLists.Add($"{IPSegment}{i}"); | |||
} | |||
} | |||
IPLists.ForEach((item) => | |||
{ | |||
Ping myPing = new Ping(); | |||
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); | |||
myPing.SendAsync(item, 1000, null); | |||
}); | |||
} | |||
private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) | |||
{ | |||
if (e.Reply.Status == IPStatus.Success) | |||
{ | |||
string ip = e.Reply.Address.ToString(); | |||
if (!DeviceLists.ContainsKey(ip)) | |||
{ | |||
DeviceStatus DS = new DeviceStatus(); | |||
DS.modbusTcp.IsReconnect = false; | |||
DS.modbusTcp.ConnectOk = new Action(() => | |||
{ | |||
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20); | |||
if (DeviceName.Length > 0) | |||
{ | |||
DeviceLists.TryAdd(ip, DS); | |||
DeviceLists[ip].Init(DeviceName); | |||
DeviceLists[ip].modbusTcp.IsReconnect = false; | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
DeviceListViewModel.devices.Add(new Devices() | |||
{ | |||
DeviceName = DeviceName, | |||
IpAddress = ip | |||
}); | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
if (Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
} | |||
} | |||
} | |||
if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName)) | |||
NewRecipeViewModel.RawMaterialNames.Add(DeviceName); | |||
})); | |||
} | |||
else | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
} | |||
}); | |||
DS.modbusTcp.ConnectFail = new Action(() => | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
MessageLog.GetInstance.Show($"{ip}连接失败"); | |||
}); | |||
DS.modbusTcp.Disconnect = new Action(() => | |||
{ | |||
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); | |||
var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); | |||
if (res != null && DeviceListViewModel.devices.Contains(res)) | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
DeviceListViewModel.devices.Remove(res); | |||
if (!NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName)) | |||
NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); | |||
})); | |||
if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); | |||
}); | |||
Task.Run(new Action(() => | |||
{ | |||
DS.modbusTcp.ModbusTcpConnect(ip, 502); | |||
IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
})); | |||
} | |||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
} | |||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||
} | |||
} | |||
public class DeviceStatus | |||
{ | |||
#region 对象属性声明 | |||
public string DeviceName = String.Empty; | |||
public string IpAddress => modbusTcp.IPAdress; | |||
/// <summary> | |||
/// 设备状态 | |||
/// </summary> | |||
public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); | |||
public ModbusTcp modbusTcp = new ModbusTcp(); | |||
public bool IsConnected => modbusTcp.Connected; | |||
#endregion | |||
public void Init(string DeviceName) | |||
{ | |||
this.DeviceName = DeviceName; | |||
if (modbusTcp.Connected) | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//获取设备运行状态 | |||
var res = this.modbusTcp.Read(DeviceAddress.RunStatus); | |||
if (res != null && res is ushort[] ushortValue) | |||
{ | |||
if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; | |||
} | |||
//获取设备料仓剩余重量 | |||
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10; | |||
Thread.Sleep(100); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
} | |||
public void SetDeviceName(string name) | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); | |||
this.modbusTcp.SetString(DeviceAddress.DeviceName, name); | |||
} | |||
public void StatusReset() | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); | |||
} | |||
public void Dispose() | |||
{ | |||
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); | |||
} | |||
public void Start(uint Value) | |||
{ | |||
if (modbusTcp.Connected) | |||
{ | |||
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量 | |||
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class LocaPar | |||
{ | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>(); | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class RawMaterialDeviceStatus | |||
{ | |||
/// <summary> | |||
/// 原料类型 | |||
/// 1:液体 | |||
/// 2:膏体 | |||
/// 3:粉体 | |||
/// </summary> | |||
public ushort RawMaterialType { get; set; } | |||
/// <summary> | |||
/// 料仓重量反馈 | |||
/// </summary> | |||
public float WeightFeedback { get; set; } | |||
/// <summary> | |||
/// 上限反馈 | |||
/// </summary> | |||
public bool UpLimitFeedback { get; set; } | |||
/// <summary> | |||
/// 下限反馈 | |||
/// </summary> | |||
public bool DownLimitFeedback { get; set; } | |||
/// <summary> | |||
/// 下料重量反馈 | |||
/// </summary> | |||
public float CutWeightFeedback { get; set; } | |||
/// <summary> | |||
/// 设备运行状态 | |||
/// </summary> | |||
public ushort RunStatus { get; set; } | |||
} | |||
} |
@@ -0,0 +1,88 @@ | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
/// <summary> | |||
/// 原料模块 | |||
/// </summary> | |||
public class RawMaterialModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
/// <summary> | |||
/// 原料设备IP | |||
/// </summary> | |||
public string DeviceIp { get; set; } | |||
/// <summary> | |||
/// 原料重量设置 | |||
/// </summary> | |||
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||
private uint _mRawMaterialWeight; | |||
/// <summary> | |||
/// 原料类型 MW18 | |||
/// 1:液体 | |||
/// 2:膏体 | |||
/// 3:粉体 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } | |||
private ushort _mRawMaterialType; | |||
/// <summary> | |||
/// 料仓重量反馈 MD40 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } } | |||
private float _mWeightFeedback; | |||
/// <summary> | |||
/// 上限反馈 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } } | |||
private bool _mUpLimtFeedback; | |||
/// <summary> | |||
/// 下限反馈 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } } | |||
private bool _mDownLimtFeedback; | |||
/// <summary> | |||
/// 下料重量反馈 MD52 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } | |||
private float _mUpLimtWeightFeedback; | |||
/// <summary> | |||
/// 原料ID | |||
/// </summary> | |||
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialId; | |||
/// <summary> | |||
/// 原料设备执行状态 | |||
/// 1:空闲状态 | |||
/// 2:下料中 | |||
/// 3:下料完成 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } | |||
private ushort _mRecipeStatus = 1; | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
/// <summary> | |||
/// 配方模块 | |||
/// </summary> | |||
public class RecipeModel : ObservableObject | |||
{ | |||
[Newtonsoft.Json.JsonIgnore] | |||
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } | |||
private bool _mIsEnable = true; | |||
/// <summary> | |||
/// 序号 | |||
/// </summary> | |||
public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } | |||
private int _mSerialNum; | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
/// <summary> | |||
/// 配方编码 | |||
/// </summary> | |||
public string RecipCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } | |||
private string _mRecipCode; | |||
[Newtonsoft.Json.JsonIgnore] | |||
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); | |||
/// <summary> | |||
/// 原料集合 | |||
/// </summary> | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||
} | |||
} |
@@ -0,0 +1,380 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystem.View.AlarmRecordView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:AlarmRecordViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary> | |||
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" /> | |||
<convert:IsEnableConvert x:Key="isEnableConvert" /> | |||
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />--> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="22" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||
<Setter Property="CaretBrush" Value="Aqua" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="DataTextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="Foreground" Value="Red" /> | |||
<Setter Property="FontSize" Value="14" /> | |||
</Style> | |||
<ControlTemplate x:Key="ButTemplate" TargetType="Button"> | |||
<Border | |||
x:Name="br" | |||
Background="Transparent" | |||
BorderBrush="#FF19B7EC" | |||
BorderThickness="2"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<ContentControl | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
<Trigger Property="IsPressed" Value="true"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel | |||
Margin="0,8" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<DatePicker | |||
Background="Transparent" | |||
BorderBrush="#aa3aa7f3" | |||
BorderThickness="2" | |||
SelectedDate="{Binding StartDateTime}" | |||
Style="{StaticResource PickerStyle}" | |||
Text="请输入开始时间" | |||
Visibility="{Binding IsVisibility}" /> | |||
<DatePicker | |||
Margin="20,0,20,0" | |||
Background="Transparent" | |||
BorderBrush="#aa3aa7f3" | |||
BorderThickness="2" | |||
SelectedDate="{Binding EndDateTime}" | |||
Style="{StaticResource PickerStyle}" | |||
Text="请输入结束时间" | |||
Visibility="{Binding IsVisibility}" /> | |||
<Button | |||
Width="140" | |||
Height="30" | |||
Background="#FF19B7EC" | |||
Command="{Binding ControlCommand}" | |||
Content="{Binding ControlButText}" | |||
FontFamily="楷体" | |||
FontSize="18" | |||
Template="{StaticResource ButTemplate}"> | |||
<Button.Foreground> | |||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||
<GradientStop Color="#FFBB662A" /> | |||
<GradientStop Offset="1" Color="White" /> | |||
</LinearGradientBrush> | |||
</Button.Foreground> | |||
</Button> | |||
<Button | |||
Width="140" | |||
Height="30" | |||
Margin="20,0,0,0" | |||
Background="#FF19B7EC" | |||
Command="{Binding SwitchCommand}" | |||
Content="{Binding ButContent}" | |||
FontFamily="楷体" | |||
FontSize="18" | |||
Template="{StaticResource ButTemplate}"> | |||
<Button.Foreground> | |||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||
<GradientStop Color="#FFBB662A" /> | |||
<GradientStop Offset="1" Color="White" /> | |||
</LinearGradientBrush> | |||
</Button.Foreground> | |||
</Button> | |||
</StackPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="ID" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="报警日期" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="报警时间" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="报警信息" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="4" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="报警值" /> | |||
<Grid Grid.Column="5"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="报警等级" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 表格数据显示--> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<Grid> | |||
<!--#region 实时报警信息--> | |||
<ItemsControl ItemsSource="{Binding AlarmInfos}" Visibility="{Binding CurrentDataVis}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid x:Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding NumId}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Time}" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Info}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="4" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Value}" /> | |||
<Grid Grid.Column="5"> | |||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="6" | |||
BorderBrush="{StaticResource BorderSolid}" | |||
BorderThickness="1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
<!--#endregion--> | |||
<!--#region 历史报警信息--> | |||
<ItemsControl ItemsSource="{Binding HistoryAlarm}" Visibility="{Binding HistoryDataVis}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid x:Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Id}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Time}" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Info}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="4" | |||
Style="{StaticResource DataTextBlockStyle}" | |||
Text="{Binding Value}" /> | |||
<Grid Grid.Column="5"> | |||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="6" | |||
BorderBrush="{StaticResource BorderSolid}" | |||
BorderThickness="1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
<!--#endregion--> | |||
</Grid> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// AlarmRecordView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class AlarmRecordView : UserControl | |||
{ | |||
public AlarmRecordView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,122 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystem.View.ChangeDeviceNameView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
Title="ChangeDeviceNameView" | |||
Width="400" | |||
Height="200" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:ChangeDeviceNameViewModel /> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Border | |||
Name="br" | |||
Background="#FF0B2F5F" | |||
BorderThickness="1"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.5*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="请输入新设备名称:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
FontSize="16" | |||
Text="{Binding DeviceName}" /> | |||
</StackPanel> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Grid.Column="1" | |||
Width="148" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
Command="{Binding ConfirmCommand}" | |||
Content="确认" /> | |||
<Button | |||
Name="btClose" | |||
Width="148" | |||
Height="30" | |||
Command="{Binding CancleCommand}" | |||
Content="取消" /> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,31 @@ | |||
using BPASmartClient.Helper; | |||
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.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// ChangeDeviceNameView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ChangeDeviceNameView : Window | |||
{ | |||
public ChangeDeviceNameView() | |||
{ | |||
InitializeComponent(); | |||
ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose"); | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
} | |||
} | |||
} |
@@ -0,0 +1,143 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystem.View.DeviceListView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:DeviceListViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> | |||
<Style.Resources> | |||
<!-- SelectedItem with focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.HighlightBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
<!-- SelectedItem without focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.ControlBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
</Style.Resources> | |||
<!-- 设置触发器 --> | |||
<Style.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
</Style.Triggers> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid> | |||
<ListView | |||
Grid.Column="1" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding devices}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="4" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border | |||
Name="ShadowElement" | |||
Height="150" | |||
VerticalAlignment="Top" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="2" | |||
ClipToBounds="True" | |||
CornerRadius="8"> | |||
<Border.Effect> | |||
<DropShadowEffect | |||
BlurRadius="18" | |||
ShadowDepth="0" | |||
Color="#00BEFA" /> | |||
</Border.Effect> | |||
<Grid Margin="20,0,20,0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Row="0" | |||
Grid.ColumnSpan="2" | |||
VerticalAlignment="Bottom" | |||
FontSize="40" | |||
Foreground="#00BEFA" | |||
Text="{Binding DeviceName}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Grid.ColumnSpan="2" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="Aqua" | |||
Text="设备IP:" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
FontSize="14" | |||
Foreground="Aqua" | |||
Text="{Binding IpAddress}" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
Width="130" | |||
Height="30" | |||
Margin="0,0,0,10" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding IpAddress}" | |||
Content="修改设备名称" | |||
IsEnabled="{Binding IsEnable}" /> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// DeviceListView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DeviceListView : UserControl | |||
{ | |||
public DeviceListView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystem.View.HardwareStatusView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:HardwareStatusViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="硬件状态" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// HardwareStatusView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class HardwareStatusView : UserControl | |||
{ | |||
public HardwareStatusView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,251 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystem.View.MainWindow" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
Title="MainWindow" | |||
Width="1300" | |||
Height="800" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="False" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Window.DataContext> | |||
<vm:MainViewModel /> | |||
</Window.DataContext> | |||
<Border x:Name="br" Style="{DynamicResource border主窗体背景}"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="60" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 标题 --> | |||
<Grid Grid.Row="0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="300" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
Height="52" | |||
VerticalAlignment="Top" | |||
Style="{DynamicResource bordertop矩形}" /> | |||
<Border Style="{DynamicResource bordertopL}" /> | |||
<Image | |||
Margin="20,0,0,0" | |||
VerticalAlignment="Center" | |||
Style="{DynamicResource imagetop_Title}" /> | |||
<Grid Grid.Column="1"> | |||
<ListBox | |||
x:Name="lstEnt" | |||
Background="{x:Null}" | |||
BorderBrush="{x:Null}" | |||
BorderThickness="0" | |||
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}" | |||
ItemsSource="{Binding Menus}"> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<StackPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton | |||
Command="{Binding DataContext.TogglePag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding CommandParameter}" | |||
Content="{Binding MenuName}" | |||
GroupName="all" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</Grid> | |||
<StackPanel | |||
Grid.Column="4" | |||
Height="50" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Orientation="Horizontal"> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<Grid> | |||
<ToggleButton | |||
Name="tb" | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
IsChecked="{Binding UserManagement}" | |||
Style="{DynamicResource StatusBtnStyle网络连接状态}" | |||
ToolTip="用户管理" /> | |||
<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 --> | |||
<Popup | |||
AllowsTransparency="True" | |||
Focusable="False" | |||
IsOpen="{Binding IsChecked, ElementName=tb}" | |||
Placement="Bottom" | |||
PlacementTarget="{Binding ElementName=tb}" | |||
StaysOpen="False"> | |||
<Border Background="#081424" ClipToBounds="True"> | |||
<Grid Width="100" Margin="0"> | |||
<StackPanel Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding PasswordChange}" | |||
Content="密码修改" | |||
Cursor="Hand" /> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding Login}" | |||
Content="登录账号" | |||
Cursor="Hand" /> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding ExitLogin}" | |||
Content="退出登录" | |||
Cursor="Hand" /> | |||
</StackPanel> | |||
</Grid> | |||
</Border> | |||
</Popup> | |||
</Grid> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<ToggleButton | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
DataContext="{Binding IsAlarm}" | |||
Style="{DynamicResource StatusBtnStyle告警}" | |||
ToolTip="告警消息" /> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center" /> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<Button | |||
x:Name="ButClose" | |||
Grid.Column="4" | |||
Margin="10,0,20,0" | |||
VerticalAlignment="Center" | |||
Content="退出" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" | |||
ToolTip="退出程序" /> | |||
</StackPanel> | |||
</Grid> | |||
<!-- 底部窗体 --> | |||
<Grid Grid.Row="1" Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="45" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 顶部装饰 --> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border右下}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border左下}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border右上}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border左上}" /> | |||
<Grid Margin="10"> | |||
<Border Width="600" Style="{DynamicResource borderFromTitle}" /> | |||
<StackPanel Orientation="Horizontal"> | |||
<CheckBox | |||
Margin="5,0,5,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" /> | |||
</StackPanel> | |||
<TextBlock | |||
x:Name="Title" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="16" | |||
Foreground="#feffff" | |||
Text="{Binding WindowTitleName}" /> | |||
</Grid> | |||
<!--#region 底部窗体栏--> | |||
<ContentControl | |||
x:Name="contentRegion" | |||
Grid.Row="1" | |||
Content="{Binding MyWindow}" /> | |||
<!--#endregion--> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,48 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// Interaction logic for MainWindow.xaml | |||
/// </summary> | |||
public partial class MainWindow : Window | |||
{ | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
this.ButClose.Click += (o, e) => { this.Close(); }; | |||
this.MaxWidth = SystemParameters.WorkArea.Width; | |||
this.MaxHeight = SystemParameters.WorkArea.Height; | |||
this.br.MouseLeftButtonDown += (o, e) => | |||
{ | |||
if (e.ClickCount > 1) | |||
{ | |||
if (this.WindowState == WindowState.Maximized) | |||
this.WindowState = WindowState.Normal; | |||
else if (this.WindowState == WindowState.Normal) | |||
this.WindowState = WindowState.Maximized; | |||
} | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
} | |||
} | |||
} |
@@ -0,0 +1,222 @@ | |||
<Window | |||
x:Class="BPASmartClient.DosingSystem.View.NewRecipeView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
Title="NewRecipeView" | |||
Width="550" | |||
Height="450" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewRecipeViewModel /> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Border Name="br" BorderThickness="1"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" /> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="5" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--<Button | |||
Name="btClose" | |||
Margin="0,0,5,0" | |||
Padding="10,5" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
Content="X" | |||
FontSize="18" | |||
Foreground="White" /> | |||
<Border BorderBrush="#88DDDDDD" BorderThickness="0,0,0,1" />--> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="请输入配方名称:" /> | |||
<TextBlock | |||
Margin="0,0,10,0" | |||
HorizontalAlignment="Right" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="10,0,0,0" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
FontSize="16" | |||
Text="{Binding RecipeName}" /> | |||
<Button | |||
Width="148" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料" Cursor="Hand" /> | |||
<Button | |||
Width="80" | |||
Height="30" | |||
Command="{Binding SaveCommand}" | |||
Content="确认" /> | |||
<Button | |||
Name="btClose" | |||
Width="80" | |||
Height="30" | |||
Margin="7,0,0,0" | |||
Content="取消" /> | |||
</StackPanel> | |||
<ScrollViewer Grid.Row="2" Margin="5"> | |||
<ItemsControl ItemsSource="{Binding RawMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="40"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}" /> | |||
<!--<TextBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
Text="{Binding RawMaterialName}" />--> | |||
<StackPanel | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Name="tb" | |||
Grid.Column="1" | |||
Width="150" | |||
Height="29" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="{Binding RawMaterialWeight}" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Margin="0,0,8,4" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Text="mg" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Column="2" | |||
Margin="10,0,10,0" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialId}" | |||
Content="删除" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -0,0 +1,32 @@ | |||
using BPASmartClient.Helper; | |||
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.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// NewRecipeView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewRecipeView : Window | |||
{ | |||
public NewRecipeView() | |||
{ | |||
InitializeComponent(); | |||
this.btClose.Click += (o, e) => { this.Close(); }; | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
ActionManage.GetInstance.CancelRegister("CloseNewRecipeView"); | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,188 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystem.View.RecipeControlView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:RecipeControlViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> | |||
<Style.Resources> | |||
<!-- SelectedItem with focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.HighlightBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
<!-- SelectedItem without focus --> | |||
<SolidColorBrush | |||
x:Key="{x:Static SystemColors.ControlBrushKey}" | |||
Opacity=".4" | |||
Color="White" /> | |||
</Style.Resources> | |||
<!-- 设置触发器 --> | |||
<Style.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="true"> | |||
<Setter Property="Background" Value="White" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
</Style.Triggers> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding Recipes}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Height="150" VerticalAlignment="Top"> | |||
<Border | |||
Name="ShadowElement" | |||
Height="150" | |||
VerticalAlignment="Top" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="2" | |||
ClipToBounds="True" | |||
CornerRadius="8"> | |||
<Border.Effect> | |||
<DropShadowEffect | |||
BlurRadius="18" | |||
ShadowDepth="0" | |||
Color="#00BEFA" /> | |||
</Border.Effect> | |||
</Border> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="auto" /> | |||
</Grid.ColumnDefinitions> | |||
<Grid Margin="20,0,0,0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
FontSize="40" | |||
Foreground="White" | |||
Text="{Binding RecipeName}" /> | |||
<Button | |||
Grid.Row="1" | |||
Width="80" | |||
Height="30" | |||
HorizontalAlignment="Left" | |||
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipeName}" | |||
Content="配方下发" | |||
IsEnabled="{Binding IsEnable}" /> | |||
</Grid> | |||
<ListView | |||
Grid.Column="1" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="2,0,2,0" | |||
ItemsSource="{Binding RawMaterials}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="4" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<StackPanel | |||
Grid.Column="1" | |||
Height="20" | |||
Margin="20,0,0,0" | |||
VerticalAlignment="Top" | |||
Orientation="Horizontal"> | |||
<Ellipse | |||
Width="{Binding ElementName=n, Path=ActualHeight}" | |||
Margin="0,0,5,0" | |||
Fill="{Binding RecipeStatus, Converter={StaticResource StatusConverter}}" /> | |||
<TextBlock | |||
Name="n" | |||
FontSize="16" | |||
Foreground="White" | |||
Text="{Binding RawMaterialName}" /> | |||
</StackPanel> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
<StackPanel | |||
Grid.Column="2" | |||
Margin="5,0" | |||
VerticalAlignment="Center"> | |||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal"> | |||
<Ellipse | |||
Width="{Binding ElementName=tb, Path=ActualHeight}" | |||
Margin="0,0,5,0" | |||
Fill="Green" /> | |||
<TextBlock | |||
Name="tb" | |||
Foreground="#ddd" | |||
Text="准备就绪" /> | |||
</StackPanel> | |||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal"> | |||
<Ellipse | |||
Width="{Binding ElementName=tb, Path=ActualHeight}" | |||
Margin="0,0,5,0" | |||
Fill="Yellow" /> | |||
<TextBlock | |||
Name="tb1" | |||
Foreground="#ddd" | |||
Text="等待接料" /> | |||
</StackPanel> | |||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal"> | |||
<Ellipse | |||
Width="{Binding ElementName=tb, Path=ActualHeight}" | |||
Margin="0,0,5,0" | |||
Fill="Aqua" /> | |||
<TextBlock | |||
Name="tb2" | |||
Foreground="#ddd" | |||
Text="接料完成" /> | |||
</StackPanel> | |||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal"> | |||
<Ellipse | |||
Width="{Binding ElementName=tb, Path=ActualHeight}" | |||
Margin="0,0,5,0" | |||
Fill="Red" /> | |||
<TextBlock | |||
Name="tb3" | |||
Foreground="#ddd" | |||
Text="设备异常" /> | |||
</StackPanel> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// RecipeControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeControlView : UserControl | |||
{ | |||
public RecipeControlView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,246 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.DosingSystem.View.RecipeSettingsView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />--> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="buttonStyle" TargetType="Button"> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Foreground" Value="Aqua" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:RecipeSettingsViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 操作按钮--> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding NewRecipe}" | |||
Content="新建配方" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
IcoText="" | |||
Style="{StaticResource NewButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SaveRecipe}" | |||
Content="保存配方" | |||
EnableColor="#FFB7B7B7" | |||
FontSize="17" | |||
Foreground="Aqua" | |||
IcoText="" | |||
IsEnabled="True" | |||
Style="{StaticResource NewButtonStyle}" /> | |||
</StackPanel> | |||
<!--#endregion--> | |||
<!--#region 表格标题栏设置--> | |||
<!--<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="序号" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="配方名称" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="编码" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="结束时间" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Grid Grid.Column="5"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="制作状态" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="6" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="完成时间" /> | |||
</Grid>--> | |||
<!--#endregion--> | |||
<!--#region 表格数据显示--> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding Recipes}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton Background="Transparent" GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding SerialNum}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Left" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipeName}" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipCode}" /> | |||
<!--<Grid Grid.Column="3"> | |||
<Button | |||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="编辑" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid>--> | |||
<Grid Grid.Column="5"> | |||
<Button | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="详情" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
<Grid Grid.Column="6"> | |||
<Button | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="删除" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
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.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// RecipeSettingsView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeSettingsView : UserControl | |||
{ | |||
public RecipeSettingsView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class AlarmRecordViewModel : ObservableObject | |||
{ | |||
} | |||
} |
@@ -0,0 +1,71 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.DosingSystem.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class ChangeDeviceNameViewModel : ObservableObject | |||
{ | |||
public ChangeDeviceNameViewModel() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is string str) IpAddress = str; | |||
}), "ChangeDeviceNameViewOpen"); | |||
CancleCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); | |||
ConfirmCommand = new RelayCommand(() => | |||
{ | |||
if (string.IsNullOrEmpty(DeviceName)) | |||
{ | |||
ErrorInfo = "设备名称不能为空"; | |||
return; | |||
} | |||
int index = Array.FindIndex(DeviceListViewModel.devices.ToArray(), p => p.IpAddress == IpAddress); | |||
if (index >= 0 && index < DeviceListViewModel.devices.Count) | |||
{ | |||
if (DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null) | |||
ErrorInfo = "设备名称已存在"; | |||
else | |||
{ | |||
NewRecipeViewModel.RawMaterialNames.Remove(DeviceListViewModel.devices.ElementAt(index).DeviceName); | |||
NewRecipeViewModel.RawMaterialNames.Add(DeviceName); | |||
DeviceListViewModel.devices.ElementAt(index).DeviceName = DeviceName; | |||
DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称 | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
} | |||
} | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); | |||
} | |||
} | |||
}); | |||
} | |||
private static string IpAddress = string.Empty; | |||
public RelayCommand ConfirmCommand { get; set; } | |||
public RelayCommand CancleCommand { get; set; } | |||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
private string _mErrorInfo; | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.DosingSystem.View; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class DeviceListViewModel : ObservableObject | |||
{ | |||
public DeviceListViewModel() | |||
{ | |||
ChangeNameCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string str) | |||
{ | |||
ChangeDeviceNameView cdn = new ChangeDeviceNameView(); | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str); | |||
cdn.ShowDialog(); | |||
} | |||
}); | |||
} | |||
public RelayCommand<object> ChangeNameCommand { get; set; } | |||
public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||
} | |||
public class Devices : ObservableObject | |||
{ | |||
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } } | |||
private string _mIpAddress; | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class HardwareStatusViewModel : ObservableObject | |||
{ | |||
} | |||
} |
@@ -0,0 +1,161 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.DosingSystem.Model; | |||
using Newtonsoft.Json; | |||
using System.IO; | |||
using System.Reflection; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class MainViewModel : ObservableObject | |||
{ | |||
//ObservableCollection<ActionMenu> menus = new ObservableCollection<ActionMenu>(); | |||
//private Permission _permission; | |||
//public Permission permission | |||
//{ | |||
// get { return _permission; } | |||
// set | |||
// { | |||
// var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList(); | |||
// if (res != null && res.Count > 0) | |||
// { | |||
// Menus.Clear(); | |||
// res.ForEach((item) => { Menus.Add(item); }); | |||
// } | |||
// _permission = value; | |||
// } | |||
//} | |||
public MainViewModel() | |||
{ | |||
//Json<LocaPar>.Read(); | |||
TogglePag = new RelayCommand<object>(DoNavChanged); | |||
Login = new RelayCommand(() => { DoNavChanged("BPASmartClient.DosingSystem.View.AdminstratorsView_用户登录"); UserManagement = false; }); | |||
PasswordChange = new RelayCommand(() => | |||
{ | |||
//DoNavChanged("PasswordChangeView.密码修改"); | |||
UserManagement = false; | |||
}); | |||
ExitLogin = new RelayCommand(() => | |||
{ | |||
//SystemUtils.ShowScreenKeyboard(); | |||
//DoNavChanged("LoginView.退出登录"); | |||
UserManagement = false; | |||
}); | |||
//Config.GetInstance.Init(); | |||
LoginRegister(); | |||
MenuInit(); | |||
//permission = Permission.管理员; | |||
//if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); | |||
DeviceInquire.GetInstance.Init(); | |||
} | |||
private void LoginRegister() | |||
{ | |||
ActionManage.GetInstance.Register(new Func<object, object>((o) => | |||
{ | |||
//if (o != null && o is string str) | |||
//{ | |||
// var strs = str.Split("-="); | |||
// if (strs != null && strs.Length == 3) | |||
// { | |||
// var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]); | |||
// if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString()) | |||
// { | |||
// permission = us.permission; | |||
// return string.Empty; | |||
// } | |||
// } | |||
//} | |||
return "用户名或密码错误"; | |||
}), "LoginBPASmartClient.DosingSystem"); | |||
} | |||
private void MenuInit() | |||
{ | |||
//menus.Add(new ActionMenu() | |||
//{ | |||
// MenuName = "配方设置", | |||
// CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置", | |||
// permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||
//}); | |||
//menus.Add(new ActionMenu() | |||
//{ | |||
// MenuName = "设备列表", | |||
// CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表", | |||
// permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||
//}); | |||
//menus.Add(new ActionMenu() | |||
//{ | |||
// MenuName = "硬件状态", | |||
// CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态", | |||
// permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
//}); | |||
//menus.Add(new ActionMenu() | |||
//{ | |||
// MenuName = "报警记录", | |||
// CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录", | |||
// permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
//}); | |||
//menus.Add(new ActionMenu() | |||
//{ | |||
// MenuName = "配方下发", | |||
// CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制", | |||
// permission = new Permission[] { Permission.管理员, Permission.操作员 }, | |||
//}); | |||
} | |||
public void DoNavChanged(object obj) | |||
{ | |||
if (obj != null && obj is string stobj) | |||
{ | |||
var strs = stobj.Split('_'); | |||
if (strs != null && strs.Length == 2) | |||
{ | |||
Type type; | |||
if (!stobj.Contains("BPASmartClient.DosingSystem")) | |||
{ | |||
type = Assembly.Load("BPASmartClient.CustomResource").GetType(strs[0]); | |||
} | |||
else type = Type.GetType(strs[0]); | |||
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null); | |||
if (res != null && res is FrameworkElement fe) MyWindow = fe; | |||
WindowTitleName = strs[1]; | |||
} | |||
} | |||
} | |||
public RelayCommand<object> TogglePag { get; set; } | |||
public RelayCommand Login { get; set; } | |||
public RelayCommand PasswordChange { get; set; } | |||
public RelayCommand ExitLogin { get; set; } | |||
public ObservableCollection<ActionMenu> Menus { get; set; } = new ObservableCollection<ActionMenu>(); | |||
public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } } | |||
private FrameworkElement _mMyWindow; | |||
public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } } | |||
private string _mWindowTitleName; | |||
public bool UserManagement { get { return _mUserManagement; } set { _mUserManagement = value; OnPropertyChanged(); } } | |||
private bool _mUserManagement; | |||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||
} | |||
} |
@@ -0,0 +1,131 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.DosingSystem.Model; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class NewRecipeViewModel : ObservableObject | |||
{ | |||
public NewRecipeViewModel() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is RecipeModel rm) | |||
{ | |||
RecipeName = rm.RecipeName; | |||
foreach (var item in rm.RawMaterials) | |||
{ | |||
RawMaterials.Add(item); | |||
} | |||
RecipCode = rm.RecipCode; | |||
} | |||
}), "Details"); | |||
AddCommand = new RelayCommand(() => | |||
{ | |||
p: | |||
string guid = Guid.NewGuid().ToString(); | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | |||
{ | |||
RawMaterials.Add(new RawMaterialModel() | |||
{ | |||
RawMaterialId = guid | |||
}); | |||
} | |||
else goto p; | |||
}); | |||
RemoveCommand = new RelayCommand<object>((obj) => | |||
{ | |||
if (obj is string rm) | |||
{ | |||
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm); | |||
if (res != null) RawMaterials.Remove(res); | |||
} | |||
}); | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
for (int i = 0; i < RawMaterials.Count; i++) | |||
{ | |||
var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); | |||
if (res != null) RawMaterials.ElementAt(i).DeviceIp = res.IpAddress; | |||
} | |||
if (RecipCode.Length <= 0) | |||
{ | |||
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName); | |||
if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count) | |||
{ | |||
ErrorInfo = "该配方已存在,请重新输入"; | |||
} | |||
else | |||
{ | |||
AddRecipes(); | |||
} | |||
} | |||
else | |||
{ | |||
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipCode); | |||
if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(res).RecipeName = RecipeName; | |||
Json<LocaPar>.Data.Recipes.ElementAt(res).RawMaterials.Clear(); | |||
foreach (var item in RawMaterials) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(res).RawMaterials.Add(item); | |||
} | |||
} | |||
} | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
}); | |||
} | |||
private void AddRecipes() | |||
{ | |||
string date = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); | |||
var dates = date.Split("-").ToList(); | |||
StringBuilder sb = new StringBuilder(); | |||
dates?.ForEach((item) => { sb.Append(item); }); | |||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||
{ | |||
SerialNum = Json<LocaPar>.Data.Recipes.Count + 1, | |||
RawMaterials = RawMaterials, | |||
RecipCode = sb.ToString(), | |||
RecipeName = RecipeName, | |||
}); | |||
} | |||
static NewRecipeViewModel() | |||
{ | |||
RawMaterialNames.Clear(); | |||
} | |||
private string RecipCode = string.Empty; | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
private string _mErrorInfo; | |||
public RelayCommand AddCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
public RelayCommand SaveCommand { get; set; } | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||
public static ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | |||
} | |||
} |
@@ -0,0 +1,92 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.DosingSystem.Model; | |||
using System.Threading; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class RecipeControlViewModel : ObservableObject | |||
{ | |||
ConcurrentQueue<string> devices = new ConcurrentQueue<string>(); | |||
public RecipeControlViewModel() | |||
{ | |||
Recipes = Json<LocaPar>.Data.Recipes; | |||
StartCommand = new RelayCommand<object>((o) => | |||
{ | |||
//if (o != null && o is string deviceName) | |||
//{ | |||
// int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName); | |||
// if (index >= 0 && index < Recipes.Count) | |||
// { | |||
// Recipes.ElementAt(index).IsEnable = false; | |||
// } | |||
// MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); | |||
// devices.Enqueue(deviceName); | |||
//} | |||
MessageLog.GetInstance.ShowUserLog($"下发工单 { Guid.NewGuid().ToString()}"); | |||
}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (devices.Count > 0) | |||
{ | |||
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0)); | |||
if (index >= 0 && index < Recipes.Count) | |||
{ | |||
Recipes.ElementAt(index).Are.Reset(); | |||
Recipes.ElementAt(index).IsEnable = false; | |||
foreach (var item in Recipes.ElementAt(index).RawMaterials) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动写入 | |||
} | |||
Recipes.ElementAt(index).Are.WaitOne(); | |||
devices.TryDequeue(out string deviceName); | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "启动配发下发"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < Recipes.Count; i++) | |||
{ | |||
for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; | |||
Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; | |||
var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); | |||
if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count) | |||
{ | |||
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset(); | |||
} | |||
Recipes.ElementAt(i).IsEnable = true; | |||
Recipes.ElementAt(i).Are.Set(); | |||
} | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "RecipeControlViewModelStatusInquire"); | |||
} | |||
public RelayCommand<object> StartCommand { get; set; } | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } | |||
} | |||
} |
@@ -0,0 +1,63 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.DosingSystem.Model; | |||
using BPASmartClient.DosingSystem.View; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public class RecipeSettingsViewModel : ObservableObject | |||
{ | |||
public RecipeSettingsViewModel() | |||
{ | |||
//Json<LocaPar>.Read(); | |||
Recipes = Json<LocaPar>.Data.Recipes; | |||
NewRecipe = new Action(() => | |||
{ | |||
NewRecipeView nrv = new NewRecipeView(); | |||
nrv.ShowDialog(); | |||
}); | |||
SaveRecipe = new Action(() => { Json<LocaPar>.Save(); }); | |||
RemoveCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o is string str) | |||
{ | |||
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); | |||
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res); | |||
} | |||
}); | |||
DetailsCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string str) | |||
{ | |||
ActionManage.GetInstance.CancelRegister("Details"); | |||
NewRecipeView nrv = new NewRecipeView(); | |||
ActionManage.GetInstance.Send("Details", Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str)); | |||
nrv.ShowDialog(); | |||
} | |||
}); | |||
} | |||
public Action NewRecipe { get; set; } | |||
public Action SaveRecipe { get; set; } | |||
public RelayCommand<object> EditCommand { get; set; } | |||
public RelayCommand<object> DetailsCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } | |||
} | |||
} |
@@ -0,0 +1,79 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | |||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | |||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | |||
<security> | |||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | |||
<!-- UAC 清单选项 | |||
如果想要更改 Windows 用户帐户控制级别,请使用 | |||
以下节点之一替换 requestedExecutionLevel 节点。 | |||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | |||
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。 | |||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此 | |||
元素。 | |||
--> | |||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |||
</requestedPrivileges> | |||
</security> | |||
</trustInfo> | |||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | |||
<application> | |||
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的 | |||
Windows 版本的列表。取消评论适当的元素, | |||
Windows 将自动选择最兼容的环境。 --> | |||
<!-- Windows Vista --> | |||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> | |||
<!-- Windows 7 --> | |||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> | |||
<!-- Windows 8 --> | |||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> | |||
<!-- Windows 8.1 --> | |||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> | |||
<!-- Windows 10 --> | |||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> | |||
</application> | |||
</compatibility> | |||
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行 | |||
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需 | |||
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应 | |||
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。 | |||
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation --> | |||
<!-- | |||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | |||
<windowsSettings> | |||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | |||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware> | |||
</windowsSettings> | |||
</application> | |||
--> | |||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) --> | |||
<!-- | |||
<dependency> | |||
<dependentAssembly> | |||
<assemblyIdentity | |||
type="win32" | |||
name="Microsoft.Windows.Common-Controls" | |||
version="6.0.0.0" | |||
processorArchitecture="*" | |||
publicKeyToken="6595b64144ccf1df" | |||
language="*" | |||
/> | |||
</dependentAssembly> | |||
</dependency> | |||
--> | |||
</assembly> |
@@ -0,0 +1,13 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.6" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,11 +1,6 @@ | |||
using Microsoft.AspNetCore.SignalR.Client; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace FryPot_DosingSystem.Helper | |||
namespace BPASmartClient.HubHelper | |||
{ | |||
public class HubHelper | |||
{ | |||
@@ -13,17 +8,18 @@ namespace FryPot_DosingSystem.Helper | |||
public static HubHelper GetInstance => _Instance ?? (_Instance = new HubHelper()); | |||
private HubHelper() { } | |||
public Action<object> Report { get; set; } | |||
public Action<object> Upstreamrequest { get; set; } | |||
HubConnection hubConnection; | |||
public void Connect() | |||
public void Connect(string ip, int port) | |||
{ | |||
hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl("http://localhost:5175/personhub").Build();//连接 | |||
hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接 | |||
hubConnection.On<object>("Report", (s) => { Report?.Invoke(s); }); | |||
hubConnection.On<string>("", (s) => | |||
{ | |||
//注册接收消息的委托 | |||
}); | |||
hubConnection.On<object>("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); }); | |||
try | |||
{ | |||
@@ -40,7 +36,5 @@ namespace FryPot_DosingSystem.Helper | |||
hubConnection.SendAsync("Send", info); | |||
} | |||
} | |||
} | |||
} |
@@ -5,9 +5,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<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" /> | |||
<PackageReference Include="MQTTnet" Version="3.1.2" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -1,76 +1,258 @@ | |||
using BPA.MQTTClient; | |||
using Microsoft.Extensions.Configuration; | |||
//using BPA.MQTTClient; | |||
//using Microsoft.Extensions.Configuration; | |||
//using MQTTnet.Client; | |||
//using MQTTnet.Client; | |||
//using MQTTnet; | |||
//using MQTTnet.Client; | |||
//using MQTTnet.Client.Options; | |||
//using MQTTnet.Client.Receiving; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using MQTTnet; | |||
using MQTTnet.Client; | |||
using MQTTnet.Client.Receiving; | |||
using MQTTnet.Client.Options; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MQTT | |||
{ | |||
public class MQTTProxy | |||
{ | |||
private IMqttClient client; | |||
IMqttClientOptions options; | |||
public Action<string> MessageRecive { get; set; } | |||
public Action Connected { get; set; } | |||
public Action LostConnect { get; set; } | |||
public bool IsConnected { get; set; } | |||
private IMqttClient client; | |||
Action UseDisconnectedAction; | |||
public async void Connect(string UserName, string pass, string IP, int port, string clientID) | |||
{ | |||
options = new MqttClientOptionsBuilder().WithTcpServer(IP, port).WithClientId(clientID).WithCredentials(UserName, pass).Build(); | |||
client = new MqttFactory().CreateMqttClient(); | |||
client.UseDisconnectedHandler(c => | |||
{ | |||
if (UseDisconnectedAction == null) | |||
{ | |||
Reconnect();//注册UseDisconnectedAction委托 | |||
UseDisconnectedAction();//执行委托 | |||
} | |||
}).UseApplicationMessageReceivedHandler(c => | |||
{ | |||
MessageRecive?.Invoke(Encoding.UTF8.GetString(c.ApplicationMessage.Payload)); | |||
}).UseConnectedHandler((e) => | |||
{ | |||
//MessageLog.GetInstance.Show($"连接成功"); | |||
}); | |||
try | |||
{ | |||
await client.ConnectAsync(options); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.Message); | |||
MessageLog.GetInstance.Show("mqtt连接失败!重连执行中"); | |||
} | |||
if (client.IsConnected) | |||
{ | |||
MessageLog.GetInstance.Show("MQTT连接成功!"); | |||
Connected?.Invoke(); | |||
} | |||
public void Connect(string userName, string Password, string ip, int port, string clientId) | |||
} | |||
private void Reconnect() | |||
{ | |||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); | |||
configurationBuilder.AddMqttClientHostedService(p => | |||
UseDisconnectedAction = new Action(() => | |||
{ | |||
p.Server = ip; | |||
p.Port = port; | |||
//p.UserName = "rafiul"; | |||
//p.Password = "12345678"; | |||
p.UserName = userName; | |||
p.Password = Password; | |||
p.mqttClientConnectedHandlerDelegate = new MQTTnet.Client.Connecting.MqttClientConnectedHandlerDelegate(e => | |||
MessageLog.GetInstance.ShowEx("MQTT 断开连接"); | |||
Thread.Sleep(2000); | |||
while (!UniversalHelper.GetInstance().GetNetworkState()) | |||
{ | |||
IsConnected = true; | |||
Connected?.Invoke(); | |||
}); | |||
//p.mqttClientDisconnectedHandlerDelegate = new MQTTnet.Client.Disconnecting.MqttClientDisconnectedHandlerDelegate(e => | |||
//{ | |||
// IsConnected = false; | |||
// LostConnect?.Invoke(); | |||
//}); | |||
p.ConnectedResult += (s, e) => | |||
Thread.Sleep(2000); | |||
} | |||
bool ErrorFlag = false; | |||
while (!client.IsConnected) | |||
{ | |||
client = e; | |||
}; | |||
p.MqttApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(e => | |||
try | |||
{ | |||
MessageLog.GetInstance.Show($"重连中"); | |||
client.ConnectAsync(options).Wait(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (!ErrorFlag) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
ErrorFlag = true; | |||
} | |||
} | |||
Thread.Sleep(3000); | |||
} | |||
if (client.IsConnected) | |||
{ | |||
MessageRecive?.Invoke(Encoding.Default.GetString(e.ApplicationMessage.Payload)); | |||
}); | |||
MessageLog.GetInstance.Show("MQTT重连成功!"); | |||
LostConnect?.Invoke(); | |||
} | |||
UseDisconnectedAction = null; | |||
}); | |||
} | |||
public void CloseConnect() | |||
/// <summary> | |||
/// Mqtt 订阅 | |||
/// </summary> | |||
/// <param name="topic">需要订阅的主题</param> | |||
public async void MqttSubscriptionAsync(string topic) | |||
{ | |||
client.Dispose(); | |||
if (client != null && client.IsConnected) | |||
{ | |||
try | |||
{ | |||
var result = await client.SubscribeAsync(new MqttTopicFilterBuilder().WithTopic(topic).WithExactlyOnceQoS().Build()); | |||
} | |||
catch { } | |||
} | |||
} | |||
public async void Publish(string topic, string content) | |||
/// <summary> | |||
/// Mqtt 订阅 | |||
/// </summary> | |||
/// <param name="topic">需要订阅的主题</param> | |||
public async void Subscrib(params string[] topic) | |||
{ | |||
if (client.IsConnected) | |||
await client.PublishAsync(topic, content); | |||
if (client != null && client.IsConnected) | |||
{ | |||
try | |||
{ | |||
foreach (var item in topic) | |||
{ | |||
var result = await client.SubscribeAsync(new MqttTopicFilterBuilder().WithTopic(item).WithExactlyOnceQoS().Build()); | |||
} | |||
} | |||
catch { } | |||
} | |||
} | |||
public async void Subscrib(params string[] topics) | |||
/// <summary> | |||
/// Mqtt 发布 | |||
/// </summary> | |||
/// <param name="topic">需要发布的主题</param> | |||
/// <param name="content">需要发布的内容</param> | |||
public async void Publish(string topic, string content) | |||
{ | |||
foreach (var topic in topics) | |||
if (client != null && client.IsConnected) | |||
{ | |||
await client.SubscribeAsync(new MqttTopicFilter() { Topic = topic, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); | |||
var msg = new MqttApplicationMessageBuilder().WithTopic(topic).WithPayload(content).WithExactlyOnceQoS().Build(); | |||
try | |||
{ | |||
var result = await client.PublishAsync(msg); | |||
} | |||
catch { } | |||
} | |||
} | |||
//public Action<string> MessageRecive { get; set; } | |||
//public Action Connected { get; set; } | |||
//public Action LostConnect { get; set; } | |||
//public bool IsConnected { get; set; } | |||
//private IMqttClient client; | |||
//public void Connect(string userName, string Password, string ip, int port, string clientId) | |||
//{ | |||
// IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); | |||
// configurationBuilder.AddMqttClientHostedService(p => | |||
// { | |||
// p.Server = ip; | |||
// p.Port = port; | |||
// //p.UserName = "rafiul"; | |||
// //p.Password = "12345678"; | |||
// p.UserName = userName; | |||
// p.Password = Password; | |||
// p.mqttClientConnectedHandlerDelegate = new MQTTnet.Client.Connecting.MqttClientConnectedHandlerDelegate(e => | |||
// { | |||
// IsConnected = true; | |||
// Connected?.Invoke(); | |||
// }); | |||
// //p.mqttClientDisconnectedHandlerDelegate = new MQTTnet.Client.Disconnecting.MqttClientDisconnectedHandlerDelegate(e => | |||
// //{ | |||
// // IsConnected = false; | |||
// // LostConnect?.Invoke(); | |||
// //}); | |||
// p.ConnectedResult += (s, e) => | |||
// { | |||
// client = e; | |||
// }; | |||
// p.MqttApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(e => | |||
// { | |||
// MessageRecive?.Invoke(Encoding.Default.GetString(e.ApplicationMessage.Payload)); | |||
// }); | |||
// }); | |||
//} | |||
public void CloseConnect() | |||
{ | |||
client.Dispose(); | |||
} | |||
//public async void Publish(string topic, string content) | |||
//{ | |||
// if (client.IsConnected) | |||
// await client.PublishAsync(topic, content); | |||
//} | |||
//public async void Subscrib(params string[] topics) | |||
//{ | |||
// foreach (var topic in topics) | |||
// { | |||
// await client.SubscribeAsync(new MqttTopicFilter() { Topic = topic, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); | |||
// } | |||
//} | |||
} | |||
} |
@@ -17,7 +17,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
</ItemGroup> | |||
@@ -115,10 +115,10 @@ namespace BPASmartClient.MorkS | |||
WriteRecipeBoms(); | |||
} | |||
}); | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); | |||
@@ -362,7 +362,7 @@ namespace BPASmartClient.MorkS | |||
{ | |||
if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||
{ | |||
DeviceProcessLogShow($"位置:={loc},检测开关1:{alarm.Supply1_LossBowl},检测开关1:{alarm.Supply2_LossBowl}"); | |||
//DeviceProcessLogShow($"位置:={loc},检测开关1:{alarm.Supply1_LossBowl},检测开关1:{alarm.Supply2_LossBowl}"); | |||
if (loc == 10 && !alarm.Supply1_LossBowl) | |||
{ | |||
BowLoc = loc; | |||
@@ -375,10 +375,14 @@ namespace BPASmartClient.MorkS | |||
} | |||
} | |||
} | |||
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) | |||
if (BowLoc >= 10 && BowLoc <= 11) | |||
{ | |||
orderLocInfo.Loc = BowLoc; | |||
BowlControl(orderLocInfo); | |||
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) | |||
{ | |||
orderLocInfo.Loc = BowLoc; | |||
BowlControl(orderLocInfo); | |||
} | |||
} | |||
} | |||
} | |||
@@ -597,9 +601,13 @@ namespace BPASmartClient.MorkS | |||
int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; | |||
int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count; | |||
int index = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId); | |||
bool isok = index >= 0 && index < mORKS.CookNoodlesComplete.Length && mORKS.CookNoodlesComplete[index]; | |||
mORKS.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKS.TurntableLocLists.Count > 0 && !mORKS.TurntableLowerLimit, 4); | |||
mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); | |||
//mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); | |||
mORKS.RobotTaskInterlock = isok && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); | |||
} | |||
@@ -34,15 +34,6 @@ namespace BPASmartClient.DosingSystem | |||
else | |||
mv.Close(); | |||
//MainWindow mw = new MainWindow(); | |||
//LoginView lv = new LoginView(); | |||
//var res = lv.ShowDialog(); | |||
//if (res != null && res == true) | |||
// mw.Show(); | |||
//else | |||
// mw.Close(); | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
@@ -15,7 +15,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.46" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
@@ -16,7 +16,6 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.6" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="NModbus" Version="3.0.72" /> | |||
</ItemGroup> | |||
@@ -25,6 +24,7 @@ | |||
<ProjectReference Include="..\BPASmartClient.AGV\BPASmartClient.AGV.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.HubHelper\BPASmartClient.HubHelper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
</ItemGroup> | |||
@@ -1,4 +1,7 @@ | |||
using System; | |||
using BPASmartClient.AGV.Feedback; | |||
using BPASmartClient.HubHelper; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
@@ -27,7 +30,19 @@ namespace FryPot_DosingSystem.View | |||
{ | |||
InitializeComponent(); | |||
Initialize(); | |||
HubHelper.GetInstance.Report = new Action<object>((o) => | |||
{ | |||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(o.ToString()); | |||
}); | |||
HubHelper.GetInstance.Upstreamrequest = new Action<object>((o) => | |||
{ | |||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(o.ToString()); | |||
}); | |||
HubHelper.GetInstance.Connect("192.168.1.56", 8089); | |||
} | |||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) | |||
{ | |||
base.OnMouseLeftButtonDown(e); | |||
@@ -40,7 +55,6 @@ namespace FryPot_DosingSystem.View | |||
{ | |||
this.DragMove(); | |||
} | |||
} | |||
} | |||
@@ -59,6 +73,6 @@ namespace FryPot_DosingSystem.View | |||
} | |||
} | |||
} |
@@ -1,25 +0,0 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<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> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | |||
<ProjectReference Include="..\Lebai.SDK\Lebai.SDK.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,644 +0,0 @@ | |||
using BPA.Message; | |||
using BPA.Message.Enum; | |||
using BPA.Message.IOT; | |||
using BPASmartClient.Device; | |||
using BPASmartClient.DRCoffee; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.GSIceCream; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Lebai; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.SCChip; | |||
using Robotc; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.MORKIC | |||
{ | |||
/* | |||
* 冰淇淋咖啡机组合套装 | |||
* 物料位置: | |||
* 1:冰淇料 | |||
* 2:冰淇淋杯 | |||
* 5:咖啡 | |||
* 6:咖啡杯 | |||
*/ | |||
public class Control_MORKIC : BaseDevice | |||
{ | |||
//咖啡机主控程序 | |||
private CoffeeMachine coffeeMachine; | |||
//单片机主控程序 | |||
private ICChipMachine icchipMachine; | |||
//广绅单口冰淇淋机 | |||
private IceCreamMachine iceCreamMachine; | |||
//物料存放位置 | |||
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
/// <summary> | |||
/// 获取乐百机器人的数据 | |||
/// </summary> | |||
SignalResult lebai = new SignalResult(); | |||
/// <summary> | |||
/// 咖啡位置是否有东西 | |||
/// </summary> | |||
private bool IsCoffeeMake = false; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
private bool working = false; | |||
private bool IceIsOK = true; | |||
public void ConnectOk() | |||
{ | |||
} | |||
/// <summary> | |||
/// 当前正在制作咖啡 | |||
/// </summary> | |||
SimOrderData MakeCoffeeOrder = new SimOrderData(); | |||
/// <summary> | |||
/// 咖啡订单队列 | |||
/// </summary> | |||
ConcurrentQueue<SimOrderData> morkOrderPushesCoffee = new ConcurrentQueue<SimOrderData>(); | |||
/// <summary> | |||
/// 冰淇淋订单队列 | |||
/// </summary> | |||
ConcurrentQueue<SimOrderData> morkOrderPushesIceCream = new ConcurrentQueue<SimOrderData>(); | |||
/// <summary> | |||
/// 等待取餐的订单,只有一个 | |||
/// </summary> | |||
ConcurrentQueue<SimOrderData> WaitTakeMealOrder = new ConcurrentQueue<SimOrderData>(); | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
if (s is DrCoffeeDrinksCode cf) | |||
{ | |||
DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() }); | |||
} | |||
else if (s is Dictionary<string, string> ms) | |||
{ | |||
if (ms.ContainsKey("Button")) | |||
{ | |||
switch (ms["Button"]) | |||
{ | |||
case "启动示教": | |||
LebaiRobot.GetInstance.StartTeachMode(); | |||
break; | |||
case "停止示教": | |||
LebaiRobot.GetInstance.EndtTeachMode(); | |||
break; | |||
case "启动机器人": | |||
LebaiRobot.GetInstance.StartRobot(); | |||
break; | |||
case "急停": | |||
LebaiRobot.GetInstance.EStopRobot(); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (MakeCoffeeOrder != null) | |||
MakeCoffeeOrder.OrderStatus = 1; | |||
}); | |||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); | |||
//一系列外围基础配置 | |||
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value; | |||
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value; | |||
var com_IceCream = config.AppSettings.Settings["COM_IceCream"].Value; | |||
var baud_IceCream = config.AppSettings.Settings["BAUD_IceCream"].Value; | |||
var iceCreamCXBThreshold = int.Parse(config.AppSettings.Settings["IceCream_CXB_Threshold"].Value); | |||
var com_ICChip = config.AppSettings.Settings["COM_ICChip"].Value; | |||
var baud_ICChip = config.AppSettings.Settings["BAUD_IChip"].Value; | |||
if (iceCreamCXBThreshold > 0) | |||
{ | |||
//设置冰淇淋成型比 | |||
MorkIStatus.GetInstance().CXB_Threshold = (byte)iceCreamCXBThreshold; | |||
} | |||
//咖啡机创建 | |||
coffeeMachine = new CoffeeMachine(); | |||
//单片机机创建 | |||
icchipMachine = new ICChipMachine(); | |||
//冰淇淋机创建 | |||
iceCreamMachine = new IceCreamMachine(); | |||
Main(); | |||
ReadRobotData(); | |||
OrderMake(); | |||
} | |||
private int NoOrderTime = 0; | |||
public override DeviceClientType DeviceType => DeviceClientType.MORKT; | |||
//订单制作 | |||
public void OrderMake() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (IsHealth && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake)) | |||
{ | |||
working = true; NoOrderTime = 0; | |||
//1.有咖啡订单 取杯去制作 | |||
if (!IsCoffeeMake)//位置无杯子 | |||
{ | |||
if (morkOrderPushesCoffee.Count > 0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder)) | |||
{ | |||
IsCoffeeMake = true; MakeCoffeeOrder = simOrder; | |||
MessageLog.GetInstance.Show($"开始制作 [咖啡] 订单[{simOrder.morkOrder.SortNum}]"); | |||
DoCoffee(simOrder); | |||
} | |||
} | |||
if (!LebaiRobot.GetInstance.GetInput())//取餐口是否有餐饮 | |||
{ | |||
//取餐位的订单完成 | |||
if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
//1.制作冰淇淋 | |||
if (morkOrderPushesIceCream.Count > 0 && MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if (MorkIStatus.GetInstance().CXB >= 86 && morkOrderPushesIceCream.Count > 0)//成型比大于80 我才会制作 | |||
{ | |||
if (LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if (IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口"); | |||
IceIsOK = false; | |||
} | |||
else if (morkOrderPushesIceCream.TryDequeue(out SimOrderData order)) | |||
{ | |||
IceIsOK = true; | |||
MessageLog.GetInstance.Show($"开始制作 [冰淇淋] 订单[{order.morkOrder.SortNum}]"); | |||
DoIceCream(order); | |||
} | |||
} | |||
//2.取咖啡到取餐口 | |||
if (IsCoffeeMake) | |||
{ | |||
if (MakeCoffeeOrder != null && MakeCoffeeOrder.OrderStatus == 1) | |||
{ | |||
MessageLog.GetInstance.Show($"将咖啡移动到取餐位 [咖啡] 订单[{MakeCoffeeOrder.morkOrder.SortNum}]"); | |||
DoCoffeeQC(MakeCoffeeOrder); | |||
MakeCoffeeOrder = null; | |||
IsCoffeeMake = false; | |||
} | |||
} | |||
} | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
if (IsHealth == false && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake)) | |||
{ | |||
MessageLog.GetInstance.Show($"机器连接问题 订单,不允许制作,请检查设备连接后尝试," + | |||
$"乐白:{LebaiRobot.GetInstance.IsConnected}咖啡机:{MorkIStatus.GetInstance().CanDo}单片机:{ChipStatus.GetInstance().CanDo}"); | |||
if (LebaiRobot.GetInstance.IsConnected && IsCoffeeMake && !LebaiRobot.GetInstance.GetInput())//乐白有订单 | |||
{ | |||
MessageLog.GetInstance.Show($"将咖啡移动到取餐位 [咖啡] 订单[{MakeCoffeeOrder.morkOrder.SortNum}]"); | |||
DoCoffeeQC(MakeCoffeeOrder); | |||
MakeCoffeeOrder = null; | |||
IsCoffeeMake = false; | |||
} | |||
} | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
coffeeMachine.Start(); | |||
//单片机开启主线程 | |||
icchipMachine.Start(); | |||
//冰淇淋机开启主线程 | |||
iceCreamMachine.Start(); | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
//ThreadManage.GetInstance().StartLong(new Action(() => | |||
//{ | |||
// GeneralConfig.Healthy = | |||
// LebaiRobot.GetInstance.IsConnected && | |||
// MorkCStatus.GetInstance().CanDo && | |||
// ChipStatus.GetInstance().CanDo; | |||
// //GeneralConfig.Healthy = true; | |||
// Thread.Sleep(100); | |||
//}), "MORK-IC心跳刷新"); | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
while (!LebaiRobot.GetInstance.IsConnected) | |||
{ | |||
Thread.Sleep(10); | |||
} | |||
//LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_欢迎); | |||
}), "MORK-IC欢迎"); | |||
} | |||
public void DataParse<T>(T order) | |||
{ | |||
if (order is MorkOrderPush morkOrderPush) | |||
{ | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
string loc_coffe = string.Empty; | |||
string loc_cup = string.Empty; | |||
#region 订单分类 | |||
//遍历物料 | |||
foreach (var item in morkOrderPush.GoodBatchings) | |||
{ | |||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
if (res != null) | |||
{ | |||
//验证商品是咖啡还是冰淇淋 | |||
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) | |||
{ | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
//获取主料和容器位置 | |||
switch (batchings[res.BatchingLoc].BatchingClass) | |||
{ | |||
case BATCHING_CLASS.HOLDER: | |||
loc_cup = res.BatchingLoc; | |||
break; | |||
case BATCHING_CLASS.MAIN_MATERIAL: | |||
loc_coffe = res.BatchingLoc; | |||
break; | |||
} | |||
} | |||
} | |||
//根据商品类型执行具体制作流程 | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush }); | |||
break; | |||
case GOODS_TYPE.ICECREAM: | |||
morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush }); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
MessageLog.GetInstance.Show("未知的商品类型"); | |||
break; | |||
} | |||
#endregion | |||
} | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
/// <param name="batchingLoc">物料位置</param> | |||
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) | |||
{ | |||
if (batchings.ContainsKey(batchingLoc)) | |||
return batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private void Wait(int value = 101) | |||
{ | |||
while (!(lebai.Ok && lebai.Value == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
} | |||
/// <summary> | |||
/// 做咖啡-接杯子 并且 回到 安全位置 | |||
/// </summary> | |||
private void DoCoffee(SimOrderData order) | |||
{ | |||
#region 且时且多入场设备程序 | |||
int checkeNum = 0; | |||
// are.Reset(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.morkOrder.SuborderId, ORDER_STATUS.COOKING); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
MessageLog.GetInstance.Show("尝试取咖啡杯!"); | |||
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("咖啡杯取杯完成"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//加场景 回初始位置 | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(order.Loc) }.Publish(); //接咖啡控制 | |||
DeviceProcessLogShow($"发送咖啡机制作{order.Loc}!"); | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 将咖啡杯子 取走到 取餐口 | |||
/// </summary> | |||
private void DoCoffeeQC(SimOrderData order) | |||
{ | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId,BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.morkOrder.GoodsName}等待取餐"); | |||
WaitTakeMealOrder.Enqueue(order); | |||
} | |||
/// <summary> | |||
/// 做冰淇淋 | |||
/// </summary> | |||
private void DoIceCream(SimOrderData order) | |||
{ | |||
//if (LebaiRobot.GetInstance.GetInput(3)) | |||
//{ | |||
// MessageLog.GetInstance.Show("请擦拭冰淇淋机出口"); | |||
// return; | |||
//} | |||
#region 且时且多入场设备程序 | |||
int checkeNum = 0; | |||
//are.Reset(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
MessageLog.GetInstance.Show("尝试取冰淇淋杯!"); | |||
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) | |||
{ | |||
//退出循环回到初始位置 | |||
MessageLog.GetInstance.Show($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
MessageLog.GetInstance.Show($"执行{count}次取冰淇淋杯!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
count++; | |||
goto p; | |||
} | |||
MessageLog.GetInstance.Show("冰淇淋杯检测完成"); | |||
#region 通讯冰淇淋机 | |||
//制冷模式 | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.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); | |||
#endregion | |||
while (LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐"); | |||
WaitTakeMealOrder.Enqueue(order); | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 冰淇淋制作 | |||
/// </summary> | |||
public void IceCreamCookCheck() | |||
{ | |||
int retry = 3; | |||
DateTime beginTime = DateTime.Now; | |||
while (!LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if (retry <= 0 && DateTime.Now.Subtract(beginTime).TotalSeconds >= 10) | |||
{ | |||
MessageLog.GetInstance.Show("超时未出料,重试次数用尽"); | |||
break; | |||
} | |||
if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5) | |||
{ | |||
MessageLog.GetInstance.Show("超时未出料,重新发送打料指令"); | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.打料 }.Publish(); | |||
beginTime = DateTime.Now; | |||
retry--; | |||
} | |||
Thread.Sleep(10); | |||
} | |||
MessageLog.GetInstance.Show("开始等待6s"); | |||
Thread.Sleep(5000); | |||
} | |||
//private void CoffeEndCookHandle(IEvent @event, EventBus.EventCallBackHandle callBack) | |||
//{ | |||
// //are.Set(); | |||
// if(MakeCoffeeOrder!=null) | |||
// MakeCoffeeOrder.OrderStatus = 1; | |||
//} | |||
public void ReadRobotData() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
lebai = LebaiRobot.GetInstance.GetValueAsync(); | |||
LebaiRobot.GetInstance.GetRobotModeStatus(); | |||
//LebaiRobot.GetInstance.GetInput(); | |||
Thread.Sleep(100); | |||
}), "乐百机器人数据读取", true); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
} | |||
/// <summary> | |||
/// IOT 广播消息命令 | |||
/// </summary> | |||
public void IotBroadcast<T>(T broadcast) | |||
{ | |||
if (broadcast != null && broadcast is IOTCommandModel iOTCommand) | |||
{ | |||
switch (iOTCommand.CommandName) | |||
{ | |||
case 0://控制类 | |||
if (iOTCommand.CommandValue != null) | |||
{ | |||
if (iOTCommand.CommandValue.ContainsKey("SimOrder")) | |||
{ | |||
//SimOrder(new SimOrderData { NoodleLoc = 1, BowlLoc = 10 }); | |||
} | |||
} | |||
break; | |||
case 1://设置属性 | |||
break; | |||
case 2://通知消息 | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
{ | |||
} | |||
public override void MainTask() | |||
{ | |||
} | |||
public override void ResetProgram() | |||
{ | |||
} | |||
} | |||
public class SimOrderData | |||
{ | |||
public string id { get; set; } | |||
public int OrderStatus { get; set; } | |||
public string Loc { get; set; } | |||
public MorkOrderPush morkOrder { get; set; } | |||
public SimOrderData() | |||
{ | |||
id = Guid.NewGuid().ToString(); | |||
OrderStatus = 0; | |||
} | |||
} | |||
} |
@@ -1,122 +0,0 @@ | |||
| |||
using BPASmartClient.Lebai; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MORKIC | |||
{ | |||
internal enum GOODS_TYPE | |||
{ | |||
NEITHER, | |||
COFFEE, | |||
ICECREAM, | |||
} | |||
internal enum BATCHING_CLASS | |||
{ | |||
HOLDER, | |||
MAIN_MATERIAL, | |||
} | |||
internal class PolymerBatching | |||
{ | |||
internal const string ICE_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string ICE_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string ICE_MAIN_BATCHIN3_LOC = "54"; | |||
internal const string COFFEE_HOLDER_LOC = "30"; | |||
internal const string ICE_HOLDER_LOC = "51"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
{"3", GOODS_TYPE.COFFEE}, | |||
{"4", GOODS_TYPE.COFFEE}, | |||
{"5", GOODS_TYPE.COFFEE}, | |||
{"6", GOODS_TYPE.COFFEE}, | |||
{"7", GOODS_TYPE.COFFEE}, | |||
{"8", GOODS_TYPE.COFFEE}, | |||
{"9", GOODS_TYPE.COFFEE}, | |||
{"10",GOODS_TYPE.COFFEE}, | |||
{"11",GOODS_TYPE.COFFEE}, | |||
{"12",GOODS_TYPE.COFFEE}, | |||
{"13",GOODS_TYPE.COFFEE}, | |||
{"14",GOODS_TYPE.COFFEE}, | |||
{"15",GOODS_TYPE.COFFEE}, | |||
{"16",GOODS_TYPE.COFFEE}, | |||
{"17",GOODS_TYPE.COFFEE}, | |||
{"18",GOODS_TYPE.COFFEE}, | |||
{"19",GOODS_TYPE.COFFEE}, | |||
{"20",GOODS_TYPE.COFFEE}, | |||
{"21",GOODS_TYPE.COFFEE}, | |||
{"22",GOODS_TYPE.COFFEE}, | |||
{"23",GOODS_TYPE.COFFEE}, | |||
{"24",GOODS_TYPE.COFFEE}, | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{"30",GOODS_TYPE.COFFEE}, | |||
{"51",GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN1_LOC,GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN2_LOC,GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN3_LOC,GOODS_TYPE.ICECREAM}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
public BATCHING_CLASS BatchingClass { get; set; } | |||
private string loc; | |||
public string Loc | |||
{ | |||
get { return loc; } | |||
set | |||
{ | |||
loc = value; | |||
if (GOODS_TYPES.ContainsKey(loc)) | |||
GoodsType = GOODS_TYPES[loc]; | |||
switch (loc) | |||
{ | |||
case COFFEE_HOLDER_LOC: | |||
case ICE_HOLDER_LOC: | |||
BatchingClass = BATCHING_CLASS.HOLDER; | |||
break; | |||
default: | |||
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; | |||
break; | |||
} | |||
} | |||
} | |||
internal static Dictionary<string, PolymerBatching> BuildAll() | |||
{ | |||
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>(); | |||
foreach (var item in GOODS_TYPES) | |||
{ | |||
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); | |||
} | |||
return temp; | |||
} | |||
internal static IC_SE GetIceCreamSE(string loc, out int sence) | |||
{ | |||
switch (loc) | |||
{ | |||
case ICE_MAIN_BATCHIN1_LOC: | |||
sence = LebaiRobot.SENCE_接1号冰淇淋; | |||
return IC_SE.SE_1; | |||
case ICE_MAIN_BATCHIN2_LOC: | |||
sence = LebaiRobot.SENCE_接2号冰淇淋; | |||
return IC_SE.SE_2; | |||
case ICE_MAIN_BATCHIN3_LOC: | |||
sence = LebaiRobot.SENCE_接3号冰淇淋; | |||
return IC_SE.SE_3; | |||
default: | |||
sence = LebaiRobot.SENCE_接1号冰淇淋; | |||
return IC_SE.SE_1; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
namespace HubHelper | |||
{ | |||
public class HubHelper | |||
{ | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
</Project> |
@@ -104,8 +104,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.IceMaker", " | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_BarCounter", "BPASmartClient.MorkT_BarCounter\BPASmartClient.MorkT_BarCounter.csproj", "{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}" | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Container", "BPASmartClient.MorkT_Container\BPASmartClient.MorkT_Container.csproj", "{EFE6E0AB-5218-436A-B1F3-8861AF28F785}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
@@ -960,26 +958,6 @@ Global | |||
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x64.Build.0 = Release|Any CPU | |||
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x86.ActiveCfg = Release|Any CPU | |||
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x86.Build.0 = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x64.Build.0 = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x86.Build.0 = Debug|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM.Build.0 = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM64.Build.0 = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x64.ActiveCfg = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x64.Build.0 = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x86.ActiveCfg = Release|Any CPU | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x86.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -1027,7 +1005,6 @@ Global | |||
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | |||
{F61AC179-156D-4075-BFEB-355862231F48} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{EFE6E0AB-5218-436A-B1F3-8861AF28F785} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
EndGlobalSection | |||
GlobalSection(ExtensibilityGlobals) = postSolution | |||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | |||
@@ -0,0 +1,73 @@ | |||
namespace TestDemo | |||
{ | |||
partial class Form1 | |||
{ | |||
/// <summary> | |||
/// Required designer variable. | |||
/// </summary> | |||
private System.ComponentModel.IContainer components = null; | |||
/// <summary> | |||
/// Clean up any resources being used. | |||
/// </summary> | |||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | |||
protected override void Dispose(bool disposing) | |||
{ | |||
if (disposing && (components != null)) | |||
{ | |||
components.Dispose(); | |||
} | |||
base.Dispose(disposing); | |||
} | |||
#region Windows Form Designer generated code | |||
/// <summary> | |||
/// Required method for Designer support - do not modify | |||
/// the contents of this method with the code editor. | |||
/// </summary> | |||
private void InitializeComponent() | |||
{ | |||
this.button1 = new System.Windows.Forms.Button(); | |||
this.button2 = new System.Windows.Forms.Button(); | |||
this.SuspendLayout(); | |||
// | |||
// button1 | |||
// | |||
this.button1.Location = new System.Drawing.Point(12, 12); | |||
this.button1.Name = "button1"; | |||
this.button1.Size = new System.Drawing.Size(97, 43); | |||
this.button1.TabIndex = 0; | |||
this.button1.Text = "button1"; | |||
this.button1.UseVisualStyleBackColor = true; | |||
this.button1.Click += new System.EventHandler(this.button1_Click); | |||
// | |||
// button2 | |||
// | |||
this.button2.Location = new System.Drawing.Point(137, 12); | |||
this.button2.Name = "button2"; | |||
this.button2.Size = new System.Drawing.Size(88, 43); | |||
this.button2.TabIndex = 1; | |||
this.button2.Text = "button2"; | |||
this.button2.UseVisualStyleBackColor = true; | |||
this.button2.Click += new System.EventHandler(this.button2_Click); | |||
// | |||
// Form1 | |||
// | |||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); | |||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |||
this.ClientSize = new System.Drawing.Size(641, 298); | |||
this.Controls.Add(this.button2); | |||
this.Controls.Add(this.button1); | |||
this.Name = "Form1"; | |||
this.Text = "Form1"; | |||
this.ResumeLayout(false); | |||
} | |||
#endregion | |||
private Button button1; | |||
private Button button2; | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
using BPASmartClient.AGV.Feedback; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Http; | |||
using Newtonsoft.Json; | |||
namespace TestDemo | |||
{ | |||
public partial class Form1 : Form | |||
{ | |||
public Form1() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void button1_Click(object sender, EventArgs e) | |||
{ | |||
AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); | |||
string value = JsonConvert.SerializeObject(aGVToUpSystem); | |||
string url = $"http://192.168.1.56:8089/apicallback/quicktron/robotjob/report?sign={value}"; | |||
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); | |||
} | |||
private void button2_Click(object sender, EventArgs e) | |||
{ | |||
Upstreamrequest aGVToUpSystem = new Upstreamrequest(); | |||
string value = JsonConvert.SerializeObject(aGVToUpSystem); | |||
string url = $"http://192.168.1.56:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}"; | |||
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); | |||
} | |||
} | |||
} |
@@ -0,0 +1,60 @@ | |||
<root> | |||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |||
<xsd:element name="root" msdata:IsDataSet="true"> | |||
<xsd:complexType> | |||
<xsd:choice maxOccurs="unbounded"> | |||
<xsd:element name="metadata"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" use="required" type="xsd:string" /> | |||
<xsd:attribute name="type" type="xsd:string" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" /> | |||
<xsd:attribute ref="xml:space" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="assembly"> | |||
<xsd:complexType> | |||
<xsd:attribute name="alias" type="xsd:string" /> | |||
<xsd:attribute name="name" type="xsd:string" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="data"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
<xsd:attribute ref="xml:space" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="resheader"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" use="required" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:choice> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:schema> | |||
<resheader name="resmimetype"> | |||
<value>text/microsoft-resx</value> | |||
</resheader> | |||
<resheader name="version"> | |||
<value>2.0</value> | |||
</resheader> | |||
<resheader name="reader"> | |||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
<resheader name="writer"> | |||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
</root> |
@@ -0,0 +1,17 @@ | |||
namespace TestDemo | |||
{ | |||
internal static class Program | |||
{ | |||
/// <summary> | |||
/// The main entry point for the application. | |||
/// </summary> | |||
[STAThread] | |||
static void Main() | |||
{ | |||
// To customize application configuration such as set high DPI settings or default font, | |||
// see https://aka.ms/applicationconfiguration. | |||
ApplicationConfiguration.Initialize(); | |||
Application.Run(new Form1()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWindowsForms>true</UseWindowsForms> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.AGV\BPASmartClient.AGV.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Http\BPASmartClient.Http.csproj" /> | |||
</ItemGroup> | |||
</Project> |