liulb@mesnac.com 1 year ago
commit eb8e7881e2

@ -1,5 +1,7 @@
using Admin.Core.Common;
using Admin.Core.Model;
using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -67,7 +69,9 @@ namespace Admin.Core.Extensions
}
);
});
return new SqlSugarClient(listConfig);
SqlSugarClient client = new SqlSugarClient(listConfig);
// var childA = client.GetConnection("aucma_mes").Ado.SqlQuery<BaseBomInfo>("select * from BASE_BOMINFO where OBJ_ID='1'");
return client;
});
}

@ -51,15 +51,16 @@ namespace Admin.Core.Repository
_dbBase = unitOfWork.GetDbClient();
}
#region 判断数据库连接状态
/// <summary>
/// 判断数据库连接状态
/// </summary>
/// <returns></returns>
public bool GetConnectionState()
{
return _db.Ado.IsValidConnection();
}
return _db.Ado.IsValidConnection();
}
#endregion
#region 异步方法

@ -8,6 +8,7 @@ using Admin.Core.Repository;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.RunPlc;
using Aucma.Core.Scanner;
using Autofac;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -61,6 +62,9 @@ namespace Aucma.Core.BoxFoam
//注册业务服务
AddServices(services);
//扫码器
services.AddScannerSetup();
//任务调度
services.AddJobSetup();
//PLC
@ -85,7 +89,7 @@ namespace Aucma.Core.BoxFoam
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter, IRunPlcService runPlcService)//
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter, IRunPlcService runPlcService,IScannerService scannerService)//
{
// 使用静态文件
app.UseStaticFiles();
@ -96,6 +100,8 @@ namespace Aucma.Core.BoxFoam
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
//PLC
app.UsePlcMildd(runPlcService);
//开启扫码服务
app.UseScannerMildd(scannerService);
}
#region 注册服务

@ -6,6 +6,10 @@ using System;
using log4net;
using System.Diagnostics;
using System.Threading;
using Admin.Core.Common;
using Aucma.Core.PLc;
using Aucma.Core.Scanner;
using System.Linq;
namespace Aucma.Core.BoxFoam.ViewModels
{
@ -19,12 +23,82 @@ namespace Aucma.Core.BoxFoam.ViewModels
private FoamPlanPageView foamPlanPageView = new FoamPlanPageView();
FoamMonitorPageView foamMonitorPageView = new FoamMonitorPageView();
FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView();
public MainWindowViewModel()
{
UserContent = firstPage;
init();
}
public void init()
{
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
timer.AutoReset = true;
timer.Enabled = true;
timer.Start();
}
#region 设备状态刷新
/// <summary>
/// 设备状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
{
RefreshMesDb();
RefreshPlc();
RefreshScanner();
}
/// <summary>
/// 数据库状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}
/// <summary>
/// plc状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshPlc()
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc"));
if (obj != null)
{
if (obj.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
else
{
PlcState(false);
}
}
/// <summary>
/// 扫码器状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshScanner()
{
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
bool flag1 = MvCodeHelper.ConnectionStatus(ip1);
Scanner1State(flag1);
}
#endregion
#region 更换界面
public System.Windows.Controls.UserControl _content;
@ -142,19 +216,70 @@ namespace Aucma.Core.BoxFoam.ViewModels
break;
}
}
#endregion
#endregion
#region MES数据库状态
/// <summary>
/// MES数据库-文字
/// </summary>
public string _mesDbUIStatusWb;
public string MesDbUIStatusWb
{
get => _mesDbUIStatusWb;
set => SetProperty(ref _mesDbUIStatusWb, value);
}
/// <summary>
/// MES数据库-颜色
/// </summary>
public string _mesDbUIColor;
public string MesDbUIColor
{
get => _mesDbUIColor;
set => SetProperty(ref _mesDbUIColor, value);
}
/// <summary>
/// MES数据库-图标
/// </summary>
public string _mesUIIcon;
public string MesUIIcon
{
get => _mesUIIcon;
set => SetProperty(ref _mesUIIcon, value);
}
/// <summary>
/// MES数据库连接状态
/// </summary>
/// <param name="type"></param>
public void MesDbState(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
MesDbUIStatusWb = "MES数据库连接成功";
MesDbUIColor = "Green";
MesUIIcon = "Assets/Images/Green.png";
}
else
{
MesDbUIStatusWb = "MES数据库异常";
MesDbUIColor = "Red";
MesUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region plc 状态
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plcUIStatus;
public string _plcUIStatusWb;
public string PlcUIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _plcUIStatus;
set => SetProperty(ref _plcUIStatus, value);
get => _plcUIStatusWb;
set => SetProperty(ref _plcUIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
@ -162,8 +287,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
public string _plcUIColor;
public string PlcUIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _plcUIColor;
set => SetProperty(ref _plcUIColor, value);
}
@ -173,8 +296,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
public string _plcUIIcon;
public string PlcUIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _plcUIIcon;
set => SetProperty(ref _plcUIIcon, value);
}
@ -185,18 +306,80 @@ namespace Aucma.Core.BoxFoam.ViewModels
/// <param name="type"></param>
public void PlcState(bool type)
{
if (type)
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White";
PlcUIIcon = "Assets/Images/正常.png";
}
else
if (type)
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "Green";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 扫码器1状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner1UIStatusWb;
public string Scanner1UIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _scanner1UIStatusWb;
set => SetProperty(ref _scanner1UIStatusWb, value);
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner1UIColor;
public string Scanner1UIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _scanner1UIColor;
set => SetProperty(ref _scanner1UIColor, value);
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner1UIIcon;
public string Scanner1UIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _scanner1UIIcon;
set => SetProperty(ref _scanner1UIIcon, value);
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner1State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png";
}
if (type)
{
Scanner1UIStatusWb = "扫码器1连接成功";
Scanner1UIColor = "Green";
Scanner1UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner1UIStatusWb = "扫码器1状态异常";
Scanner1UIColor = "Red";
Scanner1UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
}

@ -8,7 +8,7 @@
Title="澳柯玛箱体发泡控制系统"
d:DesignHeight="1080"
d:DesignWidth="1920" FontFamily="Microsoft YaHei"
WindowStyle="ToolWindow" WindowState="Maximized"
WindowStyle="None" WindowState="Maximized"
WindowStartupLocation="CenterScreen"
>
<Window.Background>
@ -59,10 +59,7 @@
<DockPanel Grid.Row="2" Margin="5 0 5 3">
<Border BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Height="50" Orientation="Horizontal" Margin="5 0" HorizontalAlignment="Left">
<Button Content="实时监控" x:Name="FirstPage" FontSize="18" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FirstPage}" />
<Button Content="实时库存" x:Name="RealTimeInventoryPage" FontSize="18" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=RealTimeInventoryPage}" />
@ -76,25 +73,26 @@
<Button Content="最小化" x:Name="Minimized" FontSize="18" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Background="#FF9900" BorderBrush="#FF9900" />
<Button Content="退 出" x:Name="Exit" Margin="5 0" FontSize="18" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Background="#FF0033" BorderBrush="#FF0033"/>
</StackPanel>
<StackPanel Grid.Row="2" Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock x:Name="PLCState" Text="PLC" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<StackPanel Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="MesDbStatus" ImageSource="{Binding MesUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="DB" Text="数据库" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="MesDbStateTxt" Text="{Binding MesDbUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding MesDbUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="BarCodeStatusTxt" Text="扫描器" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="PLCState" Text="{Binding PlcUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding PlcUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="BarCodeStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="Scanner1Status" ImageSource="{Binding Scanner1UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

@ -212,16 +212,25 @@
"SubscriptionClientName": "Admin.Core"
},
"Middleware": {
"Plc": {
"Enabled": true
},
"QuartzNetJob": {
"Enabled": true
},
"Scanner": { //
"Enabled": true
},
"Melsec": {
"ConString": "10.10.92.30",
"Port": 6000,
"Enabled": true
"Scanner1": { //1
"Ip": "192.168.1.19",
"Name": "扫码器1"
},
"Scanner2": { //2
"Ip": "192.168.1.20",
"Name": "扫码器2"
},
"ScannerGun": { //
"Enabled": false
}
},
"PLCServer": [

@ -76,7 +76,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}
@ -111,7 +111,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// <param name="e"></param>
public void RefreshScanner()
{
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
string ip2 = Appsettings.app("Middleware", "Scanner2", "Ip");
bool flag1 = MvCodeHelper.ConnectionStatus(ip1);
bool flag2 = MvCodeHelper.ConnectionStatus(ip2);
@ -195,14 +195,13 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// </summary>
public static void OpenOsk()
{
Process proc = new Process();
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Windows\System32\osk.exe";
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
}
#endregion
#region 界面切换
/// <summary>
/// 界面切换
@ -283,11 +282,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plcUIStatus;
public string _plcUIStatusWb;
public string PlcUIStatusWb
{
get => _plcUIStatus;
set => SetProperty(ref _plcUIStatus, value);
get => _plcUIStatusWb;
set => SetProperty(ref _plcUIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色

@ -7,6 +7,8 @@ using Admin.Core.Model;
using Admin.Core.Repository;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.RunPlc;
using Aucma.Core.Scanner;
using Autofac;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -60,9 +62,13 @@ namespace Aucma.Core.DoorFoam
//注册业务服务
AddServices(services);
//扫码器
services.AddScannerSetup();
//任务调度
services.AddJobSetup();
//PLC
services.AddPlcSetup();
//支持编码大全 例如:支持 System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030")
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
@ -83,7 +89,7 @@ namespace Aucma.Core.DoorFoam
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter)
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter, IScannerService scannerService, IRunPlcService runPlcService)
{
// 使用静态文件
app.UseStaticFiles();
@ -93,6 +99,10 @@ namespace Aucma.Core.DoorFoam
// 开启QuartzNetJob调度服务
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
//开启扫码服务
app.UseScannerMildd(scannerService);
//PLC
app.UsePlcMildd(runPlcService);
}
#region 注册服务

@ -7,6 +7,10 @@ using log4net;
using System.Diagnostics;
using System.Threading;
using NPOI.HSSF.Record;
using Admin.Core.Common;
using Aucma.Core.PLc;
using Aucma.Core.Scanner;
using System.Linq;
namespace Aucma.Core.DoorFoam.ViewModels
{
@ -15,12 +19,82 @@ namespace Aucma.Core.DoorFoam.ViewModels
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页
private StatisticsPageView recordPage = new StatisticsPageView();
public MainWindowViewModel()
{
UserContent = firstPage;
init();
}
public void init()
{
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
timer.AutoReset = true;
timer.Enabled = true;
timer.Start();
}
#region 设备状态刷新
/// <summary>
/// 设备状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
{
RefreshMesDb();
RefreshPlc();
RefreshScanner();
}
/// <summary>
/// 数据库状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}
/// <summary>
/// plc状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshPlc()
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc"));
if (obj != null)
{
if (obj.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
else
{
PlcState(false);
}
}
/// <summary>
/// 扫码器状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshScanner()
{
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
bool flag1 = MvCodeHelper.ConnectionStatus(ip1);
Scanner1State(flag1);
}
#endregion
#region 更换界面
public System.Windows.Controls.UserControl _content;
@ -122,19 +196,70 @@ namespace Aucma.Core.DoorFoam.ViewModels
break;
}
}
#endregion
#endregion
#region MES数据库状态
/// <summary>
/// MES数据库-文字
/// </summary>
public string _mesDbUIStatusWb;
public string MesDbUIStatusWb
{
get => _mesDbUIStatusWb;
set => SetProperty(ref _mesDbUIStatusWb, value);
}
/// <summary>
/// MES数据库-颜色
/// </summary>
public string _mesDbUIColor;
public string MesDbUIColor
{
get => _mesDbUIColor;
set => SetProperty(ref _mesDbUIColor, value);
}
/// <summary>
/// MES数据库-图标
/// </summary>
public string _mesUIIcon;
public string MesUIIcon
{
get => _mesUIIcon;
set => SetProperty(ref _mesUIIcon, value);
}
/// <summary>
/// MES数据库连接状态
/// </summary>
/// <param name="type"></param>
public void MesDbState(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
MesDbUIStatusWb = "MES数据库连接成功";
MesDbUIColor = "Green";
MesUIIcon = "Assets/Images/Green.png";
}
else
{
MesDbUIStatusWb = "MES数据库异常";
MesDbUIColor = "Red";
MesUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region plc 状态
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plcUIStatus;
public string _plcUIStatusWb;
public string PlcUIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _plcUIStatus;
set => SetProperty(ref _plcUIStatus, value);
get => _plcUIStatusWb;
set => SetProperty(ref _plcUIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
@ -142,8 +267,6 @@ namespace Aucma.Core.DoorFoam.ViewModels
public string _plcUIColor;
public string PlcUIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _plcUIColor;
set => SetProperty(ref _plcUIColor, value);
}
@ -153,8 +276,6 @@ namespace Aucma.Core.DoorFoam.ViewModels
public string _plcUIIcon;
public string PlcUIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _plcUIIcon;
set => SetProperty(ref _plcUIIcon, value);
}
@ -165,20 +286,81 @@ namespace Aucma.Core.DoorFoam.ViewModels
/// <param name="type"></param>
public void PlcState(bool type)
{
if (type)
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White";
PlcUIIcon = "Assets/Images/正常.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png";
}
if (type)
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "Green";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 扫码器1状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner1UIStatusWb;
public string Scanner1UIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _scanner1UIStatusWb;
set => SetProperty(ref _scanner1UIStatusWb, value);
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner1UIColor;
public string Scanner1UIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _scanner1UIColor;
set => SetProperty(ref _scanner1UIColor, value);
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner1UIIcon;
public string Scanner1UIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _scanner1UIIcon;
set => SetProperty(ref _scanner1UIIcon, value);
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner1State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
Scanner1UIStatusWb = "扫码器1连接成功";
Scanner1UIColor = "Green";
Scanner1UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner1UIStatusWb = "扫码器1状态异常";
Scanner1UIColor = "Red";
Scanner1UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
}
}

@ -62,10 +62,7 @@
<DockPanel Grid.Row="2" Margin="5 0 5 3">
<Border BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Height="50" Orientation="Horizontal" Margin="5 0" HorizontalAlignment="Left">
<Button Content="发泡线监控" x:Name="FoamLinePage" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FoamLinePage}" Margin="5 0" />
<Button Content="发泡机监控" x:Name="FoamMachinesPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FoamMachinesPage}" />
@ -74,26 +71,27 @@
<Button Content="最小化" x:Name="Minimized" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Width="100" Background="#FF9900" BorderBrush="#FF9900" />
<Button Content="退 出" x:Name="Exit" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Width="100" Background="#FF0033" BorderBrush="#FF0033" />
</StackPanel>
<StackPanel Grid.Row="2" Height="50" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 5 0">
<TextBlock x:Name="PLCState" Text="PLC" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<StackPanel Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="MesDbStatus" ImageSource="{Binding MesUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="DB" Text="数据库" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="MesDbStateTxt" Text="{Binding MesDbUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding MesDbUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="BarCodeStatusTxt" Text="扫描器" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="PLCState" Text="{Binding PlcUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding PlcUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="BarCodeStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="Scanner1Status" ImageSource="{Binding Scanner1UIIcon}"/>
</Border.Background>
</Border>
</StackPanel>
<TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

@ -175,11 +175,35 @@
"SubscriptionClientName": "Admin.Core"
},
"Middleware": {
"Plc": {
"Enabled": true
},
"QuartzNetJob": {
"Enabled": true
},
"Scanner": { //
"Enabled": true
},
"Scanner1": { //1
"Ip": "192.168.1.19",
"Name": "扫码器1"
},
"Scanner2": { //2
"Ip": "192.168.1.20",
"Name": "扫码器2"
},
"ScannerGun": { //
"Enabled": false
}
},
"PLCServer": [
{
"Id": 1,
"EquipName": "发泡Plc",
"IP": "127.0.0.1",
"Port": 6000
}
],
"IpRateLimiting": {
"EnableEndpointRateLimiting": false, //False: globally executed, true: executed for each
"StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter

@ -7,6 +7,7 @@ using Admin.Core.Model;
using Admin.Core.Repository;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.RunPlc;
using Aucma.Core.Scanner;
using Autofac;
using Microsoft.AspNetCore.Builder;
@ -65,6 +66,8 @@ namespace Aucma.Core.Palletiz
services.AddJobSetup();
//扫码器
services.AddScannerSetup();
//PLC
services.AddPlcSetup();
//支持编码大全 例如:支持 System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030")
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
@ -86,7 +89,7 @@ namespace Aucma.Core.Palletiz
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService,
ISchedulerCenter schedulerCenter, IScannerService scannerService)
ISchedulerCenter schedulerCenter, IScannerService scannerService, IRunPlcService runPlcService)
{
// 使用静态文件
app.UseStaticFiles();
@ -97,6 +100,8 @@ namespace Aucma.Core.Palletiz
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
//开启扫码服务
app.UseScannerMildd(scannerService);
//PLC
app.UsePlcMildd(runPlcService);
}
#region 注册服务

@ -7,6 +7,10 @@ using log4net;
using System.Diagnostics;
using System.Threading;
using NPOI.HSSF.Record;
using Admin.Core.Common;
using Aucma.Core.PLc;
using Aucma.Core.Scanner;
using System.Linq;
namespace Aucma.Core.Palletiz.ViewModels
{
@ -19,8 +23,79 @@ namespace Aucma.Core.Palletiz.ViewModels
public MainWindowViewModel()
{
UserContent = firstPage;
init();
}
public void init()
{
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
timer.AutoReset = true;
timer.Enabled = true;
timer.Start();
}
#region 设备状态刷新
/// <summary>
/// 设备状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
{
RefreshMesDb();
RefreshPlc();
RefreshScanner();
}
/// <summary>
/// 数据库状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}
/// <summary>
/// plc状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshPlc()
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("分垛库Plc"));
if (obj != null)
{
if (obj.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
else
{
PlcState(false);
}
}
/// <summary>
/// 扫码器状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshScanner()
{
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
bool flag1 = MvCodeHelper.ConnectionStatus(ip1);
Scanner1State(flag1);
}
#endregion
#region 更换界面
public System.Windows.Controls.UserControl _content;
@ -125,19 +200,70 @@ namespace Aucma.Core.Palletiz.ViewModels
break;
}
}
#endregion
#endregion
#region MES数据库状态
/// <summary>
/// MES数据库-文字
/// </summary>
public string _mesDbUIStatusWb;
public string MesDbUIStatusWb
{
get => _mesDbUIStatusWb;
set => SetProperty(ref _mesDbUIStatusWb, value);
}
/// <summary>
/// MES数据库-颜色
/// </summary>
public string _mesDbUIColor;
public string MesDbUIColor
{
get => _mesDbUIColor;
set => SetProperty(ref _mesDbUIColor, value);
}
/// <summary>
/// MES数据库-图标
/// </summary>
public string _mesUIIcon;
public string MesUIIcon
{
get => _mesUIIcon;
set => SetProperty(ref _mesUIIcon, value);
}
/// <summary>
/// MES数据库连接状态
/// </summary>
/// <param name="type"></param>
public void MesDbState(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
MesDbUIStatusWb = "MES数据库连接成功";
MesDbUIColor = "Green";
MesUIIcon = "Assets/Images/Green.png";
}
else
{
MesDbUIStatusWb = "MES数据库异常";
MesDbUIColor = "Red";
MesUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region plc 状态
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plcUIStatus;
public string _plcUIStatusWb;
public string PlcUIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _plcUIStatus;
set => SetProperty(ref _plcUIStatus, value);
get => _plcUIStatusWb;
set => SetProperty(ref _plcUIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
@ -145,8 +271,6 @@ namespace Aucma.Core.Palletiz.ViewModels
public string _plcUIColor;
public string PlcUIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _plcUIColor;
set => SetProperty(ref _plcUIColor, value);
}
@ -156,8 +280,6 @@ namespace Aucma.Core.Palletiz.ViewModels
public string _plcUIIcon;
public string PlcUIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _plcUIIcon;
set => SetProperty(ref _plcUIIcon, value);
}
@ -168,18 +290,80 @@ namespace Aucma.Core.Palletiz.ViewModels
/// <param name="type"></param>
public void PlcState(bool type)
{
if (type)
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White";
PlcUIIcon = "Assets/Images/正常.png";
}
else
if (type)
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "Green";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 扫码器1状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner1UIStatusWb;
public string Scanner1UIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _scanner1UIStatusWb;
set => SetProperty(ref _scanner1UIStatusWb, value);
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner1UIColor;
public string Scanner1UIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _scanner1UIColor;
set => SetProperty(ref _scanner1UIColor, value);
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner1UIIcon;
public string Scanner1UIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _scanner1UIIcon;
set => SetProperty(ref _scanner1UIIcon, value);
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner1State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png";
}
if (type)
{
Scanner1UIStatusWb = "扫码器1连接成功";
Scanner1UIColor = "Green";
Scanner1UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner1UIStatusWb = "扫码器1状态异常";
Scanner1UIColor = "Red";
Scanner1UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion

@ -8,7 +8,7 @@
d:DesignHeight="800"
d:DesignWidth="1000" FontFamily="Microsoft YaHei"
MinHeight="1080" MinWidth="1920" WindowState="Maximized"
WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow"
WindowStartupLocation="CenterScreen" WindowStyle="None"
>
<Window.Background>
<ImageBrush ImageSource="/Assets/images/background.jpg" />
@ -58,10 +58,7 @@
<DockPanel Grid.Row="2" Margin="5 0 5 3">
<Border BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Height="50" Orientation="Horizontal" Margin="5 0" HorizontalAlignment="Left">
<Button Content="实时监控" x:Name="FirstPage" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FirstPage}" Margin="5 0" />
<Button Content="扫描记录" x:Name="RecordPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=RecordPage}" />
@ -70,27 +67,26 @@
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Width="100" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Width="100" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="2" Height="50" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 5 0">
<TextBlock x:Name="PLCState" Text="PLC" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<StackPanel Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="MesDbStatus" ImageSource="{Binding MesUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="DB" Text="数据库" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="MesDbStateTxt" Text="{Binding MesDbUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding MesDbUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="BarCodeStatusTxt" Text="扫描器" VerticalAlignment="Center" Foreground="white" FontSize="15" Margin="10,0"/>
<TextBlock x:Name="PLCState" Text="{Binding PlcUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding PlcUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="BarCodeStatus" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="Scanner1Status" ImageSource="{Binding Scanner1UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

@ -164,16 +164,25 @@
"SubscriptionClientName": "Admin.Core"
},
"Middleware": {
"Plc": {
"Enabled": true
},
"QuartzNetJob": {
"Enabled": true
},
"Scanner": { //
"Enabled": true
},
"Melsec": {
"ConString": "10.10.92.30",
"Port": 6000,
"Enabled": true
"Scanner1": { //1
"Ip": "192.168.1.19",
"Name": "扫码器1"
},
"Scanner2": { //2
"Ip": "192.168.1.20",
"Name": "扫码器2"
},
"ScannerGun": { //
"Enabled": false
}
},
"PLCServer": [

@ -68,7 +68,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}

@ -10,6 +10,9 @@ using System.Windows.Interop;
using System.Collections.ObjectModel;
using Admin.Core.Common;
using System.IO;
using Aucma.Core.PLc;
using Aucma.Core.Scanner;
using System.Linq;
namespace Aucma.Core.SheetMetal.ViewModels
{
@ -19,12 +22,91 @@ namespace Aucma.Core.SheetMetal.ViewModels
private IndexPageView firstPage = new IndexPageView();//首页
private LogPageView logPage = new LogPageView();//日志
private StatisticsPageView statisticsPage = new StatisticsPageView();//统计
public MainWindowViewModel()
{
UserContent = firstPage;
init();
}
public void init()
{
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
timer.AutoReset = true;
timer.Enabled = true;
timer.Start();
}
#region 设备状态刷新
/// <summary>
/// 设备状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
{
RefreshMesDb();
RefreshPlc();
}
/// <summary>
/// 数据库状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshMesDb()
{
MesDbState(true);
}
/// <summary>
/// plc状态刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void RefreshPlc()
{
// 后板plc
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("后板Plc"));
if (obj != null)
{
if (obj.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
else
{
PlcState(false);
}
// u壳plc
var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("U壳PLC"));
if (obj2 != null)
{
if (obj2.plc.IsConnected)
{
Plc2State(true);
}
else
{
Plc2State(false);
}
}
else
{
Plc2State(false);
}
}
#endregion
#region 更换界面
public System.Windows.Controls.UserControl _content;
@ -130,19 +212,69 @@ namespace Aucma.Core.SheetMetal.ViewModels
break;
}
}
#endregion
#endregion
#region MES数据库状态
/// <summary>
/// MES数据库-文字
/// </summary>
public string _mesDbUIStatusWb;
public string MesDbUIStatusWb
{
get => _mesDbUIStatusWb;
set => SetProperty(ref _mesDbUIStatusWb, value);
}
/// <summary>
/// MES数据库-颜色
/// </summary>
public string _mesDbUIColor;
public string MesDbUIColor
{
get => _mesDbUIColor;
set => SetProperty(ref _mesDbUIColor, value);
}
/// <summary>
/// MES数据库-图标
/// </summary>
public string _mesUIIcon;
public string MesUIIcon
{
get => _mesUIIcon;
set => SetProperty(ref _mesUIIcon, value);
}
#region plc 状态
/// <summary>
/// MES数据库连接状态
/// </summary>
/// <param name="type"></param>
public void MesDbState(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
MesDbUIStatusWb = "MES数据库连接成功";
MesDbUIColor = "Green";
MesUIIcon = "Assets/Images/Green.png";
}
else
{
MesDbUIStatusWb = "MES数据库异常";
MesDbUIColor = "Red";
MesUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 后板plc 状态
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plcUIStatus;
public string _plcUIStatusWb;
public string PlcUIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _plcUIStatus;
set => SetProperty(ref _plcUIStatus, value);
get => _plcUIStatusWb;
set => SetProperty(ref _plcUIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
@ -150,8 +282,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
public string _plcUIColor;
public string PlcUIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _plcUIColor;
set => SetProperty(ref _plcUIColor, value);
}
@ -161,30 +291,85 @@ namespace Aucma.Core.SheetMetal.ViewModels
public string _plcUIIcon;
public string PlcUIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _plcUIIcon;
set => SetProperty(ref _plcUIIcon, value);
}
/// <summary>
/// PLC连接状态-true:连接成功false:失败
/// 后板PLC连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void PlcState(bool type)
{
if (type)
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White";
PlcUIIcon = "Assets/Images/正常.png";
}
else
if (type)
{
PlcUIStatusWb = "后板PLC连接成功";
PlcUIColor = "Green";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "后板PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region U壳PLC状态
/// <summary>
/// UI plc 展示状态-文字
/// </summary>
public string _plc2UIStatusWb;
public string Plc2UIStatusWb
{
get => _plc2UIStatusWb;
set => SetProperty(ref _plc2UIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
/// </summary>
public string _plc2UIColor;
public string Plc2UIColor
{
get => _plc2UIColor;
set => SetProperty(ref _plc2UIColor, value);
}
/// <summary>
/// UI plc 展示状态-图标
/// </summary>
public string _plc2UIIcon;
public string Plc2UIIcon
{
get => _plc2UIIcon;
set => SetProperty(ref _plc2UIIcon, value);
}
/// <summary>
/// PLC连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Plc2State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png";
}
if (type)
{
Plc2UIStatusWb = "U壳PLC连接成功";
Plc2UIColor = "Green";
Plc2UIIcon = "Assets/Images/Green.png";
}
else
{
Plc2UIStatusWb = "U壳PLC状态异常";
Plc2UIColor = "Red";
Plc2UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
}

@ -60,10 +60,7 @@
<DockPanel Grid.Row="2" Margin="5 0 0 3">
<Border BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Height="60" Orientation="Horizontal" Margin="5 0" HorizontalAlignment="Left">
<Button Content="生产计划" x:Name="FirstPage" FontSize="20" Height="40" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FirstPage}" />
<Button Content="设备监控" x:Name="LogPage" FontSize="20" Height="40" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=LogPage}" />
@ -72,25 +69,25 @@
<Button Content="最小化" x:Name="Minimized" FontSize="20" Height="40" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Background="#FF9900" BorderBrush="#FF9900" />
<Button Content="退 出" x:Name="Exit" FontSize="20" Height="40" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Background="#df4642" BorderBrush="#df4642" />
</StackPanel>
<StackPanel Grid.Row="2" Height="50" Margin="5 0" Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock x:Name="BeforPLcState" Text="箱壳PLC" VerticalAlignment="Center" Foreground="white" FontSize="20" Margin="10,0"/>
<StackPanel Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="BeforPLcStateColor" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="MesDbStatus" ImageSource="{Binding MesUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="AfterPlcState" Text="后板PLC" VerticalAlignment="Center" Foreground="white" FontSize="20" Margin="10,0"/>
<TextBlock x:Name="MesDbStateTxt" Text="{Binding MesDbUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding MesDbUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="AfterPlcStateColor" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="DB" Text="数据库" VerticalAlignment="Center" Foreground="white" FontSize="20" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15" >
<TextBlock x:Name="PLCState" Text="{Binding PlcUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding PlcUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>
<ImageBrush x:Name="Plc2Status" ImageSource="{Binding Plc2UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="PLC2State" Text="{Binding Plc2UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Plc2UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

Loading…
Cancel
Save