change -产品下线plc状态

dev
liuwf 1 year ago
parent 7fea8372dd
commit 07d2488ea4

@ -73,6 +73,12 @@
<ProjectReference Include="..\Admin.Core.Extensions\Admin.Core.Extensions.csproj" /> <ProjectReference Include="..\Admin.Core.Extensions\Admin.Core.Extensions.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="MvCodeReaderSDK.Net">
<HintPath>..\dll\MvCodeReaderSDK.Net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Views\StatisticsPageView.xaml.cs"> <Compile Update="Views\StatisticsPageView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>

@ -143,7 +143,6 @@ namespace Aucma.Core.ProductOffLine.ViewModels
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
achievement.Add(random.Next(60, 100)); achievement.Add(random.Next(60, 100));
} }
var column = new ColumnSeries(); var column = new ColumnSeries();

@ -7,11 +7,17 @@ using log4net;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using NPOI.HSSF.Record; using NPOI.HSSF.Record;
using Aucma.Core.PLc;
using System.Linq;
using System.Threading.Tasks;
namespace Aucma.Core.ProductOffLine.ViewModels namespace Aucma.Core.ProductOffLine.ViewModels
{ {
public partial class MainWindowViewModel : ObservableObject public partial class MainWindowViewModel : ObservableObject
{ {
#region plc状态刷新
#endregion
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel)); private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页 private IndexPageView firstPage = new IndexPageView();//首页
private StatisticsPageView recordPage = new StatisticsPageView(); private StatisticsPageView recordPage = new StatisticsPageView();
@ -19,6 +25,60 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public MainWindowViewModel() public MainWindowViewModel()
{ {
UserContent = firstPage; UserContent = firstPage;
PlcState(true);
// test();
}
public async void test()
{
Task.Run(() =>
{
//Thread.Sleep(4000);
//PlcState(false);
Thread.Sleep(10000);
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
{
obj.plc.Read("M100");
if (obj.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
else
{
PlcState(false);
}
Thread.Sleep(5000);
var obj1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
obj.plc.Read("M100");
if (obj1.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
Thread.Sleep(5000);
var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
obj.plc.Read("M100");
if (obj2.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
});
} }
#region 更换界面 #region 更换界面
@ -168,17 +228,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels
if (type) if (type)
{ {
PlcUIStatusWb = "PLC连接成功"; PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White"; PlcUIColor = "Greed";
PlcUIIcon = "Assets/Images/正常.png"; PlcUIIcon = "Assets/Images/Green.png";
} }
else else
{ {
PlcUIStatusWb = "PLC状态异常"; PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red"; PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png"; PlcUIIcon = "Assets/Images/Red.png";
} }
} }
#endregion #endregion
} }
} }

@ -71,10 +71,10 @@
<StackPanel Grid.Row="2" Height="50" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Row="2" Height="50" Orientation="Horizontal" HorizontalAlignment="Right">
<Border Width="30" Height="30" CornerRadius="15"> <Border Width="30" Height="30" CornerRadius="15">
<Border.Background> <Border.Background>
<ImageBrush x:Name="PlcStatus" ImageSource="/Assets/Images/Green.png"/> <ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background> </Border.Background>
</Border> </Border>
<TextBlock x:Name="PLCState" Text="PLC连接成功" VerticalAlignment="Center" Foreground="Green" 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 Width="30" Height="30" CornerRadius="15">
<Border.Background> <Border.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/> <ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>

Loading…
Cancel
Save