diff --git a/Admin.Core.Repository/BASE/BaseRepository.cs b/Admin.Core.Repository/BASE/BaseRepository.cs
index c4618014..56917d10 100644
--- a/Admin.Core.Repository/BASE/BaseRepository.cs
+++ b/Admin.Core.Repository/BASE/BaseRepository.cs
@@ -59,16 +59,25 @@ namespace Admin.Core.Repository
///
public bool GetConnectionState()
{
- if (_db.CopyNew().Ado.IsValidConnection())
+ try
{
-
- return true;
+ if (_db.CopyNew().Ado.IsValidConnection())
+ {
+
+ return true;
+ }
+ else
+ {
+ _db.Close();
+ _db.Open();
+ return false;
+ }
}
- else
+ catch (Exception ex)
{
- _db.Close();
- _db.Open();
- return true;
+
+ Console.WriteLine(ex.ToString());
+ return false;
}
}
diff --git a/Aucma.Core.BoxFoam/ViewModels/SearchCriteriaViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/SearchCriteriaViewModel.cs
index 4faf1f49..7776c2ab 100644
--- a/Aucma.Core.BoxFoam/ViewModels/SearchCriteriaViewModel.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/SearchCriteriaViewModel.cs
@@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
+using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -51,17 +52,27 @@ namespace Aucma.Core.BoxFoam.ViewModels
[RelayCommand]
private void SaveSearchCriteria(Object window)
{
- var config = ((Aucma.Core.BoxFoam.ViewModels.SearchCriteriaViewModel)((System.Windows.FrameworkElement)window).DataContext).Configurations;
- var info = config.ToList();
- string items = string.Empty;
- foreach (var configuration in info)
+ try
{
- items += configuration.ToString() + "%";
+ Console.WriteLine("==================初始配置文件数据"+ appConfig.searchItems);
+ Console.WriteLine("==================测试数据");
+ var config = ((Aucma.Core.BoxFoam.ViewModels.SearchCriteriaViewModel)((System.Windows.FrameworkElement)window).DataContext).Configurations;
+ var info = config.ToList();
+ Console.WriteLine("========待保存数据" + info.ToJson());
+ string items = string.Empty;
+ foreach (var configuration in info)
+ {
+ items += configuration.ToString() + "%";
+ }
+ appConfig.searchItems = string.Empty;
+ appConfig.searchItems = items;
+ Console.WriteLine("==========配置文件数据appConfig.searchItems" + appConfig.searchItems);
+ Init();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message.ToString());
}
- appConfig.searchItems = string.Empty;
- appConfig.searchItems = items;
-
- Init();
}
#endregion
diff --git a/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs b/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs
index 75f7fd15..6f482fb7 100644
--- a/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs
+++ b/Aucma.Core.DoorFoam/Business/CollectionFoamMachine.cs
@@ -99,7 +99,7 @@ namespace Aucma.Core.DoorFoam.Business
}
tempKeys.Add(kvPair.Key, record);
}
- if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
+ if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff) && !kvPair.Value.MixpistOff.Equals("0"))
{
kvPair.Value.ProductLineCode = "CX_02";
kvPair.Value.StationNumber = "1004";
diff --git a/Aucma.Core.DoorFoam/Business/DoorCollection.cs b/Aucma.Core.DoorFoam/Business/DoorCollection.cs
index d2d98d8f..5f51ec26 100644
--- a/Aucma.Core.DoorFoam/Business/DoorCollection.cs
+++ b/Aucma.Core.DoorFoam/Business/DoorCollection.cs
@@ -44,80 +44,84 @@ namespace Aucma.Core.DoorFoam.Business
public void startCollect()
{
- while (true)
+ Task.Run(() =>
{
- //semaphore.WaitOne();
- try
+ while (true)
{
- Thread.Sleep(5000);
- var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("DoorPlc"));
-
- if (obj != null)
+ try
{
- //读取所有模具状态
- List moldStatusList = ReadModeStatus(obj);
- //读取所有模具型号
- List moldTypeList = ReadModeType(obj);
- //读取所有模具产量
- List aDoorMoldOutPutList = ReadADoorModeProduct(obj);
- List bDoorMoldOutPutList = ReadBDoorModeProduct(obj);
+ Thread.Sleep(2000);
- #region 读取设备状态(1运行 2停机 3故障)、生产节拍、节拍、设备报警
- byte[] info = obj.plc.Read("DB490.646", 10);
- int deviceStatus = 0;
- float productTakt = 0;
- float taktNum = 0;
- if (info != null)
- {
- //设备状态1运行 2停机 3故障
- deviceStatus = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
- // 台车节拍
- productTakt = int.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
- //整圈节拍
- taktNum = int.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
- }
+ var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("DoorPlc"));
- int deviceAlarm = obj.plc.ReadInt32("DB490.2136");
- #endregion
+ if (obj != null)
+ {
+ //读取所有模具状态
+ List moldStatusList = ReadModeStatus(obj);
+ //读取所有模具型号
+ List moldTypeList = ReadModeType(obj);
+ //读取所有模具产量
+ List aDoorMoldOutPutList = ReadADoorModeProduct(obj);
+ List bDoorMoldOutPutList = ReadBDoorModeProduct(obj);
- List result = new List();
-
- var mergedCollection = from moldStatus in moldStatusList
- join moldType in moldTypeList on new { moldStatus.StationTrolleyNumber } equals new { moldType.StationTrolleyNumber }
- join moldOutPut_A in aDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_A.StationTrolleyNumber }
- join moldOutPut_B in bDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_B.StationTrolleyNumber }
- select new DoorFoamMachine
- {
- StationTrolleyNumber = moldStatus.StationTrolleyNumber,
- GunNumber = moldStatus.GunNumber,
- MoldStatus = moldStatus.MoldStatus,
- MainId = moldStatus.MainId,
- MoldType = moldType.MoldType.Replace("\b","").Replace("\u0001", "").Replace("\0", "").Trim(),
- MoldProdutionA = moldOutPut_A.MoldProdutionA,
- MoldProdutionB = moldOutPut_B.MoldProdutionB,
- DeviceStatus = deviceStatus,
- DeviceAlarm = deviceAlarm,
- ProductTakt = productTakt,
- Takt = taktNum,
- CreateTime = DateTime.Now
- };
- result = mergedCollection.ToList();
- if(result != null)
- {
- RefreshDoorFoamMachineEvent?.Invoke(result);
+ #region 读取设备状态(1运行 2停机 3故障)、生产节拍、节拍、设备报警
+ byte[] info = obj.plc.Read("DB490.646", 10);
+ int deviceStatus = 0;
+ float productTakt = 0;
+ float taktNum = 0;
+ if (info != null)
+ {
+ //设备状态1运行 2停机 3故障
+ deviceStatus = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
+ // 台车节拍
+ productTakt = int.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
+ //整圈节拍
+ taktNum = int.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
+ }
+
+ int deviceAlarm = obj.plc.ReadInt32("DB490.2136");
+ #endregion
+
+ List result = new List();
+
+ var mergedCollection = from moldStatus in moldStatusList
+ join moldType in moldTypeList on new { moldStatus.StationTrolleyNumber } equals new { moldType.StationTrolleyNumber }
+ join moldOutPut_A in aDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_A.StationTrolleyNumber }
+ join moldOutPut_B in bDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_B.StationTrolleyNumber }
+ select new DoorFoamMachine
+ {
+ StationTrolleyNumber = moldStatus.StationTrolleyNumber,
+ GunNumber = moldStatus.GunNumber,
+ MoldStatus = moldStatus.MoldStatus,
+ MainId = moldStatus.MainId,
+ MoldType = moldType.MoldType.Replace("\b", "").Replace("\u0001", "").Replace("\0", "").Trim(),
+ MoldProdutionA = moldOutPut_A.MoldProdutionA,
+ MoldProdutionB = moldOutPut_B.MoldProdutionB,
+ DeviceStatus = deviceStatus,
+ DeviceAlarm = deviceAlarm,
+ ProductTakt = productTakt,
+ Takt = taktNum,
+ CreateTime = DateTime.Now
+ };
+ result = mergedCollection.ToList();
+ if (result != null)
+ {
+ RefreshDoorFoamMachineEvent?.Invoke(result);
+
+ var addFlag = _doorFoamMachineServices.AddAsync(result).Result;
+ }
- var addFlag = _doorFoamMachineServices.AddAsync(result).Result;
}
-
}
- }
- catch (Exception ex)
- {
+ catch (Exception ex)
+ {
- Console.WriteLine($"门体发泡数据采集异常:{ex.Message}");
+ Console.WriteLine($"门体发泡数据采集异常:{ex.Message}");
+ }
}
- }
+ });
+
}
///
/// 读取模位状态
diff --git a/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs b/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs
index 63425f66..d68e98a6 100644
--- a/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs
+++ b/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs
@@ -7,7 +7,10 @@ using Admin.Core.Tasks;
using Aucma.Core.DoorFoam.Business;
using Aucma.Core.DoorFoam.Models;
using CommunityToolkit.Mvvm.ComponentModel;
+using log4net;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.IdentityModel.Logging;
+using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -20,6 +23,8 @@ namespace Aucma.Core.DoorFoam.ViewModels
public partial class FoamMachinesPageViewModel : ObservableObject
{
IBoxLastShotRecordServices _boxLastShotRecordServices;
+ private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(FoamMachinesPageViewModel));
+
public FoamMachinesPageViewModel()
{
@@ -206,43 +211,53 @@ namespace Aucma.Core.DoorFoam.ViewModels
}
#region 加载DataGrid数据
- private async Task LoadData()
+ private void LoadData()
{
- System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
+
+ try
{
- LastShotRecordDataGrid.Clear();
-
- int i = 1;
- var list = await _boxLastShotRecordServices.QueryAsync();
+ var list = _boxLastShotRecordServices.QueryAsync(x => x.CreateTime >= System.DateTime.Now.AddDays(-1)).Result.Take(30).OrderByDescending(d => d.CreateTime);
if (list == null) return;
- list.OrderByDescending(d => d.CreateTime).Take(30);
- foreach (var item in list)
- {
- string system = string.Empty;
- if (item.System == "1") { system = "1系统"; }
- if (item.System == "2") { system = "2系统"; }
- LastShotRecordModel model = new LastShotRecordModel();
- if (LastShotRecordDataGrid.Count() == 0)
- {
- model.No = 1;
- }
- else
- {
- model.No = LastShotRecordDataGrid.Count() + 1;
- }
- model.No = i;
- model.System = system;
- model.GunHead = item.GunCode;
- model.PolInjectionpressure = item.PolHp;
- model.IsoInjectionpressure = item.IsoHp;
- model.PolInjectiontemperature = item.PolTemp;
- model.IsoInjectiontemperature = item.IsoTemp;
- model.LastTime = item.CreateTime;
- model.Createtime = item.CreateTime;
- model.StationNumber = item.PourNu;
- LastShotRecordDataGrid.Insert(0, model);
- }
- }));
+ System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
+ {
+ LastShotRecordDataGrid.Clear();
+
+ int i = 1;
+ // var list = await _boxLastShotRecordServices.QueryAsync();
+
+ // list.OrderByDescending(d => d.CreateTime).Take(30);
+ foreach (var item in list)
+ {
+ string system = string.Empty;
+ if (item.System == "1") { system = "1系统"; }
+ if (item.System == "2") { system = "2系统"; }
+ LastShotRecordModel model = new LastShotRecordModel();
+ if (LastShotRecordDataGrid.Count() == 0)
+ {
+ model.No = 1;
+ }
+ else
+ {
+ model.No = LastShotRecordDataGrid.Count() + 1;
+ }
+ model.No = i;
+ model.System = system;
+ model.GunHead = item.GunCode;
+ model.PolInjectionpressure = item.PolHp;
+ model.IsoInjectionpressure = item.IsoHp;
+ model.PolInjectiontemperature = item.PolTemp;
+ model.IsoInjectiontemperature = item.IsoTemp;
+ model.LastTime = item.CreateTime;
+ model.Createtime = item.CreateTime;
+ model.StationNumber = item.PourNu;
+ LastShotRecordDataGrid.Insert(0, model);
+ }
+ }));
+ }
+ catch (Exception ex)
+ {
+ logHelper.Info(ex.Message.ToString());
+ }
}
#endregion
diff --git a/Aucma.Core.DoorFoam/ViewModels/IndexPageViewModel.cs b/Aucma.Core.DoorFoam/ViewModels/IndexPageViewModel.cs
index 6aff577f..28ac5016 100644
--- a/Aucma.Core.DoorFoam/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.DoorFoam/ViewModels/IndexPageViewModel.cs
@@ -40,17 +40,11 @@ namespace Aucma.Core.DoorFoam.ViewModels
RefreshDoorFoamMachineDataGrid(info);
};
- Task.Run(() =>
- {
- Thread.Sleep(1000*10);
+
doorCollection.startCollect();
- });
-
- Task.Run(() =>
- {
- Thread.Sleep(1000 * 10);
+
collectionFoam.startCollect();
- });
+
}
#region 获取今天的数据