Browse Source

代码更新

master
pengliangyang 1 year ago
parent
commit
49cf92b0f7
8 changed files with 41 additions and 23 deletions
  1. +1
    -1
      DosingSystem/BPASmartClient.DosingSystem.csproj
  2. +1
    -1
      DosingSystem/Model/DeviceInquire.cs
  3. +1
    -1
      DosingSystem/Service/SiemensDevice.cs
  4. +0
    -2
      DosingSystem/View/RecipeControlView.xaml
  5. +1
    -1
      DosingSystem/View/RecipeControlView.xaml.cs
  6. +1
    -1
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  7. +15
    -9
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  8. +21
    -7
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs

+ 1
- 1
DosingSystem/BPASmartClient.DosingSystem.csproj View File

@@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.21" />
<PackageReference Include="BPA.Helper" Version="1.0.22" />
<PackageReference Include="BPA.Message" Version="1.0.46" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>


+ 1
- 1
DosingSystem/Model/DeviceInquire.cs View File

@@ -115,7 +115,7 @@ namespace BPASmartClient.DosingSystem
else Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = IPSegment;
TestData();
IpAddressLines();
DeviceDataInit();
//DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (IPQueues.Count >= IPLists.Count)


+ 1
- 1
DosingSystem/Service/SiemensDevice.cs View File

@@ -38,7 +38,7 @@ namespace BPASmartClient.DosingSystem

ThreadManage.GetInstance().StartLong(new Action(() =>
{
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
//GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32);
if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
{


+ 0
- 2
DosingSystem/View/RecipeControlView.xaml View File

@@ -875,8 +875,6 @@
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>


<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"


+ 1
- 1
DosingSystem/View/RecipeControlView.xaml.cs View File

@@ -35,7 +35,7 @@ namespace BPASmartClient.DosingSystem.View
this.Wait.ItemsSource = RecipeControlViewModel.UserTreeCompelete;
CookingGrid.Visibility = Visibility.Collapsed;
WaitOrCompleteGrid.Visibility = Visibility.Visible;
this.Wait.Visibility = Visibility.Hidden;
this.Wait.Visibility = Visibility.Visible;
}

private void RadioButtonWait_Click(object sender, RoutedEventArgs e)


+ 1
- 1
DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -52,7 +52,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (obj is string rm)
{
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm);
if (res != null) Global.DeviceRawMaterials.Remove(res);
if (res != null) RawMaterials.Remove(res);
}
});



+ 15
- 9
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -19,8 +19,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
public class RecipeControlViewModel : NotifyBase
{
ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>();
ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>();
public static ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>();
public static ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>();
public RecipeControlViewModel()
{
StartCommand = new RelayCommand<object>(RecipeIssued);
@@ -53,9 +53,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
Recipes.ElementAt(index).IsEnable = false;
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = false;
}
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}");
RecipeNames.Enqueue(deviceName);
var t = RecipeNames.GetHashCode();
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName);
UserTreeWait.Add(new RecipeModel { SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials });
}
@@ -184,17 +186,17 @@ namespace BPASmartClient.DosingSystem.ViewModel
int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName);
if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count)
{
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus;
//recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus;
}
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
{
if (GlobalDevice.PlcData.IsAllowIngredients[j])
{
int cnt = j + 1;//获取允许配料信号桶号的料仓位置
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.Loc == j)).RawMaterialWeight;
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.Loc == cnt)).RawMaterialWeight;
string deviceName = DeviceInquire.GetInstance.devices.ElementAt(Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt)).DeviceName;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);
if (cnt > 0 && loc > 0 && deviceName != null && weight > 0)
if (cnt > 0 && loc >= 0 && deviceName != null && weight >= 0)
{
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index < 0)
@@ -206,7 +208,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
IssueStatus = 0,
});
}
else
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index >= 0)
{
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0)
{
@@ -214,7 +217,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
}
if (RTrig.GetInstance("StatusReset").Start(recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3) && StockStatus.ElementAt(St_index).IssueStatus == 1)
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
{
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
@@ -225,15 +228,18 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
}
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成
int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count();
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成
{
StockStatus.Clear();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.1", true);//配方使用桶数写入
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
Recipes.ElementAt(recipIndex).IsEnable = true;
Json<LocaPar>.Data.Recipes.ElementAt(recipIndex).IsEnable = true;
Recipes.ElementAt(recipIndex).Are.Set();
}
}
}
}
@@ -248,7 +254,7 @@ namespace BPASmartClient.DosingSystem.ViewModel

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;

public string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnPropertyChanged(); } }
public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } }
private static string _RecipeName;

/// <summary>


+ 21
- 7
DosingSystem/ViewModel/RecipeSettingsViewModel.cs View File

@@ -50,10 +50,17 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (MessageNotify.GetInstance.ShowDialog($"是否删除【{o.ToString()}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning))
{
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
Json<LocaPar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!");
MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}");
if (res.IsEnable)
{
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
Json<LocaPar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!");
MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}");
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"删除【{o.ToString()}】配方失败,配方正在使用!");
}
}
}
});
@@ -65,9 +72,16 @@ namespace BPASmartClient.DosingSystem.ViewModel
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
if (res != null)
{
NewRecipeView nrv = new NewRecipeView();
ActionManage.GetInstance.Send("Details", res);
nrv.ShowDialog();
if (res.IsEnable)
{
NewRecipeView nrv = new NewRecipeView();
ActionManage.GetInstance.Send("Details", res);
nrv.ShowDialog();
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"编辑【{o.ToString()}】配方失败,配方正在使用!");
}
}
//MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
}


Loading…
Cancel
Save