liuwf 6 months ago
parent 39bb6488a9
commit cf01d9af57

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>

@ -129,6 +129,7 @@ namespace Aucma.Core.Palletiz.Business
/// <param name="asciiStr">20位是正常扫码传输的条码,手动入库传的是人工选择的成品型号</param>
private void InStore(string spaceArea, string asciiStr)
{
#region 未登录禁止入库
if (string.IsNullOrEmpty(appConfig.TeamName))
{
@ -137,6 +138,7 @@ namespace Aucma.Core.Palletiz.Business
}
#endregion
Task.Run(() =>
{
RecordInStore recordInstore = new RecordInStore();
@ -176,7 +178,7 @@ namespace Aucma.Core.Palletiz.Business
bool result = false;
SendInStoreTask(asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range);
SendInStoreTask(spaceArea,asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range);
#region 添加入库记录
@ -399,7 +401,7 @@ namespace Aucma.Core.Palletiz.Business
/// <param name="spaceinfo"></param>
/// <param name="result"></param>
/// <exception cref="ArgumentException"></exception>
private void SendInStoreTask(string asciiStr, BaseSpaceInfo spaceinfo, ref bool result,int prodWeight,ref string msg,out int rangeResult)
private void SendInStoreTask(string spaceArea, string asciiStr, BaseSpaceInfo spaceinfo, ref bool result,int prodWeight,ref string msg,out int rangeResult)
{
int spinFlag = -1;
rangeResult = 0;
@ -413,7 +415,7 @@ namespace Aucma.Core.Palletiz.Business
bool isFlag = true;
int spaceCode = StringChange.ParseToInt(spaceinfo.SpaceCode);
spinFlag =JudgeRotation(spaceCode, prodWeight, out int ranges);
spinFlag =JudgeRotation(spaceArea,spaceCode, prodWeight, out int ranges);
rangeResult = ranges;
if (spinFlag == -1)
{
@ -431,7 +433,15 @@ namespace Aucma.Core.Palletiz.Business
result = false;
return;
}
bool answerFlag = _plc.ReadBool("B1000");
bool answerFlag = false;
if (spaceinfo.SpaceArea == "A")
{
answerFlag = _plc.ReadBool("B1000");
}
else if (spaceinfo.SpaceArea == "B")
{
answerFlag = _plc.ReadBool("B1010");
}
if (answerFlag)
{
@ -460,20 +470,31 @@ namespace Aucma.Core.Palletiz.Business
else if (spaceinfo.SpaceArea == "B")
{
result = false;
if (!_plc.WriteInt16("D0", spinFlag.ToString()))
{
throw new ArgumentException($"旋转角度下发至PLC失败");
}
if (!_plc.WriteInt16("D9", spaceCode.ToString()))
{
throw new ArgumentException($"货道号下发至PLC失败");
}
_plc.WriteInt16("B1002", "1");//发送完成信号
result = true;
}
}
/// <summary>
/// 根据货物容积确定旋转规则 转180度发1不转发3
/// 根据货物容积确定旋转规则
/// </summary>
/// <param name="prodWeight"></param>
/// <returns></returns>
public int JudgeRotation(int spaceCode,int prodWeight, out int ranges)
public int JudgeRotation(string spaceArea,int spaceCode,int prodWeight, out int ranges)
{
try
{
List<JumpRange> list = appConfig.GetJumpRanges();
List<JumpRange> list = appConfig.GetJumpRanges(spaceArea);
foreach (JumpRange range in list)
{
if (range.MinModel <= prodWeight && range.MaxModel > prodWeight) // 找到该型号规则

@ -191,7 +191,7 @@ namespace Aucma.Core.Palletiz.ViewModels
}));
}
var info2 = inStoreBusiness.GetBaseSpaceinfos("A");
var info2 = inStoreBusiness.GetBaseSpaceinfos("B");
info2 = info2.OrderBy(x => x.ObjId).ToList();
if (info2 != null)
{

@ -21,8 +21,11 @@ namespace Aucma.Core.Palletiz.ViewModels
public List<JumpRange> jumpRanges = new List<JumpRange>();
public SetRangeWindowViewModel()
//默认A
public string position = "A";
public SetRangeWindowViewModel(string Position)
{
position = Position;
InitDataGrid();
DeleteCommand = new RelayCommand<object>(obj => Delete(obj));
@ -34,11 +37,16 @@ namespace Aucma.Core.Palletiz.ViewModels
{
string objId = obj.ToString();
Console.WriteLine(objId);
JumpRange delete = config.GetJumpRanges().FirstOrDefault(x => x.ObjId == int.Parse(objId));
JumpRange delete = config.GetJumpRanges(position).FirstOrDefault(x => x.ObjId == int.Parse(objId));
string deleteStr = $"[{delete.MinModel}-{delete.MaxModel}-{delete.OddSpaceRange}-{delete.EvenSpaceRange}]";
// 配置文件减去该字符串
// string temp = config.RangeConfig;
// string result1 = temp.Replace(deleteStr, "");
if(position== "A")
{
config.RangeConfig = config.RangeConfig.Replace(deleteStr, "");
}
else
{
config.RangeConfigB = config.RangeConfigB.Replace(deleteStr, "");
}
config.RangeConfig = config.RangeConfig.Replace(deleteStr, "");
MessageBox.Show("删除成功");
InitDataGrid();
@ -55,7 +63,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{
int id = 1;
ListItems.Clear();
List<JumpRange> list = config.GetJumpRanges();
List<JumpRange> list = config.GetJumpRanges(position);
if (list == null || list.Count == 0) return;
foreach(JumpRange jumpRange in list)
{
@ -138,8 +146,15 @@ namespace Aucma.Core.Palletiz.ViewModels
{
MessageBoxResult result = MessageBox.Show("确认保存吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
if(position== "A")
{
config.RangeConfig = config.RangeConfig + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]";
}
else
{
config.RangeConfigB = config.RangeConfigB + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]";
}
MessageBox.Show("保存成功");
@ -156,7 +171,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{
try
{
List<JumpRange> list = config.GetJumpRanges();
List<JumpRange> list = config.GetJumpRanges(position);
foreach (JumpRange range in list)
{
if (range.MinModel <= prodWeight && range.MaxModel > prodWeight) // 找到该型号规则

@ -133,8 +133,9 @@
<TextBlock Grid.Column="1" Text="{Binding Msg}" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<Grid Grid.Column="2">
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal" Margin="10,0,30,0">
<Button Content="异常入库" FontSize="18" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="40" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0" Click="Minimized_Click"/>
<Button Content="转向设置" FontSize="18" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="40" Background="#5283D7" BorderBrush="#5283D7" Margin="0,0,10,0" Click="Exit_Click"/>
<Button Content="异常入库" FontSize="18" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0" Click="Minimized_Click"/>
<Button Content="转向设置A" FontSize="18" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#5283D7" BorderBrush="#5283D7" Margin="0,0,10,0" Click="Exit_Click"/>
<Button Content="转向设置B" FontSize="18" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#5283D7" BorderBrush="#5283D7" Margin="0,0,10,0" Click="Exit_ClickB"/>
<Button Content="{Binding InStoreAmount}" FontSize="18" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="40" Background="Transparent" Margin="0,0,10,0"/>
</StackPanel>

@ -30,7 +30,7 @@ namespace Aucma.Core.Palletiz.Views
private void Exit_Click(object sender, RoutedEventArgs e)
{
SetRangeWindow window = new SetRangeWindow();
SetRangeWindow window = new SetRangeWindow("A");
window.ShowDialog();
}
@ -39,5 +39,11 @@ namespace Aucma.Core.Palletiz.Views
HandPalletizView window = new HandPalletizView();
window.ShowDialog();
}
private void Exit_ClickB(object sender, RoutedEventArgs e)
{
SetRangeWindow window = new SetRangeWindow("B");
window.ShowDialog();
}
}
}

@ -20,9 +20,9 @@ namespace Aucma.Core.Palletiz.Views
/// </summary>
public partial class SetRangeWindow : Window
{
public SetRangeWindow()
public SetRangeWindow(String position)
{
SetRangeWindowViewModel viewModel = new SetRangeWindowViewModel();
SetRangeWindowViewModel viewModel = new SetRangeWindowViewModel(position);
this.DataContext = viewModel;
InitializeComponent();
}

@ -29,11 +29,11 @@ namespace Aucma.Core.Palletiz.config
}
public List<JumpRange> GetJumpRanges()
public List<JumpRange> GetJumpRanges(string position)
{
List<JumpRange> jumpRanges = new List<JumpRange>();
int id = 1;
string configStr = RangeConfig;
string configStr = position=="A"? RangeConfig : RangeConfigB;
string[] configs = configStr.Split(new[] { "][" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < configs.Length; i++)
{
@ -82,7 +82,23 @@ namespace Aucma.Core.Palletiz.config
new PlcConfig(){spaceCode = 11,spaceArea = "A",address = "X1123"},
new PlcConfig(){spaceCode = 12,spaceArea = "A",address = "X1129"},
new PlcConfig(){spaceCode = 13,spaceArea = "A",address = "X1133"},
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X1139"}
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X1139"},
new PlcConfig(){spaceCode = 1,spaceArea = "B",address = "X0D3"},
new PlcConfig(){spaceCode = 2,spaceArea = "B",address = "X0D9"},
new PlcConfig(){spaceCode = 3,spaceArea = "B",address = "X0E3"},
new PlcConfig(){spaceCode = 4,spaceArea = "B",address = "X0E9"},
new PlcConfig(){spaceCode = 5,spaceArea = "B",address = "X0F3"},
new PlcConfig(){spaceCode = 6,spaceArea = "B",address = "X0F9"},
new PlcConfig(){spaceCode = 7,spaceArea = "B",address = "X103"},
new PlcConfig(){spaceCode = 8,spaceArea = "B",address = "X109"},
new PlcConfig(){spaceCode = 9,spaceArea = "B",address = "X113"},
new PlcConfig(){spaceCode = 10,spaceArea = "B",address = "X119"},
new PlcConfig(){spaceCode = 11,spaceArea = "B",address = "X123"},
new PlcConfig(){spaceCode = 12,spaceArea = "B",address = "X129"},
new PlcConfig(){spaceCode = 13,spaceArea = "B",address = "X133"},
new PlcConfig(){spaceCode = 14,spaceArea = "B",address = "X139"}
};
@ -92,7 +108,11 @@ namespace Aucma.Core.Palletiz.config
set { iniHelper.IniWriteValue("RangeConfig", "rangeString", value); }
}
public string RangeConfigB
{
get { return iniHelper.IniReadValue("RangeConfig", "rangeStringB"); }
set { iniHelper.IniWriteValue("RangeConfig", "rangeStringB", value); }
}
/// <summary>
/// 产线编号

@ -154,6 +154,8 @@ namespace Aucma.Core.PalletizCX1.Business
}
#endregion
Task.Run(() =>
{
if (asciiStr.Length == 20)
@ -189,7 +191,7 @@ namespace Aucma.Core.PalletizCX1.Business
{
throw new ArgumentException($"{spaceArea}货道区域为空");
}
if (spaceArea == "C") return;
_offlineService.GetProductInfosBySnCode(asciiStr, out ProductOffline prodInfo);
@ -490,7 +492,7 @@ namespace Aucma.Core.PalletizCX1.Business
}
else if(spaceinfo.SpaceArea =="C")
{
answerFlag = _plc.ReadBool("B1000");
answerFlag = _plc.ReadBool("B1003");
}
if (answerFlag)
@ -536,16 +538,16 @@ namespace Aucma.Core.PalletizCX1.Business
}
else if (spaceinfo.SpaceArea == "C")
{
if (!_plc.WriteInt16("D2", spinFlag.ToString()))
if (!_plc.WriteInt16("D3002", spinFlag.ToString()))
{
throw new ArgumentException($"C区域旋转角度下发至PLC失败");
}
if (!_plc.WriteInt16("D29", spaceCode.ToString()))
if (!_plc.WriteInt16("D49", spaceCode.ToString()))
{
throw new ArgumentException($"C区域货道号下发至PLC失败");
}
_plc.WriteInt16("B1001", "1");//发送完成信号
_plc.WriteInt16("B1103", "1");//发送完成信号
result = true;
}

@ -39,6 +39,9 @@ namespace Aucma.Core.PalletizCX1.ViewModels
// B库扫码器ip
private static string BScannerIp = allScanners.First(x => x.Name == "ScannerB").Ip;
// C库扫码器ip
private static string CScannerIp = allScanners.First(x => x.Name == "ScannerC").Ip;
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页
private StatisticsPageView recordPage = new StatisticsPageView();
@ -57,6 +60,7 @@ namespace Aucma.Core.PalletizCX1.ViewModels
{
RefreshScanner(AScannerIp, false);
RefreshScanner(BScannerIp, false);
RefreshScanner(CScannerIp, false);
TouchSocketService.RefreshStateEvent += RefreshScanner;
@ -138,6 +142,10 @@ namespace Aucma.Core.PalletizCX1.ViewModels
{
Scanner2State(flag);
}
else if (ip == CScannerIp)
{
Scanner3State(flag);
}
}
#endregion
@ -507,7 +515,61 @@ namespace Aucma.Core.PalletizCX1.ViewModels
}
#endregion
#region C库扫码器状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner3UIStatusWb;
public string Scanner3UIStatusWb
{
get => _scanner3UIStatusWb;
set => SetProperty(ref _scanner3UIStatusWb, value);
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner3UIColor;
public string Scanner3UIColor
{
get => _scanner3UIColor;
set => SetProperty(ref _scanner3UIColor, value);
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner3UIIcon;
public string Scanner3UIIcon
{
get => _scanner3UIIcon;
set => SetProperty(ref _scanner3UIIcon, value);
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner3State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
Scanner3UIStatusWb = "C库扫码器";
Scanner3UIColor = "Green";
Scanner3UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner3UIStatusWb = "C库扫码器";
Scanner3UIColor = "Red";
Scanner3UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 刷新时间

@ -93,6 +93,12 @@
</Border.Background>
</Border>
<TextBlock x:Name="Scanner2" Text="{Binding Scanner2UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner2UIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="Scanner3Status" ImageSource="{Binding Scanner3UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="Scanner3" Text="{Binding Scanner3UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner3UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

@ -101,7 +101,22 @@ namespace Aucma.Core.PalletizCX1.config
new PlcConfig(){spaceCode = 11,spaceArea = "A",address = "X163"},
new PlcConfig(){spaceCode = 12,spaceArea = "A",address = "X169"},
new PlcConfig(){spaceCode = 13,spaceArea = "A",address = "X173"},
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X179"}
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X179"},
new PlcConfig(){spaceCode = 1,spaceArea = "C",address = "X1243"},
new PlcConfig(){spaceCode = 2,spaceArea = "C",address = "X1249"},
new PlcConfig(){spaceCode = 3,spaceArea = "C",address = "X1253"},
new PlcConfig(){spaceCode = 4,spaceArea = "C",address = "X1259"},
new PlcConfig(){spaceCode = 5,spaceArea = "C",address = "X1263"},
new PlcConfig(){spaceCode = 6,spaceArea = "C",address = "X1269"},
new PlcConfig(){spaceCode = 7,spaceArea = "C",address = "X1273"},
new PlcConfig(){spaceCode = 8,spaceArea = "C",address = "X1279"},
new PlcConfig(){spaceCode = 9,spaceArea = "C",address = "X1283"},
new PlcConfig(){spaceCode = 10,spaceArea = "C",address = "X1289"},
new PlcConfig(){spaceCode = 11,spaceArea = "C",address = "X1293"},
new PlcConfig(){spaceCode = 12,spaceArea = "C",address = "X1299"},
new PlcConfig(){spaceCode = 13,spaceArea = "C",address = "X12A3"},
new PlcConfig(){spaceCode = 14,spaceArea = "C",address = "X12A9"}
};

@ -41,6 +41,7 @@ using LiveCharts.Defaults;
using System.Windows.Documents;
using Aucma.Core.ProductOffLine.Config;
using Org.BouncyCastle.Asn1.X509;
using Aucma.Core.ProductOffLine.Common;
/*
@ -52,7 +53,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
private SpeechStr speechStr = SpeechStr.Instance;
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
@ -74,7 +75,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
await Task.Run(() =>
{
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
OffLineBusiness.RefreshChartsEvent += RefreshCharts;
OffLineBusiness.RefreshChartsEvent += RefreshChartsOff;
LoginPageViewModel.RefreshChartsEvent += RefreshCharts;
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
OffLineQty = "0";
@ -86,6 +87,20 @@ namespace Aucma.Core.ProductOffLine.ViewModels
});
}
/// <summary>
/// 下线后刷新页面展示图表并喇叭提示
/// </summary>
public void RefreshChartsOff()
{
List<OffLineInfo> list = LoadData();
speechStr.SpeakAsync($"{list.Count}");
InitEveryDayMethod(list);
}
/// <summary>
/// 刷新页面展示图表
/// </summary>

@ -40,6 +40,7 @@ using ChartsByTime = Admin.Core.Model.ViewModels.ChartsByTime;
using LiveCharts.Defaults;
using System.Windows.Documents;
using Aucma.Core.ProductOffLineCX1.Config;
using Aucma.Core.ProductOffLineCX1.Common;
/*
@ -51,7 +52,7 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
private SpeechStr speechStr = SpeechStr.Instance;
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
@ -67,7 +68,7 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
OffLineBusiness.RefreshChartsEvent += RefreshCharts;
OffLineBusiness.RefreshChartsEvent += RefreshChartsOff;
LoginPageViewModel.RefreshChartsEvent += RefreshCharts;
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
@ -83,10 +84,19 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels
RefreshCharts();
// listTime = _baseBomInfoServices.getWorkTime().Result;
});
}
/// <summary>
/// 下线后刷新页面展示图表并喇叭提示
/// </summary>
public void RefreshChartsOff()
{
List<OffLineInfo> list = LoadData();
speechStr.SpeakAsync($"{list.Count}");
InitEveryDayMethod(list);
});
}

Loading…
Cancel
Save