change -产品下线plc状态

dev
liuwf 1 year ago
parent 7fea8372dd
commit 07d2488ea4

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

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

@ -7,11 +7,17 @@ using log4net;
using System.Diagnostics;
using System.Threading;
using NPOI.HSSF.Record;
using Aucma.Core.PLc;
using System.Linq;
using System.Threading.Tasks;
namespace Aucma.Core.ProductOffLine.ViewModels
{
public partial class MainWindowViewModel : ObservableObject
{
#region plc状态刷新
#endregion
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页
private StatisticsPageView recordPage = new StatisticsPageView();
@ -19,6 +25,60 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public MainWindowViewModel()
{
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 更换界面
@ -168,17 +228,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels
if (type)
{
PlcUIStatusWb = "PLC连接成功";
PlcUIColor = "White";
PlcUIIcon = "Assets/Images/正常.png";
PlcUIColor = "Greed";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/失败-01.png";
PlcUIIcon = "Assets/Images/Red.png";
}
}
#endregion
}
}

@ -71,10 +71,10 @@
<StackPanel Grid.Row="2" 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="PlcStatus" ImageSource="{Binding PlcUIIcon}"/>
</Border.Background>
</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.Background>
<ImageBrush x:Name="PlcStatusImage" ImageSource="/Assets/Images/Green.png"/>

Loading…
Cancel
Save