Parcourir la source

暂存

reconfiguration
lyw il y a 2 mois
Parent
révision
9c9fd7c380
18 fichiers modifiés avec 2700 ajouts et 134 suppressions
  1. +12
    -9
      BPASmartClient.Academy/50L/PlcControl.cs
  2. +14
    -5
      BPASmartClient.Academy/App.xaml.cs
  3. +0
    -6
      BPASmartClient.Academy/BPASmartClient.Academy.csproj
  4. +5
    -5
      BPASmartClient.Academy/Converter/DeviceCtrlConvert.cs
  5. +4
    -0
      BPASmartClient.Academy/Model/DataFeedback.cs
  6. +4
    -0
      BPASmartClient.Academy/Model/ProjectType.cs
  7. +13
    -8
      BPASmartClient.Academy/Model/SaveData.cs
  8. +27
    -20
      BPASmartClient.Academy/Model/Simens_PLC.cs
  9. +47
    -31
      BPASmartClient.Academy/View/DeviceChartView.xaml
  10. +45
    -39
      BPASmartClient.Academy/View/DeviceChartView.xaml.cs
  11. +2
    -2
      BPASmartClient.Academy/View/DeviceMotionView.xaml
  12. +1966
    -0
      BPASmartClient.Academy/View/DeviceMotion_2View.xaml
  13. +388
    -0
      BPASmartClient.Academy/View/DeviceMotion_2View.xaml.cs
  14. +26
    -7
      BPASmartClient.Academy/View/HistoryChartView.xaml
  15. +45
    -0
      BPASmartClient.Academy/View/HistoryChartView.xaml.cs
  16. +1
    -1
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  17. +1
    -1
      BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs
  18. +100
    -0
      BPASmartClient.Academy/ViewModel/DeviceMotion_2ViewModel.cs

+ 12
- 9
BPASmartClient.Academy/50L/PlcControl.cs Voir le fichier

@@ -21,10 +21,13 @@ namespace BPASmartClient.Academy._50L

public void Init()
{
CommHelper.CreateSiemens(CpuType.S7200Smart, Json<DevicePar>.Data.IpAddress).OnSuccess(s =>
Task.Factory.StartNew(() =>
{
comm = s.Content;
Read();
CommHelper.CreateSiemens(CpuType.S7200Smart, Json<DevicePar>.Data.IpAddress).OnSuccess(s =>
{
comm = s.Content;
Read();
});
});
}

@@ -103,13 +106,13 @@ namespace BPASmartClient.Academy._50L
}
Thread.Sleep(10);
}, "数据获取", true);
ThreadManage.GetInstance.StartLong(() =>
{
if (true)//产品开始测试数据
{
//ThreadManage.GetInstance.StartLong(() =>
//{
// if (true)//产品开始测试数据
// {
}
}, "实时曲线数据");
// }
//}, "实时曲线数据");

}



+ 14
- 5
BPASmartClient.Academy/App.xaml.cs Voir le fichier

@@ -134,30 +134,34 @@ namespace BPASmartClient.Academy
// subMenumodels = RecipeManage,
//});
#endregion

#region 硬件设备监控
bool Is10L = Json<DevicePar>.Data.ProjectTypeName == ProjectType.HKYF20240714.ToString();
int num = 0;
if (Enum.TryParse(typeof(ProjectType), Json<DevicePar>.Data.ProjectTypeName,out var enmuvalue))
{
num = (int) enmuvalue;
}
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = Is10L ? "View.DeviceMotionView" : "View.ReactionKettle50LView"
ToggleWindowPath = num==0 ? "View.DeviceMotionView" :num==1? "View.ReactionKettle50LView": "View.DeviceMotion_2View"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "数据曲线",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = Is10L ? "View.DeviceChartView" : "View.DeviceChart50LView"
ToggleWindowPath = num==0 ? "View.DeviceChartView" :num==1? "View.DeviceChart50LView": "View.DeviceChartView"
}); ;
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "历史曲线",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.Academy",
ToggleWindowPath = Is10L ? "View.HistoryChartView" : "View.HistoryChart50LView"
ToggleWindowPath = num==0 ? "View.HistoryChartView" : num==1?"View.HistoryChart50LView": "View.HistoryChartView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
@@ -277,11 +281,16 @@ namespace BPASmartClient.Academy
{
case ProjectType.HKYF20240714:
Sqlite.GetInstance.Init();
Simens_PLC.GetInstance.Init();
Simens_PLC.GetInstance.Connect();
break;
case ProjectType.HKYF20240714_2:
Sqlite.GetInstance.Init();
Simens_PLC.GetInstance.Init();
Simens_PLC.GetInstance.Connect();
break;
case ProjectType.HKYF20240916:
SqliteOperate.GetInstance.Init();
//SqliteOperate.GetInstance.Init();
//PlcControl.GetInstance.Init();
break;
default:


+ 0
- 6
BPASmartClient.Academy/BPASmartClient.Academy.csproj Voir le fichier

@@ -35,10 +35,4 @@
<Resource Include="50L\Page\罐.png" />
</ItemGroup>

<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

+ 5
- 5
BPASmartClient.Academy/Converter/DeviceCtrlConvert.cs Voir le fichier

@@ -14,7 +14,7 @@ namespace BPASmartClient.Academy.Converter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter.ToString() == "1")
if (parameter.ToString() == "1")//流向正向
{
if (value is bool)
{
@@ -34,7 +34,7 @@ namespace BPASmartClient.Academy.Converter
}

}
else if (parameter.ToString() == "2")
else if (parameter.ToString() == "2")//管道颜色
{
if (value is bool)
{
@@ -53,7 +53,7 @@ namespace BPASmartClient.Academy.Converter
return Color.FromRgb(255, 255, 255);
}
}
else if(parameter.ToString() == "3")
else if(parameter.ToString() == "3")//电机颜色
{
if (value is bool)
{
@@ -72,7 +72,7 @@ namespace BPASmartClient.Academy.Converter
return MotorColor.Gray;
}
}
else if(parameter.ToString()=="4")
else if(parameter.ToString()=="4")//字体颜色
{
if (value is bool)
{
@@ -91,7 +91,7 @@ namespace BPASmartClient.Academy.Converter
return new SolidColorBrush(Color.FromRgb(255, 255, 255));
}
}
else
else//流向反向
{
if (value is bool)
{


+ 4
- 0
BPASmartClient.Academy/Model/DataFeedback.cs Voir le fichier

@@ -62,6 +62,10 @@ namespace BPASmartClient.Academy.Model
/// </summary>
public ChartValues<DataValue> PressureWok { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 反应釜蒸汽压力
/// </summary>
public ChartValues<DataValue> PressureWok_Week { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 反应釜重量
/// </summary>
public ChartValues<DataValue> WeightWok { get; set; } = new ChartValues<DataValue>();


+ 4
- 0
BPASmartClient.Academy/Model/ProjectType.cs Voir le fichier

@@ -19,5 +19,9 @@ namespace BPASmartClient.Academy.Model
/// 50L反应釜
/// </summary>
HKYF20240916 = 1,
/// <summary>
/// 10L反应釜_2
/// </summary>
HKYF20240714_2 = 2,
}
}

+ 13
- 8
BPASmartClient.Academy/Model/SaveData.cs Voir le fichier

@@ -38,10 +38,11 @@ namespace BPASmartClient.Academy.Model
///// </summary>
//public int M103_Speed { get; set; }

///// <summary>
///// 比例阀开度曲线
///// </summary>
//public double OpenValve { get; set; }
/// <summary>
/// 比例阀开度曲线
/// </summary>
public double OpenValve { get; set; }

/// <summary>
/// 反应釜温度
/// </summary>
@@ -54,10 +55,14 @@ namespace BPASmartClient.Academy.Model
/// 反应釜排气温度
/// </summary>
public int TempVent { get; set; }
///// <summary>
///// 反应釜压力
///// </summary>
//public double PressureWok { get; set; }
/// <summary>
/// 反应釜压力
/// </summary>
public double PressureWok { get; set; }
/// <summary>
/// 反应釜蒸汽压力
/// </summary>
public double PressureWok_Week { get; set; }
/// <summary>
/// 冷却水罐重量
/// </summary>


+ 27
- 20
BPASmartClient.Academy/Model/Simens_PLC.cs Voir le fichier

@@ -25,6 +25,7 @@ namespace BPASmartClient.Academy.Model
private Simens_PLC() { }

public DataFeedback dataFeedback { get; set; } = new DataFeedback();
public PipeLineMode PipeLine { get; set; } = new PipeLineMode();
public string id { get; set; } = "";
//public SiemensHelper siemens { get; set; } = new SiemensHelper();
public ICommSiemens siemens = CommHelper.Siemens;
@@ -242,63 +243,63 @@ namespace BPASmartClient.Academy.Model
//阀门3-4连接
if (deviceCtrl.VX102 || deviceCtrl.VX103)
{
DeviceMotionViewModel.PipeLine.PipeH_1.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 2;
PipeLine.PipeH_1.Fill = true;
PipeLine.PipeH_1.Direction = 2;
}
else
{
DeviceMotionViewModel.PipeLine.PipeH_1.Fill = false;
DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 0;
PipeLine.PipeH_1.Fill = false;
PipeLine.PipeH_1.Direction = 0;
}
//阀门10-11连接
if (!deviceCtrl.VX110 && !deviceCtrl.VX109)
{
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = false;
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 0;
PipeLine.PipeH_2.Fill = false;
PipeLine.PipeH_2.Direction = 0;
}
else
{
if (deviceCtrl.VX109)
{
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 1;
PipeLine.PipeH_2.Fill = true;
PipeLine.PipeH_2.Direction = 1;
}
if (deviceCtrl.VX110)
{
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 2;
PipeLine.PipeH_2.Fill = true;
PipeLine.PipeH_2.Direction = 2;
}
}
//阀门9-12连接
if (!deviceCtrl.VX108 && !deviceCtrl.VX111)
{
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = false;
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 0;
PipeLine.PipeH_3.Fill = false;
PipeLine.PipeH_3.Direction = 0;
}
else
{
if (deviceCtrl.VX108)
{
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 1;
PipeLine.PipeH_3.Fill = true;
PipeLine.PipeH_3.Direction = 1;
}
if (deviceCtrl.VX111)
{
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 2;
PipeLine.PipeH_3.Fill = true;
PipeLine.PipeH_3.Direction = 2;
}
}

//阀门13-14连接
if (deviceCtrl.VX112 || deviceCtrl.VX113)
{
DeviceMotionViewModel.PipeLine.PipeH_4.Fill = true;
DeviceMotionViewModel.PipeLine.PipeH_4.Direction = 1;
PipeLine.PipeH_4.Fill = true;
PipeLine.PipeH_4.Direction = 1;
}
else
{
DeviceMotionViewModel.PipeLine.PipeH_4.Fill = false;
DeviceMotionViewModel.PipeLine.PipeH_4.Direction = 0;
PipeLine.PipeH_4.Fill = false;
PipeLine.PipeH_4.Direction = 0;
}
}

@@ -348,6 +349,9 @@ namespace BPASmartClient.Academy.Model
TempMaterial = siemens.Read<int>("DB1.DBD2026").Content,
TempVent = siemens.Read<int>("DB1.DBD2030").Content,
WeightWok = siemens.Read<float>("DB1.DBD2018").Content,
PressureWok = siemens.Read<float>("DB1.DBD2034").Content,
PressureWok_Week = siemens.Read<float>("DB1.DBD2038").Content,
OpenValve = siemens.Read<float>("DB1.DBD2014").Content,
};
Sqlite.GetInstance.AddData(saveData);
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M101_Speed });
@@ -356,6 +360,9 @@ namespace BPASmartClient.Academy.Model
DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = saveData.Date, Value = saveData.TempMaterial });
DataView(dataFeedback.TempVent, new DataValue() { DateTime = saveData.Date, Value = saveData.TempVent });
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = saveData.Date, Value = saveData.WeightWok });
DataView(dataFeedback.OpenValve, new DataValue() { DateTime = saveData.Date, Value = saveData.OpenValve });
DataView(dataFeedback.PressureWok, new DataValue() { DateTime = saveData.Date, Value = saveData.PressureWok });
DataView(dataFeedback.PressureWok_Week, new DataValue() { DateTime = saveData.Date, Value = saveData.PressureWok_Week });
}

Thread.Sleep(1000);


+ 47
- 31
BPASmartClient.Academy/View/DeviceChartView.xaml Voir le fichier

@@ -15,10 +15,12 @@
<vm:DeviceChartViewModel />
</UserControl.DataContext>
<Grid>
<UniformGrid x:Name="ooo"
<UniformGrid
x:Name="ooo"
Grid.Row="1"
Rows="2"
Columns="2">
Columns="3"
Rows="2">
<!--#region 温度曲线-->
<StackPanel Orientation="Vertical">
<lvc:CartesianChart
x:Name="ppp"
@@ -54,16 +56,14 @@
Values="{Binding DataFeedback.TempVent}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis >
<lvc:Axis MaxValue="200" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
Unit="{Binding AxisUnit}">
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -93,7 +93,9 @@
</StackPanel>

</StackPanel>
<!--#endregion-->

<!--#region 转速曲线-->
<StackPanel Margin="20,0,0,0" Orientation="Vertical">
<lvc:CartesianChart
Height="270"
@@ -121,16 +123,14 @@
Values="{Binding DataFeedback.M102_Speed}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<lvc:Axis MinValue="0" MaxValue="100">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
Unit="{Binding AxisUnit}">
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -138,7 +138,7 @@
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="转速曲线/rpm" />
<TextBlock Foreground="White" Text="转速曲线/" />
<Rectangle
Width="20"
Height="2"
@@ -154,8 +154,10 @@
</StackPanel>

</StackPanel>
<!--#endregion-->

<!--<StackPanel Orientation="Vertical">
<!--#region 比例阀开度曲线 -->
<StackPanel Orientation="Vertical">
<lvc:CartesianChart
Height="270"
HorizontalAlignment="Stretch"
@@ -175,16 +177,14 @@
Values="{Binding DataFeedback.OpenValve}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<lvc:Axis MaxValue="100" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
Unit="{Binding AxisUnit}">
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -192,7 +192,7 @@
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="比例阀开度曲线" />
<TextBlock Foreground="White" Text="比例阀开度曲线/%" />
<Rectangle
Width="20"
Height="2"
@@ -201,9 +201,11 @@
<TextBlock Foreground="White" Text="比例阀开度" />
</StackPanel>

</StackPanel>-->
</StackPanel>
<!--#endregion-->

<!--<StackPanel Orientation="Vertical">
<!--#region 压力曲线 -->
<StackPanel Orientation="Vertical">
<lvc:CartesianChart
Height="270"
HorizontalAlignment="Stretch"
@@ -221,21 +223,26 @@
Stroke="#F1C74B"
StrokeThickness="2"
Values="{Binding DataFeedback.PressureWok}" />
<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="#FF1FFF"
StrokeThickness="2"
Values="{Binding DataFeedback.PressureWok_Week}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis
LabelFormatter="{Binding doubleFormatter}"
MaxValue="1.0"
MinValue="0">
MaxValue="0.6"
MinValue="-0.1">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
Unit="{Binding AxisUnit}">
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -250,10 +257,18 @@
Margin="20,0,0,2"
Fill="#F1C74B" />
<TextBlock Foreground="White" Text="反应釜压力" />
<Rectangle
Width="20"
Height="2"
Margin="20,0,0,2"
Fill="#FF1FFF" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力" />
</StackPanel>

</StackPanel>-->
</StackPanel>
<!--#endregion-->

<!--#region 重量曲线 -->
<StackPanel Margin="0,20,0,0" Orientation="Vertical">
<lvc:CartesianChart
Height="270"
@@ -269,7 +284,7 @@
Fill="Transparent"
LineSmoothness="1"
PointGeometry="{x:Null}"
Stroke="Purple"
Stroke="#fe43fe"
StrokeThickness="2"
Values="{Binding DataFeedback.WeightWok}" />
</lvc:CartesianChart.Series>
@@ -281,9 +296,7 @@
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
Unit="{Binding AxisUnit}">
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -296,12 +309,14 @@
Width="20"
Height="2"
Margin="20,0,0,2"
Fill="Purple" />
Fill="#fe43fe" />
<TextBlock Foreground="White" Text="冷却水罐重量" />
</StackPanel>

</StackPanel>
<!--#endregion-->
</UniformGrid>
<!--#region 总曲线 -->
<Grid
x:Name="chartGrid"
HorizontalAlignment="Stretch"
@@ -327,5 +342,6 @@
Click="Button_Click"
Content="退出" />
</Grid>
<!--#endregion-->
</Grid>
</UserControl>

+ 45
- 39
BPASmartClient.Academy/View/DeviceChartView.xaml.cs Voir le fichier

@@ -99,46 +99,52 @@ namespace BPASmartClient.Academy.View
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
//case "比例阀开度曲线":
// plotModel.Series.Clear();
// plotModel = new PlotModel() { Title = "比例阀开度曲线" };
// chartGrid.Visibility = Visibility.Visible;
// List<DataPoint> open = new List<DataPoint>();
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
// {
// open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve));

// });
// line.Points.AddRange(open);
// 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, MaximumRange = maxrange });
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
// }
// plotModel.Series.Add(line);
// plotModel.InvalidatePlot(true);//重新加载曲线
// chartView.Model = plotModel;
// break;
//case "压力曲线":
// plotModel.Series.Clear();
// plotModel = new PlotModel() { Title = "反应釜压力曲线" };
// chartGrid.Visibility = Visibility.Visible;
// List<DataPoint> pressure = new List<DataPoint>();
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
// {
// pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok));
case "比例阀开度曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "比例阀开度曲线" };
OxyPlot.Series.LineSeries line_open = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "比例阀开度", MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> open = new List<DataPoint>();
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
{
open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve));

// });
// line.Points.AddRange(pressure);
// 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, MaximumRange = maxrange });
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
// }
// plotModel.Series.Add(line);
// plotModel.InvalidatePlot(true);//重新加载曲线
// chartView.Model = plotModel;
// break;
});
line_open.Points.AddRange(open);
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, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_open);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
case "压力曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "反应釜压力曲线" };
OxyPlot.Series.LineSeries line_pre = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜压力", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_preweek = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜蒸汽压力", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
chartGrid.Visibility = Visibility.Visible;
List<DataPoint> pressure = new List<DataPoint>();
List<DataPoint> pressure_week = new List<DataPoint>();
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t =>
{
pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok));
pressure_week.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok_Week));
});
line_pre.Points.AddRange(pressure);
line_preweek.Points.AddRange(pressure_week);
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, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_pre);
plotModel.Series.Add(line_preweek);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
case "重量曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "冷却水罐重量曲线" };


+ 2
- 2
BPASmartClient.Academy/View/DeviceMotionView.xaml Voir le fichier

@@ -1734,9 +1734,9 @@
Height="30"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="0"
Click="TempSet_CLick"
Content="启动"
BorderThickness="0"
Foreground="White"
GroupName="tempctrl"
Style="{StaticResource radiobutton}" />
@@ -1744,8 +1744,8 @@
Width="100"
Height="30"
Margin="40,0,0,0"
Click="TempCLose_CLick"
BorderThickness="0"
Click="TempCLose_CLick"
Content="停止"
Foreground="White"
GroupName="tempctrl"


+ 1966
- 0
BPASmartClient.Academy/View/DeviceMotion_2View.xaml
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 388
- 0
BPASmartClient.Academy/View/DeviceMotion_2View.xaml.cs Voir le fichier

@@ -0,0 +1,388 @@
using BPASmartClient.CustomResource.UserControls.MessageShow;
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>
/// DeviceMotion_2View.xaml 的交互逻辑
/// </summary>
public partial class DeviceMotion_2View : UserControl
{
public DeviceMotion_2View()
{
InitializeComponent();
this.DataContext = DeviceMotion_2ViewModel.GetInstance;
this.Loaded += DeviceMotionView_Loaded;
}
private void DeviceMotionView_Loaded(object sender, RoutedEventArgs e)
{
Simens_PLC.GetInstance.connect = o =>
{
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;
}
});

};
}

private string tempName = "配料罐升温";
private void auto_click(object sender, RoutedEventArgs e)
{
RadioButton radioButton = (RadioButton)sender;
switch (radioButton.Content.ToString())
{
case "反应釜升温":
tempName = "反应釜升温";
wokTemp.Visibility = Visibility.Visible;
caliTemp.Visibility = Visibility.Collapsed;
break;
case "配料罐升温":
tempName = "配料罐升温";
wokTemp.Visibility = Visibility.Visible;
caliTemp.Visibility = Visibility.Collapsed;
break;
case "反应釜降温":
tempName = "反应釜降温";
wokTemp.Visibility = Visibility.Visible;
caliTemp.Visibility = Visibility.Collapsed;
break;
case "温度校准":
tempName = "温度校准";
wokTemp.Visibility = Visibility.Collapsed;
caliTemp.Visibility = Visibility.Visible;
break;
default:
break;
}
}

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

int bit = Convert.ToInt32(radioButton.Tag.ToString());
if (bit < 8)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", true);
}
else if (bit < 16)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", true);
}
else if(bit<32)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true);
}
else
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1003.{bit - 32}", true);
}
}
}

private void Close_Click(object sender, RoutedEventArgs e)
{
RadioButton radioButton = sender as RadioButton;
if (Simens_PLC.GetInstance.IsConnected)
{
int bit = Convert.ToInt32(radioButton.Tag.ToString());
if (bit < 8)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", false);
}
else if (bit < 16)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", false);
}
else if (bit < 32)
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", false);
}
else
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1003.{bit - 32}", false);
}
}

}






private void TempSet_CLick(object sender, RoutedEventArgs e)
{
bool suc;
if (Simens_PLC.GetInstance.IsConnected)
{
switch (tempName)
{
case "反应釜升温":
int tempValue;
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true);
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue);
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
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.DBX1001.6", true);
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10));
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue);
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
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;
int value;
suc = int.TryParse(tempvent.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1024", value).OnFailure(o =>
{
val = false;
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);
});
}
suc = int.TryParse(tempmaterial.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1028", value).OnFailure(o =>
{
val = false;
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);
});
}
suc = int.TryParse(tempwok.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1032", value).OnFailure(o =>
{
val = false;
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);
});
}
if (val)
{
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "成功", "校准完成", 1, 1);
});
}
break;
default:
break;
}
}

}

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)
{
if (Simens_PLC.GetInstance.IsConnected)
{
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 new_Click(object sender, RoutedEventArgs e)
{
if (Simens_PLC.GetInstance.IsConnected)
{
RadioButton radioButton = sender as RadioButton;
if (radioButton.Content.ToString().Contains("开"))
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX3000.{radioButton.Tag}", true);
}
else
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX3000.{radioButton.Tag}", false);
}
}

}
}
}

+ 26
- 7
BPASmartClient.Academy/View/HistoryChartView.xaml Voir le fichier

@@ -104,7 +104,7 @@
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="1.7*"/>
<ColumnDefinition Width="1.7*" />
</Grid.ColumnDefinitions>
<!--#region 表格-->
<Grid
@@ -171,6 +171,7 @@
<!--#region 表格内容-->
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RecipeCharts}">
@@ -243,7 +244,7 @@
PlacementTarget="{Binding ElementName=ceshi}">
<Grid
Width="200"
Height="200"
Height="300"
Background="Transparent">
<Path
Fill="#ff0C255F"
@@ -253,8 +254,8 @@
<GeometryGroup>
<PathGeometry>
<PathFigure StartPoint="0,10">
<LineSegment Point="0,200" />
<LineSegment Point="200,200" />
<LineSegment Point="0,300" />
<LineSegment Point="200,300" />
<LineSegment Point="200,10" />
<LineSegment Point="60,10" />
<LineSegment Point="50,0" />
@@ -271,7 +272,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<Border Margin="0,10">
<Border Margin="0,10,0,0">
<Button
Width="100"
Height="35"
@@ -280,7 +281,7 @@
Content="温度曲线"
Style="{StaticResource ButtonStyle}" />
</Border>
<Border Margin="0,10">
<Border Margin="0,10,0,0">
<Button
Width="100"
Height="35"
@@ -289,7 +290,7 @@
Content="转速曲线"
Style="{StaticResource ButtonStyle}" />
</Border>
<Border Margin="0,10">
<Border Margin="0,10,0,0">
<Button
Width="100"
Height="35"
@@ -298,6 +299,24 @@
Content="重量曲线"
Style="{StaticResource ButtonStyle}" />
</Border>
<Border Margin="0,10,0,0">
<Button
Width="100"
Height="35"
Click="Button_Click"
CommandParameter="{Binding ElementName=num, Path=Text, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Content="压力曲线"
Style="{StaticResource ButtonStyle}" />
</Border>
<Border Margin="0,10,0,0">
<Button
Width="100"
Height="35"
Click="Button_Click"
CommandParameter="{Binding ElementName=num, Path=Text, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Content="开度曲线"
Style="{StaticResource ButtonStyle}" />
</Border>
</StackPanel>
</Grid>
</Popup>


+ 45
- 0
BPASmartClient.Academy/View/HistoryChartView.xaml.cs Voir le fichier

@@ -17,6 +17,7 @@ using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using OxyPlot;
using OxyPlot.Axes;
using LiveCharts.Definitions.Charts;

namespace BPASmartClient.Academy.View
{
@@ -113,6 +114,50 @@ namespace BPASmartClient.Academy.View
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
case "开度曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "比例阀开度曲线" };
OxyPlot.Series.LineSeries line_open = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "比例阀开度", MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> open = new List<DataPoint>();
Sqlite.GetInstance.FindList(recipeChart).ForEach(t =>
{
open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve));

});
line_open.Points.AddRange(open);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")});
}
plotModel.Series.Add(line_open);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
case "压力曲线":
plotModel.Series.Clear();
plotModel = new PlotModel() { Title = "反应釜压力曲线" };
OxyPlot.Series.LineSeries line_pre = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜压力", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
OxyPlot.Series.LineSeries line_preweek = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜蒸汽压力", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> pressure = new List<DataPoint>();
List<DataPoint> pressure_week = new List<DataPoint>();
Sqlite.GetInstance.FindList(recipeChart).ForEach(t =>
{
pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok));
pressure_week.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok_Week));
});
line_pre.Points.AddRange(pressure);
line_preweek.Points.AddRange(pressure_week);
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_pre);
plotModel.Series.Add(line_preweek);
plotModel.InvalidatePlot(true);//重新加载曲线
chartView.Model = plotModel;
break;
default:
break;
}


+ 1
- 1
BPASmartClient.Academy/View/ReactionKettle50LView.xaml Voir le fichier

@@ -363,7 +363,7 @@
Width="60"
Height="5"
LineWidth="1"
Speed="1.5" />
Speed="10" />
<bpa:HandValve
Canvas.Top="183.5"
Canvas.Right="343.4"


+ 1
- 1
BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs Voir le fichier

@@ -68,7 +68,7 @@ namespace BPASmartClient.Academy.ViewModel
sv.Show();
});
}
public static PipeLineMode PipeLine { get; set; } = new PipeLineMode();
public PipeLineMode PipeLine { get; set; } = Simens_PLC.GetInstance.PipeLine;

private string _name = "";



+ 100
- 0
BPASmartClient.Academy/ViewModel/DeviceMotion_2ViewModel.cs Voir le fichier

@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Academy.ViewModel
{
public class DeviceMotion_2ViewModel:NotifyBase
{
private static DeviceMotion_2ViewModel Instance;
public static DeviceMotion_2ViewModel GetInstance { get; set; } = Instance ??= new DeviceMotion_2ViewModel();
public DeviceMotion_2ViewModel()
{
Start = new BPARelayCommand(() =>
{
if (Name != "" && Simens_PLC.GetInstance.IsConnected)
{
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);
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);
Content = "系统启动";
break;
default:
break;
}
}
else
{
if (!Simens_PLC.GetInstance.IsConnected)
{
MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information);
}
else
{
MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information);
}
IsChecked = false;
}
});

DataRecordCommand = new BPARelayCommand(() =>
{
ParameterSetView sv = new ParameterSetView();
sv.Show();
});
}
public PipeLineMode PipeLine { get; set; } = Simens_PLC.GetInstance.PipeLine;

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; }

private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl;

public DeviceCtrl DeviceStatus
{
get { return _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; }
set { _deviceStatus = Simens_PLC.GetInstance.deviceCtrl = value; OnPropertyChanged(); }
}
}
}

Chargement…
Annuler
Enregistrer