change-AB入库方向切换需要判断plc

main
liuwf 12 months ago
parent c26efe8398
commit 9085610112

@ -132,7 +132,7 @@ namespace Aucma.Core.ProductOffLine.Business
HandSendPlcWindow.SendPlcPassEvent += DownLoadPassFlag;
TouchSocketService.ReceiveCodeDelegateEvent += ReceiveAndConsumption;
TouchSocketService.NoReadReceiveEvent += NoRead;
}
#region 变量定义
/// <summary>
@ -143,6 +143,7 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
/// <summary>
/// TCP接收NoRead提醒
/// </summary>

@ -80,6 +80,25 @@ namespace Aucma.Core.ProductOffLine.Config
set { iniHelper.IniWriteValue("system", "PassWord", value); }
}
/// <summary>
///分垛模式1手动2自动默认手动
/// </summary>
public string SelectedMaterialType
{
get { return iniHelper.IniReadValue("system", "SelectedMaterialType"); }
set { iniHelper.IniWriteValue("system", "SelectedMaterialType", value); }
}
/// <summary>
///去往分垛库方向,A库为1B库为2老线默认B库2新线默认A库1
/// </summary>
public string PalletizDirection
{
get { return iniHelper.IniReadValue("system", "PalletizDirection"); }
set { iniHelper.IniWriteValue("system", "PalletizDirection", value); }
}
}
}

@ -1,7 +1,9 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.HwPLc;
using Aucma.Core.ProductOffLine.Business;
using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
using CommunityToolkit.Mvvm.ComponentModel;
@ -31,20 +33,50 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
OffLineBusiness offLineBusiness = OffLineBusiness.Instance;
private IndexPageView firstPage = new IndexPageView();//首页
private AppConfig appConfig = AppConfig.Instance;
private DirectionEditView directionEditView = new DirectionEditView();
private SelectQualityView selectQualityView = new SelectQualityView();
private SelectQualityView selectQualityView = new SelectQualityView();
public QualityPageViewModel()
{
UserContent1 = directionEditView;
UserContent2 = selectQualityView;
DirectionInit();
// 传入库方向
offLineBusiness.getDirectioneEvent += getInstoreDirection;
QualityPageView.getAllQualityEvent += test;
_baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService<IBaseQualityInspectionItemInfoServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
init();
}
// 初始化界面分垛模式及分垛方向
private void DirectionInit()
{
#region 默认方向
if (appConfig.PalletizDirection == "1")
{
_isSelectedOptionA = true;
_isSelectedOptionB = false;
}
else if (appConfig.PalletizDirection == "2")
{
_isSelectedOptionA = false;
_isSelectedOptionB = true;
}
else
{
_isSelectedOptionA = true;
_isSelectedOptionB = true;
appConfig.PalletizDirection = "1";
}
#endregion
}
/// <summary>
@ -61,7 +93,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
if (SelectedMaterialType != null && SelectedMaterialType.Content.ToString() == "自动模式")
{
BaseMaterialInfo info = _baseMaterialInfoServices.Query(x => x.MaterialCode == materialType).FirstOrDefault();
if (info != null&& !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向
if (info != null && !string.IsNullOrEmpty(info.InboundDirection)) // 设置过了方向
{
direction = info.InboundDirection;
}
@ -100,19 +132,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public async Task<List<BaseQualityInspectionItemInfo>> test()
{
List<BaseQualityInspectionItemInfo> list = await _baseQualityInspectionItemInfoServices.query();
return list;
}
public async void init()
{
await _baseQualityInspectionItemInfoServices.query();
//Task.Run(() =>
//{
// Thread.Sleep(5000);
// string A = getInstoreDirection("9001001802");
// Console.WriteLine(A);
//});
}
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
@ -136,24 +163,57 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
}
}
#region 单选框
private bool _isSelectedOptionA;
public bool IsSelectedOptionA
{
get { return _isSelectedOptionA; }
set
{
if (_isSelectedOptionA != value)
{
_isSelectedOptionA = value;
OnPropertyChanged(nameof(IsSelectedOptionA));
// 如果选择了A选项将B选项设为false
if (_isSelectedOptionA)
if (value)
{
var result = MessageBox.Show("确认切换A库方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
IsSelectedOptionB = false;
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
// obj = null;
if (obj != null)
{
bool flag = obj.plc.ReadBool("B100A");
if (flag)
{
_isSelectedOptionA = value;
OnPropertyChanged(nameof(IsSelectedOptionA));
appConfig.PalletizDirection = "1";
// 如果选择了A选项将B选项设为false
if (_isSelectedOptionA)
{
IsSelectedOptionB = false;
}
MessageBox.Show("切换成功");
}
else
{
MessageBox.Show("切换失败,请检查提升机及二楼平台是否残留箱体或数据!");
}
}
else
{
MessageBox.Show("Plc连接失败请检查连接!");
}
}
}
else
{
_isSelectedOptionA = value;
OnPropertyChanged(nameof(IsSelectedOptionA));
}
}
}
@ -163,22 +223,143 @@ namespace Aucma.Core.ProductOffLine.ViewModels
get { return _isSelectedOptionB; }
set
{
if (_isSelectedOptionB != value)
{
_isSelectedOptionB = value;
OnPropertyChanged(nameof(IsSelectedOptionB));
// 如果选择了B选项将A选项设为false
if (_isSelectedOptionB)
if (value)
{
var result = MessageBox.Show("确认切换B方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
IsSelectedOptionA = false;
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
// obj = null;
if (obj != null)
{
bool flag = obj.plc.ReadBool("B100A");
if (flag)
{
_isSelectedOptionB = value;
OnPropertyChanged(nameof(IsSelectedOptionB));
appConfig.PalletizDirection = "2";
// 如果选择了B选项将A选项设为false
if (_isSelectedOptionB)
{
IsSelectedOptionA = false;
}
MessageBox.Show("切换成功");
}
else
{
MessageBox.Show("切换失败,请检查提升机及二楼平台是否残留箱体或数据!");
}
}
else
{
MessageBox.Show("Plc连接失败请检查连接!");
}
}
}
else
{
_isSelectedOptionB = value;
OnPropertyChanged(nameof(IsSelectedOptionB));
}
}
}
#endregion
//#region 单选框
//private bool _isSelectedOptionA;
//public bool IsSelectedOptionA
//{
// get { return _isSelectedOptionA; }
// set
// {
// if (_isSelectedOptionA != value)
// {
// MessageBoxResult result = MessageBox.Show("确认切换方向吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
// if (result == MessageBoxResult.Yes)
// {
// // 读取plc点位判断能否切换
// var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
// if (obj != null)
// {
// bool flag = obj.plc.ReadBool("B100A");
// if (flag)
// {
// _isSelectedOptionA = value;
// OnPropertyChanged(nameof(IsSelectedOptionA));
// // 如果选择了A选项将B选项设为false
// if (_isSelectedOptionA)
// {
// IsSelectedOptionB = false;
// }
// }
// else
// {
// MessageBox.Show("请检查提升机及二楼平台是否残留箱体或数据!");
// }
// }
// else
// {
// MessageBox.Show("Plc连接失败请检查连接!");
// }
// }
// }
// }
//}
//private bool _isSelectedOptionB;
//public bool IsSelectedOptionB
//{
// get { return _isSelectedOptionB; }
// set
// {
// if (_isSelectedOptionB != value)
// {
// MessageBoxResult result = MessageBox.Show("确认切换方向吗?","确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
// if (result == MessageBoxResult.Yes)
// {
// // 读取plc点位判断能否切换
// var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
// if (obj != null)
// {
// bool flag = obj.plc.ReadBool("B100A");
// if (flag)
// {
// _isSelectedOptionB = value;
// OnPropertyChanged(nameof(IsSelectedOptionB));
// // 如果选择了B选项将A选项设为false
// if (_isSelectedOptionB)
// {
// IsSelectedOptionA = false;
// }
// }
// else
// {
// MessageBox.Show("请检查提升机及二楼平台是否残留箱体或数据!");
// }
// }
// else
// {
// MessageBox.Show("Plc连接失败请检查连接!");
// }
// }
// }
// }
//}
//#endregion
#endregion
@ -190,7 +371,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
[RelayCommand]
private void ExecQuery(object obj)
{
}
#endregion
}

@ -70,12 +70,12 @@
<Grid Grid.Row="1">
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="分垛模式选择:" Margin="10 0" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<ComboBox SelectedItem="{Binding SelectedMaterialType}" Width="200" Margin="5 0 0 0" VerticalAlignment="Center" FontSize="30" Foreground="White">
<ComboBoxItem Content="自动模式" Foreground="Blue"/>
<ComboBox Name="SelectedMaterialType" SelectedItem="{Binding SelectedMaterialType,Mode=TwoWay}" Width="200" Margin="5 0 0 0" VerticalAlignment="Center" FontSize="30" Foreground="White">
<ComboBoxItem Content="手动模式" Foreground="Blue" />
<ComboBoxItem Content="自动模式" Foreground="Blue"/>
</ComboBox>
<Border Margin="100 0 0 0">
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Center">
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Center" >
<TextBlock Text="手动方向设置: " Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<RadioButton Content="A" FontSize="20" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" />
<RadioButton Content="B" FontSize="20" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Margin="10 0 0 0"/>

@ -1,6 +1,7 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.ProductOffLine.ViewModels;
using Microsoft.Extensions.DependencyInjection;
using System;
@ -27,17 +28,23 @@ namespace Aucma.Core.ProductOffLine.Views
{
public delegate Task<List<BaseQualityInspectionItemInfo>> getAllQuality();
public static event getAllQuality getAllQualityEvent;
private AppConfig appConfig = AppConfig.Instance;
public QualityPageView()
{
InitializeComponent();
QualityPageViewModel viewmodel = new QualityPageViewModel();
this.DataContext = viewmodel;
}
}
}

@ -229,10 +229,10 @@
"EquipName": "成品下线Plc",
"PlcType": "Melsec",
"Enabled": true,
//"IP": "127.0.0.1",
//"Port": 6000
"IP": "10.10.92.70",
"Port": 2015
"IP": "127.0.0.1",
"Port": 6000
//"IP": "10.10.92.70",
// "Port": 2015
}
],

Loading…
Cancel
Save