@@ -35,6 +35,7 @@ namespace BPASmartClient.Academy | |||
Forground = System.Windows.Media.Brushes.Red | |||
}); | |||
}); | |||
AlarmViewModel.AlarmInfos = MessageNotify.GetInstance.alarmLogs; | |||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "Academy", out createNew); | |||
if (!createNew) | |||
{ | |||
@@ -183,6 +184,13 @@ namespace BPASmartClient.Academy | |||
AssemblyName = "BPASmartClient.Academy", | |||
ToggleWindowPath = "View.DeviceChartView" | |||
}); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "数据曲线", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.Academy", | |||
ToggleWindowPath = "View.HistoryChartView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
@@ -2,7 +2,7 @@ | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows7.0</TargetFramework> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<UseWPF>true</UseWPF> | |||
@@ -56,6 +56,14 @@ namespace BPASmartClient.Academy.Model | |||
private bool _vx114 = false; | |||
public bool VX115 { get { return _vx115; } set { _vx115 = value; OnPropertyChanged(); } } | |||
private bool _vx115 = false; | |||
public int TempWok { get { return _tempWok; } set { _tempWok = value; OnPropertyChanged(); } } | |||
private int _tempWok; | |||
public int TempMaterial { get { return _tempMaterial; } set { _tempMaterial = value; OnPropertyChanged(); } } | |||
private int _tempMaterial; | |||
public float WeightWok { get { return _weightWok; } set { _weightWok = value; OnPropertyChanged(); } } | |||
private float _weightWok; | |||
public int TempVent { get { return _tempVent; } set { _tempVent = value; OnPropertyChanged(); } } | |||
private int _tempVent; | |||
} | |||
} |
@@ -46,7 +46,7 @@ namespace BPASmartClient.Academy.Model | |||
///// </summary> | |||
//public double PressureWok { get; set; } | |||
/// <summary> | |||
/// 反应釜重量 | |||
/// 冷却水罐重量 | |||
/// </summary> | |||
public float WeightWok { get; set; } | |||
} | |||
@@ -23,6 +23,7 @@ namespace BPASmartClient.Academy.Model | |||
private static Simens_PLC _instance; | |||
public static Simens_PLC GetInstance { get; set; } = _instance ??= new Simens_PLC(); | |||
private Simens_PLC() { } | |||
public DataFeedback dataFeedback { get; set; } = new DataFeedback(); | |||
public string id { get; set; } = ""; | |||
//public SiemensHelper siemens { get; set; } = new SiemensHelper(); | |||
@@ -107,6 +108,7 @@ namespace BPASmartClient.Academy.Model | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", Simens_PLC.GetInstance.AlarmInfo[o], 2, 1); | |||
}); | |||
MessageNotify.GetInstance.ShowAlarmLog(Simens_PLC.GetInstance.AlarmInfo[o]); | |||
} | |||
}); | |||
}); | |||
@@ -198,7 +200,22 @@ namespace BPASmartClient.Academy.Model | |||
{ | |||
deviceCtrl.VX115 = o.Content; | |||
}); | |||
siemens.Read<int>("DB1.DBD2022").OnSuccess(o => | |||
{ | |||
deviceCtrl.TempWok = o.Content; | |||
}); | |||
siemens.Read<int>("DB1.DBD2026").OnSuccess(o => | |||
{ | |||
deviceCtrl.TempMaterial = o.Content; | |||
}); | |||
siemens.Read<float>("DB1.DBD2018").OnSuccess(o => | |||
{ | |||
deviceCtrl.WeightWok = o.Content; | |||
}); | |||
siemens.Read<int>("DB1.DBD2030").OnSuccess(o => | |||
{ | |||
deviceCtrl.TempVent = o.Content; | |||
}); | |||
PipeDetect(); | |||
Thread.Sleep(100); | |||
} | |||
@@ -19,7 +19,7 @@ namespace BPASmartClient.Academy.Model | |||
get | |||
{ | |||
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory); | |||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\data.db"); | |||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB{DateTime.Now.ToString("yyyy-MM-dd")}\\data.db"); | |||
} | |||
} | |||
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() | |||
@@ -297,7 +297,7 @@ | |||
Height="2" | |||
Margin="20,0,0,2" | |||
Fill="Purple" /> | |||
<TextBlock Foreground="White" Text="反应釜重量" /> | |||
<TextBlock Foreground="White" Text="冷却水罐重量" /> | |||
</StackPanel> | |||
</StackPanel> | |||
@@ -141,10 +141,10 @@ namespace BPASmartClient.Academy.View | |||
// break; | |||
case "重量曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "反应釜重量曲线"}; | |||
plotModel = new PlotModel() { Title = "冷却水罐重量曲线" }; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> ww = new List<DataPoint>(); | |||
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "反应釜重量",Color = OxyColor.FromRgb(0, 0, 0),LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End }; | |||
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "冷却水罐重量", Color = OxyColor.FromRgb(0, 0, 0),LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End }; | |||
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||
{ | |||
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok)); | |||
@@ -154,7 +154,7 @@ namespace BPASmartClient.Academy.View | |||
if (!(plotModel.Axes.Count > 0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")}); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")}); | |||
} | |||
plotModel.Series.Add(line_5); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
@@ -42,25 +42,26 @@ namespace BPASmartClient.Academy.View | |||
{ | |||
Simens_PLC.GetInstance.connect = o => | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
if (o) | |||
{ | |||
ooo.Opacity = 1; | |||
ooo.IsHitTestVisible = true; | |||
state.Visibility = Visibility.Collapsed; | |||
} | |||
else | |||
{ | |||
//App.Current.Dispatcher.Invoke(() => | |||
//{ | |||
// if (o) | |||
// { | |||
// ooo.Opacity = 1; | |||
// ooo.IsHitTestVisible = true; | |||
// state.Visibility = Visibility.Collapsed; | |||
// } | |||
// else | |||
// { | |||
// ooo.Opacity = 0.5; | |||
// ooo.IsHitTestVisible = false; | |||
// state.Text = "设 备 未 连 接"; | |||
// //MessageNotify.GetInstance.ShowRunLog("设备未连接"); | |||
// state.Visibility = Visibility.Visible; | |||
// state.Foreground = Brushes.Red; | |||
// } | |||
//}); | |||
ooo.Opacity = 0.5; | |||
ooo.IsHitTestVisible = false; | |||
state.Text = "设 备 未 连 接"; | |||
state.Visibility = Visibility.Visible; | |||
state.Foreground = Brushes.Red; | |||
} | |||
}); | |||
}; | |||
} | |||
@@ -72,20 +73,22 @@ namespace BPASmartClient.Academy.View | |||
{ | |||
case "反应釜升温": | |||
tempName = "反应釜升温"; | |||
wokTemp.Visibility = Visibility.Collapsed; | |||
setTemp.Visibility = Visibility.Visible; | |||
wokTemp.Visibility = Visibility.Visible; | |||
caliTemp.Visibility = Visibility.Collapsed; | |||
break; | |||
case "配料罐升温": | |||
tempName = "配料罐升温"; | |||
wokTemp.Visibility = Visibility.Visible; | |||
setTemp.Visibility = Visibility.Collapsed; | |||
caliTemp.Visibility = Visibility.Collapsed; | |||
break; | |||
case "反应釜降温": | |||
tempName = "反应釜降温"; | |||
wokTemp.Visibility = Visibility.Visible; | |||
caliTemp.Visibility = Visibility.Collapsed; | |||
break; | |||
case "温度校准": | |||
tempName = "温度校准"; | |||
wokTemp.Visibility = Visibility.Collapsed; | |||
setTemp.Visibility = Visibility.Collapsed; | |||
caliTemp.Visibility = Visibility.Visible; | |||
break; | |||
default: | |||
@@ -95,9 +98,24 @@ namespace BPASmartClient.Academy.View | |||
private void Open_Click(object sender, RoutedEventArgs e) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
if (radioButton.Content.ToString().Contains("配料搅拌")) | |||
{ | |||
hzSet.Visibility = Visibility.Visible; | |||
motorName.Text = "配料搅拌频率:"; | |||
ooo.Opacity = 0.5; | |||
ooo.IsHitTestVisible = false; | |||
} | |||
if (radioButton.Content.ToString().Contains("反应釜搅拌")) | |||
{ | |||
hzSet.Visibility = Visibility.Visible; | |||
motorName.Text = "反应釜搅拌频率:"; | |||
ooo.Opacity = 0.5; | |||
ooo.IsHitTestVisible = false; | |||
} | |||
if (Simens_PLC.GetInstance.IsConnected) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||
if (bit < 8) | |||
{ | |||
@@ -112,14 +130,13 @@ namespace BPASmartClient.Academy.View | |||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true); | |||
} | |||
} | |||
} | |||
private void Close_Click(object sender, RoutedEventArgs e) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
if (Simens_PLC.GetInstance.IsConnected) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||
if (bit < 8) | |||
{ | |||
@@ -149,7 +166,7 @@ namespace BPASmartClient.Academy.View | |||
{ | |||
case "反应釜升温": | |||
int tempValue; | |||
suc = int.TryParse(temp.Text.ToString(), out tempValue); | |||
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); | |||
if (suc) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true); | |||
@@ -166,12 +183,12 @@ namespace BPASmartClient.Academy.View | |||
break; | |||
case "配料罐升温": | |||
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); | |||
int time; | |||
suc = int.TryParse(time_1.Text.ToString(), out time); | |||
//int time; | |||
//suc = int.TryParse(time_1.Text.ToString(), out time); | |||
if (suc) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true); | |||
Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); | |||
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); | |||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue); | |||
} | |||
else | |||
@@ -181,8 +198,24 @@ namespace BPASmartClient.Academy.View | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); | |||
}); | |||
} | |||
break; | |||
case "反应釜降温": | |||
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); | |||
//int time; | |||
//suc = int.TryParse(time_1.Text.ToString(), out time); | |||
if (suc) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", true); | |||
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); | |||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue); | |||
} | |||
else | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); | |||
}); | |||
} | |||
break; | |||
case "温度校准": | |||
bool val = true; | |||
@@ -257,6 +290,79 @@ namespace BPASmartClient.Academy.View | |||
} | |||
} | |||
private void hzSet_Click(object sender, RoutedEventArgs e) | |||
{ | |||
hzSet.Visibility = Visibility.Collapsed; | |||
int value; | |||
bool suc = int.TryParse(motorValue.Text.ToString(),out value); | |||
if ( suc&& Simens_PLC.GetInstance.IsConnected&& value >= 20 && value <= 100) | |||
{ | |||
if (motorName.Text.ToString().Contains("配料搅拌")) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1004", value).OnFailure(o => | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "频率写入失败", 1, 1); | |||
}); | |||
}); | |||
} | |||
if (motorName.Text.ToString().Contains("反应釜搅拌")) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1008", value).OnFailure(o => | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "频率写入失败", 1, 1); | |||
}); | |||
}); | |||
} | |||
} | |||
else | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查频率设备连接、数据格式等", 1, 1); | |||
}); | |||
} | |||
ooo.Opacity = 1; | |||
ooo.IsHitTestVisible = true; | |||
} | |||
private void hzCancel_Click(object sender, RoutedEventArgs e) | |||
{ | |||
hzSet.Visibility = Visibility.Collapsed; | |||
ooo.Opacity = 1; | |||
ooo.IsHitTestVisible = true; | |||
} | |||
private void TempCLose_CLick(object sender, RoutedEventArgs e) | |||
{ | |||
switch (tempName) | |||
{ | |||
case "配料罐升温": | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", false); | |||
break; | |||
case "反应釜升温": | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", false); | |||
break; | |||
case "反应釜降温": | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", false); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
private void ClearBtn_CLick(object sender, RoutedEventArgs e) | |||
{ | |||
if (Simens_PLC.GetInstance.IsConnected) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.7", true); | |||
} | |||
} | |||
//private void xxx_MouseMove(object sender, MouseEventArgs e) | |||
//{ | |||
// CartesianChart liveCharts = sender as CartesianChart; | |||
@@ -0,0 +1,16 @@ | |||
<UserControl x:Class="BPASmartClient.Academy.View.HistoryChartView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Academy.View" | |||
xmlns:vm ="clr-namespace:BPASmartClient.Academy.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:HistoryChartViewModel/> | |||
</UserControl.DataContext> | |||
<Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.Academy.View | |||
{ | |||
/// <summary> | |||
/// HistoryChartView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class HistoryChartView : UserControl | |||
{ | |||
public HistoryChartView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -15,7 +15,7 @@ namespace BPASmartClient.Academy.ViewModel | |||
public class DeviceMotionViewModel : NotifyBase | |||
{ | |||
private static DeviceMotionViewModel Instance; | |||
public static DeviceMotionViewModel GetInstance { get; set; } = Instance??=new DeviceMotionViewModel(); | |||
public static DeviceMotionViewModel GetInstance { get; set; } = Instance ??= new DeviceMotionViewModel(); | |||
public DeviceMotionViewModel() | |||
{ | |||
Start = new BPARelayCommand(() => | |||
@@ -0,0 +1,16 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.ViewModel | |||
{ | |||
internal class HistoryChartViewModel:NotifyBase | |||
{ | |||
public HistoryChartViewModel() | |||
{ | |||
} | |||
} | |||
} |