3 Commits

10 changed files with 1413 additions and 684 deletions
Split View
  1. +3
    -0
      BPASmartClient.Academy/50L/AlarmData.cs
  2. +48
    -10
      BPASmartClient.Academy/50L/BoolAddEnum.cs
  3. +153
    -31
      BPASmartClient.Academy/50L/DeviceStatus.cs
  4. +11
    -6
      BPASmartClient.Academy/50L/FloatAddEnum.cs
  5. +57
    -20
      BPASmartClient.Academy/50L/PlcControl.cs
  6. +14
    -1
      BPASmartClient.Academy/50L/SamplingData.cs
  7. +14
    -0
      BPASmartClient.Academy/App.xaml.cs
  8. +843
    -615
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  9. +195
    -1
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs
  10. +75
    -0
      BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs

+ 3
- 0
BPASmartClient.Academy/50L/AlarmData.cs View File

@@ -17,5 +17,8 @@ namespace BPASmartClient.Academy._50L

[Alarm("负压风机异常")]
public bool AbnormalNegativePressureFan { get; set; }

[Alarm("卤水泵异常")]
public bool BrinePumpError { get; set; }
}
}

+ 48
- 10
BPASmartClient.Academy/50L/BoolAddEnum.cs View File

@@ -13,24 +13,62 @@ namespace BPASmartClient.Academy._50L
[Add("DB1.DBX1000.1")]
负压风机,
[Add("DB1.DBX1000.2")]
反应釜回原点,
卤水泵,
[Add("DB1.DBX1000.3")]
反应釜压缩空气进气阀,
反应釜回原点,
[Add("DB1.DBX1000.4")]
反应釜排热空气阀,
反应釜去倒料位,
[Add("DB1.DBX1000.5")]
反应釜泄压阀,
反应釜旋转电机点动,
[Add("DB1.DBX1000.6")]
称重水罐负压阀,
[Add("DB1.DBX1000.7")]
称重水罐重量清零,
[Add("DB1.DBX1001.0")]
反应釜升温,
[Add("DB1.DBX1001.1")]
[Add("DB1.DBX1000.7")]
反应釜降温,
[Add("DB1.DBX1000.2")]
[Add("DB1.DBX1001.0")]
冷凝水罐降温,
[Add("DB1.DBX1001.1")]
反应釜泄压阀,
[Add("DB1.DBX1001.2")]
排热空气阀,
[Add("DB1.DBX1001.3")]
热气排空阀,
[Add("DB1.DBX1001.4")]
冷凝水进气阀,
[Add("DB1.DBX1001.5")]
反应釜排水阀,
[Add("DB1.DBX1001.6")]
反应釜进清水阀,
[Add("DB1.DBX1001.7")]
反应釜压缩空气进气阀,
[Add("DB1.DBX1002.0")]
反应釜进卤水阀,
[Add("DB1.DBX1002.1")]
冷凝水罐真空阀,
[Add("DB1.DBX1002.2")]
空压机启动,
[Add("DB1.DBX1002.3")]
备用IN8,
[Add("DB1.DBX1002.4")]
备用IN9,
[Add("DB1.DBX1002.5")]
备用IN10,
[Add("DB1.DBX1002.6")]
备用IN11,
[Add("DB1.DBX1002.7")]
备用IN12,
[Add("DB1.DBX1003.0")]
备用IN13,
[Add("DB1.DBX1003.1")]
备用IN14,
[Add("DB1.DBX1003.2")]
备用IN15,
[Add("DB1.DBX1003.3")]
备用IN16,
[Add("DB1.DBX1003.4")]
称重水罐重量清零,
[Add("DB1.DBX1003.5")]
卤水配制罐重量清零,
[Add("DB1.DBX1003.6")]
系统启动,
[Add("DB1.DBX1003.7")]
心跳,


+ 153
- 31
BPASmartClient.Academy/50L/DeviceStatus.cs View File

@@ -9,60 +9,182 @@ namespace BPASmartClient.Academy._50L
public class DeviceStatus:NotifyBase
{
/// <summary>
/// 旋转电机启停反馈
/// 旋转电机启停反馈 V2000.0
/// </summary>
public bool TurnMotor{get { return _turnMotor; }set { _turnMotor = value; OnPropertyChanged(); }}
private bool _turnMotor;
public bool ReactTurnMotor {get { return _reactTurnMotor; }set { _reactTurnMotor = value; OnPropertyChanged(); }}
private bool _reactTurnMotor;
/// <summary>
/// 负压风机启动反馈
/// 负压风机启动反馈 V2000.1
/// </summary>
public bool Fans { get { return _fans; } set { _fans = value; OnPropertyChanged(); } }
private bool _fans;

/// <summary>
/// 卤水泵启动反馈 V2000.2
/// </summary>
public bool BrinePumpState { get { return _brinePumpState; } set { _brinePumpState = value; OnPropertyChanged(); } }
private bool _brinePumpState;

/// <summary>
/// 反应釜进蒸汽阀 V2000.3
/// </summary>
public bool ReactInSteamValue { get { return _reactInSteamValue; } set { _reactInSteamValue = value; OnPropertyChanged(); } }
private bool _reactInSteamValue;

/// <summary>
/// 反应釜进冷却水阀 V2000.4
/// </summary>
public bool ReactInColdValve { get { return _reactInColdValve; } set { _reactInColdValve = value; OnPropertyChanged(); } }
private bool _reactInColdValve;
/// <summary>
/// 反应釜出冷却水阀 V2000.5
/// </summary>
public bool ReactOutColdValve { get { return _reactOutColdValve; } set { _reactOutColdValve = value; OnPropertyChanged(); } }
private bool _reactOutColdValve;

/// <summary>
/// 反应釜排水阀 V2000.6
/// </summary>
public bool ReactDrainValve { get { return _reactDrainValve; } set { _reactDrainValve = value; OnPropertyChanged(); } }
private bool _reactDrainValve;

/// <summary>
/// 反应釜进清水阀 V2000.7
/// </summary>
public bool ReactInCleanWaterValve { get { return _reactInCleanWaterValve; } set { _reactInCleanWaterValve = value; OnPropertyChanged(); } }
private bool _reactInCleanWaterValve;

/// <summary>
/// 压缩空气进气阀反馈 V2001.0
/// </summary>
public bool ReactPressureAirInValve { get { return _reactPressureAirInValve; } set { _reactPressureAirInValve = value; OnPropertyChanged(); } }
private bool _reactPressureAirInValve;

/// <summary>
/// 反应釜进卤水阀 V2001.1
/// </summary>
public bool ReactInBrineWaterValve { get { return _reactInBrineWaterValve; } set { _reactInBrineWaterValve = value; OnPropertyChanged(); } }
private bool _reactInBrineWaterValve;

/// <summary>
/// 反应釜排热空气阀反馈 V2001.2
/// </summary>
public bool ReactOutHotGasValve { get { return _reactOutHotGasValve; } set { _reactOutHotGasValve = value; OnPropertyChanged(); } }
private bool _reactOutHotGasValve;

/// <summary>
/// 热气排空阀反馈 V2001.3
/// </summary>
public bool HotGasEmptyValve { get { return _hotGasEmptyValve; } set { _hotGasEmptyValve = value; OnPropertyChanged(); } }
private bool _hotGasEmptyValve;


/// <summary>
/// 冷凝水罐进气阀 V2001.4
/// </summary>
public bool ColdWaterTankInAirValve { get { return _coldWaterTankInAirValve; } set { _coldWaterTankInAirValve = value; OnPropertyChanged(); } }
private bool _coldWaterTankInAirValve;

/// <summary>
/// 冷凝水罐进水阀反馈 V2001.5
/// </summary>
public bool ColdWaterTankInWaterValve { get { return _coldWaterTankInWaterValve; } set { _coldWaterTankInWaterValve = value; OnPropertyChanged(); } }
private bool _coldWaterTankInWaterValve;

/// <summary>
/// 反应釜原点位置反馈 V2001.6
/// </summary>
public bool ReactHomeBit { get { return _reactHomeBit; } set { _reactHomeBit = value; OnPropertyChanged(); } }
private bool _reactHomeBit;

/// <summary>
/// 反应釜泄压阀反馈 V2001.7
/// </summary>
public bool ReactPressureReliefValve { get { return _reactPressureReliefValve; } set { _reactPressureReliefValve = value; OnPropertyChanged(); } }
private bool _reactPressureReliefValve;
/// <summary>
/// 冷凝水罐真空阀反馈 V2002.0
/// </summary>
public bool ColdWaterTankVacuumValve { get { return _coldWaterTankVacuumValve; } set { _coldWaterTankVacuumValve = value; OnPropertyChanged(); } }
private bool _coldWaterTankVacuumValve;

/// <summary>
/// 心跳反馈 V2003.7
/// </summary>
public bool HeartBeat { get { return _heartBeat; } set { _heartBeat = value; OnPropertyChanged(); } }
private bool _heartBeat;

///// 蒸汽梳水阀反馈
///// </summary>
//public bool CardWater { get { return _cardWater; } set { _cardWater = value; OnPropertyChanged(); } }
//private bool _cardWater;

///// <summary>
///// 称重水罐负压阀反馈
///// </summary>
//public bool WeightPot { get { return _weightPot; } set { _weightPot = value; OnPropertyChanged(); } }
//private bool _weightPot;

#region 模拟量
/// <summary>
/// 压缩空气进气阀反馈
/// 反应釜温度 VD2006
/// </summary>
public bool InAir { get { return _inAir; } set { _inAir = value; OnPropertyChanged(); } }
private bool _inAir;
public float ReactTemp { get { return _reactTemp; } set { _reactTemp = value; OnPropertyChanged(); } }
private float _reactTemp;

/// <summary>
/// 排热空气阀反馈
/// 反应釜蒸汽压力 VD2010
/// </summary>
public bool OutAir { get { return _outAir; } set { _outAir = value; OnPropertyChanged(); } }
private bool _outAir;
public float ReactSteamPressure { get { return _reactSteamPressure; } set { _reactSteamPressure = value; OnPropertyChanged(); } }
private float _reactSteamPressure;

/// <summary>
/// 泄压阀反馈
/// 反应釜蒸汽流量 VD2014
/// </summary>
public bool RelivePre { get { return _relivePre; } set { _relivePre = value; OnPropertyChanged(); } }
private bool _relivePre;
public float ReactSteamFlow { get { return _reactSteamFlow; } set { _reactSteamFlow = value; OnPropertyChanged(); } }
private float _reactSteamFlow;

/// <summary>
/// 进冷却水阀反馈
/// 冷凝水罐温度 VD2018
/// </summary>
public bool InCold { get { return _inCold; } set { _inCold = value; OnPropertyChanged(); } }
private bool _inCold;
public float ColdWaterTankTemp { get { return _coldWaterTankTemp; } set { _coldWaterTankTemp = value; OnPropertyChanged(); } }
private float _coldWaterTankTemp;

/// <summary>
/// 出冷却水阀反馈
/// 冷凝水罐湿度 VD2022
/// </summary>
public bool OutCold { get { return _outCold; } set { _outCold = value; OnPropertyChanged(); } }
private bool _outCold;
public float ColdWaterTankHumidity { get { return _coldWaterTankHumidity; } set { _coldWaterTankHumidity = value; OnPropertyChanged(); } }
private float _coldWaterTankHumidity;

/// <summary>
/// 蒸汽梳水阀反馈
/// 负压流量 VD2026
/// </summary>
public bool CardWater { get { return _cardWater; } set { _cardWater = value; OnPropertyChanged(); } }
private bool _cardWater;
public float VacuumFlow { get { return _vacuumFlow; } set { _vacuumFlow = value; OnPropertyChanged(); } }
private float _vacuumFlow;

/// <summary>
/// 冷凝水罐进水阀反馈
/// 称重水罐重量 VD2030
/// </summary>
public bool ColdPot { get { return _coldPot; } set { _coldPot = value; OnPropertyChanged(); } }
private bool _coldPot;
public float WaterTankWeight { get { return _waterTankWeight; } set { _waterTankWeight = value; OnPropertyChanged(); } }
private float _waterTankWeight;

/// <summary>
/// 称重水罐负压阀反馈
/// 反应釜编码器值 VD2034
/// </summary>
public bool WeightPot { get { return _weightPot; } set { _weightPot = value; OnPropertyChanged(); } }
private bool _weightPot;
public float ReactEncoderValue { get { return _reactEncoderValue; } set { _reactEncoderValue = value; OnPropertyChanged(); } }
private float _reactEncoderValue;

/// <summary>
/// 反应釜原点位置反馈
/// 蒸汽比例阀实际开度 VD2038
/// </summary>
public bool OriginBit { get { return _originBit; } set { _originBit = value; OnPropertyChanged(); } }
private bool _originBit;
public float SteamProportValveRealOpening { get { return _steamProportValveRealOpening; } set { _steamProportValveRealOpening = value; OnPropertyChanged(); } }
private float _steamProportValveRealOpening;

/// <summary>
/// 卤水配制罐重量 VD2042
/// </summary>
public float BrineTankWeight { get { return _brineTankWeight; } set { _brineTankWeight = value; OnPropertyChanged(); } }
private float _brineTankWeight;
#endregion
}
}

+ 11
- 6
BPASmartClient.Academy/50L/FloatAddEnum.cs View File

@@ -9,18 +9,23 @@ namespace BPASmartClient.Academy._50L
public enum FloatAddEnum
{
[Add("DB1.DBD1004")]
反应釜旋转电机速度,
反应釜旋转炒制速度,
[Add("DB1.DBD1008")]
反应釜设定升温温度,
反应釜旋转慢速度,
[Add("DB1.DBD1016")]
反应釜设定温温度,
反应釜设定温温度,
[Add("DB1.DBD1020")]
反应釜温度校准,
反应釜设定降温温度,
[Add("DB1.DBD1024")]
冷凝水罐温度校准,
反应釜温度校准,
[Add("DB1.DBD1028")]
蒸汽比例阀开度,
冷凝水罐设定降温温度,
[Add("DB1.DBD1032")]
冷凝水罐温度校准,
[Add("DB1.DBD1036")]
蒸汽比例阀开度,
[Add("DB1.DBD1040")]
反应釜蒸汽压力上限

}
}

+ 57
- 20
BPASmartClient.Academy/50L/PlcControl.cs View File

@@ -15,7 +15,7 @@ namespace BPASmartClient.Academy._50L
private volatile static PlcControl _Instance;
public static PlcControl GetInstance => _Instance ?? (_Instance = new PlcControl());
private PlcControl() { }
public bool? IsConnect => comm.IsReconnect;
public bool IsConnect => true;
public DeviceStatus DeviceStatus { get; set; } = new DeviceStatus();
private ICommSiemens comm = CommHelper.Siemens;

@@ -38,7 +38,7 @@ namespace BPASmartClient.Academy._50L

TaskManage.GetInstance.StartLong(() =>
{
comm.Read<bool[]>("DB1.DBX2000.0", 11).OnSuccess(s =>
comm.Read<bool[]>("DB1.DBX2000.0", 17).OnSuccess(s =>
{
//Data[FeedbackData.旋转电机启停反馈] = s.Content[0];
//Data[FeedbackData.负压风机启动反馈] = s.Content[1];
@@ -51,20 +51,34 @@ namespace BPASmartClient.Academy._50L
//Data[FeedbackData.冷凝水罐进水阀反馈] = s.Content[8];
//Data[FeedbackData.称重水罐负压阀反馈] = s.Content[9];
//Data[FeedbackData.反应釜原点位置反馈] = s.Content[10];
DeviceStatus.TurnMotor = s.Content[0];
#region V2000
DeviceStatus.ReactTurnMotor = s.Content[0];
DeviceStatus.Fans = s.Content[1];
DeviceStatus.InAir = s.Content[2];
DeviceStatus.OutAir = s.Content[3];
DeviceStatus.RelivePre = s.Content[4];
DeviceStatus.InCold = s.Content[5];
DeviceStatus.OutCold = s.Content[6];
DeviceStatus.CardWater = s.Content[7];
DeviceStatus.ColdPot = s.Content[8];
DeviceStatus.WeightPot = s.Content[9];
DeviceStatus.OriginBit = s.Content[10];
DeviceStatus.BrinePumpState = s.Content[2];
DeviceStatus.ReactInSteamValue = s.Content[3];
DeviceStatus.ReactInColdValve = s.Content[4];
DeviceStatus.ReactOutColdValve = s.Content[5];
DeviceStatus.ReactDrainValve = s.Content[6];
DeviceStatus.ReactInCleanWaterValve = s.Content[7];
#endregion

#region V2001
DeviceStatus.ReactPressureAirInValve = s.Content[8];
DeviceStatus.ReactInBrineWaterValve = s.Content[9];
DeviceStatus.ReactOutHotGasValve = s.Content[10];
DeviceStatus.HotGasEmptyValve = s.Content[11];
DeviceStatus.ColdWaterTankInAirValve = s.Content[12];
DeviceStatus.ColdWaterTankInWaterValve = s.Content[13];
DeviceStatus.ReactHomeBit = s.Content[14];
DeviceStatus.ReactPressureReliefValve = s.Content[15];
#endregion

#region V2002
DeviceStatus.ColdWaterTankVacuumValve = s.Content[16];
#endregion
});

comm.Read<float[]>("DB1.DBD2006", 9).OnSuccess(s =>
comm.Read<float[]>("DB1.DBD2006", 10).OnSuccess(s =>
{
//Data[FeedbackData.反应釜温度] = s.Content[0];
//Data[FeedbackData.反应釜蒸汽压力] = s.Content[1];
@@ -75,6 +89,18 @@ namespace BPASmartClient.Academy._50L
//Data[FeedbackData.称重水罐重量] = s.Content[6];
//Data[FeedbackData.反应釜编码器值] = s.Content[7];
//Data[FeedbackData.蒸汽比例阀实际开度] = s.Content[8];
DeviceStatus.ReactTemp = s.Content[0];
DeviceStatus.ReactSteamPressure = s.Content[1];
DeviceStatus.ReactSteamFlow = s.Content[2];
DeviceStatus.ColdWaterTankTemp = s.Content[3];
DeviceStatus.ColdWaterTankHumidity = s.Content[4];
DeviceStatus.VacuumFlow = s.Content[5];
DeviceStatus.WaterTankWeight = s.Content[6];
DeviceStatus.ReactEncoderValue = s.Content[7];
DeviceStatus.SteamProportValveRealOpening = s.Content[8];
DeviceStatus.BrineTankWeight = s.Content[9];


SamplingData sampling = new SamplingData()
{
Temperature = s.Content[0],
@@ -84,20 +110,23 @@ namespace BPASmartClient.Academy._50L
CondensateWaterHumidity = s.Content[4],
NegativePressureFlowRate = s.Content[5],
WeighingWaterTankWeight = s.Content[6],
ProportionalValveOpening = s.Content[7],
ReactEncoderValue = s.Content[7],
ProportionalValveOpening = s.Content[8],
BrineTankWeight = s.Content[9]
};
SqliteOperate.GetInstance.Add(sampling);
SqliteOperate.GetInstance.RealtimeChart(sampling);

});

comm.Read<bool[]>("DB1.DBX1003.7", 1).OnSuccess(s => { Data[FeedbackData.心跳] = s.Content[0]; });
comm.Read<bool[]>("DB1.DBX1003.7", 1).OnSuccess(s => DeviceStatus.HeartBeat = s.Content[0] );

comm.Read<bool[]>("DB1.DBX2004.0", 3).OnSuccess(s =>
comm.Read<bool[]>("DB1.DBX2004.0", 16).OnSuccess(s =>
{
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").EStop = s.Content[0];
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").RotatingMachinesError = s.Content[1];
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").AbnormalNegativePressureFan = s.Content[2];
AlarmHelper.GetInstance.Get<AlarmData>("50L反应釜").BrinePumpError = s.Content[3];
});

if (Delay.GetInstance("心跳").Start(FeedbackData.心跳.GetValue<bool>(), 3))
@@ -116,19 +145,27 @@ namespace BPASmartClient.Academy._50L

}

public void Write(BoolAddEnum add, bool value)
public OperateResult Write(BoolAddEnum add, bool value)
{
if (boolAdds.ContainsKey(add))
{
comm.Write(boolAdds[add], value);
return comm.Write(boolAdds[add], value);
}
else
{
return OperateResult.Failed($"未查找到该地址{add.ToString()}");
}
}

public void Write(FloatAddEnum add, float value)
public OperateResult Write(FloatAddEnum add, float value)
{
if (floatAdds.ContainsKey(add))
{
comm.Write(floatAdds[add], value);
return comm.Write(floatAdds[add], value);
}
else
{
return OperateResult.Failed($"未查找到该地址{add.ToString()}");
}
}



+ 14
- 1
BPASmartClient.Academy/50L/SamplingData.cs View File

@@ -48,9 +48,18 @@ namespace BPASmartClient.Academy._50L
/// </summary>
public float WeighingWaterTankWeight { get; set; }
/// <summary>
/// 反应釜编码器值
/// </summary>
public float ReactEncoderValue { get; set; }
/// <summary>
/// 蒸汽比例阀实际开度
/// </summary>
public float ProportionalValveOpening { get; set; }
/// <summary>
/// 卤水配制罐重量
/// </summary>
public float BrineTankWeight { get; set; }


public SamplingData()
{
@@ -70,7 +79,9 @@ namespace BPASmartClient.Academy._50L
/// <param name="wwtw">称重水罐重量</param>
/// <param name="pvo">蒸汽比例阀实际开度</param>
/// <param name="pid">产品id</param>
public SamplingData(float t, float sp, float sfr, float cwt, float cwh, float npfr, float wwtw, float pvo, string pid)
/// <param name="reactEncoderValue">反应釜编码器实际值</param>
/// <param name="brineTankWeight">卤水罐重量</param>
public SamplingData(float t, float sp, float sfr, float cwt, float cwh, float npfr, float wwtw, float pvo, string pid, float reactEncoderValue, float brineTankWeight)
{
Createtime = DateTime.Now;
Temperature = t;
@@ -81,6 +92,8 @@ namespace BPASmartClient.Academy._50L
NegativePressureFlowRate = npfr;
WeighingWaterTankWeight = wwtw;
ProportionalValveOpening = pvo;
ReactEncoderValue = reactEncoderValue;
BrineTankWeight = brineTankWeight;
ProductNumberId = pid;
Id = Guid.NewGuid().ToString();
}


+ 14
- 0
BPASmartClient.Academy/App.xaml.cs View File

@@ -156,6 +156,20 @@ namespace BPASmartClient.Academy
ToggleWindowPath = num==0 ? "View.DeviceMotionView" :num==1? "View.ReactionKettle50LView": "View.DeviceMotion_2View"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备控制模板1",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = "View.DeviceMotionView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备控制模板2",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = "View.DeviceMotion_2View"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "数据曲线",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },


+ 843
- 615
BPASmartClient.Academy/View/ReactionKettle50LView.xaml
File diff suppressed because it is too large
View File


+ 195
- 1
BPASmartClient.Academy/View/ReactionKettle50LView.xaml.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.Academy._50L;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -6,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
@@ -25,8 +27,200 @@ namespace BPASmartClient.Academy.View
{
InitializeComponent();
this.DataContext = ReactionKettle50LViewModel.GetInstance;
this.Loaded += ReactionKettle50LView_Loaded;
}

private void ReactionKettle50LView_Loaded(object sender, RoutedEventArgs e)
{
}


private void open_Click(object sender, RoutedEventArgs e)
{
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim()))
{
if (PlcControl.GetInstance.IsConnect)
{
var tag = button.Tag.ToString().Trim();
BoolAddEnum addr=(BoolAddEnum)Enum.Parse(typeof(BoolAddEnum), tag);
var result= PlcControl.GetInstance.Write(addr, true);
if (result !=null && result.IsSuccess)
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入{tag}:True");
}
else
{
Notify(EnumPromptType.Error, $"写入失败", $"失败:写入{tag}:True\n{result.Message}");
}
}
else
{
Notify(EnumPromptType.Error, "失败", "设备未连接");
}
}
}

private void close_Click(object sender, RoutedEventArgs e)
{
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim()))
{
if (PlcControl.GetInstance.IsConnect)
{
var tag = button.Tag.ToString().Trim();
BoolAddEnum addr = (BoolAddEnum)Enum.Parse(typeof(BoolAddEnum), tag);
var result = PlcControl.GetInstance.Write(addr, false);
if (result != null && result.IsSuccess)
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入{tag}:False");
}
else
{
Notify(EnumPromptType.Error, $"写入失败", $"失败:写入{tag}:False\n{result.Message}");
}
}
else
{
Notify(EnumPromptType.Error, "失败", "设备未连接");
}
}
}

private void Notify(EnumPromptType promptType,string title,string msg)
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
NoticeDemoViewModel.OpenMsg(promptType, App.Current.MainWindow, title, msg);
}));
}

private void auto_click(object sender, RoutedEventArgs e)
{

}

private void TempSet_CLick(object sender, RoutedEventArgs e)
{
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim()))
{
if (PlcControl.GetInstance.IsConnect)
{
var tag = button.Tag.ToString().Trim();

switch (tag)
{
case "反应釜升温":
if (float.TryParse(reactorHeatUpTemp.Text,out float reactorHeatTemp) && reactorHeatTemp <= 200f && reactorHeatTemp >= 0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜设定升温温度, MathF.Round(reactorHeatTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.反应釜升温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入反应釜升温:{reactorHeatTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
case "反应釜降温":
if (float.TryParse(reactorCoolDownTemp.Text, out float reactorCoolTemp) && reactorCoolTemp<=200f && reactorCoolTemp>=0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜设定降温温度, MathF.Round(reactorCoolTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.反应釜降温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入反应釜降温:{reactorCoolTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
case "冷凝水罐降温":
if (float.TryParse(ColdWaterTankCoolDownTemp.Text, out float CWTTemp) && CWTTemp <= 200f && CWTTemp >= 0f)
{
PlcControl.GetInstance.Write(FloatAddEnum.冷凝水罐设定降温温度, MathF.Round(CWTTemp, 2)).OnSuccess((s) =>
{
PlcControl.GetInstance.Write(BoolAddEnum.冷凝水罐降温, true).OnSuccess((s2) =>
{
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入冷凝水罐降温:{CWTTemp}");
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}).OnFailure((s) => {
Notify(EnumPromptType.Error, "写入失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入失败", $"输入的温度不是一个有效的数字,范围0-200℃。");
}
break;
}
}
else
{
Notify(EnumPromptType.Error, "失败", "设备未连接");
}
}
}

private void TempCLose_CLick(object sender, RoutedEventArgs e)
{
close_Click(sender, e);
}

private void TempAdjust_Click(object sender, RoutedEventArgs e)
{
if (PlcControl.GetInstance.IsConnect)
{
if (float.TryParse(reactorTempAdjustValue.Text, out float reactorAdjustTemp))
{
PlcControl.GetInstance.Write(FloatAddEnum.反应釜温度校准, MathF.Round(reactorAdjustTemp, 2)).OnSuccess((s) =>
{
Notify(EnumPromptType.Success, $"写入校准成功", $"成功:写入反应釜温度校准:{reactorAdjustTemp}");
}).OnFailure((s) =>
{
Notify(EnumPromptType.Error, "写入校准失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入校准失败", $"【反应釜温度校准】输入的温度不是一个有效的数字");
}

if (float.TryParse(coldWaterTankTempAdjustValue.Text, out float CWTAdjustValue))
{
PlcControl.GetInstance.Write(FloatAddEnum.冷凝水罐温度校准, MathF.Round(CWTAdjustValue, 2)).OnSuccess((s) =>
{
Notify(EnumPromptType.Success, $"写入校准成功", $"成功:写入冷凝水罐温度校准:{CWTAdjustValue}");
}).OnFailure((s) =>
{
Notify(EnumPromptType.Error, "写入校准失败", $"{s.Message}。");
});
}
else
{
Notify(EnumPromptType.Error, "写入校准失败", $"【冷凝水罐温度校准】输入的温度不是一个有效的数字");
}
}
else
{
Notify(EnumPromptType.Error, "校准失败", "设备未连接");
}
}

}
}

+ 75
- 0
BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs View File

@@ -13,13 +13,88 @@ namespace BPASmartClient.Academy.ViewModel
public static ReactionKettle50LViewModel GetInstance => _Instance ?? (_Instance = new ReactionKettle50LViewModel());
private ReactionKettle50LViewModel()
{
Start = new BPARelayCommand(() =>
{
if (Name != "" && PlcControl.GetInstance.IsConnect)
{
switch (Content)
{
case "系统启动":
IsChecked = true;
//DataFeedback dataFeedback = new DataFeedback();
//dataFeedback.Name = Name;
//var snd = new SaveNameData(Name);
//dataFeedback.ProductNumberId = snd.Id;
//Sqlite.GetInstance.AddData(snd);
//Simens_PLC.GetInstance.id = snd.Id;
//Simens_PLC.GetInstance.dataFeedback = dataFeedback;
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true);
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true);
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, true);
Content = "系统停止";
break;
case "系统停止":
IsChecked = false;
//Simens_PLC.GetInstance.id = "";
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
//Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
PlcControl.GetInstance.Write(BoolAddEnum.系统启动, false);
Content = "系统启动";
break;
default:
break;
}
}
else
{
if (!PlcControl.GetInstance.IsConnect)
{
MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information);
}
else
{
MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information);
}
IsChecked = false;
}
});

DataRecordCommand = new BPARelayCommand(() =>
{
ParameterSetView sv = new ParameterSetView();
sv.Show();
});
}

public DeviceStatus DeviceStatus{get { return _mdeviceStatus; }set { _mdeviceStatus = value;OnPropertyChanged(); }}
private DeviceStatus _mdeviceStatus = PlcControl.GetInstance.DeviceStatus;

private string _name = "";

public string Name
{
get { return _name; }
set { _name = value; OnPropertyChanged(); }
}
private string _content = "系统启动";

public string Content
{
get { return _content; }
set { _content = value; OnPropertyChanged(); }
}

private bool _isChecked = false;

public bool IsChecked
{
get { return _isChecked; }
set { _isChecked = value; OnPropertyChanged(); }
}


public BPARelayCommand Start { get; set; }
public BPARelayCommand DataRecordCommand { get; set; }
}
}

Loading…
Cancel
Save