Преглед на файлове

111

一拖四味魔方配料系统
ZhaoGang преди 11 месеца
родител
ревизия
c721a16fac
променени са 11 файла, в които са добавени 186 реда и са изтрити 1291 реда
  1. +1
    -1
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  2. +9
    -2
      BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs
  3. +1
    -1
      BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml
  4. +4
    -3
      DosingSystem/App.xaml.cs
  5. +25
    -994
      DosingSystem/ExcuteControl .cs
  6. +4
    -4
      DosingSystem/Model/ConveyerBeltModel.cs
  7. +0
    -145
      DosingSystem/Model/DeviceInquire.cs
  8. +76
    -76
      DosingSystem/Service/SiemensDevice.cs
  9. +47
    -47
      DosingSystem/ViewModel/ManualControlViewModel.cs
  10. +16
    -16
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  11. +3
    -2
      DosingSystem/ViewModel/SendCtrlViewModel.cs

+ 1
- 1
BPASmartClient.CustomResource/Pages/View/MainView.xaml Целия файл

@@ -475,7 +475,7 @@
Width="150"
Height="50"
Margin="113,0,0,0"
HorizontalAlignment="Left"
HorizontalAlignment="Right"
Columns="3">
<Button
Name="ButMin"


+ 9
- 2
BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs Целия файл

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -30,7 +31,13 @@ namespace BPASmartClient.CustomResource.Pages.View
this.WindowState = WindowState.Maximized;
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
this.ButClose.Click += (o, e) => { this.Close(); Application.Current.Shutdown(); };
this.ButClose.Click += (o, e) => {
if (MessageNotify.GetInstance.ShowDialog("确认关闭上位机系统吗?",DialogType.Warning))
{
this.Close();
Application.Current.Shutdown();
}
};
this.MoveBorder.MouseLeftButtonDown += (o, e) =>
{
if (e.ClickCount > 1)


+ 1
- 1
BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml Целия файл

@@ -34,7 +34,7 @@
</ControlTemplate>

<Style x:Key="IcoButtonStyle" TargetType="local:IcoButton">
<Setter Property="FontFamily" Value="../Fonts/pic/#iconfont"/>
<Setter Property="FontFamily" Value="../Fonts/pic/#iconfont" />
<Setter Property="FontSize" Value="14" />
<!--<Setter Property="Background" Value="#2219b7ec" />
<Setter Property="BorderBrush" Value="#ff19b7ec" />


+ 4
- 3
DosingSystem/App.xaml.cs Целия файл

@@ -95,15 +95,16 @@ namespace BPASmartClient.DosingSystem
}
else
mv.Close();
ServerFactory.GetInstance.Set(new APIServer());
MqttServer.GetInstance.Init();
//ServerFactory.GetInstance.Set(new APIServer());
//MqttServer.GetInstance.Init();
MainWindow = mv;
}

protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
excute?.MqttDisConnect();
excute?.ShutDown();
//excute?.MqttDisConnect();
Json<LocalRecipe>.Save();
Json<DevicePar>.Save();
Json<LocaMaterial>.Save();


+ 25
- 994
DosingSystem/ExcuteControl .cs
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 4
- 4
DosingSystem/Model/ConveyerBeltModel.cs Целия файл

@@ -18,7 +18,7 @@ namespace BPASmartClient.DosingSystem
{
_mSpeed = value;

SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", (short)value);
//SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", (short)value);
//SiemensDevice.GetInstance.MySiemens.WriteInt16(4, (short)value, (Num * 2 + 132));
MessageNotify.GetInstance.ShowRunLog($"DB4.DBW{Num * 2 + 132},{value}");
OnPropertyChanged();
@@ -34,9 +34,9 @@ namespace BPASmartClient.DosingSystem
_mConveyerBeltWork = value;
if (Num >= 1 && Num <= 32)
{
var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6);
SiemensDevice.GetInstance.MySiemens.Write(add, value);
MessageNotify.GetInstance.ShowRunLog($"{add},{value}");
//var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6);
//SiemensDevice.GetInstance.MySiemens.Write(add, value);
//MessageNotify.GetInstance.ShowRunLog($"{add},{value}");
}
OnPropertyChanged();
}


+ 0
- 145
DosingSystem/Model/DeviceInquire.cs Целия файл

@@ -451,152 +451,7 @@ namespace BPASmartClient.DosingSystem
Thread.Sleep(10);
}), $"{DeviceName} 开始监听", true);
TaskManage.GetInstance.StartLong(new Action(() =>
{
Thread.Sleep(1000);
if (ExcuteControl.GetInstance.mqttCollection.ContainsKey($"Stock{IpAddress.Split(".")[3].Substring(0, 1)}") && ExcuteControl.GetInstance.mqttCollection[$"Stock{IpAddress.Split(".")[3].Substring(0, 1)}"]._mqttClient.IsConnected)
{
StockPropertyReport();
StockEventReport();
}
}),$"{DeviceName}属性实时上报",true);
}
}
/// <summary>
/// 料仓属性上报
/// </summary>
public void StockPropertyReport()
{
#if !Debug
AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel();
model.StockOnlineStatus = this.modbusTcp.IsConnected()==true?1:0;
model.StockRealWeight = (int)deviceStatus.WeightFeedback;
model.BucketRealWeight = deviceStatus.NowWeightFeedback;
model.StockDeviceNum = (int)deviceStatus.DeviceNum;
model.StockDeviceName = deviceStatus.DeviceName;
model.StockWorkModel = deviceStatus.WorkModel == true ? 1 : 0;
model.StockSlowlyAddWeight = deviceStatus.SlowAddWeight;
model.StockPreCloseValueWeight = deviceStatus.PreCloseValueWeight;
model.StockRapidAcceleration = (int)deviceStatus.RapidAcceleration;
model.StockSlowAcceleration = (int)deviceStatus.SlowAcceleration;
model.StockServoManualSpeed = (int)deviceStatus.ServoManualSpeed;
model.StockUpperLimitWeight = (int)deviceStatus.SiloUpperLimitWeight;
model.StockLowerLimitWeight = (int)deviceStatus.SiloLowerLimitWeight;
model.StockStirringSpeed = (int)deviceStatus.StirringSpeed;
switch (deviceStatus.RawMaterialType)
{

case 1:
model.StockMaterialType = "膏体"; break;
case 2:
model.StockMaterialType = "液体"; break;
case 3:
model.StockMaterialType = "粉体"; break;
}
switch (deviceStatus.RunStatus)
{
case 0:
model.StockBatchStatus = "待机"; break;
case 1:
model.StockBatchStatus = "等待配料"; break;
case 2:
model.StockBatchStatus = "配料中"; break;
case 3:
model.StockBatchStatus = "配料完成"; break;
}
#endif
#if Debug
//本地模拟测试
AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel();
model.StockRealWeight = 1;
model.BucketRealWeight = 2;
model.StockDeviceNum = 2;
model.StockDeviceName ="测试";
model.StockWorkModel = 0;
model.StockSlowlyAddWeight = 6;
model.StockPreCloseValueWeight = 7;
model.StockRapidAcceleration =46;
model.StockSlowAcceleration = 24;
model.StockServoManualSpeed = 35;
model.StockUpperLimitWeight = 57;
model.StockLowerLimitWeight = 34;
model.StockStirringSpeed = 54;
model.StockMaterialType = "粉体";
model.StockBatchStatus = "待机";
#endif
ExcuteControl.GetInstance.StokcPropertyReport(IpAddress, model);
}
/// <summary>
/// 事件上报
/// </summary>
public void StockEventReport()
{
#if !Debug
try
{
if (RTrig.GetInstance($"stop1:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"Servo:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
}

if (RTrig.GetInstance($"EStop2:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2))
{

ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"SiloUpperLimit:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit))
{
if (DeviceName == "盐")
MessageNotify.GetInstance.ShowRunLog("料仓1 上限报警");
if (DeviceName == "A20")
MessageNotify.GetInstance.ShowRunLog("料仓2 上限报警");
if (DeviceName == "A30")
MessageNotify.GetInstance.ShowRunLog("料仓3 上限报警");
if (DeviceName == "A40")
MessageNotify.GetInstance.ShowRunLog("料仓4 上限报警");
if (DeviceName == "A50")
MessageNotify.GetInstance.ShowRunLog("料仓5 上限报警");
if (DeviceName == "A60")
MessageNotify.GetInstance.ShowRunLog("料仓6 上限报警");
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"SiloLowerLimit:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit))
{
if (DeviceName == "盐")
MessageNotify.GetInstance.ShowRunLog("料仓1 下限报警");
if (DeviceName == "A20")
MessageNotify.GetInstance.ShowRunLog("料仓2 下限报警");
if (DeviceName == "A30")
MessageNotify.GetInstance.ShowRunLog("料仓3 下限报警");
if (DeviceName == "A40")
MessageNotify.GetInstance.ShowRunLog("料仓4 下限报警");
if (DeviceName == "A50")
MessageNotify.GetInstance.ShowRunLog("料仓5 下限报警");
if (DeviceName == "A60")
MessageNotify.GetInstance.ShowRunLog("料仓6 下限报警");
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);

}
}
catch (Exception)
{

//throw;
}
#endif
#if Debug
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);
#endif
}
public void SetDeviceName(string name,int index)
{


+ 76
- 76
DosingSystem/Service/SiemensDevice.cs Целия файл

@@ -36,7 +36,7 @@ namespace BPASmartClient.DosingSystem
}
TaskManage.GetInstance.StartLong(new Action(() =>
{
if (IsConnect)
if (SendSimens.IsConnected())
{
SendSimens.Write("DB1.DBX704.0", tempValue);//设备心跳
tempValue = !tempValue;
@@ -46,11 +46,11 @@ namespace BPASmartClient.DosingSystem
TaskManage.GetInstance.StartLong(new Action(() =>
{
//App.Current.Dispatcher.Invoke(() => {
if (IsConnect)
if (SendSimens.IsConnected())
{
sendCtrlModel.SendInfo = SendSimens.Read<ushort>("DB1.DBX700.0").Content.Tobool();
sendCtrlModel.Stop = SendSimens.Read<ushort>("I0.0").Content.Tobool();
App.Current.Dispatcher.Invoke(() =>
App.Current?.Dispatcher?.Invoke(() =>
{
if (sendCtrlModel.CylinderModels.Count > 0)
{
@@ -75,8 +75,8 @@ namespace BPASmartClient.DosingSystem
sendCtrlModel.Clinder_2 = SendSimens.Read<ushort>("DB1.DBX300.4").Content.Tobool();
sendCtrlModel.Clinder_3 = SendSimens.Read<ushort>("DB1.DBX300.5").Content.Tobool();
sendCtrlModel.InSendSp = SendSimens.Read<ushort>("DB1.DBW100").Content;
sendCtrlModel.OutSendSp = SendSimens.Read<ushort>("DB1.DBW100").Content;
sendCtrlModel.CacheSendSp = SendSimens.Read<ushort>("DB1.DBW100").Content;
sendCtrlModel.OutSendSp = SendSimens.Read<ushort>("DB1.DBW102").Content;
sendCtrlModel.CacheSendSp = SendSimens.Read<ushort>("DB1.DBW104").Content;
}
//});

@@ -84,82 +84,82 @@ namespace BPASmartClient.DosingSystem
}), "读取输送线设备数据", true);
}
}
public class SiemensDevice
{
private volatile static SiemensDevice _Instance;
public static SiemensDevice GetInstance => _Instance ?? (_Instance = new SiemensDevice());
private SiemensDevice() { }
//public class SiemensDevice
//{
// private volatile static SiemensDevice _Instance;
// public static SiemensDevice GetInstance => _Instance ?? (_Instance = new SiemensDevice());
// private SiemensDevice() { }

public Siemens MySiemens { get; set; } = new Siemens();
// public Siemens MySiemens { get; set; } = new Siemens();

private bool IsConnect { get; set; }
public bool tempValue = false;
public void Connect(string ip)
{
MySiemens.Connected = () =>
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
if (IsConnect)
{
MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳
tempValue = !tempValue;
}
Thread.Sleep(200);
}), "设备心跳", true);
// private bool IsConnect { get; set; }
// public bool tempValue = false;
// public void Connect(string ip)
// {
// MySiemens.Connected = () =>
// {
// TaskManage.GetInstance.StartLong(new Action(() =>
// {
// if (IsConnect)
// {
// MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳
// tempValue = !tempValue;
// }
// Thread.Sleep(200);
// }), "设备心跳", true);

TaskManage.GetInstance.StartLong(new Action(() =>
{
GlobalDevice.PlcData = MySiemens.Read<PlcToComputer>(3).Content;//获取PLC到上位机的数据
//var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据
var res = MySiemens.Read<ushort[]>("DB4.DBW134", 32).Content;
if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
{
GlobalDevice.MotorSpeed = ushorts;
}
uint data = MySiemens.Read<uint>("DB5.DBD6").Content;//获取输送带控制信号
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
GlobalDevice.MotorControl = (uint)(data.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt();
Thread.Sleep(50);
}), "读取输送线设备数据", true);
};
try
{
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.2.200", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });
// TaskManage.GetInstance.StartLong(new Action(() =>
// {
// GlobalDevice.PlcData = MySiemens.Read<PlcToComputer>(3).Content;//获取PLC到上位机的数据
// //var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据
// var res = MySiemens.Read<ushort[]>("DB4.DBW134", 32).Content;
// if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
// {
// GlobalDevice.MotorSpeed = ushorts;
// }
// uint data = MySiemens.Read<uint>("DB5.DBD6").Content;//获取输送带控制信号
// //GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
// GlobalDevice.MotorControl = (uint)(data.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt();
// Thread.Sleep(50);
// }), "读取输送线设备数据", true);
// };
// try
// {
// IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.2.200", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });

}
catch (Exception)
{
// }
// catch (Exception)
// {

//throw;
}
}
// //throw;
// }
// }

/// <summary>
/// 通过顺序编号获取西门子数据地址
/// </summary>
/// <param name="Prefix">地址标头</param>
/// <param name="num">编号</param>
/// <param name="StartAdd">起始地址</param>
/// <returns></returns>
public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0)
{
if (num > 0)
{
string Add = string.Empty;
var FirstAdd = num / 8;
var EndAdd = (num % 8);
if (EndAdd == 0)
{
FirstAdd--;
EndAdd = 7;
}
else EndAdd--;
Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}";
return Add;
}
return default;
}
// /// <summary>
// /// 通过顺序编号获取西门子数据地址
// /// </summary>
// /// <param name="Prefix">地址标头</param>
// /// <param name="num">编号</param>
// /// <param name="StartAdd">起始地址</param>
// /// <returns></returns>
// public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0)
// {
// if (num > 0)
// {
// string Add = string.Empty;
// var FirstAdd = num / 8;
// var EndAdd = (num % 8);
// if (EndAdd == 0)
// {
// FirstAdd--;
// EndAdd = 7;
// }
// else EndAdd--;
// Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}";
// return Add;
// }
// return default;
// }

}
//}
}

+ 47
- 47
DosingSystem/ViewModel/ManualControlViewModel.cs Целия файл

@@ -52,23 +52,23 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
if (o != null)
{
if (o.ToString().Contains("升降气缸"))
{
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
if (index >= 0 && index < cylinderModels.Count)
{
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num);
SiemensDevice.GetInstance.MySiemens.Write(addRes, true);
}
}
else if (o.ToString().Contains("上桶工位气缸"))
{
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", true);
}
else if (o.ToString().Contains("下桶工位气缸"))
{
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", true);
}
//if (o.ToString().Contains("升降气缸"))
//{
// int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
// if (index >= 0 && index < cylinderModels.Count)
// {
// var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num);
// SiemensDevice.GetInstance.MySiemens.Write(addRes, true);
// }
//}
//else if (o.ToString().Contains("上桶工位气缸"))
//{
// SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", true);
//}
//else if (o.ToString().Contains("下桶工位气缸"))
//{
// SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", true);
//}
}
});

@@ -77,39 +77,39 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
if (o != null)
{
if (o.ToString().Contains("升降气缸"))
{
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
if (index >= 0 && index < cylinderModels.Count)
{
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num);
SiemensDevice.GetInstance.MySiemens.Write(addRes, false);
}
}
else if (o.ToString().Contains("上桶工位气缸"))
{
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", false);
}
else if (o.ToString().Contains("下桶工位气缸"))
{
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", false);
}
//if (o.ToString().Contains("升降气缸"))
//{
// int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
// if (index >= 0 && index < cylinderModels.Count)
// {
// var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num);
// SiemensDevice.GetInstance.MySiemens.Write(addRes, false);
// }
//}
//else if (o.ToString().Contains("上桶工位气缸"))
//{
// SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", false);
//}
//else if (o.ToString().Contains("下桶工位气缸"))
//{
// SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", false);
//}
}
});

SystemStart = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true);
//SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true);
Thread.Sleep(100);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0").Content;
SystemControlText = res ? "停止" : "启动";
//var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0").Content;
//SystemControlText = res ? "停止" : "启动";
});
ModelSwitch = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false);
Thread.Sleep(100);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content;
ModelSwitchText = res ? "自动" : "手动";
//SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false);
//Thread.Sleep(100);
//var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content;
//ModelSwitchText = res ? "自动" : "手动";
});

TaskManage.GetInstance.StartLong(new Action(() =>
@@ -139,13 +139,13 @@ namespace BPASmartClient.DosingSystem.ViewModel

private void Init()
{
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0").Content;
SystemControlText = res ? "停止" : "启动";
SystemStatus = res ? "停止" : "启动";
//var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0").Content;
//SystemControlText = res ? "停止" : "启动";
//SystemStatus = res ? "停止" : "启动";

var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content;
ModelSwitchText = res1 ? "自动" : "手动";
SystemStatus = res1 ? "自动" : "手动";
//var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1").Content;
//ModelSwitchText = res1 ? "自动" : "手动";
//SystemStatus = res1 ? "自动" : "手动";
}

/// <summary>


+ 16
- 16
DosingSystem/ViewModel/RecipeControlViewModel.cs Целия файл

@@ -860,21 +860,21 @@ namespace BPASmartClient.DosingSystem.ViewModel
//int item = test1.ToInt();
//prop1:
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true);
Task.Run(() =>
{
int cout = DeviceNum - 1;
while (!SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content) //DB3.DBX148.0-31 148.0-148.5代表6个料仓位置
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", true);
Thread.Sleep(200);
}
while (SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content)
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", false);
}
MessageNotify.GetInstance.ShowRunLog($"{cout}号气缸复位信号写入成功!");
});
//SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true);
//Task.Run(() =>
//{
// int cout = DeviceNum - 1;
// while (!SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content) //DB3.DBX148.0-31 148.0-148.5代表6个料仓位置
// {
// SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", true);
// Thread.Sleep(200);
// }
// while (SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content)
// {
// SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", false);
// }
// MessageNotify.GetInstance.ShowRunLog($"{cout}号气缸复位信号写入成功!");
//});
var res = recipeProcesses.ElementAt(recIndex).RawMaterials.FirstOrDefault(p => p.Status != Status.配料完成 && p.RawMaterialName == tempRawMaterialName && p.Loc == j + 1);
if (res != null)
res.Status = Status.配料完成;
@@ -994,7 +994,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
MessageNotify.GetInstance.ShowUserLog($"原料:{item.RawMaterialName},桶号:{item.Loc},设定配料重量{item.RawMaterialWeight}g,实际配料重量{item.UpLimtWeightFeedback}g");
}
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.0", true);//配料完成
//SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.0", true);//配料完成
MessageNotify.GetInstance.ShowRunLog($"配方:{CurrentRecipeName},配料完成");
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));


+ 3
- 2
DosingSystem/ViewModel/SendCtrlViewModel.cs Целия файл

@@ -3,6 +3,7 @@ using BPA.Communication;
using BPA.Helper;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.DosingSystem.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -18,7 +19,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
public SendCtrlViewModel()
{
sendCtrlModel =SimensSend.GetInstance.sendCtrlModel.ToJson().FromJSON<SendCtrlModel>();
}

@@ -26,7 +27,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
/// 传送带状态显示
/// </summary>
public SendCtrlModel SendCtrlModel { get { return sendCtrlModel; } set { sendCtrlModel = value; OnPropertyChanged(); } }
private SendCtrlModel sendCtrlModel = SimensSend.GetInstance.sendCtrlModel;
private SendCtrlModel sendCtrlModel = new();

public SendCtrl SendCtrl { get { return _sendCtrl; } set { _sendCtrl = value; OnPropertyChanged(); } }
private SendCtrl _sendCtrl = new SendCtrl();


Зареждане…
Отказ
Запис