Browse Source

上传

reconfiguration
lyw 3 months ago
parent
commit
0e691456cc
14 changed files with 616 additions and 223 deletions
  1. +8
    -0
      BPASmartClient.Academy/App.xaml.cs
  2. +1
    -1
      BPASmartClient.Academy/BPASmartClient.Academy.csproj
  3. +9
    -1
      BPASmartClient.Academy/Model/DeviceCtrl.cs
  4. +1
    -1
      BPASmartClient.Academy/Model/SaveData.cs
  5. +18
    -1
      BPASmartClient.Academy/Model/Simens_PLC.cs
  6. +1
    -1
      BPASmartClient.Academy/Model/Sqlite.cs
  7. +1
    -1
      BPASmartClient.Academy/View/DeviceChartView.xaml
  8. +3
    -3
      BPASmartClient.Academy/View/DeviceChartView.xaml.cs
  9. +376
    -182
      BPASmartClient.Academy/View/DeviceMotionView.xaml
  10. +137
    -31
      BPASmartClient.Academy/View/DeviceMotionView.xaml.cs
  11. +16
    -0
      BPASmartClient.Academy/View/HistoryChartView.xaml
  12. +28
    -0
      BPASmartClient.Academy/View/HistoryChartView.xaml.cs
  13. +1
    -1
      BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs
  14. +16
    -0
      BPASmartClient.Academy/ViewModel/HistoryChartViewModel.cs

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

@@ -35,6 +35,7 @@ namespace BPASmartClient.Academy
Forground = System.Windows.Media.Brushes.Red Forground = System.Windows.Media.Brushes.Red
}); });
}); });
AlarmViewModel.AlarmInfos = MessageNotify.GetInstance.alarmLogs;
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "Academy", out createNew); ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "Academy", out createNew);
if (!createNew) if (!createNew)
{ {
@@ -183,6 +184,13 @@ namespace BPASmartClient.Academy
AssemblyName = "BPASmartClient.Academy", AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = "View.DeviceChartView" 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() MenuManage.GetInstance.menuModels.Add(new MenuModel()
{ {
MainMenuIcon = "", MainMenuIcon = "",


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

@@ -2,7 +2,7 @@


<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>


+ 9
- 1
BPASmartClient.Academy/Model/DeviceCtrl.cs View File

@@ -56,6 +56,14 @@ namespace BPASmartClient.Academy.Model
private bool _vx114 = false; private bool _vx114 = false;
public bool VX115 { get { return _vx115; } set { _vx115 = value; OnPropertyChanged(); } } public bool VX115 { get { return _vx115; } set { _vx115 = value; OnPropertyChanged(); } }
private bool _vx115 = false; 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;
} }
} }

+ 1
- 1
BPASmartClient.Academy/Model/SaveData.cs View File

@@ -46,7 +46,7 @@ namespace BPASmartClient.Academy.Model
///// </summary> ///// </summary>
//public double PressureWok { get; set; } //public double PressureWok { get; set; }
/// <summary> /// <summary>
/// 反应釜重量
/// 冷却水罐重量
/// </summary> /// </summary>
public float WeightWok { get; set; } public float WeightWok { get; set; }
} }


+ 18
- 1
BPASmartClient.Academy/Model/Simens_PLC.cs View File

@@ -23,6 +23,7 @@ namespace BPASmartClient.Academy.Model
private static Simens_PLC _instance; private static Simens_PLC _instance;
public static Simens_PLC GetInstance { get; set; } = _instance ??= new Simens_PLC(); public static Simens_PLC GetInstance { get; set; } = _instance ??= new Simens_PLC();
private Simens_PLC() { } private Simens_PLC() { }

public DataFeedback dataFeedback { get; set; } = new DataFeedback(); public DataFeedback dataFeedback { get; set; } = new DataFeedback();
public string id { get; set; } = ""; public string id { get; set; } = "";
//public SiemensHelper siemens { get; set; } = new SiemensHelper(); //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); 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; 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(); PipeDetect();
Thread.Sleep(100); Thread.Sleep(100);
} }


+ 1
- 1
BPASmartClient.Academy/Model/Sqlite.cs View File

@@ -19,7 +19,7 @@ namespace BPASmartClient.Academy.Model
get get
{ {
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory); 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() public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()


+ 1
- 1
BPASmartClient.Academy/View/DeviceChartView.xaml View File

@@ -297,7 +297,7 @@
Height="2" Height="2"
Margin="20,0,0,2" Margin="20,0,0,2"
Fill="Purple" /> Fill="Purple" />
<TextBlock Foreground="White" Text="反应釜重量" />
<TextBlock Foreground="White" Text="冷却水罐重量" />
</StackPanel> </StackPanel>


</StackPanel> </StackPanel>


+ 3
- 3
BPASmartClient.Academy/View/DeviceChartView.xaml.cs View File

@@ -141,10 +141,10 @@ namespace BPASmartClient.Academy.View
// break; // break;
case "重量曲线": case "重量曲线":
plotModel.Series.Clear(); plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "反应釜重量曲线"};
plotModel = new PlotModel() { Title = "冷却水罐重量曲线" };
chartGrid.Visibility = Visibility.Visible; chartGrid.Visibility = Visibility.Visible;
List<DataPoint> ww = new List<DataPoint>(); 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 => Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
{ {
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok)); ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok));
@@ -154,7 +154,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0)) 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 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.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线 plotModel.InvalidatePlot(true);//重新加载曲线


+ 376
- 182
BPASmartClient.Academy/View/DeviceMotionView.xaml
File diff suppressed because it is too large
View File


+ 137
- 31
BPASmartClient.Academy/View/DeviceMotionView.xaml.cs View File

@@ -42,25 +42,26 @@ namespace BPASmartClient.Academy.View
{ {
Simens_PLC.GetInstance.connect = o => 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 "反应釜升温": case "反应釜升温":
tempName = "反应釜升温"; tempName = "反应釜升温";
wokTemp.Visibility = Visibility.Collapsed;
setTemp.Visibility = Visibility.Visible;
wokTemp.Visibility = Visibility.Visible;
caliTemp.Visibility = Visibility.Collapsed; caliTemp.Visibility = Visibility.Collapsed;
break; break;
case "配料罐升温": case "配料罐升温":
tempName = "配料罐升温"; tempName = "配料罐升温";
wokTemp.Visibility = Visibility.Visible; wokTemp.Visibility = Visibility.Visible;
setTemp.Visibility = Visibility.Collapsed;
caliTemp.Visibility = Visibility.Collapsed;
break;
case "反应釜降温":
tempName = "反应釜降温";
wokTemp.Visibility = Visibility.Visible;
caliTemp.Visibility = Visibility.Collapsed; caliTemp.Visibility = Visibility.Collapsed;
break; break;
case "温度校准": case "温度校准":
tempName = "温度校准"; tempName = "温度校准";
wokTemp.Visibility = Visibility.Collapsed; wokTemp.Visibility = Visibility.Collapsed;
setTemp.Visibility = Visibility.Collapsed;
caliTemp.Visibility = Visibility.Visible; caliTemp.Visibility = Visibility.Visible;
break; break;
default: default:
@@ -95,9 +98,24 @@ namespace BPASmartClient.Academy.View


private void Open_Click(object sender, RoutedEventArgs e) 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) if (Simens_PLC.GetInstance.IsConnected)
{ {
RadioButton radioButton = sender as RadioButton;
int bit = Convert.ToInt32(radioButton.Tag.ToString()); int bit = Convert.ToInt32(radioButton.Tag.ToString());
if (bit < 8) if (bit < 8)
{ {
@@ -112,14 +130,13 @@ namespace BPASmartClient.Academy.View
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true); Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true);
} }
} }
} }


private void Close_Click(object sender, RoutedEventArgs e) private void Close_Click(object sender, RoutedEventArgs e)
{ {
RadioButton radioButton = sender as RadioButton;
if (Simens_PLC.GetInstance.IsConnected) if (Simens_PLC.GetInstance.IsConnected)
{ {
RadioButton radioButton = sender as RadioButton;
int bit = Convert.ToInt32(radioButton.Tag.ToString()); int bit = Convert.ToInt32(radioButton.Tag.ToString());
if (bit < 8) if (bit < 8)
{ {
@@ -149,7 +166,7 @@ namespace BPASmartClient.Academy.View
{ {
case "反应釜升温": case "反应釜升温":
int tempValue; int tempValue;
suc = int.TryParse(temp.Text.ToString(), out tempValue);
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
if (suc) if (suc)
{ {
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true); Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true);
@@ -166,12 +183,12 @@ namespace BPASmartClient.Academy.View
break; break;
case "配料罐升温": case "配料罐升温":
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); 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) if (suc)
{ {
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true); 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); Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue);
} }
else else
@@ -181,8 +198,24 @@ namespace BPASmartClient.Academy.View
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); 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; break;
case "温度校准": case "温度校准":
bool val = true; 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) //private void xxx_MouseMove(object sender, MouseEventArgs e)
//{ //{
// CartesianChart liveCharts = sender as CartesianChart; // CartesianChart liveCharts = sender as CartesianChart;


+ 16
- 0
BPASmartClient.Academy/View/HistoryChartView.xaml View File

@@ -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>

+ 28
- 0
BPASmartClient.Academy/View/HistoryChartView.xaml.cs View File

@@ -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();
}
}
}

+ 1
- 1
BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs View File

@@ -15,7 +15,7 @@ namespace BPASmartClient.Academy.ViewModel
public class DeviceMotionViewModel : NotifyBase public class DeviceMotionViewModel : NotifyBase
{ {
private static DeviceMotionViewModel Instance; private static DeviceMotionViewModel Instance;
public static DeviceMotionViewModel GetInstance { get; set; } = Instance??=new DeviceMotionViewModel();
public static DeviceMotionViewModel GetInstance { get; set; } = Instance ??= new DeviceMotionViewModel();
public DeviceMotionViewModel() public DeviceMotionViewModel()
{ {
Start = new BPARelayCommand(() => Start = new BPARelayCommand(() =>


+ 16
- 0
BPASmartClient.Academy/ViewModel/HistoryChartViewModel.cs View File

@@ -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()
{

}
}
}

Loading…
Cancel
Save